diff options
author | Toomas Soome <tsoome@me.com> | 2021-07-02 11:17:30 +0300 |
---|---|---|
committer | Toomas Soome <tsoome@me.com> | 2022-07-21 08:45:18 +0300 |
commit | 5e897995316df4eaf44613326c4cc090d915778c (patch) | |
tree | 4f3627de7ce893e06166ab4e0666ae8b2f267111 /usr/src/boot | |
parent | ba5ca68405ba4441c86a6cfc87f4ddcb3565c81d (diff) | |
download | illumos-gate-5e897995316df4eaf44613326c4cc090d915778c.tar.gz |
14748 loader: support for hiding the cursor on the console
Reviewed by: Garrett D'Amore <garrett@damore.org>
Approved by: Robert Mustacchi <rm@fingolfin.org>
Diffstat (limited to 'usr/src/boot')
-rw-r--r-- | usr/src/boot/Makefile.version | 2 | ||||
-rw-r--r-- | usr/src/boot/common/tem.c | 65 | ||||
-rw-r--r-- | usr/src/boot/forth/menu.4th | 6 | ||||
-rw-r--r-- | usr/src/boot/forth/screen.4th | 4 | ||||
-rw-r--r-- | usr/src/boot/sys/sys/tem_impl.h | 3 |
5 files changed, 73 insertions, 7 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index 30812e2f31..bbab986bcc 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -34,4 +34,4 @@ LOADER_VERSION = 1.1 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2022.07.11.1 +BOOT_VERSION = $(LOADER_VERSION)-2022.07.15.1 diff --git a/usr/src/boot/common/tem.c b/usr/src/boot/common/tem.c index 8eef7da2b6..35676e7273 100644 --- a/usr/src/boot/common/tem.c +++ b/usr/src/boot/common/tem.c @@ -24,6 +24,7 @@ * Use is subject to license terms. * Copyright 2016 Joyent, Inc. * Copyright 2021 Toomas Soome <tsoome@me.com> + * Copyright 2021 RackTop Systems, Inc. */ /* @@ -1077,7 +1078,7 @@ tem_input_byte(struct tem_vt_state *tem, uint8_t c) static void tem_terminal_emulate(struct tem_vt_state *tem, uint8_t *buf, int len) { - if (tem->tvs_isactive) + if (tem->tvs_isactive && !tem->tvs_cursor_hidden) tem_callback_cursor(tem, VIS_HIDE_CURSOR); for (; len > 0; len--, buf++) @@ -1088,7 +1089,7 @@ tem_terminal_emulate(struct tem_vt_state *tem, uint8_t *buf, int len) */ tem_send_data(tem); - if (tem->tvs_isactive) + if (tem->tvs_isactive && !tem->tvs_cursor_hidden) tem_callback_cursor(tem, VIS_DISPLAY_CURSOR); } @@ -1727,6 +1728,44 @@ tem_chkparam(struct tem_vt_state *tem, uint8_t ch) tem->tvs_state = A_STATE_START; } +static void +tem_chkparam_qmark(struct tem_vt_state *tem, tem_char_t ch) +{ + switch (ch) { + case 'h': /* DEC private mode set */ + tem_setparam(tem, 1, 1); + switch (tem->tvs_params[0]) { + case 25: /* show cursor */ + /* + * Note that cursor is not displayed either way + * at this entry point. Clearing the flag ensures + * that on exit from tem_safe_terminal_emulate + * we will display the cursor. + */ + tem_send_data(tem); + tem->tvs_cursor_hidden = false; + break; + } + break; + case 'l': + /* DEC private mode reset */ + tem_setparam(tem, 1, 1); + switch (tem->tvs_params[0]) { + case 25: /* hide cursor */ + /* + * Note that the cursor is not displayed already. + * This is true regardless of the flag state. + * Setting this flag ensures we won't display it + * on exit from tem_safe_terminal_emulate. + */ + tem_send_data(tem); + tem->tvs_cursor_hidden = true; + break; + } + break; + } + tem->tvs_state = A_STATE_START; +} /* * Gather the parameters of an ANSI escape sequence @@ -1738,9 +1777,25 @@ tem_getparams(struct tem_vt_state *tem, uint8_t ch) tem->tvs_paramval = ((tem->tvs_paramval * 10) + (ch - '0')); tem->tvs_gotparam = true; /* Remember got parameter */ return; /* Return immediately */ - } else if (tem->tvs_state == A_STATE_CSI_EQUAL || - tem->tvs_state == A_STATE_CSI_QMARK) { + } else if (tem->tvs_state == A_STATE_CSI_EQUAL) { tem->tvs_state = A_STATE_START; + } else if (tem->tvs_state == A_STATE_CSI_QMARK) { + if (tem->tvs_curparam < TEM_MAXPARAMS) { + if (tem->tvs_gotparam) { + /* get the parameter value */ + tem->tvs_params[tem->tvs_curparam] = + tem->tvs_paramval; + } + tem->tvs_curparam++; + } + if (ch == ';') { + /* Restart parameter search */ + tem->tvs_gotparam = false; + tem->tvs_paramval = 0; /* No parameter value yet */ + } else { + /* Handle escape sequence */ + tem_chkparam_qmark(tem, ch); + } } else { if (tem->tvs_curparam < TEM_MAXPARAMS) { if (tem->tvs_gotparam) { @@ -1754,7 +1809,7 @@ tem_getparams(struct tem_vt_state *tem, uint8_t ch) if (ch == ';') { /* Restart parameter search */ tem->tvs_gotparam = false; - tem->tvs_paramval = 0; /* No parame value yet */ + tem->tvs_paramval = 0; /* No parameter value yet */ } else { /* Handle escape sequence */ tem_chkparam(tem, ch); diff --git a/usr/src/boot/forth/menu.4th b/usr/src/boot/forth/menu.4th index 304abb4aeb..407dc8b578 100644 --- a/usr/src/boot/forth/menu.4th +++ b/usr/src/boot/forth/menu.4th @@ -989,6 +989,7 @@ also menu-namespace then then + cursor-invisible cursor-set menu-create begin \ Loop forever @@ -997,6 +998,7 @@ also menu-namespace getkey \ Block here, waiting for a key to be pressed dup -1 = if + cursor-normal cursor-set drop exit \ Caught abort (abnormal return) then @@ -1004,6 +1006,7 @@ also menu-namespace \ Ctrl-Enter/Ctrl-J (10) dup over 13 = swap 10 = or if drop ( no longer needed ) + cursor-normal cursor-set s" boot" evaluate exit ( pedantic; never reached ) then @@ -1041,6 +1044,7 @@ also menu-namespace 0= if drop \ key pressed drop \ loop iterator + cursor-normal cursor-set exit else swap \ need iterator on top @@ -1075,6 +1079,8 @@ also menu-namespace evaluate 0= if 2drop + cursor-normal + cursor-set exit then else diff --git a/usr/src/boot/forth/screen.4th b/usr/src/boot/forth/screen.4th index fe5a684002..69be55ec75 100644 --- a/usr/src/boot/forth/screen.4th +++ b/usr/src/boot/forth/screen.4th @@ -79,3 +79,7 @@ marker task-screen.4th \ Place the cursor at the bottom left of the screen : at-bl 0 sr at-xy ; +\ set cursor invisible or normal (civis/cnorm) +: cursor-invisible ( -- ) [char] l ; +: cursor-normal ( -- ) [char] h ; +: cursor-set ( cursor-mode -- ) escc [char] ? emit 25 .# emit ; diff --git a/usr/src/boot/sys/sys/tem_impl.h b/usr/src/boot/sys/sys/tem_impl.h index c6ef043ae0..aa7f30aa9c 100644 --- a/usr/src/boot/sys/sys/tem_impl.h +++ b/usr/src/boot/sys/sys/tem_impl.h @@ -64,7 +64,7 @@ extern "C" { #define TEM_ATTR(c) (((c) & TEM_ATTR_MASK) << 21) #define TEM_ATTR_ISSET(c, a) ((TEM_CHAR_ATTR(c) & (a)) == (a)) -#define TEM_MAXPARAMS 5 /* maximum number of ANSI paramters */ +#define TEM_MAXPARAMS 32 /* maximum number of ANSI paramters */ #define TEM_MAXFKEY 30 /* max length of function key with <ESC>Q */ #define MAX_TEM 2 /* max number of loadable terminal emulators */ @@ -207,6 +207,7 @@ struct tem_vt_state { bool tvs_isactive; bool tvs_initialized; /* initialization flag */ + bool tvs_cursor_hidden; list_node_t tvs_list_node; }; |