tty: hide cursor unless waiting for user input

Use vi (cursor_invisible) and ve (cursor_normal) to hide and show
cursor, if the terminal supports those.  This way on a slower
connection the cursor doesn't jump all over the place when doing
map or menu updates.
This commit is contained in:
Pasi Kallinen
2024-04-02 10:25:32 +03:00
parent de69dd750b
commit 7030b0b9fe
5 changed files with 28 additions and 0 deletions

View File

@@ -36,6 +36,10 @@ static void kill_hilite(void);
/* (see tcap.h) -- nh_CM, nh_ND, nh_CD, nh_HI,nh_HE, nh_US,nh_UE, ul_hack */
struct tc_lcl_data tc_lcl_data = { 0, 0, 0, 0, 0, 0, 0, FALSE };
static char *nh_VI = (char *) 0; /* cursor_invisible */
static char *nh_VE = (char *) 0; /* cursor_normal */
/*static char *nh_VS = (char *) 0;*/ /* cursor_visible (highlighted cursor) */
static char *HO, *CL, *CE, *UP, *XD, *BC, *SO, *SE, *TI, *TE;
static char *VS, *VE;
static char *ME, *MR, *MB, *MH, *MD;
@@ -280,6 +284,12 @@ tty_startup(int *wid, int *hgt)
if (!ME)
ME = SE ? SE : nullstr; /* default to SE value */
nh_VI = Tgetstr(nhStr("vi"));
nh_VE = Tgetstr(nhStr("ve"));
/*nh_VS = Tgetstr(nhStr("vs"));*/
if (!nh_VI || !nh_VE /*|| !nh_VS*/ )
nh_VI = nh_VE = /*nh_VS =*/ (char *) 0;
/* Get rid of padding numbers for nh_HI and nh_HE. Hope they
* aren't really needed!!! nh_HI and nh_HE are outputted to the
* pager as a string - so how can you send it NULs???
@@ -737,6 +747,16 @@ tty_nhbell(void)
(void) fflush(stdout);
}
/* hide or show cursor */
void
tty_curs_set(int visibility)
{
if (!visibility && nh_VI)
xputs(nh_VI);
else if (visibility && nh_VE)
xputs(nh_VE);
}
#ifdef ASCIIGRAPH
void
graph_on(void)