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:
@@ -2210,6 +2210,7 @@ tty: add support for petattr
|
||||
tty: if a ^C interrupt occurred while DECgraphics characters were being drawn
|
||||
on the map, the "Really quit?" prompt would be illegible due to being
|
||||
rendered with VT line drawing characters
|
||||
tty: hide cursor unless waiting for user input
|
||||
Unix: when user name is used as default character name, keep hyphenated value
|
||||
intact instead stripping off dash and whatever follows as if that
|
||||
specified role/race/&c (worked once upon a time; broken since 3.3.0)
|
||||
|
||||
@@ -255,6 +255,7 @@ extern void tty_raw_print_bold(const char *);
|
||||
extern int tty_nhgetch(void);
|
||||
extern int tty_nh_poskey(coordxy *, coordxy *, int *);
|
||||
extern void tty_nhbell(void);
|
||||
extern void tty_curs_set(int);
|
||||
extern int tty_doprev_message(void);
|
||||
extern char tty_yn_function(const char *, const char *, char);
|
||||
extern void tty_getlin(const char *, char *);
|
||||
|
||||
@@ -79,7 +79,9 @@ hooked_tty_getlin(
|
||||
for (;;) {
|
||||
(void) fflush(stdout);
|
||||
Strcat(strcat(strcpy(gt.toplines, query), " "), obufp);
|
||||
tty_curs_set(1);
|
||||
c = pgetchar();
|
||||
tty_curs_set(0);
|
||||
if (c == '\033' || c == EOF) {
|
||||
if (c == '\033' && obufp[0] != '\0') {
|
||||
obufp[0] = '\0';
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -542,6 +542,7 @@ tty_init_nhwindows(int *argcp UNUSED, char **argv UNUSED)
|
||||
/* to port dependant tty setup */
|
||||
tty_startup(&wid, &hgt);
|
||||
setftty(); /* calls start_screen */
|
||||
tty_curs_set(0);
|
||||
|
||||
/* set up tty descriptor */
|
||||
ttyDisplay = (struct DisplayDesc *) alloc(sizeof (struct DisplayDesc));
|
||||
@@ -807,6 +808,7 @@ tty_exit_nhwindows(const char *str)
|
||||
{
|
||||
winid i;
|
||||
|
||||
tty_curs_set(1);
|
||||
tty_suspend_nhwindows(str);
|
||||
/*
|
||||
* Disable windows to avoid calls to window routines.
|
||||
@@ -3985,6 +3987,7 @@ tty_nhgetch(void)
|
||||
|
||||
HUPSKIP_RESULT('\033');
|
||||
print_vt_code1(AVTC_INLINE_SYNC);
|
||||
tty_curs_set(1);
|
||||
(void) fflush(stdout);
|
||||
/* Note: if raw_print() and wait_synch() get called to report terminal
|
||||
* initialization problems, then wins[] and ttyDisplay might not be
|
||||
@@ -4018,6 +4021,7 @@ tty_nhgetch(void)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
tty_curs_set(0);
|
||||
if (!i)
|
||||
i = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */
|
||||
else if (i == EOF)
|
||||
|
||||
Reference in New Issue
Block a user