mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-09 05:32:11 -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:
parent
429478f914
commit
c71cc50e52
@ -1091,7 +1091,9 @@ empty box when the window loses focus; an underline or a vertical
|
||||
line becomes dotted.
|
||||
|
||||
The \q{\ii{Cursor blinks}} option makes the cursor blink on and off. This
|
||||
works in any of the cursor modes.
|
||||
works in any of the cursor modes. (On Windows, the blink rate matches
|
||||
that configured in Control Panel; so this setting will have no effect
|
||||
if cursor blinking has been disabled system-wide.)
|
||||
|
||||
\S{config-font} Controlling the \i{font} used in the terminal window
|
||||
|
||||
|
@ -1381,9 +1381,10 @@ static void term_schedule_tblink(Terminal *term)
|
||||
*/
|
||||
static void term_schedule_cblink(Terminal *term)
|
||||
{
|
||||
if (term->blink_cur && term->has_focus) {
|
||||
int delay = CBLINK_DELAY;
|
||||
if (term->blink_cur && term->has_focus && delay > 0) {
|
||||
if (!term->cblink_pending)
|
||||
term->next_cblink = schedule_timer(CBLINK_DELAY, term_timer, term);
|
||||
term->next_cblink = schedule_timer(delay, term_timer, term);
|
||||
term->cblink_pending = true;
|
||||
} else {
|
||||
term->cblinker = true; /* reset when not in use */
|
||||
|
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user