macOS: Use the system cursor blink interval by default

Can be changed with:

defaults write -g NSTextInsertionPointBlinkPeriodOff -float 500
defaults write -g NSTextInsertionPointBlinkPeriodOn -float 500
This commit is contained in:
Kovid Goyal 2019-02-25 09:37:48 +05:30
parent 2387c71b3c
commit 72ccf87d19
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 34 additions and 5 deletions

View File

@ -66,6 +66,10 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- macOS: Fix :opt:`sync_to_monitor` not working on Mojave.
- macOS: Use the system cursor blink interval by default
:opt:`cursor_blink_interval`.
0.13.3 [2019-01-19]
------------------------------

View File

@ -427,6 +427,21 @@ - (void)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type {
return Py_BuildValue("s", [locale UTF8String]);
}
double
cocoa_cursor_blink_interval(void) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
double on_period_ms = [defaults doubleForKey:@"NSTextInsertionPointBlinkPeriodOn"];
double off_period_ms = [defaults doubleForKey:@"NSTextInsertionPointBlinkPeriodOff"];
double period_ms = [defaults doubleForKey:@"NSTextInsertionPointBlinkPeriod"];
double max_value = 60 * 1000.0, ans = -1.0;
if (on_period_ms || off_period_ms) {
ans = on_period_ms + off_period_ms;
} else if (period_ms) {
ans = period_ms;
}
return ans > max_value ? 0.0 : ans;
}
void
cocoa_set_hide_from_tasks(void) {
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];

View File

@ -309,13 +309,15 @@ def cursor_text_color(x):
background color of the cell underneath instead, use the special keyword: background'''))
o('cursor_shape', 'block', option_type=to_cursor_shape, long_text=_(
'The cursor shape can be one of (block, beam, underline)'))
o('cursor_blink_interval', 0.5, option_type=positive_float, long_text=_('''
o('cursor_blink_interval', -1, option_type=float, long_text=_('''
The interval (in seconds) at which to blink the cursor. Set to zero to disable
blinking. Note that numbers smaller than :opt:`repaint_delay` will be limited
to :opt:`repaint_delay`. Stop blinking cursor after the specified number of
seconds of keyboard inactivity. Set to zero to never stop blinking.
blinking. Negative values mean use system default. Note that numbers smaller
than :opt:`repaint_delay` will be limited to :opt:`repaint_delay`.
'''))
o('cursor_stop_blinking_after', 15.0, option_type=positive_float, long_text=_('''
Stop blinking cursor after the specified number of seconds of keyboard
inactivity. Set to zero to never stop blinking.
'''))
o('cursor_stop_blinking_after', 15.0, option_type=positive_float)
# }}}

View File

@ -16,6 +16,7 @@ extern void cocoa_set_hide_from_tasks(void);
extern void cocoa_set_titlebar_color(void *w, color_type color);
extern bool cocoa_alt_option_key_pressed(unsigned long);
extern size_t cocoa_get_workspace_ids(void *w, size_t *workspace_ids, size_t array_sz);
extern double cocoa_cursor_blink_interval(void);
#if GLFW_KEY_LAST >= MAX_KEY_COUNT
@ -541,6 +542,13 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
CC(standard, IBEAM); CC(click, HAND); CC(arrow, ARROW);
#undef CC
if (OPT(click_interval) < 0) OPT(click_interval) = glfwGetDoubleClickInterval(glfw_window);
if (OPT(cursor_blink_interval) < 0) {
OPT(cursor_blink_interval) = 0.5;
#ifdef __APPLE__
double cbi = cocoa_cursor_blink_interval();
if (cbi >= 0) OPT(cursor_blink_interval) = cbi / 2.0;
#endif
}
is_first_window = false;
}
OSWindow *w = add_os_window();