~ubuntu-branches/ubuntu/trusty/kvirc/trusty-proposed

« back to all changes in this revision

Viewing changes to src/kvilib/irc/KviControlCodes.h

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 opinion) 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
 
 
35
/**
 
36
* \file KviControlCodes.h
 
37
* \author Szymon Stefanek
 
38
* \brief This file holds the text control codes
 
39
 
40
* It was originally named KviMircCntrl
 
41
*/
 
42
 
 
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
 
 
50
 
 
51
// ASCII Stuff: the following defines are meant to be escape sequences
 
52
//              that can go thru an IRC connection
 
53
 
 
54
// The following table is a 30-minute analysis of the escape characters commonly used over the IRC protocol...
 
55
// created when looking for a good placement for the CRYPT escape char in KVirc.
 
56
// I guess that the best chars to be used were FS,GS,RS,US,DC1,DC2,DC3,DC4...they have the "less defined"
 
57
// meaning as ASCII control chars.
 
58
// mmmh... :) 
 
59
 
 
60
// ASCII                              IRC Meaning
 
61
// 000 NUL Null                       (Cannot be assigned)
 
62
// 001 SOH Start of heading           ( CTCP Escape: only beginning of the message )
 
63
// 002 STX Start of text              ( Bold text )
 
64
// 003 ETX End of text                ( Color text escape sequence )
 
65
// 004 EOT End of transmission        ( Assigned internally (escape) )
 
66
// 005 ENQ Enquiry (WRU: Who are you) ( Assigned internally (unescape) )
 
67
// 006 ACK Acknowledge                (Not so good, but can be used as last resource)
 
68
// 007 BEL Bell                       ( Recognized as bell by terminals and IRCII ) (Used also by some IRC servers)
 
69
// 008 BS  Backspace                  (Should not be assigned: terminal control)
 
70
// 009 HT  Horizontal tabulation      (Should not be assigned: terminal control)
 
71
// 010 LF  Line feed                  (Should not be assigned: terminal control)
 
72
// 011 VT  Vertical tabulation        (Should not be assigned: terminal control)
 
73
// 012 FF  Form feed                  (Should not be assigned: terminal control)
 
74
// 013 CR  Carriage return            (Should not be assigned: terminal control)
 
75
// 014 SO  Shift out                  (Should not be assigned: terminal control)
 
76
// 015 SI  Shift in                   ( Resets Bold,Color,Underline and Reverse ) (Conflicting with terminal control)
 
77
// 016 DLE Data link escape           (Decent, can be assigned)
 
78
// 017 DC1 Device control 1           (Good to be assigned)
 
79
// 018 DC2 Device control 2           (Good to be assigned)
 
80
// 019 DC3 Device control 3           (Good to be assigned)
 
81
// 020 DC4 Device control 4           (Good to be assigned)
 
82
// 021 NAK Negative acknowledge       (Not so good, but could be used as last resource)
 
83
// 022 SYN Synchronous idle           ( Reverse text )
 
84
// 023 ETB End of transmission block  (Decent, can be assigned)
 
85
// 024 CAN Cancel                     (Should not be assigned: terminal control)
 
86
// 025 EM  End of medium              (Decent, can be assigned)
 
87
// 026 SUB Substitute                 (Should not be assigned: terminal control)
 
88
// 027 ESC Escape                     (Should not be assigned: terminal control)
 
89
// 028 FS  File separator             (Excellent, should be used as first candidate)
 
90
// 029 GS  Group separator            ( ICONS Escape: beginning of a word )
 
91
// 030 RS  Record separator           ( CRYPT Escape: only beginning of the message )
 
92
// 031 US  Unit separator             ( Underline text )
 
93
 
 
94
 
 
95
//
 
96
// mIrc control codes
 
97
//
 
98
//31 (0001 1111) US (Unit separator)
 
99
//2  (0000 0010) STX (Start of text)
 
100
//15 (0000 1111) SI (Shift in)
 
101
//22 (0001 0110) SYN (Synchronous idle)
 
102
//3  (0000 0011) ETX (End of text)
 
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
 
 
115
 
 
116
/**
 
117
* \namespace KviControlCodes
 
118
* \brief Holds all text control code KVIrc uses
 
119
*/
 
120
namespace KviControlCodes
 
121
{
 
122
        /**
 
123
        * \enum Color
 
124
        * \brief Contains mIRC color codes
 
125
        */
 
126
        enum Color {
 
127
                White       =   0,   /**< White */
 
128
                Black       =   1,   /**< Black */
 
129
                DarkBlue    =   2,   /**< Dark blue */
 
130
                DarkGreen   =   3,   /**< Dark green */
 
131
                Red         =   4,   /**< Red */
 
132
                DarkRed     =   5,   /**< Dark red */
 
133
                DarkViolet  =   6,   /**< Dark violet */
 
134
                Orange      =   7,   /**< Orange */
 
135
                Yellow      =   8,   /**< Yellow */
 
136
                LightGreen  =   9,   /**< Light green */
 
137
                BlueMarine  =  10,   /**< Blue marine */
 
138
                LightBlue   =  11,   /**< Light blue */
 
139
                Blue        =  12,   /**< Blue */
 
140
                LightViolet =  13,   /**< Light violet */
 
141
                DarkGray    =  14,   /**< Dark gray */
 
142
                LightGray   =  15,   /**< Light gray */
 
143
                Transparent = 100,   /**< Transparent, non standard color code for KviIrcView */
 
144
                NoChange    = 101    /**< No change, non standard color code for KviIrcView */
 
145
        };
 
146
 
 
147
        /**
 
148
        * \enum Control
 
149
        * \brief Contains mIRC control codes
 
150
        */
 
151
        enum Control {
 
152
                CTCP        = 0x01,   /**< CTCP, IRC control code */
 
153
                Bold        = 0x02,   /**< Bold */
 
154
                Color       = 0x03,   /**< Color */
 
155
                Escape      = 0x04,   /**< Escape, totally artificial and internal to KviIrcView */
 
156
                UnEscape    = 0x05,   /**< Unescape, totally artificial and internal to KviIrcView */
 
157
                UnIcon      = 0x06,   /**< Unicon, totally artificial and internal to KviIrcView */
 
158
                Reset       = 0x0f,   /**< Reset */
 
159
                Reverse     = 0x16,   /**< Reverse */
 
160
                Icon        = 0x1d,   /**< Icon, KVIrc control code */
 
161
                CryptEscape = 0x1e,   /**< Crypt escape, KVIrc control code */
 
162
                Underline   = 0x1f    /**< Underline */
 
163
        };
 
164
 
 
165
        /**
 
166
        * \brief Removes control bytes from the given string
 
167
        * \param szData The string to clean
 
168
        * \return QString
 
169
        */
 
170
        KVILIB_API QString stripControlBytes(const QString & szData);
 
171
 
 
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_