mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-17 22:14:53 +02:00
Rationalize mouse cursor shape handling
Now can use the full range of standard mouse cursor shapes similar to those supported by browsers via the CSS cursor property. Still needs to be fully implemented for cocoa backend.
This commit is contained in:
@@ -588,27 +588,61 @@ Set the active window to the window under the mouse when moving the mouse around
|
||||
'''
|
||||
)
|
||||
|
||||
pointer_shape_names = (
|
||||
# start pointer shape names (auto generated by gen-key-constants.py do not edit)
|
||||
'arrow',
|
||||
'beam',
|
||||
'text',
|
||||
'pointer',
|
||||
'hand',
|
||||
'help',
|
||||
'wait',
|
||||
'progress',
|
||||
'crosshair',
|
||||
'vertical-text',
|
||||
'move',
|
||||
'e-resize',
|
||||
'ne-resize',
|
||||
'nw-resize',
|
||||
'n-resize',
|
||||
'se-resize',
|
||||
'sw-resize',
|
||||
's-resize',
|
||||
'w-resize',
|
||||
'ew-resize',
|
||||
'ns-resize',
|
||||
'nesw-resize',
|
||||
'nwse-resize',
|
||||
'zoom-in',
|
||||
'zoom-out',
|
||||
'alias',
|
||||
'copy',
|
||||
'not-allowed',
|
||||
'no-drop',
|
||||
'grab',
|
||||
'grabbing',
|
||||
# end pointer shape names
|
||||
)
|
||||
|
||||
opt('pointer_shape_when_grabbed', 'arrow',
|
||||
choices=('arrow', 'beam', 'hand'), ctype='pointer_shape',
|
||||
choices=pointer_shape_names, ctype='pointer_shape',
|
||||
long_text='''
|
||||
The shape of the mouse pointer when the program running in the terminal grabs
|
||||
the mouse. Valid values are: :code:`arrow`, :code:`beam` and :code:`hand`.
|
||||
the mouse.
|
||||
'''
|
||||
)
|
||||
|
||||
opt('default_pointer_shape', 'beam',
|
||||
choices=('arrow', 'beam', 'hand'), ctype='pointer_shape',
|
||||
choices=pointer_shape_names, ctype='pointer_shape',
|
||||
long_text='''
|
||||
The default shape of the mouse pointer. Valid values are: :code:`arrow`,
|
||||
:code:`beam` and :code:`hand`.
|
||||
The default shape of the mouse pointer.
|
||||
'''
|
||||
)
|
||||
|
||||
opt('pointer_shape_when_dragging', 'beam',
|
||||
choices=('arrow', 'beam', 'hand'), ctype='pointer_shape',
|
||||
choices=pointer_shape_names, ctype='pointer_shape',
|
||||
long_text='''
|
||||
The default shape of the mouse pointer when dragging across text. Valid values
|
||||
are: :code:`arrow`, :code:`beam` and :code:`hand`.
|
||||
The default shape of the mouse pointer when dragging across text.
|
||||
'''
|
||||
)
|
||||
|
||||
|
||||
6
kitty/options/parse.py
generated
6
kitty/options/parse.py
generated
@@ -934,7 +934,7 @@ class Parser:
|
||||
raise ValueError(f"The value {val} is not a valid choice for default_pointer_shape")
|
||||
ans["default_pointer_shape"] = val
|
||||
|
||||
choices_for_default_pointer_shape = frozenset(('arrow', 'beam', 'hand'))
|
||||
choices_for_default_pointer_shape = frozenset(('arrow', 'beam', 'text', 'pointer', 'hand', 'help', 'wait', 'progress', 'crosshair', 'vertical-text', 'move', 'e-resize', 'ne-resize', 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'ew-resize', 'ns-resize', 'nesw-resize', 'nwse-resize', 'zoom-in', 'zoom-out', 'alias', 'copy', 'not-allowed', 'no-drop', 'grab', 'grabbing'))
|
||||
|
||||
def detect_urls(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||
ans['detect_urls'] = to_bool(val)
|
||||
@@ -1140,7 +1140,7 @@ class Parser:
|
||||
raise ValueError(f"The value {val} is not a valid choice for pointer_shape_when_dragging")
|
||||
ans["pointer_shape_when_dragging"] = val
|
||||
|
||||
choices_for_pointer_shape_when_dragging = frozenset(('arrow', 'beam', 'hand'))
|
||||
choices_for_pointer_shape_when_dragging = frozenset(('arrow', 'beam', 'text', 'pointer', 'hand', 'help', 'wait', 'progress', 'crosshair', 'vertical-text', 'move', 'e-resize', 'ne-resize', 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'ew-resize', 'ns-resize', 'nesw-resize', 'nwse-resize', 'zoom-in', 'zoom-out', 'alias', 'copy', 'not-allowed', 'no-drop', 'grab', 'grabbing'))
|
||||
|
||||
def pointer_shape_when_grabbed(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||
val = val.lower()
|
||||
@@ -1148,7 +1148,7 @@ class Parser:
|
||||
raise ValueError(f"The value {val} is not a valid choice for pointer_shape_when_grabbed")
|
||||
ans["pointer_shape_when_grabbed"] = val
|
||||
|
||||
choices_for_pointer_shape_when_grabbed = frozenset(('arrow', 'beam', 'hand'))
|
||||
choices_for_pointer_shape_when_grabbed = frozenset(('arrow', 'beam', 'text', 'pointer', 'hand', 'help', 'wait', 'progress', 'crosshair', 'vertical-text', 'move', 'e-resize', 'ne-resize', 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'ew-resize', 'ns-resize', 'nesw-resize', 'nwse-resize', 'zoom-in', 'zoom-out', 'alias', 'copy', 'not-allowed', 'no-drop', 'grab', 'grabbing'))
|
||||
|
||||
def remember_window_size(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||
ans['remember_window_size'] = to_bool(val)
|
||||
|
||||
@@ -133,13 +133,41 @@ modify_font(PyObject *mf, Options *opts) {
|
||||
static MouseShape
|
||||
pointer_shape(PyObject *shape_name) {
|
||||
const char *name = PyUnicode_AsUTF8(shape_name);
|
||||
switch(name[0]) {
|
||||
case 'a': return ARROW;
|
||||
case 'h': return HAND;
|
||||
case 'b': return BEAM;
|
||||
default: break;
|
||||
}
|
||||
return BEAM;
|
||||
if (!name) return TEXT_POINTER;
|
||||
/* start pointer shapes (auto generated by gen-key-constants.py do not edit) */
|
||||
else if (strcmp(name, "arrow") == 0) return DEFAULT_POINTER;
|
||||
else if (strcmp(name, "beam") == 0) return TEXT_POINTER;
|
||||
else if (strcmp(name, "text") == 0) return TEXT_POINTER;
|
||||
else if (strcmp(name, "pointer") == 0) return POINTER_POINTER;
|
||||
else if (strcmp(name, "hand") == 0) return POINTER_POINTER;
|
||||
else if (strcmp(name, "help") == 0) return HELP_POINTER;
|
||||
else if (strcmp(name, "wait") == 0) return WAIT_POINTER;
|
||||
else if (strcmp(name, "progress") == 0) return PROGRESS_POINTER;
|
||||
else if (strcmp(name, "crosshair") == 0) return CROSSHAIR_POINTER;
|
||||
else if (strcmp(name, "vertical-text") == 0) return VERTICAL_TEXT_POINTER;
|
||||
else if (strcmp(name, "move") == 0) return MOVE_POINTER;
|
||||
else if (strcmp(name, "e-resize") == 0) return E_RESIZE_POINTER;
|
||||
else if (strcmp(name, "ne-resize") == 0) return NE_RESIZE_POINTER;
|
||||
else if (strcmp(name, "nw-resize") == 0) return NW_RESIZE_POINTER;
|
||||
else if (strcmp(name, "n-resize") == 0) return N_RESIZE_POINTER;
|
||||
else if (strcmp(name, "se-resize") == 0) return SE_RESIZE_POINTER;
|
||||
else if (strcmp(name, "sw-resize") == 0) return SW_RESIZE_POINTER;
|
||||
else if (strcmp(name, "s-resize") == 0) return S_RESIZE_POINTER;
|
||||
else if (strcmp(name, "w-resize") == 0) return W_RESIZE_POINTER;
|
||||
else if (strcmp(name, "ew-resize") == 0) return EW_RESIZE_POINTER;
|
||||
else if (strcmp(name, "ns-resize") == 0) return NS_RESIZE_POINTER;
|
||||
else if (strcmp(name, "nesw-resize") == 0) return NESW_RESIZE_POINTER;
|
||||
else if (strcmp(name, "nwse-resize") == 0) return NWSE_RESIZE_POINTER;
|
||||
else if (strcmp(name, "zoom-in") == 0) return ZOOM_IN_POINTER;
|
||||
else if (strcmp(name, "zoom-out") == 0) return ZOOM_OUT_POINTER;
|
||||
else if (strcmp(name, "alias") == 0) return ALIAS_POINTER;
|
||||
else if (strcmp(name, "copy") == 0) return COPY_POINTER;
|
||||
else if (strcmp(name, "not-allowed") == 0) return NOT_ALLOWED_POINTER;
|
||||
else if (strcmp(name, "no-drop") == 0) return NO_DROP_POINTER;
|
||||
else if (strcmp(name, "grab") == 0) return GRAB_POINTER;
|
||||
else if (strcmp(name, "grabbing") == 0) return GRABBING_POINTER;
|
||||
/* end pointer shapes */
|
||||
return TEXT_POINTER;
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
6
kitty/options/types.py
generated
6
kitty/options/types.py
generated
@@ -17,13 +17,13 @@ if typing.TYPE_CHECKING:
|
||||
choices_for_allow_cloning = typing.Literal['yes', 'y', 'true', 'no', 'n', 'false', 'ask']
|
||||
choices_for_allow_remote_control = typing.Literal['password', 'socket-only', 'socket', 'no', 'n', 'false', 'yes', 'y', 'true']
|
||||
choices_for_background_image_layout = typing.Literal['mirror-tiled', 'scaled', 'tiled', 'clamped', 'centered', 'cscaled']
|
||||
choices_for_default_pointer_shape = typing.Literal['arrow', 'beam', 'hand']
|
||||
choices_for_default_pointer_shape = typing.Literal['arrow', 'beam', 'text', 'pointer', 'hand', 'help', 'wait', 'progress', 'crosshair', 'vertical-text', 'move', 'e-resize', 'ne-resize', 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'ew-resize', 'ns-resize', 'nesw-resize', 'nwse-resize', 'zoom-in', 'zoom-out', 'alias', 'copy', 'not-allowed', 'no-drop', 'grab', 'grabbing']
|
||||
choices_for_linux_display_server = typing.Literal['auto', 'wayland', 'x11']
|
||||
choices_for_macos_colorspace = typing.Literal['srgb', 'default', 'displayp3']
|
||||
choices_for_macos_show_window_title_in = typing.Literal['all', 'menubar', 'none', 'window']
|
||||
choices_for_placement_strategy = typing.Literal['center', 'top-left']
|
||||
choices_for_pointer_shape_when_dragging = typing.Literal['arrow', 'beam', 'hand']
|
||||
choices_for_pointer_shape_when_grabbed = typing.Literal['arrow', 'beam', 'hand']
|
||||
choices_for_pointer_shape_when_dragging = typing.Literal['arrow', 'beam', 'text', 'pointer', 'hand', 'help', 'wait', 'progress', 'crosshair', 'vertical-text', 'move', 'e-resize', 'ne-resize', 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'ew-resize', 'ns-resize', 'nesw-resize', 'nwse-resize', 'zoom-in', 'zoom-out', 'alias', 'copy', 'not-allowed', 'no-drop', 'grab', 'grabbing']
|
||||
choices_for_pointer_shape_when_grabbed = typing.Literal['arrow', 'beam', 'text', 'pointer', 'hand', 'help', 'wait', 'progress', 'crosshair', 'vertical-text', 'move', 'e-resize', 'ne-resize', 'nw-resize', 'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'ew-resize', 'ns-resize', 'nesw-resize', 'nwse-resize', 'zoom-in', 'zoom-out', 'alias', 'copy', 'not-allowed', 'no-drop', 'grab', 'grabbing']
|
||||
choices_for_strip_trailing_spaces = typing.Literal['always', 'never', 'smart']
|
||||
choices_for_tab_bar_align = typing.Literal['left', 'center', 'right']
|
||||
choices_for_tab_bar_style = typing.Literal['fade', 'hidden', 'powerline', 'separator', 'slant', 'custom']
|
||||
|
||||
Reference in New Issue
Block a user