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 ansi_color_scheme { 17 rgb_color black; 18 rgb_color red; 19 rgb_color green; 20 rgb_color yellow; 21 rgb_color blue; 22 rgb_color magenta; 23 rgb_color cyan; 24 rgb_color white; 25 bool operator==(const ansi_color_scheme& color); 26 }; 27 28 struct color_scheme { 29 const char* name; 30 rgb_color text_fore_color; 31 rgb_color text_back_color; 32 rgb_color cursor_fore_color; 33 rgb_color cursor_back_color; 34 rgb_color select_fore_color; 35 rgb_color select_back_color; 36 ansi_color_scheme ansi_colors; 37 ansi_color_scheme ansi_colors_h; 38 bool operator==(const color_scheme& color); 39 }; 40 41 extern color_scheme gCustomColorScheme; 42 extern const color_scheme* gPredefinedColorSchemes[]; 43 44 const uint kANSIColorCount = 16; 45 const uint kTermColorCount = 256; 46 47 48 // Helper class handling XColorName/rgb:xxx/xxx/xxx -> rgb_color conversions. 49 // The source of XColorNames is wide available rgb.txt for X11 System. 50 // It is stored in "XColorsTable" application resource as array of 51 // "hash <-> rgb_color" pairs. The table is loaded only on demand. 52 // Name hashes must be sorted to let lookup procedure work properly 53 class XColorsTable { 54 55 struct _XColorEntry { 56 uint32 hash; 57 rgb_color color; 58 }; 59 60 public: 61 XColorsTable(); 62 ~XColorsTable(); 63 64 status_t LookUpColor(const char* name, rgb_color* color); 65 private: 66 status_t _LoadXColorsTable(); 67 uint32 _HashName(const char* name); 68 69 const _XColorEntry* fTable; 70 size_t fCount; 71 }; 72 73 extern XColorsTable gXColorsTable; 74 75 #endif // _COLORS_H 76