summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe
diff options
context:
space:
mode:
authorMichael Brown2013-12-07 21:53:20 +0100
committerMichael Brown2013-12-09 16:34:07 +0100
commit7025f5c648aedf744690e9e04257d6dddc94919d (patch)
tree7117fefd350b81c92732f8f600ff2d7959c0e0fc /src/include/ipxe
parent[fbcon] Always draw cursor using current foreground and background colours (diff)
downloadipxe-7025f5c648aedf744690e9e04257d6dddc94919d.tar.gz
ipxe-7025f5c648aedf744690e9e04257d6dddc94919d.tar.xz
ipxe-7025f5c648aedf744690e9e04257d6dddc94919d.zip
[console] Add centralised concept of colours and colour pairs
Add a centralised concept of colours and colour pairs (using the default colour pairs as configured via config/colour.h). A colour pair consists of a pair of colour indices. Add the ability to redefine both a colour pair and an individual colour index, with minimal overhead if this feature is not required (e.g. because the relevant shell commands are not present in the build). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r--src/include/ipxe/ansicol.h73
-rw-r--r--src/include/ipxe/errfile.h2
2 files changed, 75 insertions, 0 deletions
diff --git a/src/include/ipxe/ansicol.h b/src/include/ipxe/ansicol.h
new file mode 100644
index 000000000..2fa084626
--- /dev/null
+++ b/src/include/ipxe/ansicol.h
@@ -0,0 +1,73 @@
+#ifndef _IPXE_ANSICOL_H
+#define _IPXE_ANSICOL_H
+
+/** @file
+ *
+ * ANSI colours
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER );
+
+#include <stdint.h>
+#include <curses.h> /* For COLOR_RED etc. */
+
+/** Default colour (usually white foreground, black background) */
+#define COLOUR_DEFAULT 9
+#define COLOR_DEFAULT COLOUR_DEFAULT
+
+/** RGB value for "not defined" */
+#define ANSICOL_NO_RGB 0x01000000
+
+/**
+ * @defgroup ansicolpairs ANSI colour pairs
+ * @{
+ */
+
+/** Default colour pair */
+#define CPAIR_DEFAULT 0
+
+/** Normal text */
+#define CPAIR_NORMAL 1
+
+/** Highlighted text */
+#define CPAIR_SELECT 2
+
+/** Unselectable text (e.g. continuation ellipses, menu separators) */
+#define CPAIR_SEPARATOR 3
+
+/** Editable text */
+#define CPAIR_EDIT 4
+
+/** Error text */
+#define CPAIR_ALERT 5
+
+/** URL text */
+#define CPAIR_URL 6
+
+/** PXE selected menu entry */
+#define CPAIR_PXE 7
+
+/** @} */
+
+/** An ANSI colour pair definition */
+struct ansicol_pair {
+ /** Foreground colour index */
+ uint8_t foreground;
+ /** Background colour index */
+ uint8_t background;
+} __attribute__ (( packed ));
+
+/* ansicol.c */
+extern void ansicol_set_pair ( unsigned int cpair );
+extern int ansicol_define_pair ( unsigned int cpair, unsigned int foreground,
+ unsigned int background );
+
+/* ansicoldef.c */
+extern int ansicol_define ( unsigned int colour, unsigned int ansi,
+ uint32_t rgb );
+
+/* Function provided by ansicol.c but overridden by ansicoldef.c, if present */
+extern void ansicol_set ( unsigned int colour, unsigned int which );
+
+#endif /* _IPXE_ANSICOL_H */
diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h
index b24764809..32c596ffe 100644
--- a/src/include/ipxe/errfile.h
+++ b/src/include/ipxe/errfile.h
@@ -66,6 +66,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define ERRFILE_null_reboot ( ERRFILE_CORE | 0x001a0000 )
#define ERRFILE_pinger ( ERRFILE_CORE | 0x001b0000 )
#define ERRFILE_fbcon ( ERRFILE_CORE | 0x001c0000 )
+#define ERRFILE_ansicol ( ERRFILE_CORE | 0x001d0000 )
+#define ERRFILE_ansicoldef ( ERRFILE_CORE | 0x001e0000 )
#define ERRFILE_eisa ( ERRFILE_DRIVER | 0x00000000 )
#define ERRFILE_isa ( ERRFILE_DRIVER | 0x00010000 )