Skip to content

Commit

Permalink
keys/lint/regexes: Add suffix & linting to general terminal commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
Niloth-p committed May 14, 2024
1 parent db9bc31 commit bb6c9f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion tools/lint-hotkeys
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ from zulipterminal.config.keys import (
KEY_BINDINGS,
display_keys_for_command,
)
from zulipterminal.config.regexes import REGEX_READLINE_COMMANDS
from zulipterminal.config.regexes import (
REGEX_READLINE_COMMANDS,
REGEX_TERMINAL_COMMANDS,
)


# absolute path to zulip-terminal
Expand Down Expand Up @@ -52,6 +55,11 @@ def lint_all_external_commands() -> None:
command_type="Urwid Readline",
suffix="READLINE_SUFFIX",
)
lint_external_commands_by_type(
regex_pattern=REGEX_TERMINAL_COMMANDS,
command_type="General terminal",
suffix="GENERAL_TERMINAL_SUFFIX",
)
print("All external commands have been linted successfully.")


Expand Down
5 changes: 3 additions & 2 deletions zulipterminal/config/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


READLINE_SUFFIX = "_READLINE"
GENERAL_TERMINAL_SUFFIX = "_GENERAL_TERMINAL"


class KeyBinding(TypedDict):
Expand Down Expand Up @@ -308,12 +309,12 @@ class KeyBinding(TypedDict):
'excluded_from_random_tips': True,
'key_category': 'stream_list',
},
'REDRAW': {
'REDRAW' + GENERAL_TERMINAL_SUFFIX: {
'keys': ['ctrl l'],
'help_text': 'Redraw screen',
'key_category': 'general',
},
'QUIT': {
'QUIT' + GENERAL_TERMINAL_SUFFIX: {
'keys': ['ctrl c'],
'help_text': 'Quit',
'key_category': 'general',
Expand Down
4 changes: 3 additions & 1 deletion zulipterminal/config/regexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


# (*) Stream and topic regexes
from zulipterminal.config.keys import READLINE_SUFFIX
from zulipterminal.config.keys import GENERAL_TERMINAL_SUFFIX, READLINE_SUFFIX


REGEX_STREAM_NAME = r"([^*>]+)"
Expand Down Expand Up @@ -53,3 +53,5 @@

# Example: UNDO_LAST_ACTION_READLINE
REGEX_READLINE_COMMANDS = rf"([A-Z_]+{READLINE_SUFFIX})"
# Example: REDRAW_GENERAL_TERMINAL
REGEX_TERMINAL_COMMANDS = rf"^.*([A-Z_]+{GENERAL_TERMINAL_SUFFIX})"

0 comments on commit bb6c9f3

Please sign in to comment.