diff --git a/docs/changelog.rst b/docs/changelog.rst index ef8a1ce61..6bae033dc 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -34,9 +34,6 @@ To update |kitty|, :doc:`follow the instructions `. - A new remote control command to :program:`visually select a window ` (:iss:`4165`) -- A new :opt:`visual_window_select_characters` option to specify the preferred - alphanumeric characters for visual window select (:pull:`4215`) - - A new option :opt:`background_image_anchor` to *anchor* the background image to a position in the OS Window, useful for displaying images with logos or similar (:pull:`4167`) diff --git a/kitty/boss.py b/kitty/boss.py index e7ef78292..0c47f807c 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -964,8 +964,6 @@ class Boss: pending_sequences: SubSequenceMap = {} fmap = get_name_to_functional_number_map() alphanumerics = get_options().visual_window_select_characters - if not alphanumerics: - alphanumerics = string.digits[1:] + string.digits[0] + string.ascii_uppercase for idx, window in tab.windows.iter_windows_with_number(only_visible=True): if only_window_ids and window.id not in only_window_ids: continue diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 79f2bb621..73970fc3c 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -3,6 +3,7 @@ # After editing this file run ./gen-config.py to apply the changes +import string from kitty.conf.types import Action, Definition @@ -888,13 +889,13 @@ does not currently work on Wayland. ''' ) -opt('visual_window_select_characters', '', +opt('visual_window_select_characters', defval=string.digits[1:] + '0' + string.ascii_uppercase, option_type='visual_window_select_characters', long_text=''' -The list of characters to use for visual window select. The value should be a -series of unique numbers or alphabets, case insensitive. The default is the -numbers 1 to 9, 0, and the alphabets A to Z. Specify your preference as a string -of characters. +The list of characters to use for visual window selection (for example for +selecting a window to focus with :sc:`focus_visible_window`). The value should +be a series of unique numbers or alphabets, case insensitive, from the set +:code:`[0-9A-Z]`. Specify your preference as a string of characters. ''' ) diff --git a/kitty/options/types.py b/kitty/options/types.py index 2c913949e..87689d3d5 100644 --- a/kitty/options/types.py +++ b/kitty/options/types.py @@ -574,7 +574,7 @@ class Options: url_style: int = 3 visual_bell_color: typing.Optional[kitty.fast_data_types.Color] = None visual_bell_duration: float = 0 - visual_window_select_characters: str = '' + visual_window_select_characters: str = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ' wayland_titlebar_color: int = 0 wheel_scroll_multiplier: float = 5.0 window_alert_on_bell: bool = True diff --git a/kitty/options/utils.py b/kitty/options/utils.py index d88e74db3..01fbecc2d 100644 --- a/kitty/options/utils.py +++ b/kitty/options/utils.py @@ -594,10 +594,11 @@ def visual_window_select_characters(x: str) -> str: import string valid_characters = string.digits + string.ascii_uppercase ans = x.upper() - if not all(ch in valid_characters for ch in ans): - raise ValueError(f'Invalid characters: {x} Only numbers (0-9) and alphabets (a-z,A-Z) are allowed. Ignoring.') - if len(set(ans)) < len(x): - raise ValueError(f'Invalid characters: {x} Contains identical numbers or alphabets, case insensitive. Ignoring.') + ans_chars = set(ans) + if not ans_chars.issubset(set(valid_characters)): + raise ValueError(f'Invalid characters in visual_window_select_characters: {x} Only numbers (0-9) and alphabets (a-z,A-Z) are allowed. Ignoring.') + if len(ans_chars) < len(x): + raise ValueError(f'Invalid characters in visual_window_select_characters: {x} Contains identical numbers or alphabets, case insensitive. Ignoring.') return ans diff --git a/kitty/tabs.py b/kitty/tabs.py index f2fa8b6ca..129acf1b6 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -600,7 +600,7 @@ class Tab: # {{{ @ac('win', ''' Focus a visible window by pressing the number of the window. Window numbers are displayed - over the windows for easy selection in this mode. + over the windows for easy selection in this mode. See :opt:`visual_window_select_characters`. ''') def focus_visible_window(self) -> None: def callback(tab: Optional[Tab], window: Optional[Window]) -> None: @@ -609,7 +609,7 @@ class Tab: # {{{ get_boss().visual_window_select_action(self, callback, 'Choose window to switch to', only_window_ids=self.all_window_ids_except_active_window) - @ac('win', 'Swap the current window with another window in the current tab, selected visually') + @ac('win', 'Swap the current window with another window in the current tab, selected visually. See :opt:`visual_window_select_characters`') def swap_with_window(self) -> None: def callback(tab: Optional[Tab], window: Optional[Window]) -> None: if tab and window: