GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
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 <robertknight@gmail.com>
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
29class 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 */
41{
42public:
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,
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 */
68{
69public:
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,
90
91
92private:
93 QTextStream* _output;
95};
96
97/**
98 * A terminal character decoder which produces pretty HTML markup
99 */
101{
102public:
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,
117
118 virtual void begin(QTextStream* output);
119 virtual void end();
120
121private:
122 void openSpan(QString& text , const QString& style);
123 void closeSpan(QString& text);
124
125 QTextStream* _output;
131
132};
133
134#endif
unsigned char LineProperty
Definition: Character.h:34
Describes the color of a single character in the terminal.
A single character in the terminal which consists of a unicode character value, foreground and backgr...
Definition: Character.h:56
An entry in a terminal display's color palette.
A terminal character decoder which produces pretty HTML markup.
CharacterColor _lastBackColor
CharacterColor _lastForeColor
HTMLDecoder()
Constructs an HTML decoder using a default black-on-white color scheme.
void closeSpan(QString &text)
const ColorEntry * _colorTable
virtual void end()
End decoding.
void openSpan(QString &text, const QString &style)
virtual void decodeLine(const Character *const characters, int count, LineProperty properties)
Converts a line of terminal characters with associated properties into a text string and writes the s...
void setColorTable(const ColorEntry *table)
Sets the colour table which the decoder uses to produce the HTML colour codes in its output.
virtual void begin(QTextStream *output)
Begin decoding characters.
A terminal character decoder which produces plain text, ignoring colours and other appearance-related...
void setTrailingWhitespace(bool enable)
Set whether trailing whitespace at the end of lines should be included in the output.
virtual void decodeLine(const Character *const characters, int count, LineProperty properties)
Converts a line of terminal characters with associated properties into a text string and writes the s...
virtual void begin(QTextStream *output)
Begin decoding characters.
virtual void end()
End decoding.
bool trailingWhitespace() const
Returns whether trailing whitespace at the end of lines is included in the output.
Base class for terminal character decoders.
virtual void end()=0
End decoding.
virtual void begin(QTextStream *output)=0
Begin decoding characters.
virtual void decodeLine(const Character *const characters, int count, LineProperty properties)=0
Converts a line of terminal characters with associated properties into a text string and writes the s...
T::properties & properties(graphics_object obj)