1 /* 2 SPDX-FileCopyrightText: 2006-2008 Robert Knight <robertknight@gmail.com> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef PLAINTEXTDECODER_H 8 #define PLAINTEXTDECODER_H 9 10 // Konsole decoders 11 #include "TerminalCharacterDecoder.h" 12 13 class QTextStream; 14 template<typename> 15 class QList; 16 17 namespace Konsole 18 { 19 /** 20 * A terminal character decoder which produces plain text, ignoring colors and other appearance-related 21 * properties of the original characters. 22 */ 23 class KONSOLEDECODERS_EXPORT PlainTextDecoder : public TerminalCharacterDecoder 24 { 25 public: 26 PlainTextDecoder(); 27 28 /** 29 * Set whether leading whitespace at the end of lines should be included 30 * in the output. 31 * Defaults to true. 32 */ 33 void setLeadingWhitespace(bool enable); 34 /** 35 * Set whether trailing whitespace at the end of lines should be included 36 * in the output. 37 * Defaults to true. 38 */ 39 void setTrailingWhitespace(bool enable); 40 /** 41 * Returns of character positions in the output stream 42 * at which new lines where added. Returns an empty if setTrackLinePositions() is false or if 43 * the output device is not a string. 44 */ 45 QList<int> linePositions() const; 46 /** Enables recording of character positions at which new lines are added. See linePositions() */ 47 void setRecordLinePositions(bool record); 48 49 void begin(QTextStream *output) override; 50 void end() override; 51 52 void decodeLine(const Character *const characters, int count, LineProperty properties) override; 53 54 private: 55 QTextStream *_output; 56 bool _includeLeadingWhitespace; 57 bool _includeTrailingWhitespace; 58 59 bool _recordLinePositions; 60 QList<int> _linePositions; 61 }; 62 } 63 64 #endif 65