source: ogBrowser-Git/qtermwidget/src/TerminalCharacterDecoder.h

qndtest
Last change on this file was 050d67a, checked in by adelcastillo <adelcastillo@…>, 15 years ago

Ahora el browser tiene consola en vez del output.
Pasado todo el sistema de compilacion a cmake.

git-svn-id: https://opengnsys.es/svn/trunk@408 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2    This file is part of Konsole, an X terminal.
3   
4    Copyright (C) 2006-7 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 "Character.h"
28
29class QTextStream;
30
31namespace 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 */
43class TerminalCharacterDecoder
44{
45public:
46        virtual ~TerminalCharacterDecoder() {}
47
48    /** Begin decoding characters.  The resulting text is appended to @p output. */
49    virtual void begin(QTextStream* output) = 0;
50    /** End decoding. */
51    virtual void end() = 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 properties Additional properties which affect all characters in the line
59         * @param output The output stream which receives the decoded text
60         */
61        virtual void decodeLine(const Character* const characters, 
62                                                        int count,
63                                                        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 */
70class PlainTextDecoder : public TerminalCharacterDecoder
71{
72public:
73        PlainTextDecoder(); 
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 setTrailingWhitespace(bool enable);
81    /**
82     * Returns whether trailing whitespace at the end of lines is included
83     * in the output.
84     */
85    bool trailingWhitespace() const;
86
87    virtual void begin(QTextStream* output);
88    virtual void end();
89
90        virtual void decodeLine(const Character* const characters,
91                                                        int count,
92                                                        LineProperty properties);       
93
94   
95private:
96    QTextStream* _output;
97    bool _includeTrailingWhitespace;
98};
99
100/**
101 * A terminal character decoder which produces pretty HTML markup
102 */
103class HTMLDecoder : public TerminalCharacterDecoder
104{
105public:
106        /**
107         * Constructs an HTML decoder using a default black-on-white color scheme.
108         */
109        HTMLDecoder();
110
111        /**
112         * Sets the colour table which the decoder uses to produce the HTML colour codes in its
113         * output
114         */
115        void setColorTable( const ColorEntry* table );
116               
117        virtual void decodeLine(const Character* const characters,
118                                                        int count,
119                                                        LineProperty properties);
120
121    virtual void begin(QTextStream* output);
122    virtual void end();
123
124private:
125        void openSpan(QString& text , const QString& style);
126        void closeSpan(QString& text);
127
128    QTextStream* _output;
129        const ColorEntry* _colorTable;
130    bool _innerSpanOpen; 
131        quint8 _lastRendition;
132        CharacterColor _lastForeColor;
133        CharacterColor _lastBackColor;
134
135};
136
137}
138
139#endif
Note: See TracBrowser for help on using the repository browser.