1 /* 2 * Copyright 2010-2013, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stefano Ceccherini, stefano.ceccherini@gmail.com 7 * Siarzhuk Zharski, zharik@gmx.li 8 */ 9 #ifndef _COLORS_H 10 #define _COLORS_H 11 12 13 #include <InterfaceDefs.h> 14 15 16 struct color_scheme { 17 const char* name; 18 rgb_color text_fore_color; 19 rgb_color text_back_color; 20 rgb_color cursor_fore_color; 21 rgb_color cursor_back_color; 22 rgb_color select_fore_color; 23 rgb_color select_back_color; 24 bool operator==(const color_scheme& color); 25 }; 26 27 extern color_scheme gCustomColorScheme; 28 extern const color_scheme* gPredefinedColorSchemes[]; 29 30 const uint kANSIColorCount = 16; 31 const uint kTermColorCount = 256; 32 33 34 // Helper class handling XColorName/rgb:xxx/xxx/xxx -> rgb_color conversions. 35 // The source of XColorNames is wide available rgb.txt for X11 System. 36 // It is stored in "XColorsTable" application resource as array of 37 // "hash <-> rgb_color" pairs. The table is loaded only on demand. 38 // Name hashes must be sorted to let lookup procedure work properly 39 class XColorsTable { 40 41 struct _XColorEntry { 42 uint32 hash; 43 rgb_color color; 44 }; 45 46 public: 47 XColorsTable(); 48 ~XColorsTable(); 49 50 status_t LookUpColor(const char* name, rgb_color* color); 51 private: 52 status_t _LoadXColorsTable(); 53 uint32 _HashName(const char* name); 54 55 const _XColorEntry* fTable; 56 size_t fCount; 57 }; 58 59 extern XColorsTable gXColorsTable; 60 61 #endif // _COLORS_H 62