KVIrc  4.9.2
DeveloperAPIs
KviControlCodes.h
Go to the documentation of this file.
1 #ifndef _KVI_CONTROLCODES_H_
2 #define _KVI_CONTROLCODES_H_
3 
4 //=============================================================================
5 //
6 // File : KviControlCodes.h
7 // Creation date : Thu Jun 29 2000 21:06:55 CEST by Szymon Stefanek
8 //
9 // This file is part of the KVIrc IRC client distribution
10 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
11 // Copyright (C) 2011 Elvio Basello (hellvis69 at gmail dot com)
12 //
13 // This program is FREE software. You can redistribute it and/or
14 // modify it under the terms of the GNU General Public License
15 // as published by the Free Software Foundation; either version 2
16 // of the License, or (at your option) any later version.
17 //
18 // This program is distributed in the HOPE that it will be USEFUL,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 // See the GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program. If not, write to the Free Software Foundation,
25 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 //
27 //=============================================================================
28 
29 //=============================================================================
30 // This file contains non-customizable standards
31 //
32 // Better do not touch this :)
33 //=============================================================================
34 
43 #include "kvi_settings.h"
44 #include "KviCString.h"
45 
46 #define KVI_MIRCCOLOR_MAX_FOREGROUND 15
47 #define KVI_MIRCCOLOR_MAX_BACKGROUND 15
48 
49 // ASCII Stuff: the following defines are meant to be escape sequences
50 // that can go through an IRC connection
51 
52 // The following table is a 30-minute analysis of the escape characters commonly used over the IRC protocol...
53 // created when looking for a good placement for the CRYPT escape char in KVirc.
54 // I guess that the best chars to be used were FS,GS,RS,US,DC1,DC2,DC3,DC4...they have the "less defined"
55 // meaning as ASCII control chars.
56 // mmmh... :)
57 
58 // ASCII IRC Meaning
59 // 000 NUL Null (Cannot be assigned)
60 // 001 SOH Start of heading ( CTCP Escape: only beginning of the message )
61 // 002 STX Start of text ( Bold text )
62 // 003 ETX End of text ( Color text escape sequence )
63 // 004 EOT End of transmission ( Assigned internally (escape) )
64 // 005 ENQ Enquiry (WRU: Who are you) ( Assigned internally (unescape) )
65 // 006 ACK Acknowledge (Not so good, but can be used as last resource)
66 // 007 BEL Bell ( Recognized as bell by terminals and IRCII ) (Used also by some IRC servers)
67 // 008 BS Backspace (Should not be assigned: terminal control)
68 // 009 HT Horizontal tabulation (Should not be assigned: terminal control)
69 // 010 LF Line feed (Should not be assigned: terminal control)
70 // 011 VT Vertical tabulation (Should not be assigned: terminal control)
71 // 012 FF Form feed (Should not be assigned: terminal control)
72 // 013 CR Carriage return (Should not be assigned: terminal control)
73 // 014 SO Shift out (Should not be assigned: terminal control)
74 // 015 SI Shift in ( Resets Bold,Color,Underline and Reverse ) (Conflicting with terminal control)
75 // 016 DLE Data link escape (Decent, can be assigned)
76 // 017 DC1 Device control 1 (Good to be assigned)
77 // 018 DC2 Device control 2 (Good to be assigned)
78 // 019 DC3 Device control 3 (Good to be assigned)
79 // 020 DC4 Device control 4 (Good to be assigned)
80 // 021 NAK Negative acknowledge (Not so good, but could be used as last resource)
81 // 022 SYN Synchronous idle ( Reverse text )
82 // 023 ETB End of transmission block (Decent, can be assigned)
83 // 024 CAN Cancel (Should not be assigned: terminal control)
84 // 025 EM End of medium (Decent, can be assigned)
85 // 026 SUB Substitute (Should not be assigned: terminal control)
86 // 027 ESC Escape (Should not be assigned: terminal control)
87 // 028 FS File separator (Excellent, should be used as first candidate)
88 // 029 GS Group separator ( ICONS Escape: beginning of a word )
89 // 030 RS Record separator ( CRYPT Escape: only beginning of the message )
90 // 031 US Unit separator ( Underline text )
91 
92 //
93 // mIrc control codes
94 //
95 //31 (0001 1111) US (Unit separator)
96 //2 (0000 0010) STX (Start of text)
97 //15 (0000 1111) SI (Shift in)
98 //22 (0001 0110) SYN (Synchronous idle)
99 //3 (0000 0011) ETX (End of text)
100 
101 // FIXME: Recent versions of mIrc use 29 as Italic text escape.
102 // This collides with our icon escape and creates a backward compatibility problem if we want to follow mIrc.
103 
104 //
105 // Irc control codes
106 //
107 //1 (0000 0001) SOH (Start of heading)
108 
109 //
110 // KVirc added control codes
111 //
112 //30 (0001 1110) RS (Record separator)
113 //29 (0001 1101) GS (Group separator)
114 
119 namespace KviControlCodes
120 {
125  enum Color
126  {
127  White = 0,
128  Black = 1,
129  DarkBlue = 2,
130  DarkGreen = 3,
131  Red = 4,
132  DarkRed = 5,
134  Orange = 7,
135  Yellow = 8,
137  BlueMarine = 10,
138  LightBlue = 11,
139  Blue = 12,
140  LightViolet = 13,
141  DarkGray = 14,
142  LightGray = 15,
143  Transparent = 100,
144  NoChange = 101
145  };
146 
151  enum Control
152  {
153  CTCP = 0x01,
154  Bold = 0x02,
155  Color = 0x03,
156  Escape = 0x04,
157  UnEscape = 0x05,
158  UnIcon = 0x06,
159  Reset = 0x0f,
160  Reverse = 0x16,
161  Icon = 0x1d,
162  CryptEscape = 0x1e,
163  Underline = 0x1f
164  };
165 
171  KVILIB_API QString stripControlBytes(const QString & szData);
172 
173  KVILIB_API const kvi_wchar_t * getColorBytesW(const kvi_wchar_t * pwData, unsigned char * pcByte1, unsigned char * pcByte2);
174 
175  KVILIB_API unsigned int getUnicodeColorBytes(const QString & szData, unsigned int iChar, unsigned char * pcByte1, unsigned char * pcByte2);
176 #if 0
177  extern KVILIB_API const char * getColorBytes(const char * pcData, unsigned char * pcByte1, unsigned char * pcByte2);
178  inline const QChar * getUnicodeColorBytes(const QChar * pData, unsigned char * pcByte1, unsigned char * pcByte2)
179  { return (QChar *)getColorBytesW((const kvi_wchar_t *)pData,pcByte1,pcByte2); }
180 #endif
181 }
182 
183 #endif //_KVI_CONTROLCODES_H_
Definition: KviControlCodes.h:136
Definition: KviControlCodes.h:132
Control
Contains mIRC control codes.
Definition: KviControlCodes.h:151
Definition: KviControlCodes.h:160
Definition: KviControlCodes.h:133
Definition: KviControlCodes.h:157
Definition: KviControlCodes.h:153
Definition: KviControlCodes.h:135
Definition: KviControlCodes.h:162
Definition: KviControlCodes.h:163
kvi_u16_t kvi_wchar_t
Definition: KviCString.h:87
Definition: KviControlCodes.h:139
Definition: KviControlCodes.h:137
Definition: KviControlCodes.h:134
Definition: KviControlCodes.h:127
Definition: KviControlCodes.h:156
Definition: KviControlCodes.h:138
Definition: KviControlCodes.h:141
Definition: KviControlCodes.h:158
Definition: KviControlCodes.h:154
Definition: KviControlCodes.h:161
QString stripControlBytes(const QString &szData)
Removes control bytes from the given string.
Definition: KviControlCodes.cpp:31
Definition: KviControlCodes.h:129
const kvi_wchar_t * getColorBytesW(const kvi_wchar_t *pwData, unsigned char *pcByte1, unsigned char *pcByte2)
Definition: KviControlCodes.cpp:86
Definition: KviControlCodes.h:142
Definition: KviControlCodes.h:128
Definition: KviControlCodes.h:131
Definition: KviControlCodes.h:144
Definition: KviControlCodes.h:143
This file contains compile time settings.
unsigned int getUnicodeColorBytes(const QString &szData, unsigned int iChar, unsigned char *pcByte1, unsigned char *pcByte2)
Definition: KviControlCodes.cpp:161
Definition: KviControlCodes.h:140
Color
Contains mIRC color codes.
Definition: KviControlCodes.h:125
Definition: KviControlCodes.h:130
#define KVILIB_API
Definition: kvi_settings.h:125
Definition: KviControlCodes.h:159