GNU Octave
3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
libgui
qterminal
libqterminal
unix
TerminalCharacterDecoder.h
Go to the documentation of this file.
1
/*
2
This file is part of Konsole, an X terminal.
3
4
Copyright (C) 2006-2007, 2013 by Robert Knight <
[email protected]
>
5
6
Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008
7
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU Lesser General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
17
18
You should have received a copy of the GNU Lesser General Public License
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21
02110-1301 USA.
22
*/
23
24
#ifndef TERMINAL_CHARACTER_DECODER_H
25
#define TERMINAL_CHARACTER_DECODER_H
26
27
#include "
unix/Character.h
"
28
29
class
QTextStream;
30
31
/**
32
* Base class for terminal character decoders
33
*
34
* The decoder converts lines of terminal characters which consist of a unicode character, foreground
35
* and background colours and other appearance-related properties into text strings.
36
*
37
* Derived classes may produce either plain text with no other colour or appearance information, or
38
* they may produce text which incorporates these additional properties.
39
*/
40
class
TerminalCharacterDecoder
41
{
42
public
:
43
virtual
~TerminalCharacterDecoder
() {}
44
45
/** Begin decoding characters. The resulting text is appended to @p output. */
46
virtual
void
begin
(QTextStream* output) = 0;
47
/** End decoding. */
48
virtual
void
end
() = 0;
49
50
/**
51
* Converts a line of terminal characters with associated properties into a text string
52
* and writes the string into an output QTextStream.
53
*
54
* @param characters An array of characters of length @p count.
55
* @param properties Additional properties which affect all characters in the line
56
* @param output The output stream which receives the decoded text
57
*/
58
virtual
void
decodeLine
(
const
Character
*
const
characters,
59
int
count,
60
LineProperty
properties) = 0;
61
};
62
63
/**
64
* A terminal character decoder which produces plain text, ignoring colours and other appearance-related
65
* properties of the original characters.
66
*/
67
class
PlainTextDecoder
:
public
TerminalCharacterDecoder
68
{
69
public
:
70
PlainTextDecoder
();
71
72
/**
73
* Set whether trailing whitespace at the end of lines should be included
74
* in the output.
75
* Defaults to true.
76
*/
77
void
setTrailingWhitespace
(
bool
enable);
78
/**
79
* Returns whether trailing whitespace at the end of lines is included
80
* in the output.
81
*/
82
bool
trailingWhitespace
()
const
;
83
84
virtual
void
begin
(QTextStream* output);
85
virtual
void
end
();
86
87
virtual
void
decodeLine
(
const
Character
*
const
characters,
88
int
count,
89
LineProperty
properties);
90
91
92
private
:
93
QTextStream*
_output
;
94
bool
_includeTrailingWhitespace
;
95
};
96
97
/**
98
* A terminal character decoder which produces pretty HTML markup
99
*/
100
class
HTMLDecoder
:
public
TerminalCharacterDecoder
101
{
102
public
:
103
/**
104
* Constructs an HTML decoder using a default black-on-white color scheme.
105
*/
106
HTMLDecoder
();
107
108
/**
109
* Sets the colour table which the decoder uses to produce the HTML colour codes in its
110
* output
111
*/
112
void
setColorTable
(
const
ColorEntry
* table );
113
114
virtual
void
decodeLine
(
const
Character
*
const
characters,
115
int
count,
116
LineProperty
properties);
117
118
virtual
void
begin
(QTextStream* output);
119
virtual
void
end
();
120
121
private
:
122
void
openSpan
(QString&
text
,
const
QString& style);
123
void
closeSpan
(QString& text);
124
125
QTextStream*
_output
;
126
const
ColorEntry
*
_colorTable
;
127
bool
_innerSpanOpen
;
128
quint8
_lastRendition
;
129
CharacterColor
_lastForeColor
;
130
CharacterColor
_lastBackColor
;
131
132
};
133
134
#endif
Generated on Mon Dec 30 2013 03:04:20 for GNU Octave by
1.8.1.2