1 /* 2 SPDX-FileCopyrightText: 2006-2008 Robert Knight <robertknight@gmail.com> 3 4 SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef HTMLDECODER_H 8 #define HTMLDECODER_H 9 10 // Konsole decoders 11 #include "TerminalCharacterDecoder.h" 12 13 #include <QFont> 14 class QString; 15 16 namespace Konsole 17 { 18 /** 19 * A terminal character decoder which produces pretty HTML markup 20 */ 21 class KONSOLEDECODERS_EXPORT HTMLDecoder : public TerminalCharacterDecoder 22 { 23 public: 24 /** 25 * Constructs an HTML decoder using a default black-on-white color scheme. 26 */ 27 explicit HTMLDecoder(const QString &colorSchemeName = QString(), const QFont &profileFont = QFont()); 28 29 void decodeLine(const Character *const characters, int count, LineProperty properties) override; 30 31 void begin(QTextStream *output) override; 32 void end() override; 33 34 private: 35 void openSpan(QString &text, const QString &style); 36 void closeSpan(QString &text); 37 38 QTextStream *_output; 39 QString _colorSchemeName; 40 QFont _profileFont; 41 QColor _colorTable[TABLE_COLORS]; 42 bool _innerSpanOpen; 43 RenditionFlags _lastRendition; 44 CharacterColor _lastForeColor; 45 CharacterColor _lastBackColor; 46 bool _validProfile; 47 }; 48 } 49 50 #endif 51