summaryrefslogtreecommitdiffstats
path: root/src/hci/mucurses
diff options
context:
space:
mode:
authorMichael Brown2013-12-07 22:00:09 +0100
committerMichael Brown2013-12-09 16:34:14 +0100
commit259858950a32862f99b740a4e8cac2954ab34ba9 (patch)
treef12c1adae65b56ff28314b531760c29fe1bc5a59 /src/hci/mucurses
parent[console] Add centralised concept of colours and colour pairs (diff)
downloadipxe-259858950a32862f99b740a4e8cac2954ab34ba9.tar.gz
ipxe-259858950a32862f99b740a4e8cac2954ab34ba9.tar.xz
ipxe-259858950a32862f99b740a4e8cac2954ab34ba9.zip
[mucurses] Use centralised concept of colour pairs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci/mucurses')
-rw-r--r--src/hci/mucurses/ansi_screen.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/hci/mucurses/ansi_screen.c b/src/hci/mucurses/ansi_screen.c
index a37daff3..1d3143f8 100644
--- a/src/hci/mucurses/ansi_screen.c
+++ b/src/hci/mucurses/ansi_screen.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <curses.h>
+#include <ipxe/ansicol.h>
#include <ipxe/console.h>
FILE_LICENCE ( GPL2_OR_LATER );
@@ -14,14 +15,13 @@ static unsigned int saved_usage;
static void ansiscr_attrs ( struct _curses_screen *scr, attr_t attrs ) {
int bold = ( attrs & A_BOLD );
attr_t cpair = PAIR_NUMBER ( attrs );
- short fcol;
- short bcol;
if ( scr->attrs != attrs ) {
scr->attrs = attrs;
- pair_content ( cpair, &fcol, &bcol );
- /* ANSI escape sequence to update character attributes */
- printf ( "\033[0;%d;3%d;4%dm", ( bold ? 1 : 22 ), fcol, bcol );
+ /* Reset attributes and set/clear bold as appropriate */
+ printf ( "\033[0;%dm", ( bold ? 1 : 22 ) );
+ /* Set foreground and background colours */
+ ansicol_set_pair ( cpair );
}
}
@@ -30,7 +30,9 @@ static void ansiscr_reset ( struct _curses_screen *scr ) {
scr->attrs = 0;
scr->curs_x = 0;
scr->curs_y = 0;
- printf ( "\033[0m\033[2J" );
+ printf ( "\0330m" );
+ ansicol_set_pair ( CPAIR_DEFAULT );
+ printf ( "\033[2J" );
}
static void ansiscr_init ( struct _curses_screen *scr ) {