mirror of https://github.com/ipxe/ipxe.git
[mucurses] Use centralised concept of colour pairs
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/17/head
parent
7025f5c648
commit
259858950a
|
@ -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 ) {
|
||||
|
|
|
@ -32,12 +32,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||
#include <ipxe/settings.h>
|
||||
#include <ipxe/editbox.h>
|
||||
#include <ipxe/keys.h>
|
||||
#include <ipxe/ansicol.h>
|
||||
#include <ipxe/login_ui.h>
|
||||
#include <config/colour.h>
|
||||
|
||||
/* Colour pairs */
|
||||
#define CPAIR_NORMAL 1
|
||||
#define CPAIR_EDIT 2
|
||||
|
||||
/* Screen layout */
|
||||
#define USERNAME_LABEL_ROW ( ( LINES / 2U ) - 4U )
|
||||
|
@ -66,8 +62,6 @@ int login_ui ( void ) {
|
|||
/* Initialise UI */
|
||||
initscr();
|
||||
start_color();
|
||||
init_pair ( CPAIR_NORMAL, COLOR_NORMAL_FG, COLOR_NORMAL_BG );
|
||||
init_pair ( CPAIR_EDIT, COLOR_EDIT_FG, COLOR_EDIT_BG );
|
||||
init_editbox ( &username_box, username, sizeof ( username ), NULL,
|
||||
USERNAME_ROW, EDITBOX_COL, EDITBOX_WIDTH, 0 );
|
||||
init_editbox ( &password_box, password, sizeof ( password ), NULL,
|
||||
|
|
|
@ -31,13 +31,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||
#include <ipxe/keys.h>
|
||||
#include <ipxe/timer.h>
|
||||
#include <ipxe/console.h>
|
||||
#include <ipxe/ansicol.h>
|
||||
#include <ipxe/menu.h>
|
||||
#include <config/colour.h>
|
||||
|
||||
/* Colour pairs */
|
||||
#define CPAIR_NORMAL 1
|
||||
#define CPAIR_SELECT 2
|
||||
#define CPAIR_SEPARATOR 3
|
||||
|
||||
/* Screen layout */
|
||||
#define TITLE_ROW 1U
|
||||
|
@ -345,9 +340,6 @@ int show_menu ( struct menu *menu, unsigned long timeout,
|
|||
/* Initialise screen */
|
||||
initscr();
|
||||
start_color();
|
||||
init_pair ( CPAIR_NORMAL, COLOR_NORMAL_FG, COLOR_NORMAL_BG );
|
||||
init_pair ( CPAIR_SELECT, COLOR_SELECT_FG, COLOR_SELECT_BG );
|
||||
init_pair ( CPAIR_SEPARATOR, COLOR_SEPARATOR_FG, COLOR_SEPARATOR_BG );
|
||||
color_set ( CPAIR_NORMAL, NULL );
|
||||
curs_set ( 0 );
|
||||
erase();
|
||||
|
|
|
@ -28,8 +28,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||
#include <ipxe/settings.h>
|
||||
#include <ipxe/editbox.h>
|
||||
#include <ipxe/keys.h>
|
||||
#include <ipxe/ansicol.h>
|
||||
#include <ipxe/settings_ui.h>
|
||||
#include <config/colour.h>
|
||||
|
||||
/** @file
|
||||
*
|
||||
|
@ -37,13 +37,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||
*
|
||||
*/
|
||||
|
||||
/* Colour pairs */
|
||||
#define CPAIR_NORMAL 1
|
||||
#define CPAIR_SELECT 2
|
||||
#define CPAIR_EDIT 3
|
||||
#define CPAIR_ALERT 4
|
||||
#define CPAIR_URL 5
|
||||
|
||||
/* Screen layout */
|
||||
#define TITLE_ROW 1U
|
||||
#define SETTINGS_LIST_ROW 3U
|
||||
|
@ -598,11 +591,6 @@ int settings_ui ( struct settings *settings ) {
|
|||
|
||||
initscr();
|
||||
start_color();
|
||||
init_pair ( CPAIR_NORMAL, COLOR_NORMAL_FG, COLOR_NORMAL_BG );
|
||||
init_pair ( CPAIR_SELECT, COLOR_SELECT_FG, COLOR_SELECT_BG );
|
||||
init_pair ( CPAIR_EDIT, COLOR_EDIT_FG, COLOR_EDIT_BG );
|
||||
init_pair ( CPAIR_ALERT, COLOR_ALERT_FG, COLOR_ALERT_BG );
|
||||
init_pair ( CPAIR_URL, COLOR_URL_FG, COLOR_URL_BG );
|
||||
color_set ( CPAIR_NORMAL, NULL );
|
||||
curs_set ( 0 );
|
||||
erase();
|
||||
|
|
|
@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||
#include <ipxe/keys.h>
|
||||
#include <ipxe/timer.h>
|
||||
#include <ipxe/uri.h>
|
||||
#include <ipxe/ansicol.h>
|
||||
#include <usr/dhcpmgmt.h>
|
||||
#include <usr/autoboot.h>
|
||||
|
||||
|
@ -41,10 +42,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
|||
*
|
||||
*/
|
||||
|
||||
/* Colour pairs */
|
||||
#define CPAIR_NORMAL 1
|
||||
#define CPAIR_SELECT 2
|
||||
|
||||
/** A PXE boot menu item */
|
||||
struct pxe_menu_item {
|
||||
/** Boot Server type */
|
||||
|
@ -204,7 +201,7 @@ static void pxe_menu_draw_item ( struct pxe_menu *menu,
|
|||
|
||||
/* Draw row */
|
||||
row = ( LINES - menu->num_items + index );
|
||||
color_set ( ( selected ? CPAIR_SELECT : CPAIR_NORMAL ), NULL );
|
||||
color_set ( ( selected ? CPAIR_PXE : CPAIR_DEFAULT ), NULL );
|
||||
mvprintw ( row, 0, "%s", buf );
|
||||
move ( row, 1 );
|
||||
}
|
||||
|
@ -224,9 +221,7 @@ static int pxe_menu_select ( struct pxe_menu *menu ) {
|
|||
/* Initialise UI */
|
||||
initscr();
|
||||
start_color();
|
||||
init_pair ( CPAIR_NORMAL, COLOR_WHITE, COLOR_BLACK );
|
||||
init_pair ( CPAIR_SELECT, COLOR_BLACK, COLOR_WHITE );
|
||||
color_set ( CPAIR_NORMAL, NULL );
|
||||
color_set ( CPAIR_DEFAULT, NULL );
|
||||
|
||||
/* Draw initial menu */
|
||||
for ( i = 0 ; i < menu->num_items ; i++ )
|
||||
|
|
Loading…
Reference in New Issue