Konsole
TerminalCharacterDecoder.h
Go to the documentation of this file.00001 /* 00002 This file is part of Konsole, an X terminal. 00003 00004 Copyright 2006-2008 by Robert Knight <robertknight@gmail.com> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU Lesser General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00019 02110-1301 USA. 00020 */ 00021 00022 #ifndef TERMINAL_CHARACTER_DECODER_H 00023 #define TERMINAL_CHARACTER_DECODER_H 00024 00025 #include "Character.h" 00026 00027 #include <QList> 00028 00029 class QTextStream; 00030 00031 namespace Konsole 00032 { 00033 00043 class TerminalCharacterDecoder 00044 { 00045 public: 00046 virtual ~TerminalCharacterDecoder() {} 00047 00049 virtual void begin(QTextStream* output) = 0; 00051 virtual void end() = 0; 00052 00061 virtual void decodeLine(const Character* const characters, 00062 int count, 00063 LineProperty properties) = 0; 00064 }; 00065 00070 class PlainTextDecoder : public TerminalCharacterDecoder 00071 { 00072 public: 00073 PlainTextDecoder(); 00074 00080 void setTrailingWhitespace(bool enable); 00085 bool trailingWhitespace() const; 00091 QList<int> linePositions() const; 00093 void setRecordLinePositions(bool record); 00094 00095 virtual void begin(QTextStream* output); 00096 virtual void end(); 00097 00098 virtual void decodeLine(const Character* const characters, 00099 int count, 00100 LineProperty properties); 00101 00102 00103 private: 00104 QTextStream* _output; 00105 bool _includeTrailingWhitespace; 00106 00107 bool _recordLinePositions; 00108 QList<int> _linePositions; 00109 }; 00110 00114 class HTMLDecoder : public TerminalCharacterDecoder 00115 { 00116 public: 00120 HTMLDecoder(); 00121 00126 void setColorTable( const ColorEntry* table ); 00127 00128 virtual void decodeLine(const Character* const characters, 00129 int count, 00130 LineProperty properties); 00131 00132 virtual void begin(QTextStream* output); 00133 virtual void end(); 00134 00135 private: 00136 void openSpan(QString& text , const QString& style); 00137 void closeSpan(QString& text); 00138 00139 QTextStream* _output; 00140 const ColorEntry* _colorTable; 00141 bool _innerSpanOpen; 00142 quint8 _lastRendition; 00143 CharacterColor _lastForeColor; 00144 CharacterColor _lastBackColor; 00145 00146 }; 00147 00148 } 00149 00150 #endif