| 1 | /* |
| 2 | This file is part of Konsole, KDE's terminal. |
| 3 | |
| 4 | Copyright 2007-2008 by Robert Knight <[email protected]> |
| 5 | Copyright 1997,1998 by Lars Doelle <[email protected]> |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 20 | 02110-1301 USA. |
| 21 | */ |
| 22 | |
| 23 | #ifndef CHARACTER_H |
| 24 | #define CHARACTER_Hcxx . . $ `lib/Character.h:24:9`! |
| 25 | |
| 26 | // Qt |
| 27 | #include <QHash> |
| 28 | |
| 29 | // Local |
| 30 | #include "CharacterColor.h"cxx . . $ `<file>/lib/CharacterColor.h`/ |
| 31 | |
| 32 | namespace Konsolecxx . . $ Konsole/ |
| 33 | { |
| 34 | |
| 35 | typedef unsigned char LinePropertycxx . . $ Konsole/LineProperty#; |
| 36 | |
| 37 | static const int LINE_DEFAULTcxx . . $ Konsole/LINE_DEFAULT. = 0; |
| 38 | static const int LINE_WRAPPEDcxx . . $ Konsole/LINE_WRAPPED. = (1 << 0); |
| 39 | static const int LINE_DOUBLEWIDTHcxx . . $ Konsole/LINE_DOUBLEWIDTH. = (1 << 1); |
| 40 | static const int LINE_DOUBLEHEIGHTcxx . . $ Konsole/LINE_DOUBLEHEIGHT. = (1 << 2); |
| 41 | |
| 42 | #define DEFAULT_RENDITIONcxx . . $ `lib/Character.h:42:9`! 0 |
| 43 | #define RE_BOLDcxx . . $ `lib/Character.h:43:9`! (1 << 0) |
| 44 | #define RE_BLINKcxx . . $ `lib/Character.h:44:9`! (1 << 1) |
| 45 | #define RE_UNDERLINEcxx . . $ `lib/Character.h:45:9`! (1 << 2) |
| 46 | #define RE_REVERSEcxx . . $ `lib/Character.h:46:9`! (1 << 3) // Screen only |
| 47 | #define RE_INTENSIVEcxx . . $ `lib/Character.h:47:9`! (1 << 3) // Widget only |
| 48 | #define RE_ITALICcxx . . $ `lib/Character.h:48:9`! (1 << 4) |
| 49 | #define RE_CURSORcxx . . $ `lib/Character.h:49:9`! (1 << 5) |
| 50 | #define RE_EXTENDED_CHARcxx . . $ `lib/Character.h:50:9`! (1 << 6) |
| 51 | #define RE_FAINTcxx . . $ `lib/Character.h:51:9`! (1 << 7) |
| 52 | #define RE_STRIKEOUTcxx . . $ `lib/Character.h:52:9`! (1 << 8) |
| 53 | #define RE_CONCEALcxx . . $ `lib/Character.h:53:9`! (1 << 9) |
| 54 | #define RE_OVERLINEcxx . . $ `lib/Character.h:54:9`! (1 << 10) |
| 55 | |
| 56 | /** |
| 57 | * A single character in the terminal which consists of a unicode character |
| 58 | * value, foreground and background colors and a set of rendition attributes |
| 59 | * which specify how it should be drawn. |
| 60 | */ |
| 61 | class Charactercxx . . $ Konsole/Character# |
| 62 | { |
| 63 | public: |
| 64 | /** |
| 65 | * Constructs a new character. |
| 66 | * |
| 67 | * @param _c The unicode character value of this character. |
| 68 | * @param _f The foreground color used to draw the character. |
| 69 | * @param _b The color used to draw the character's background. |
| 70 | * @param _r A set of rendition flags which specify how this character is to be drawn. |
| 71 | */ |
| 72 | inline Charactercxx . . $ Konsole/Character#Character(775c6e5ba34caf00).(quint16cxx . . $ quint16# _c = ' ', |
| 73 | CharacterColorcxx . . $ Konsole/CharacterColor# _f = CharacterColorcxx . . $ Konsole/CharacterColor#CharacterColor(d5cb1b1d97598ec6).(COLOR_SPACE_DEFAULTcxx . . $ `lib/CharacterColor.h:130:9`!,DEFAULT_FORE_COLORcxx . . $ `lib/CharacterColor.h:105:9`!), |
| 74 | CharacterColorcxx . . $ Konsole/CharacterColor# _b = CharacterColorcxx . . $ Konsole/CharacterColor#CharacterColor(d5cb1b1d97598ec6).(COLOR_SPACE_DEFAULTcxx . . $ `lib/CharacterColor.h:130:9`!,DEFAULT_BACK_COLORcxx . . $ `lib/CharacterColor.h:106:9`!), |
| 75 | quint8cxx . . $ quint8# _r = DEFAULT_RENDITIONcxx . . $ `lib/Character.h:42:9`!) |
| 76 | : charactercxx . . $ Konsole/Character#$anonymous_type_0#character.(_c), renditioncxx . . $ Konsole/Character#rendition.(_r), foregroundColorcxx . . $ Konsole/Character#foregroundColor.(_f), backgroundColorcxx . . $ Konsole/Character#backgroundColor.(_b) {} |
| 77 | |
| 78 | unioncxx . . $ Konsole/Character#$anonymous_type_0# |
| 79 | { |
| 80 | /** The unicode character value for this character. */ |
| 81 | wchar_t charactercxx . . $ Konsole/Character#$anonymous_type_0#character.; |
| 82 | /** |
| 83 | * Experimental addition which allows a single Character instance to contain more than |
| 84 | * one unicode character. |
| 85 | * |
| 86 | * charSequence is a hash code which can be used to look up the unicode |
| 87 | * character sequence in the ExtendedCharTable used to create the sequence. |
| 88 | */ |
| 89 | quint16cxx . . $ quint16# charSequencecxx . . $ Konsole/Character#$anonymous_type_0#charSequence.; |
| 90 | }; |
| 91 | |
| 92 | /** A combination of RENDITION flags which specify options for drawing the character. */ |
| 93 | quint8cxx . . $ quint8# renditioncxx . . $ Konsole/Character#rendition.; |
| 94 | |
| 95 | /** The foreground color used to draw this character. */ |
| 96 | CharacterColorcxx . . $ Konsole/CharacterColor# foregroundColorcxx . . $ Konsole/Character#foregroundColor.; |
| 97 | /** The color used to draw this character's background. */ |
| 98 | CharacterColorcxx . . $ Konsole/CharacterColor# backgroundColorcxx . . $ Konsole/Character#backgroundColor.; |
| 99 | |
| 100 | /** |
| 101 | * Returns true if this character has a transparent background when |
| 102 | * it is drawn with the specified @p palette. |
| 103 | */ |
| 104 | bool isTransparentcxx . . $ Konsole/Character#isTransparent(1438919534f6f1e6).(const ColorEntrycxx . . $ Konsole/ColorEntry#* palette) const; |
| 105 | /** |
| 106 | * Returns true if this character should always be drawn in bold when |
| 107 | * it is drawn with the specified @p palette, independent of whether |
| 108 | * or not the character has the RE_BOLD rendition flag. |
| 109 | */ |
| 110 | ColorEntrycxx . . $ Konsole/ColorEntry#::FontWeightcxx . . $ Konsole/ColorEntry#FontWeight# fontWeightcxx . . $ Konsole/Character#fontWeight(d801bd6c3059e593).(const ColorEntrycxx . . $ Konsole/ColorEntry#* base) const; |
| 111 | |
| 112 | /** |
| 113 | * returns true if the format (color, rendition flag) of the compared characters is equal |
| 114 | */ |
| 115 | bool equalsFormatcxx . . $ Konsole/Character#equalsFormat(3a60cc5fc593e4b3).(const Charactercxx . . $ Konsole/Character# &other) const; |
| 116 | |
| 117 | /** |
| 118 | * Compares two characters and returns true if they have the same unicode character value, |
| 119 | * rendition and colors. |
| 120 | */ |
| 121 | friend bool operatorcxx . . $ Konsole/`operator==`(2e6b4567d0fd245f). == (const Charactercxx . . $ Konsole/Character#& a, const Charactercxx . . $ Konsole/Character#& b); |
| 122 | /** |
| 123 | * Compares two characters and returns true if they have different unicode character values, |
| 124 | * renditions or colors. |
| 125 | */ |
| 126 | friend bool operatorcxx . . $ Konsole/`operator!=`(2e6b4567d0fd245f). != (const Charactercxx . . $ Konsole/Character#& a, const Charactercxx . . $ Konsole/Character#& b); |
| 127 | }; |
| 128 | |
| 129 | inline bool operatorcxx . . $ Konsole/`operator==`(2e6b4567d0fd245f). == (const Charactercxx . . $ Konsole/Character#& a, const Charactercxx . . $ Konsole/Character#& b) |
| 130 | { |
| 131 | return a.charactercxx . . $ Konsole/Character#$anonymous_type_0#character. == b.charactercxx . . $ Konsole/Character#$anonymous_type_0#character. && |
| 132 | a.renditioncxx . . $ Konsole/Character#rendition. == b.renditioncxx . . $ Konsole/Character#rendition. && |
| 133 | a.foregroundColorcxx . . $ Konsole/Character#foregroundColor. ==cxx . . $ Konsole/`operator==`(40f11079b1efd097). b.foregroundColorcxx . . $ Konsole/Character#foregroundColor. && |
| 134 | a.backgroundColorcxx . . $ Konsole/Character#backgroundColor. ==cxx . . $ Konsole/`operator==`(40f11079b1efd097). b.backgroundColorcxx . . $ Konsole/Character#backgroundColor.; |
| 135 | } |
| 136 | |
| 137 | inline bool operatorcxx . . $ Konsole/`operator!=`(2e6b4567d0fd245f). != (const Charactercxx . . $ Konsole/Character#& a, const Charactercxx . . $ Konsole/Character#& b) |
| 138 | { |
| 139 | return a.charactercxx . . $ Konsole/Character#$anonymous_type_0#character. != b.charactercxx . . $ Konsole/Character#$anonymous_type_0#character. || |
| 140 | a.renditioncxx . . $ Konsole/Character#rendition. != b.renditioncxx . . $ Konsole/Character#rendition. || |
| 141 | a.foregroundColorcxx . . $ Konsole/Character#foregroundColor. !=cxx . . $ Konsole/`operator!=`(40f11079b1efd097). b.foregroundColorcxx . . $ Konsole/Character#foregroundColor. || |
| 142 | a.backgroundColorcxx . . $ Konsole/Character#backgroundColor. !=cxx . . $ Konsole/`operator!=`(40f11079b1efd097). b.backgroundColorcxx . . $ Konsole/Character#backgroundColor.; |
| 143 | } |
| 144 | |
| 145 | inline bool Charactercxx . . $ Konsole/Character#::isTransparentcxx . . $ Konsole/Character#isTransparent(1438919534f6f1e6).(const ColorEntrycxx . . $ Konsole/ColorEntry#* base) const |
| 146 | { |
| 147 | return ((backgroundColorcxx . . $ Konsole/Character#backgroundColor.._colorSpacecxx . . $ Konsole/CharacterColor#_colorSpace. == COLOR_SPACE_DEFAULTcxx . . $ `lib/CharacterColor.h:130:9`!) && |
| 148 | base[backgroundColorcxx . . $ Konsole/Character#backgroundColor.._ucxx . . $ Konsole/CharacterColor#_u.+0+(backgroundColorcxx . . $ Konsole/Character#backgroundColor.._vcxx . . $ Konsole/CharacterColor#_v.?BASE_COLORScxx . . $ `lib/CharacterColor.h:101:9`!:0)].transparentcxx . . $ Konsole/ColorEntry#transparent.) |
| 149 | || ((backgroundColorcxx . . $ Konsole/Character#backgroundColor.._colorSpacecxx . . $ Konsole/CharacterColor#_colorSpace. == COLOR_SPACE_SYSTEMcxx . . $ `lib/CharacterColor.h:131:9`!) && |
| 150 | base[backgroundColorcxx . . $ Konsole/Character#backgroundColor.._ucxx . . $ Konsole/CharacterColor#_u.+2+(backgroundColorcxx . . $ Konsole/Character#backgroundColor.._vcxx . . $ Konsole/CharacterColor#_v.?BASE_COLORScxx . . $ `lib/CharacterColor.h:101:9`!:0)].transparentcxx . . $ Konsole/ColorEntry#transparent.); |
| 151 | } |
| 152 | |
| 153 | inline bool Charactercxx . . $ Konsole/Character#::equalsFormatcxx . . $ Konsole/Character#equalsFormat(3a60cc5fc593e4b3).(const Charactercxx . . $ Konsole/Character#& other) const |
| 154 | { |
| 155 | return |
| 156 | backgroundColorcxx . . $ Konsole/Character#backgroundColor.==cxx . . $ Konsole/`operator==`(40f11079b1efd097).other.backgroundColorcxx . . $ Konsole/Character#backgroundColor. && |
| 157 | foregroundColorcxx . . $ Konsole/Character#foregroundColor.==cxx . . $ Konsole/`operator==`(40f11079b1efd097).other.foregroundColorcxx . . $ Konsole/Character#foregroundColor. && |
| 158 | renditioncxx . . $ Konsole/Character#rendition.==other.renditioncxx . . $ Konsole/Character#rendition.; |
| 159 | } |
| 160 | |
| 161 | inline ColorEntrycxx . . $ Konsole/ColorEntry#::FontWeightcxx . . $ Konsole/ColorEntry#FontWeight# Charactercxx . . $ Konsole/Character#::fontWeightcxx . . $ Konsole/Character#fontWeight(d801bd6c3059e593).(const ColorEntrycxx . . $ Konsole/ColorEntry#* base) const |
| 162 | { |
| 163 | if (backgroundColorcxx . . $ Konsole/Character#backgroundColor.._colorSpacecxx . . $ Konsole/CharacterColor#_colorSpace. == COLOR_SPACE_DEFAULTcxx . . $ `lib/CharacterColor.h:130:9`!) |
| 164 | return base[backgroundColorcxx . . $ Konsole/Character#backgroundColor.._ucxx . . $ Konsole/CharacterColor#_u.+0+(backgroundColorcxx . . $ Konsole/Character#backgroundColor.._vcxx . . $ Konsole/CharacterColor#_v.?BASE_COLORScxx . . $ `lib/CharacterColor.h:101:9`!:0)].fontWeightcxx . . $ Konsole/ColorEntry#fontWeight.; |
| 165 | else if (backgroundColorcxx . . $ Konsole/Character#backgroundColor.._colorSpacecxx . . $ Konsole/CharacterColor#_colorSpace. == COLOR_SPACE_SYSTEMcxx . . $ `lib/CharacterColor.h:131:9`!) |
| 166 | return base[backgroundColorcxx . . $ Konsole/Character#backgroundColor.._ucxx . . $ Konsole/CharacterColor#_u.+2+(backgroundColorcxx . . $ Konsole/Character#backgroundColor.._vcxx . . $ Konsole/CharacterColor#_v.?BASE_COLORScxx . . $ `lib/CharacterColor.h:101:9`!:0)].fontWeightcxx . . $ Konsole/ColorEntry#fontWeight.; |
| 167 | else |
| 168 | return ColorEntrycxx . . $ Konsole/ColorEntry#::UseCurrentFormatcxx . . $ Konsole/ColorEntry#UseCurrentFormat.; |
| 169 | } |
| 170 | |
| 171 | extern unsigned short vt100_graphicscxx . . $ Konsole/vt100_graphics.[32]; |
| 172 | |
| 173 | |
| 174 | /** |
| 175 | * A table which stores sequences of unicode characters, referenced |
| 176 | * by hash keys. The hash key itself is the same size as a unicode |
| 177 | * character ( ushort ) so that it can occupy the same space in |
| 178 | * a structure. |
| 179 | */ |
| 180 | class ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable# |
| 181 | { |
| 182 | public: |
| 183 | /** Constructs a new character table. */ |
| 184 | ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#ExtendedCharTable(49f6e7a06ebc5aa8).(); |
| 185 | ~cxx . . $ Konsole/ExtendedCharTable#`~ExtendedCharTable`(49f6e7a06ebc5aa8).ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable#(); |
| 186 | |
| 187 | /** |
| 188 | * Adds a sequences of unicode characters to the table and returns |
| 189 | * a hash code which can be used later to look up the sequence |
| 190 | * using lookupExtendedChar() |
| 191 | * |
| 192 | * If the same sequence already exists in the table, the hash |
| 193 | * of the existing sequence will be returned. |
| 194 | * |
| 195 | * @param unicodePoints An array of unicode character points |
| 196 | * @param length Length of @p unicodePoints |
| 197 | */ |
| 198 | ushortcxx . . $ ushort# createExtendedCharcxx . . $ Konsole/ExtendedCharTable#createExtendedChar(5d258c7a68607401).(ushortcxx . . $ ushort#* unicodePoints , ushortcxx . . $ ushort# length); |
| 199 | /** |
| 200 | * Looks up and returns a pointer to a sequence of unicode characters |
| 201 | * which was added to the table using createExtendedChar(). |
| 202 | * |
| 203 | * @param hash The hash key returned by createExtendedChar() |
| 204 | * @param length This variable is set to the length of the |
| 205 | * character sequence. |
| 206 | * |
| 207 | * @return A unicode character sequence of size @p length. |
| 208 | */ |
| 209 | ushortcxx . . $ ushort#* lookupExtendedCharcxx . . $ Konsole/ExtendedCharTable#lookupExtendedChar(9d4345af5ccf9989).(ushortcxx . . $ ushort# hash , ushortcxx . . $ ushort#& length) const; |
| 210 | |
| 211 | /** The global ExtendedCharTable instance. */ |
| 212 | static ExtendedCharTablecxx . . $ Konsole/ExtendedCharTable# instancecxx . . $ Konsole/ExtendedCharTable#instance.; |
| 213 | private: |
| 214 | // calculates the hash key of a sequence of unicode points of size 'length' |
| 215 | ushortcxx . . $ ushort# extendedCharHashcxx . . $ Konsole/ExtendedCharTable#extendedCharHash(5bb79e050fa8f5ae).(ushortcxx . . $ ushort#* unicodePoints , ushortcxx . . $ ushort# length) const; |
| 216 | // tests whether the entry in the table specified by 'hash' matches the |
| 217 | // character sequence 'unicodePoints' of size 'length' |
| 218 | bool extendedCharMatchcxx . . $ Konsole/ExtendedCharTable#extendedCharMatch(ef6734a0bf559b46).(ushortcxx . . $ ushort# hash , ushortcxx . . $ ushort#* unicodePoints , ushortcxx . . $ ushort# length) const; |
| 219 | // internal, maps hash keys to character sequence buffers. The first ushort |
| 220 | // in each value is the length of the buffer, followed by the ushorts in the buffer |
| 221 | // themselves. |
| 222 | QHashcxx . . $ QHash#<ushortcxx . . $ ushort#,ushortcxx . . $ ushort#*> extendedCharTablecxx . . $ Konsole/ExtendedCharTable#extendedCharTable.; |
| 223 | }; |
| 224 | |
| 225 | } |
| 226 | Q_DECLARE_TYPEINFOcxx . . $ QTypeInfo#isComplex.(Konsole::Character, Q_MOVABLE_TYPE); |
| 227 | |
| 228 | #endif // CHARACTER_H |
| 229 |