mirror of https://github.com/ipxe/ipxe.git
Adjusted to use the normal internal mucurses API rather than accessing
stdscr directly.pull/1/head
parent
b6b36e8ac4
commit
09f9142cbf
|
@ -4,6 +4,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "mucurses.h"
|
#include "mucurses.h"
|
||||||
|
#include "cursor.h"
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
*
|
*
|
||||||
|
@ -44,6 +45,9 @@ struct _softlabelkeys {
|
||||||
unsigned int num_labels;
|
unsigned int num_labels;
|
||||||
unsigned int num_spaces;
|
unsigned int num_spaces;
|
||||||
unsigned int spaces[SLK_MAX_NUM_SPACES];
|
unsigned int spaces[SLK_MAX_NUM_SPACES];
|
||||||
|
struct cursor_pos saved_cursor;
|
||||||
|
attr_t saved_attrs;
|
||||||
|
short saved_pair;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _softlabelkeys *slks;
|
struct _softlabelkeys *slks;
|
||||||
|
@ -55,12 +59,21 @@ struct _softlabelkeys *slks;
|
||||||
this should be ok...
|
this should be ok...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void _movetoslk ( void ) {
|
static void _enter_slk ( void ) {
|
||||||
stdscr->scr->movetoyx( stdscr->scr, LINES, 0 );
|
_store_curs_pos ( stdscr, &slks->saved_cursor );
|
||||||
|
wattr_get ( stdscr, &slks->saved_attrs, &slks->saved_pair, NULL );
|
||||||
|
LINES++;
|
||||||
|
wmove ( stdscr, LINES, 0 );
|
||||||
|
wattrset ( stdscr, slks->attrs );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _leave_slk ( void ) {
|
||||||
|
LINES--;
|
||||||
|
wattr_set ( stdscr, slks->saved_attrs, slks->saved_pair, NULL );
|
||||||
|
_restore_curs_pos ( stdscr, &slks->saved_cursor );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _print_label ( struct _softlabel sl ) {
|
static void _print_label ( struct _softlabel sl ) {
|
||||||
unsigned short i = 0;
|
|
||||||
int space_ch;
|
int space_ch;
|
||||||
char str[SLK_MAX_LABEL_LEN + 1];
|
char str[SLK_MAX_LABEL_LEN + 1];
|
||||||
|
|
||||||
|
@ -88,13 +101,10 @@ static void _print_label ( struct _softlabel sl ) {
|
||||||
// post-padding
|
// post-padding
|
||||||
memset(str+strlen(str), space_ch,
|
memset(str+strlen(str), space_ch,
|
||||||
(size_t)(slks->max_label_len - strlen(str)) );
|
(size_t)(slks->max_label_len - strlen(str)) );
|
||||||
str[slks->max_label_len] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// print the formatted label
|
// print the formatted label
|
||||||
for ( ; i < slks->max_label_len; i++ ) {
|
_wputstr ( stdscr, str, NOWRAP, slks->max_label_len );
|
||||||
stdscr->scr->putc( stdscr->scr, (chtype)str[i] | slks->attrs );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -194,18 +204,12 @@ int slk_attr_set ( const attr_t attrs, short colour_pair_number,
|
||||||
* @ret rc return status code
|
* @ret rc return status code
|
||||||
*/
|
*/
|
||||||
int slk_clear ( void ) {
|
int slk_clear ( void ) {
|
||||||
chtype space_ch;
|
|
||||||
unsigned int pos_x;
|
|
||||||
|
|
||||||
if ( slks == NULL )
|
if ( slks == NULL )
|
||||||
return ERR;
|
return ERR;
|
||||||
|
|
||||||
_movetoslk();
|
_enter_slk();
|
||||||
pos_x = 0;
|
wclrtoeol ( stdscr );
|
||||||
space_ch = (chtype)' ' | slks->attrs;
|
_leave_slk();
|
||||||
|
|
||||||
for ( ; pos_x < COLS; pos_x++ )
|
|
||||||
stdscr->scr->putc( stdscr->scr, space_ch );
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -308,7 +312,7 @@ int slk_restore ( void ) {
|
||||||
|
|
||||||
pos_x = 0;
|
pos_x = 0;
|
||||||
|
|
||||||
_movetoslk();
|
_enter_slk();
|
||||||
|
|
||||||
space_ch = (chtype)' ' | slks->attrs;
|
space_ch = (chtype)' ' | slks->attrs;
|
||||||
next_space = &(slks->spaces[0]);
|
next_space = &(slks->spaces[0]);
|
||||||
|
@ -320,16 +324,18 @@ int slk_restore ( void ) {
|
||||||
|
|
||||||
if ( i == *next_space ) {
|
if ( i == *next_space ) {
|
||||||
for ( j = 0; j < slks->maj_space_len; j++, pos_x++ )
|
for ( j = 0; j < slks->maj_space_len; j++, pos_x++ )
|
||||||
stdscr->scr->putc( stdscr->scr, space_ch );
|
_wputch ( stdscr, space_ch, NOWRAP );
|
||||||
if ( next_space < last_space )
|
if ( next_space < last_space )
|
||||||
next_space++;
|
next_space++;
|
||||||
} else {
|
} else {
|
||||||
if ( pos_x < COLS )
|
if ( pos_x < COLS )
|
||||||
stdscr->scr->putc( stdscr->scr, space_ch );
|
_wputch ( stdscr, space_ch, NOWRAP );
|
||||||
pos_x++;
|
pos_x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_leave_slk();
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue