Konsole
Character.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef CHARACTER_H
00024 #define CHARACTER_H
00025
00026
00027 #include <QtCore/QHash>
00028
00029
00030 #include "CharacterColor.h"
00031
00032 namespace Konsole
00033 {
00034
00035 typedef unsigned char LineProperty;
00036
00037 static const int LINE_DEFAULT = 0;
00038 static const int LINE_WRAPPED = (1 << 0);
00039 static const int LINE_DOUBLEWIDTH = (1 << 1);
00040 static const int LINE_DOUBLEHEIGHT = (1 << 2);
00041
00042 #define DEFAULT_RENDITION 0
00043 #define RE_BOLD (1 << 0)
00044 #define RE_BLINK (1 << 1)
00045 #define RE_UNDERLINE (1 << 2)
00046 #define RE_REVERSE (1 << 3) // Screen only
00047 #define RE_INTENSIVE (1 << 3) // Widget only
00048 #define RE_CURSOR (1 << 4)
00049 #define RE_EXTENDED_CHAR (1 << 5)
00050
00056 class Character
00057 {
00058 public:
00067 inline Character(quint16 _c = ' ',
00068 CharacterColor _f = CharacterColor(COLOR_SPACE_DEFAULT,DEFAULT_FORE_COLOR),
00069 CharacterColor _b = CharacterColor(COLOR_SPACE_DEFAULT,DEFAULT_BACK_COLOR),
00070 quint8 _r = DEFAULT_RENDITION)
00071 : character(_c), rendition(_r), foregroundColor(_f), backgroundColor(_b) {}
00072
00073 union
00074 {
00076 quint16 character;
00084 quint16 charSequence;
00085 };
00086
00088 quint8 rendition;
00089
00091 CharacterColor foregroundColor;
00093 CharacterColor backgroundColor;
00094
00099 bool isTransparent(const ColorEntry* palette) const;
00105 ColorEntry::FontWeight fontWeight(const ColorEntry* base) const;
00106
00111 friend bool operator == (const Character& a, const Character& b);
00116 friend bool operator != (const Character& a, const Character& b);
00117 };
00118
00119 inline bool operator == (const Character& a, const Character& b)
00120 {
00121 return a.character == b.character &&
00122 a.rendition == b.rendition &&
00123 a.foregroundColor == b.foregroundColor &&
00124 a.backgroundColor == b.backgroundColor;
00125 }
00126
00127 inline bool operator != (const Character& a, const Character& b)
00128 {
00129 return a.character != b.character ||
00130 a.rendition != b.rendition ||
00131 a.foregroundColor != b.foregroundColor ||
00132 a.backgroundColor != b.backgroundColor;
00133 }
00134
00135 inline bool Character::isTransparent(const ColorEntry* base) const
00136 {
00137 return ((backgroundColor._colorSpace == COLOR_SPACE_DEFAULT) &&
00138 base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].transparent)
00139 || ((backgroundColor._colorSpace == COLOR_SPACE_SYSTEM) &&
00140 base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].transparent);
00141 }
00142
00143 inline ColorEntry::FontWeight Character::fontWeight(const ColorEntry* base) const
00144 {
00145 if (backgroundColor._colorSpace == COLOR_SPACE_DEFAULT)
00146 return base[backgroundColor._u+0+(backgroundColor._v?BASE_COLORS:0)].fontWeight;
00147 else if (backgroundColor._colorSpace == COLOR_SPACE_SYSTEM)
00148 return base[backgroundColor._u+2+(backgroundColor._v?BASE_COLORS:0)].fontWeight;
00149 else
00150 return ColorEntry::UseCurrentFormat;
00151 }
00152
00153 extern unsigned short vt100_graphics[32];
00154
00155
00162 class ExtendedCharTable
00163 {
00164 public:
00166 ExtendedCharTable();
00167 ~ExtendedCharTable();
00168
00180 ushort createExtendedChar(ushort* unicodePoints , ushort length);
00191 ushort* lookupExtendedChar(ushort hash , ushort& length) const;
00192
00194 static ExtendedCharTable instance;
00195 private:
00196
00197 ushort extendedCharHash(ushort* unicodePoints , ushort length) const;
00198
00199
00200 bool extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const;
00201
00202
00203
00204 QHash<ushort,ushort*> extendedCharTable;
00205 };
00206
00207 }
00208 Q_DECLARE_TYPEINFO(Konsole::Character, Q_MOVABLE_TYPE);
00209
00210 #endif // CHARACTER_H
00211