mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-05 13:32:48 -05:00
Windows: cope if caret blinking is disabled.
On Windows, when a blinking cursor is enabled, PuTTY uses the system default blink time from GetCaretBlinkTime(), which can be configured in Control Panel. Control Panel allows caret blinking to be disabled entirely, in which case GetCaretBlinkTime() returns INFINITE. PuTTY wasn't handling this case; if cursor blinking was enabled in PuTTY but disabled at the system level, the terminal window would hang, blinking the cursor madly.
This commit is contained in:
@ -5,6 +5,7 @@ add_sources_from_current_dir(utils
|
||||
utils/agent_named_pipe_name.c
|
||||
utils/arm_arch_queries.c
|
||||
utils/aux_match_opt.c
|
||||
utils/blink_time.c
|
||||
utils/centre_window.c
|
||||
utils/cmdline_arg.c
|
||||
utils/cryptoapi.c
|
||||
|
@ -203,8 +203,10 @@ void centre_window(HWND hwnd);
|
||||
|
||||
#define PUTTY_CHM_FILE "putty.chm"
|
||||
|
||||
int get_caret_blink_time(void);
|
||||
|
||||
#define GETTICKCOUNT GetTickCount
|
||||
#define CURSORBLINK GetCaretBlinkTime()
|
||||
#define CURSORBLINK get_caret_blink_time()
|
||||
#define TICKSPERSEC 1000 /* GetTickCount returns milliseconds */
|
||||
|
||||
#define DEFAULT_CODEPAGE CP_ACP
|
||||
|
21
windows/utils/blink_time.c
Normal file
21
windows/utils/blink_time.c
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Wrapper for GetCaretBlinkTime() which turns it into a signed integer,
|
||||
* with 0 meaning "no blinking".
|
||||
*/
|
||||
|
||||
#include "putty.h"
|
||||
#include <winuser.h>
|
||||
|
||||
int get_caret_blink_time(void)
|
||||
{
|
||||
UINT blinktime = GetCaretBlinkTime();
|
||||
if (blinktime == INFINITE)
|
||||
/* Windows' registry representation for 'no caret blinking'
|
||||
* is the string "-1", but we may as well use 0 as the sentinel
|
||||
* value, as it'd be bad to attempt blinking with period 0
|
||||
* in any case. */
|
||||
return 0;
|
||||
else
|
||||
/* assume this won't be so big that casting is a problem */
|
||||
return (int) blinktime;
|
||||
}
|
Reference in New Issue
Block a user