add more spacing
[personal-kdebase.git] / workspace / libs / ksysguard / processui / KTextEditVT.h
blob360451957878eeee9dba8cc8232d10793e1db104
1 /*
2 KSysGuard, the KDE System Guard
4 Copyright (c) 2008 John Tapsell <tapsell@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
23 #ifndef _KTextEditVT_h_
24 #define _KTextEditVT_h_
26 #include <QtGui/QTextEdit>
27 #include <kdemacros.h>
30 * \class KTextEditVT
31 * \brief The KTextEditVT class provides a widget that is used to edit and display
32 * both plain and rich text with the additional function of being able to
33 * programmatically append VT100 formatted text. For example to display the output
34 * from console programs.
36 * This class can be used to display the output of VT100 formatted text with
37 * ANSI escape code - for example output from the command 'ls --color'.
39 * Only a very limited number of ansi escapes sequences will have an affect. Unrecognised
40 * ansi escape sequences will be ignored and not displayed. Patches are welcome to support
41 * more of the sequences.
43 * This output can be then be inserted at the current cursor position by calling
44 * insertVTText(string);
46 * For example:
48 * \code
49 * insertVTText(QString("Hi") + QChar(08) + "ello");
50 * \endcode
52 * will insert the text "Hello" at the current character position.
53 * (Character 08 is the literal backspace character. Treated as equivalent to character 127)
55 class KDE_EXPORT KTextEditVT : public QTextEdit
57 Q_OBJECT
58 Q_PROPERTY( bool parseAnsiEscapeCodes READ parseAnsiEscapeCodes WRITE setParseAnsiEscapeCodes )
60 public:
61 KTextEditVT(QWidget* parent);
63 /** Whether to parse ANSI display code. If turned off the escape sequence will be shown literally. */
64 bool parseAnsiEscapeCodes() const;
66 public Q_SLOTS:
67 /** Set whether to parse ANSI display code. If turned off the escape sequence will be shown literally. */
68 void setParseAnsiEscapeCodes(bool displayall);
69 /** Insert the given string at the current position based on the current state.
70 * This is interpreted in a VT100 encoding. Backspace and delete will delete the previous character,
71 * escape sequences can move the cursor and set the current color etc.
73 * This just calls insertVTChar for each character in the string
75 void insertVTText(const QByteArray & string);
76 /** Insert the given string at the current position based on the current state.
77 * This is interpreted in a VT100 encoding. Backspace and delete will delete the previous character,
78 * escape sequences can move the cursor and set the current color etc.
80 * This just calls insertVTChar for each character in the string
82 void insertVTText(const QString & string);
84 /** Insert the given character at the current position based on the current state.
85 * This is interpreted in a VT100 encoding. Backspace and delete will delete the previous character,
86 * escape sequences can move the cursor and set the current color etc.
88 void insertVTChar(const QChar & c);
91 private:
92 bool mParseAnsi;
94 bool escape_sequence;
95 bool escape_CSI;
96 bool escape_OSC;
97 int escape_number1;
98 int escape_number2;
99 bool escape_number_seperator;
100 QChar escape_code;
104 #endif