• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Konsole

Character.h

Go to the documentation of this file.
00001 /*
00002     This file is part of Konsole, KDE's terminal.
00003     
00004     Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
00005     Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020     02110-1301  USA.
00021 */
00022 
00023 #ifndef CHARACTER_H
00024 #define CHARACTER_H
00025 
00026 // Qt
00027 #include <QtCore/QHash>
00028 
00029 // Local
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     // calculates the hash key of a sequence of unicode points of size 'length'
00197     ushort extendedCharHash(ushort* unicodePoints , ushort length) const;
00198     // tests whether the entry in the table specified by 'hash' matches the 
00199     // character sequence 'unicodePoints' of size 'length'
00200     bool extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const;
00201     // internal, maps hash keys to character sequence buffers.  The first ushort
00202     // in each value is the length of the buffer, followed by the ushorts in the buffer
00203     // themselves.
00204     QHash<ushort,ushort*> extendedCharTable;
00205 };
00206 
00207 }
00208 Q_DECLARE_TYPEINFO(Konsole::Character, Q_MOVABLE_TYPE);
00209 
00210 #endif // CHARACTER_H
00211 

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal