~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/ksysguard/processui/KTextEditVT.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    KSysGuard, the KDE System Guard
 
3
 
 
4
    Copyright (c) 2008 John Tapsell <tapsell@kde.org>
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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.
 
20
 
 
21
*/
 
22
 
 
23
#ifndef _KTextEditVT_h_
 
24
#define _KTextEditVT_h_
 
25
 
 
26
#include <QtGui/QTextEdit>
 
27
#include <kdemacros.h>
 
28
 
 
29
/*
 
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.
 
35
 *
 
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'.
 
38
 *
 
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.
 
42
 *
 
43
 *    This output can be then be inserted at the current cursor position by calling
 
44
 *    insertVTText(string);
 
45
 *
 
46
 *    For example:
 
47
 *
 
48
 *    \code
 
49
 *      insertVTText(QString("Hi") + QChar(08) + "ello");
 
50
 *    \endcode
 
51
 *
 
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)
 
54
 */
 
55
class KDE_EXPORT KTextEditVT : public QTextEdit
 
56
{
 
57
        Q_OBJECT
 
58
        Q_PROPERTY( bool parseAnsiEscapeCodes READ parseAnsiEscapeCodes WRITE setParseAnsiEscapeCodes )
 
59
 
 
60
public:
 
61
        KTextEditVT(QWidget* parent);
 
62
 
 
63
        /** Whether to parse ANSI display code.  If turned off the escape sequence will be shown literally. */
 
64
        bool parseAnsiEscapeCodes() const;
 
65
 
 
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.
 
72
         *
 
73
         *  This just calls insertVTChar for each character in the string
 
74
         */
 
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.
 
79
         *
 
80
         *  This just calls insertVTChar for each character in the string
 
81
         */
 
82
        void insertVTText(const QString & string);
 
83
 
 
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.
 
87
         */
 
88
        void insertVTChar(const QChar & c);
 
89
 
 
90
 
 
91
private:
 
92
        bool mParseAnsi;
 
93
 
 
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;
 
101
 
 
102
};
 
103
 
 
104
#endif