File indexing completed on 2024-04-28 05:50:39
0001 /* 0002 SPDX-FileCopyrightText: 2006-2008 Robert Knight <robertknight@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef PLAINTEXTDECODER_H 0008 #define PLAINTEXTDECODER_H 0009 0010 // Konsole decoders 0011 #include "TerminalCharacterDecoder.h" 0012 0013 class QTextStream; 0014 template<typename> 0015 class QList; 0016 0017 namespace Konsole 0018 { 0019 /** 0020 * A terminal character decoder which produces plain text, ignoring colors and other appearance-related 0021 * properties of the original characters. 0022 */ 0023 class PlainTextDecoder : public TerminalCharacterDecoder 0024 { 0025 public: 0026 PlainTextDecoder(); 0027 0028 /** 0029 * Set whether leading whitespace at the end of lines should be included 0030 * in the output. 0031 * Defaults to true. 0032 */ 0033 void setLeadingWhitespace(bool enable); 0034 /** 0035 * Set whether trailing whitespace at the end of lines should be included 0036 * in the output. 0037 * Defaults to true. 0038 */ 0039 void setTrailingWhitespace(bool enable); 0040 /** 0041 * Returns of character positions in the output stream 0042 * at which new lines where added. Returns an empty if setTrackLinePositions() is false or if 0043 * the output device is not a string. 0044 */ 0045 QList<int> linePositions() const; 0046 /** Enables recording of character positions at which new lines are added. See linePositions() */ 0047 void setRecordLinePositions(bool record); 0048 0049 void begin(QTextStream *output) override; 0050 void end() override; 0051 0052 void decodeLine(const Character *const characters, int count, LineProperty properties) override; 0053 0054 private: 0055 QTextStream *_output; 0056 bool _includeLeadingWhitespace; 0057 bool _includeTrailingWhitespace; 0058 0059 bool _recordLinePositions; 0060 QList<int> _linePositions; 0061 }; 0062 } 0063 0064 #endif