Debian Codegraph @

lib/TerminalCharacterDecoder.h

raw symbols SCIP
1 /*
2 This file is part of Konsole, an X terminal.
3
4 Copyright 2006-2008 by Robert Knight <[email protected]>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program 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
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20 */
21
22 #ifndef TERMINAL_CHARACTER_DECODER_H
23 #define TERMINAL_CHARACTER_DECODER_Hcxx . . $ `lib/TerminalCharacterDecoder.h:23:9`!
24
25 #include "Character.h"cxx . . $ `<file>/lib/Character.h`/
26
27 #include <QList>
28
29 class QTextStreamcxx . . $ QTextStream#;
30
31 namespace Konsolecxx . . $ Konsole/
32 {
33
34 /**
35 * Base class for terminal character decoders
36 *
37 * The decoder converts lines of terminal characters which consist of a unicode character, foreground
38 * and background colours and other appearance-related properties into text strings.
39 *
40 * Derived classes may produce either plain text with no other colour or appearance information, or
41 * they may produce text which incorporates these additional properties.
42 */
43 class TerminalCharacterDecodercxx . . $ Konsole/TerminalCharacterDecoder#
44 {
45 public:
46 virtual ~cxx . . $ Konsole/TerminalCharacterDecoder#`~TerminalCharacterDecoder`(ced63f7c635d850d).TerminalCharacterDecodercxx . . $ Konsole/TerminalCharacterDecoder#() {}
47
48 /** Begin decoding characters. The resulting text is appended to @p output. */
49 virtual void begincxx . . $ Konsole/TerminalCharacterDecoder#begin(aca783e314870a73).(QTextStreamcxx . . $ QTextStream#* output) = 0;
50 /** End decoding. */
51 virtual void endcxx . . $ Konsole/TerminalCharacterDecoder#end(49f6e7a06ebc5aa8).() = 0;
52
53 /**
54 * Converts a line of terminal characters with associated properties into a text string
55 * and writes the string into an output QTextStream.
56 *
57 * @param characters An array of characters of length @p count.
58 * @param count The number of characters
59 * @param properties Additional properties which affect all characters in the line
60 */
61 virtual void decodeLinecxx . . $ Konsole/TerminalCharacterDecoder#decodeLine(aa119f8849ce0e23).(const Charactercxx . . $ Konsole/Character#* const characters,
62 int count,
63 LinePropertycxx . . $ Konsole/LineProperty# properties) = 0;
64 };
65
66 /**
67 * A terminal character decoder which produces plain text, ignoring colours and other appearance-related
68 * properties of the original characters.
69 */
70 class PlainTextDecodercxx . . $ Konsole/PlainTextDecoder# : public TerminalCharacterDecodercxx . . $ Konsole/TerminalCharacterDecoder#
71 {
72 public:
73 PlainTextDecodercxx . . $ Konsole/PlainTextDecoder#PlainTextDecoder(49f6e7a06ebc5aa8).();
74
75 /**
76 * Set whether trailing whitespace at the end of lines should be included
77 * in the output.
78 * Defaults to true.
79 */
80 void setTrailingWhitespacecxx . . $ Konsole/PlainTextDecoder#setTrailingWhitespace(b45ddcbc8423892c).(bool enable);
81 /**
82 * Returns whether trailing whitespace at the end of lines is included
83 * in the output.
84 */
85 bool trailingWhitespacecxx . . $ Konsole/PlainTextDecoder#trailingWhitespace(50ce9a9e25b4a850).() const;
86 /**
87 * Returns of character positions in the output stream
88 * at which new lines where added. Returns an empty if setTrackLinePositions() is false or if
89 * the output device is not a string.
90 */
91 QListcxx . . $ QList#<int> linePositionscxx . . $ Konsole/PlainTextDecoder#linePositions(acfbda32237c20a3).() const;
92 /** Enables recording of character positions at which new lines are added. See linePositions() */
93 void setRecordLinePositionscxx . . $ Konsole/PlainTextDecoder#setRecordLinePositions(b45ddcbc8423892c).(bool record);
94
95 void begincxx . . $ Konsole/PlainTextDecoder#begin(aca783e314870a73).(QTextStreamcxx . . $ QTextStream#* output) override;
96 void endcxx . . $ Konsole/PlainTextDecoder#end(49f6e7a06ebc5aa8).() override;
97
98 void decodeLinecxx . . $ Konsole/PlainTextDecoder#decodeLine(aa119f8849ce0e23).(const Charactercxx . . $ Konsole/Character#* const characters,
99 int count,
100 LinePropertycxx . . $ Konsole/LineProperty# properties) override;
101
102
103 private:
104 QTextStreamcxx . . $ QTextStream#* _outputcxx . . $ Konsole/PlainTextDecoder#_output.;
105 bool _includeTrailingWhitespacecxx . . $ Konsole/PlainTextDecoder#_includeTrailingWhitespace.;
106
107 bool _recordLinePositionscxx . . $ Konsole/PlainTextDecoder#_recordLinePositions.;
108 QListcxx . . $ QList#<int> _linePositionscxx . . $ Konsole/PlainTextDecoder#_linePositions.;
109 };
110
111 /**
112 * A terminal character decoder which produces pretty HTML markup
113 */
114 class HTMLDecodercxx . . $ Konsole/HTMLDecoder# : public TerminalCharacterDecodercxx . . $ Konsole/TerminalCharacterDecoder#
115 {
116 public:
117 /**
118 * Constructs an HTML decoder using a default black-on-white color scheme.
119 */
120 HTMLDecodercxx . . $ Konsole/HTMLDecoder#HTMLDecoder(49f6e7a06ebc5aa8).();
121
122 /**
123 * Sets the colour table which the decoder uses to produce the HTML colour codes in its
124 * output
125 */
126 void setColorTablecxx . . $ Konsole/HTMLDecoder#setColorTable(b25cc3fd5c7c482d).( const ColorEntrycxx . . $ Konsole/ColorEntry#* table );
127
128 void decodeLinecxx . . $ Konsole/HTMLDecoder#decodeLine(aa119f8849ce0e23).(const Charactercxx . . $ Konsole/Character#* const characters,
129 int count,
130 LinePropertycxx . . $ Konsole/LineProperty# properties) override;
131
132 void begincxx . . $ Konsole/HTMLDecoder#begin(aca783e314870a73).(QTextStreamcxx . . $ QTextStream#* output) override;
133 void endcxx . . $ Konsole/HTMLDecoder#end(49f6e7a06ebc5aa8).() override;
134
135 private:
136 void openSpancxx . . $ Konsole/HTMLDecoder#openSpan(f0d40cabe90ae651).(stdcxx . . $ std/::wstringcxx . . $ std/wstring#& text , const QStringcxx . . $ QString#& style);
137 void closeSpancxx . . $ Konsole/HTMLDecoder#closeSpan(641fc13601a5d57f).(stdcxx . . $ std/::wstringcxx . . $ std/wstring#& text);
138
139 QTextStreamcxx . . $ QTextStream#* _outputcxx . . $ Konsole/HTMLDecoder#_output.;
140 const ColorEntrycxx . . $ Konsole/ColorEntry#* _colorTablecxx . . $ Konsole/HTMLDecoder#_colorTable.;
141 bool _innerSpanOpencxx . . $ Konsole/HTMLDecoder#_innerSpanOpen.;
142 quint8cxx . . $ quint8# _lastRenditioncxx . . $ Konsole/HTMLDecoder#_lastRendition.;
143 CharacterColorcxx . . $ Konsole/CharacterColor# _lastForeColorcxx . . $ Konsole/HTMLDecoder#_lastForeColor.;
144 CharacterColorcxx . . $ Konsole/CharacterColor# _lastBackColorcxx . . $ Konsole/HTMLDecoder#_lastBackColor.;
145
146 };
147
148 }
149
150 #endif