Cleanup previous PR

Doesnt need a separate changelog entry as its covered by the entry for
focus_visible_window
This commit is contained in:
Kovid Goyal 2021-11-09 22:21:04 +05:30
parent c3ff888981
commit 4318d2d7d0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 14 additions and 17 deletions

View File

@ -34,9 +34,6 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- A new remote control command to :program:`visually select a window <kitty @
select-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`)

View File

@ -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

View File

@ -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.
'''
)

View File

@ -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

View File

@ -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

View File

@ -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: