GNU Octave  4.4.1
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 
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  */
41 {
42 public:
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 {
69 public:
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 
92 private:
93  QTextStream* _output;
95 };
96 
97 /**
98  * A terminal character decoder which produces pretty HTML markup
99  */
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,
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;
131 
132 };
133 
134 #endif
An entry in a terminal display&#39;s color palette.
void closeSpan(QString &text)
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...
const ColorEntry * _colorTable
A single character in the terminal which consists of a unicode character value, foreground and backgr...
Definition: Character.h:55
Describes the color of a single character in the terminal.
unsigned char LineProperty
Definition: Character.h:34
void openSpan(QString &text, const QString &style)
bool trailingWhitespace() const
Returns whether trailing whitespace at the end of lines is included in the output.
A terminal character decoder which produces plain text, ignoring colours and other appearance-related...
write the output to stdout if nargout otherwise return the output in a character string able ode tem append Append to the destination instead of overwriting tem ascii Save a matrix in a text file without a header or any other information The matrix must be D and only the real part of any complex value is written to the file Numbers are stored in single precision format and separated by spaces Additional options for the and gzip can also be used to convert the files for backward compatibility This option is only available if Octave was built with a link to the zlib libraries end table The list of variables to save may use wildcard patterns containing the following special characters
Definition: load-save.cc:1612
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...
CharacterColor _lastForeColor
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 end()
End decoding.
Base class for terminal character decoders.
A terminal character decoder which produces pretty HTML markup.
void setTrailingWhitespace(bool enable)
Set whether trailing whitespace at the end of lines should be included in the output.
virtual void end()=0
End decoding.
virtual void end()
End decoding.
HTMLDecoder()
Constructs an HTML decoder using a default black-on-white color scheme.
virtual void begin(QTextStream *output)
Begin decoding characters.
CharacterColor _lastBackColor
virtual void begin(QTextStream *output)
Begin decoding characters.
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)=0
Begin decoding characters.
T::properties & properties(graphics_object obj)