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