Commit 1e7ce437 authored by Jonas Schäfer's avatar Jonas Schäfer

Add keyboard action to go to room by unique prefix

This is especially useful in combination with the
newly introduced `unique_prefix_tab_names` config option. It has
no default binding.
parent a15e52dc
......@@ -374,6 +374,15 @@ Actions list
Similar to F4.
**_go_to_room_name**: Jump to a tab by unique prefix.
Similar to :term:`/wup` and the default *Alt-j*. This action will take
input as long as there is at least one tab name starting with the input
given so far. If there is exactly one tab matching, the action completes
and the current tab is switched over to the tab matching the input. If
no tab matches, the action completes without any change. This means that
you can typically abort the action with Escape.
Status actions
......@@ -209,6 +209,7 @@ class Core:
'_show_plugins': self.command.plugins,
'_show_xmltab': self.command.xml_tab,
'_toggle_pane': self.toggle_left_pane,
"_go_to_room_name": self.go_to_room_name,
###### status actions ######
'_available': lambda: self.command.status('available'),
'_away': lambda: self.command.status('away'),
......@@ -1108,6 +1109,34 @@ class Core:
keyboard.continuation_keys_callback = read_next_digit
def go_to_room_name(self) -> None:
room_name_jump = []
def read_next_letter(s) -> None:
nonlocal room_name_jump
any_matched, unique_tab = self.tabs.find_by_unique_prefix(
if not any_matched:
if unique_tab is not None:
# NOTE: returning here means that as soon as the tab is
# matched, normal input resumes. If we do *not* return here,
# any further characters matching the prefix of the tab will
# be swallowed (and a lot of tab switching will happen...),
# until a non-matching character or escape or something is
# pressed.
# This behaviour *may* be desirable.
keyboard.continuation_keys_callback = read_next_letter
keyboard.continuation_keys_callback = read_next_letter
def go_to_roster(self) -> None:
"Select the roster as the current tab"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment