Warning, file /plasma/libksysguard/processui/KTextEditVT.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 KSysGuard, the KDE System Guard 0003 0004 SPDX-FileCopyrightText: 2008 John Tapsell <tapsell@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 0008 */ 0009 0010 #ifndef _KTextEditVT_h_ 0011 #define _KTextEditVT_h_ 0012 0013 #include <QTextEdit> 0014 0015 /* 0016 * \class KTextEditVT 0017 * \brief The KTextEditVT class provides a widget that is used to edit and display 0018 * both plain and rich text with the additional function of being able to 0019 * programmatically append VT100 formatted text. For example to display the output 0020 * from console programs. 0021 * 0022 * This class can be used to display the output of VT100 formatted text with 0023 * ANSI escape code - for example output from the command 'ls --color'. 0024 * 0025 * Only a very limited number of ansi escapes sequences will have an affect. Unrecognised 0026 * ansi escape sequences will be ignored and not displayed. Patches are welcome to support 0027 * more of the sequences. 0028 * 0029 * This output can be then be inserted at the current cursor position by calling 0030 * insertVTText(string); 0031 * 0032 * For example: 0033 * 0034 * \code 0035 * insertVTText(QString("Hi") + QChar(08) + "ello"); 0036 * \endcode 0037 * 0038 * will insert the text "Hello" at the current character position. 0039 * (Character 08 is the literal backspace character. Treated as equivalent to character 127) 0040 */ 0041 class Q_DECL_EXPORT KTextEditVT : public QTextEdit 0042 { 0043 Q_OBJECT 0044 Q_PROPERTY(bool parseAnsiEscapeCodes READ parseAnsiEscapeCodes WRITE setParseAnsiEscapeCodes) 0045 0046 public: 0047 explicit KTextEditVT(QWidget *parent); 0048 0049 /** Whether to parse ANSI display code. If turned off the escape sequence will be shown literally. */ 0050 bool parseAnsiEscapeCodes() const; 0051 0052 public Q_SLOTS: 0053 /** Set whether to parse ANSI display code. If turned off the escape sequence will be shown literally. */ 0054 void setParseAnsiEscapeCodes(bool displayall); 0055 /** Insert the given string at the current position based on the current state. 0056 * This is interpreted in a VT100 encoding. Backspace and delete will delete the previous character, 0057 * escape sequences can move the cursor and set the current color etc. 0058 * 0059 * This just calls insertVTChar for each character in the string 0060 */ 0061 void insertVTText(const QByteArray &string); 0062 /** Insert the given string at the current position based on the current state. 0063 * This is interpreted in a VT100 encoding. Backspace and delete will delete the previous character, 0064 * escape sequences can move the cursor and set the current color etc. 0065 * 0066 * This just calls insertVTChar for each character in the string 0067 */ 0068 void insertVTText(const QString &string); 0069 0070 /** Insert the given character at the current position based on the current state. 0071 * This is interpreted in a VT100 encoding. Backspace and delete will delete the previous character, 0072 * escape sequences can move the cursor and set the current color etc. 0073 */ 0074 void insertVTChar(const QChar &c); 0075 0076 private: 0077 bool mParseAnsi; 0078 0079 bool escape_sequence; 0080 bool escape_CSI; 0081 bool escape_OSC; 0082 int escape_number1; 0083 int escape_number2; 0084 bool escape_number_separator; 0085 QChar escape_code; 0086 }; 0087 0088 #endif