1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-05-09 13:42:09 -05:00
putty-source/windows/utils/blink_time.c
Simon Tatham c71cc50e52 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.
2025-04-24 11:31:02 +01:00

22 lines
624 B
C

/*
* 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;
}