File indexing completed on 2025-01-12 06:47:24
0001 /*************************************************************************** 0002 cansiparser.h - ANSI parser 0003 This file is a part of KMuddy distribution. 0004 ------------------- 0005 begin : Pá Jun 21 2002 0006 copyright : (C) 2002-2004 by Tomas Mecir 0007 email : kmuddy@kmuddy.com 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 ***************************************************************************/ 0018 0019 #ifndef CANSIPARSER_H 0020 #define CANSIPARSER_H 0021 0022 #include <QObject> 0023 #include <QColor> 0024 0025 #include <cactionbase.h> 0026 0027 #define CL_BLACK 0 0028 #define CL_RED 1 0029 #define CL_GREEN 2 0030 #define CL_YELLOW 3 0031 #define CL_BLUE 4 0032 #define CL_MAGENTA 5 0033 #define CL_CYAN 6 0034 #define CL_WHITE 7 0035 0036 #define CL_BRIGHT 8 0037 0038 /** 0039 ANSI parser - slot is connected to cTelnet, output goes to displaying widget 0040 and also to some other classes that handle triggers, automapper etc. 0041 *@author Tomas Mecir 0042 */ 0043 0044 class KMUDDY_EXPORT cANSIParser : public QObject, public cActionBase { 0045 Q_OBJECT 0046 public: 0047 cANSIParser (int sess); 0048 ~cANSIParser () override; 0049 0050 /** get color in color palette */ 0051 QColor color (int index); 0052 /** change color palette */ 0053 void setColor (QColor color, int index); 0054 0055 /** get default textcolor */ 0056 QColor defaultTextColor (); 0057 /** change default textcolor */ 0058 void setDefaultTextColor (QColor color); 0059 /** get default background */ 0060 QColor defaultBkColor (); 0061 /** change default background */ 0062 void setDefaultBkColor (QColor color); 0063 0064 void setUseAnsi (bool val) { useansi = val; }; 0065 0066 void eventNothingHandler (QString event, int session) override; 0067 0068 signals: 0069 void fgColor (QColor color); 0070 void bgColor (QColor color); 0071 void attrib (int a); 0072 void plainText (const QString &text); 0073 public slots: 0074 void parseText (const QString &data); 0075 void flush (); 0076 protected: 0077 void changeColor (int color); 0078 void activateBright (); 0079 void deactivateBright (); 0080 QColor mycolor[16]; 0081 0082 QString buffer; 0083 bool useansi; 0084 0085 /** some ANSI flags */ 0086 bool brightactive, blinkactive; 0087 bool underline, italics, strikeout; 0088 bool negactive; 0089 bool invisible; 0090 0091 /** some colors */ 0092 QColor curcolor, curbkcolor; 0093 QColor defcolor, defbkcolor; 0094 }; 0095 0096 #endif