Sfoglia il codice sorgente

[mucurses] Implement curs_set() to control cursor visibility

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 anni fa
parent
commit
936971d0ed

+ 6
- 0
src/hci/mucurses/ansi_screen.c Vedi File

@@ -86,6 +86,11 @@ static bool ansiscr_peek ( struct _curses_screen *scr __unused ) {
86 86
 	return iskey();
87 87
 }
88 88
 
89
+static void ansiscr_cursor ( struct _curses_screen *scr __unused,
90
+			     int visibility ) {
91
+	printf ( "\033[?25%c", ( visibility ? 'h' : 'l' ) );
92
+}
93
+
89 94
 SCREEN _ansi_screen = {
90 95
 	.init		= ansiscr_init,
91 96
 	.exit		= ansiscr_exit,
@@ -94,4 +99,5 @@ SCREEN _ansi_screen = {
94 99
 	.putc		= ansiscr_putc,
95 100
 	.getc		= ansiscr_getc,
96 101
 	.peek		= ansiscr_peek,
102
+	.cursor		= ansiscr_cursor,
97 103
 };

+ 10
- 0
src/hci/mucurses/mucurses.c Vedi File

@@ -144,3 +144,13 @@ int wmove ( WINDOW *win, int y, int x ) {
144 144
 	_wupdcurs(win);
145 145
 	return OK;
146 146
 }
147
+
148
+/**
149
+ * Set cursor visibility
150
+ *
151
+ * @v visibility cursor visibility
152
+ */
153
+int curs_set ( int visibility ) {
154
+	stdscr->scr->cursor ( stdscr->scr, visibility );
155
+	return OK;
156
+}

+ 1
- 0
src/hci/mucurses/wininit.c Vedi File

@@ -31,6 +31,7 @@ WINDOW *initscr ( void ) {
31 31
 int endwin ( void ) {
32 32
 	attrset ( 0 );
33 33
 	color_set ( 0, NULL );
34
+	curs_set ( 1 );
34 35
 	mvprintw ( ( LINES - 1 ), 0, "\n" );
35 36
 	stdscr->scr->exit( stdscr->scr );
36 37
 	return OK;

+ 7
- 0
src/include/curses.h Vedi File

@@ -75,6 +75,13 @@ typedef struct _curses_screen {
75 75
 	 * @ret FALSE	no character waiting in stream
76 76
 	 */
77 77
 	bool ( *peek ) ( struct _curses_screen *scr );
78
+	/**
79
+	 * Set cursor visibility
80
+	 *
81
+	 * @v scr	screen on which to operate
82
+	 * @v visibility cursor visibility
83
+	 */
84
+	void ( * cursor ) ( struct _curses_screen *scr, int visibility );
78 85
 } SCREEN;
79 86
 
80 87
 /** Curses Window struct */

Loading…
Annulla
Salva