Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mucurses] Implement curs_set() to control cursor visibility
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Dec 2, 2013
1 parent 135bf35 commit 936971d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/hci/mucurses/ansi_screen.c
Expand Up @@ -86,6 +86,11 @@ static bool ansiscr_peek ( struct _curses_screen *scr __unused ) {
return iskey();
}

static void ansiscr_cursor ( struct _curses_screen *scr __unused,
int visibility ) {
printf ( "\033[?25%c", ( visibility ? 'h' : 'l' ) );
}

SCREEN _ansi_screen = {
.init = ansiscr_init,
.exit = ansiscr_exit,
Expand All @@ -94,4 +99,5 @@ SCREEN _ansi_screen = {
.putc = ansiscr_putc,
.getc = ansiscr_getc,
.peek = ansiscr_peek,
.cursor = ansiscr_cursor,
};
10 changes: 10 additions & 0 deletions src/hci/mucurses/mucurses.c
Expand Up @@ -144,3 +144,13 @@ int wmove ( WINDOW *win, int y, int x ) {
_wupdcurs(win);
return OK;
}

/**
* Set cursor visibility
*
* @v visibility cursor visibility
*/
int curs_set ( int visibility ) {
stdscr->scr->cursor ( stdscr->scr, visibility );
return OK;
}
1 change: 1 addition & 0 deletions src/hci/mucurses/wininit.c
Expand Up @@ -31,6 +31,7 @@ WINDOW *initscr ( void ) {
int endwin ( void ) {
attrset ( 0 );
color_set ( 0, NULL );
curs_set ( 1 );
mvprintw ( ( LINES - 1 ), 0, "\n" );
stdscr->scr->exit( stdscr->scr );
return OK;
Expand Down
7 changes: 7 additions & 0 deletions src/include/curses.h
Expand Up @@ -75,6 +75,13 @@ typedef struct _curses_screen {
* @ret FALSE no character waiting in stream
*/
bool ( *peek ) ( struct _curses_screen *scr );
/**
* Set cursor visibility
*
* @v scr screen on which to operate
* @v visibility cursor visibility
*/
void ( * cursor ) ( struct _curses_screen *scr, int visibility );
} SCREEN;

/** Curses Window struct */
Expand Down

0 comments on commit 936971d

Please sign in to comment.