Skip to content

Commit

Permalink
Merge pull request #5062 from Textualize/binding-descriptions
Browse files Browse the repository at this point in the history
Updating descriptions in BINDINGS
  • Loading branch information
willmcgugan authored Sep 30, 2024
2 parents c5f8726 + 9de0856 commit 1e3d018
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 136 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

- Added support for keymaps (user configurable key bindings) https://github.com/Textualize/textual/pull/5038
- Added descriptions to bindings for all internal widgets, and updated casing to be consistent https://github.com/Textualize/textual/pull/5062

## [0.81.0] - 2024-09-25

Expand Down
22 changes: 16 additions & 6 deletions src/textual/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,23 @@ class CommandPalette(SystemModalScreen):
"""

BINDINGS: ClassVar[list[BindingType]] = [
Binding("ctrl+end, shift+end", "command_list('last')", show=False),
Binding("ctrl+home, shift+home", "command_list('first')", show=False),
Binding("down", "cursor_down", show=False),
Binding(
"ctrl+end, shift+end",
"command_list('last')",
"Go to bottom",
show=False,
),
Binding(
"ctrl+home, shift+home",
"command_list('first')",
"Go to top",
show=False,
),
Binding("down", "cursor_down", "Next command", show=False),
Binding("escape", "escape", "Exit the command palette"),
Binding("pagedown", "command_list('page_down')", show=False),
Binding("pageup", "command_list('page_up')", show=False),
Binding("up", "command_list('cursor_up')", show=False),
Binding("pagedown", "command_list('page_down')", "Next page", show=False),
Binding("pageup", "command_list('page_up')", "Previous page", show=False),
Binding("up", "command_list('cursor_up')", "Previous command", show=False),
]
"""
| Key(s) | Description |
Expand Down
2 changes: 1 addition & 1 deletion src/textual/widgets/_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Button(Widget, can_focus=True):
}
"""

BINDINGS = [Binding("enter", "press", "Press Button", show=False)]
BINDINGS = [Binding("enter", "press", "Press button", show=False)]

label: reactive[TextType] = reactive[TextType]("")
"""The text label that appears within the button."""
Expand Down
12 changes: 6 additions & 6 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):

BINDINGS: ClassVar[list[BindingType]] = [
Binding("enter", "select_cursor", "Select", show=False),
Binding("up", "cursor_up", "Cursor Up", show=False),
Binding("down", "cursor_down", "Cursor Down", show=False),
Binding("right", "cursor_right", "Cursor Right", show=False),
Binding("left", "cursor_left", "Cursor Left", show=False),
Binding("pageup", "page_up", "Page Up", show=False),
Binding("pagedown", "page_down", "Page Down", show=False),
Binding("up", "cursor_up", "Cursor up", show=False),
Binding("down", "cursor_down", "Cursor down", show=False),
Binding("right", "cursor_right", "Cursor right", show=False),
Binding("left", "cursor_left", "Cursor left", show=False),
Binding("pageup", "page_up", "Page up", show=False),
Binding("pagedown", "page_down", "Page down", show=False),
Binding("ctrl+home", "scroll_top", "Top", show=False),
Binding("ctrl+end", "scroll_bottom", "Bottom", show=False),
Binding("home", "scroll_home", "Home", show=False),
Expand Down
28 changes: 15 additions & 13 deletions src/textual/widgets/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,25 @@ class Input(Widget, can_focus=True):
"""A text input widget."""

BINDINGS: ClassVar[list[BindingType]] = [
Binding("left", "cursor_left", "cursor left", show=False),
Binding("ctrl+left", "cursor_left_word", "cursor left word", show=False),
Binding("right", "cursor_right", "cursor right", show=False),
Binding("ctrl+right", "cursor_right_word", "cursor right word", show=False),
Binding("backspace", "delete_left", "delete left", show=False),
Binding("home,ctrl+a", "home", "home", show=False),
Binding("end,ctrl+e", "end", "end", show=False),
Binding("delete,ctrl+d", "delete_right", "delete right", show=False),
Binding("enter", "submit", "submit", show=False),
Binding("left", "cursor_left", "Move cursor left", show=False),
Binding("ctrl+left", "cursor_left_word", "Move cursor left a word", show=False),
Binding("right", "cursor_right", "Move cursor right", show=False),
Binding(
"ctrl+w", "delete_left_word", "delete left to start of word", show=False
"ctrl+right", "cursor_right_word", "Move cursor right a word", show=False
),
Binding("ctrl+u", "delete_left_all", "delete all to the left", show=False),
Binding("backspace", "delete_left", "Delete character left", show=False),
Binding("home,ctrl+a", "home", "Go to start", show=False),
Binding("end,ctrl+e", "end", "Go to end", show=False),
Binding("delete,ctrl+d", "delete_right", "Delete character right", show=False),
Binding("enter", "submit", "Submit", show=False),
Binding(
"ctrl+f", "delete_right_word", "delete right to start of word", show=False
"ctrl+w", "delete_left_word", "Delete left to start of word", show=False
),
Binding("ctrl+k", "delete_right_all", "delete all to the right", show=False),
Binding("ctrl+u", "delete_left_all", "Delete all to the left", show=False),
Binding(
"ctrl+f", "delete_right_word", "Delete right to start of word", show=False
),
Binding("ctrl+k", "delete_right_all", "Delete all to the right", show=False),
]
"""
| Key(s) | Description |
Expand Down
4 changes: 2 additions & 2 deletions src/textual/widgets/_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class ListView(VerticalScroll, can_focus=True, can_focus_children=False):

BINDINGS: ClassVar[list[BindingType]] = [
Binding("enter", "select_cursor", "Select", show=False),
Binding("up", "cursor_up", "Cursor Up", show=False),
Binding("down", "cursor_down", "Cursor Down", show=False),
Binding("up", "cursor_up", "Cursor up", show=False),
Binding("down", "cursor_down", "Cursor down", show=False),
]
"""
| Key(s) | Description |
Expand Down
4 changes: 2 additions & 2 deletions src/textual/widgets/_option_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class OptionList(ScrollView, can_focus=True):
Binding("end", "last", "Last", show=False),
Binding("enter", "select", "Select", show=False),
Binding("home", "first", "First", show=False),
Binding("pagedown", "page_down", "Page Down", show=False),
Binding("pageup", "page_up", "Page Up", show=False),
Binding("pagedown", "page_down", "Page down", show=False),
Binding("pageup", "page_up", "Page up", show=False),
Binding("up", "cursor_up", "Up", show=False),
]
"""
Expand Down
4 changes: 2 additions & 2 deletions src/textual/widgets/_radio_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class RadioSet(Container, can_focus=True, can_focus_children=False):
"""

BINDINGS: ClassVar[list[BindingType]] = [
Binding("down,right", "next_button", "", show=False),
Binding("down,right", "next_button", "Next option", show=False),
Binding("enter,space", "toggle_button", "Toggle", show=False),
Binding("up,left", "previous_button", "", show=False),
Binding("up,left", "previous_button", "Previous option", show=False),
]
"""
| Key(s) | Description |
Expand Down
4 changes: 2 additions & 2 deletions src/textual/widgets/_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class EmptySelectError(Exception):
class SelectOverlay(OptionList):
"""The 'pop-up' overlay for the Select control."""

BINDINGS = [("escape", "dismiss")]
BINDINGS = [("escape", "dismiss", "Dismiss menu")]

DEFAULT_CSS = """
SelectOverlay {
Expand Down Expand Up @@ -200,7 +200,7 @@ class Select(Generic[SelectType], Vertical, can_focus=True):
"""Constant to flag that the widget has no selection."""

BINDINGS = [
Binding("enter,down,space,up", "show_overlay", show=False),
Binding("enter,down,space,up", "show_overlay", "Show menu", show=False),
]
"""
| Key(s) | Description |
Expand Down
2 changes: 1 addition & 1 deletion src/textual/widgets/_selection_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def initial_state(self) -> bool:
class SelectionList(Generic[SelectionType], OptionList):
"""A vertical selection list that allows making multiple selections."""

BINDINGS = [Binding("space", "select")]
BINDINGS = [Binding("space", "select", "Toggle option", show=False)]
"""
| Key(s) | Description |
| :- | :- |
Expand Down
54 changes: 27 additions & 27 deletions src/textual/widgets/_text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,63 +167,63 @@ class TextArea(ScrollView):

BINDINGS = [
# Cursor movement
Binding("up", "cursor_up", "cursor up", show=False),
Binding("down", "cursor_down", "cursor down", show=False),
Binding("left", "cursor_left", "cursor left", show=False),
Binding("right", "cursor_right", "cursor right", show=False),
Binding("ctrl+left", "cursor_word_left", "cursor word left", show=False),
Binding("ctrl+right", "cursor_word_right", "cursor word right", show=False),
Binding("home,ctrl+a", "cursor_line_start", "cursor line start", show=False),
Binding("end,ctrl+e", "cursor_line_end", "cursor line end", show=False),
Binding("pageup", "cursor_page_up", "cursor page up", show=False),
Binding("pagedown", "cursor_page_down", "cursor page down", show=False),
Binding("up", "cursor_up", "Cursor up", show=False),
Binding("down", "cursor_down", "Cursor down", show=False),
Binding("left", "cursor_left", "Cursor left", show=False),
Binding("right", "cursor_right", "Cursor right", show=False),
Binding("ctrl+left", "cursor_word_left", "Cursor word left", show=False),
Binding("ctrl+right", "cursor_word_right", "Cursor word right", show=False),
Binding("home,ctrl+a", "cursor_line_start", "Cursor line start", show=False),
Binding("end,ctrl+e", "cursor_line_end", "Cursor line end", show=False),
Binding("pageup", "cursor_page_up", "Cursor page up", show=False),
Binding("pagedown", "cursor_page_down", "Cursor page down", show=False),
# Making selections (generally holding the shift key and moving cursor)
Binding(
"ctrl+shift+left",
"cursor_word_left(True)",
"cursor left word select",
"Cursor left word select",
show=False,
),
Binding(
"ctrl+shift+right",
"cursor_word_right(True)",
"cursor right word select",
"Cursor right word select",
show=False,
),
Binding(
"shift+home",
"cursor_line_start(True)",
"cursor line start select",
"Cursor line start select",
show=False,
),
Binding(
"shift+end", "cursor_line_end(True)", "cursor line end select", show=False
"shift+end", "cursor_line_end(True)", "Cursor line end select", show=False
),
Binding("shift+up", "cursor_up(True)", "cursor up select", show=False),
Binding("shift+down", "cursor_down(True)", "cursor down select", show=False),
Binding("shift+left", "cursor_left(True)", "cursor left select", show=False),
Binding("shift+right", "cursor_right(True)", "cursor right select", show=False),
Binding("shift+up", "cursor_up(True)", "Cursor up select", show=False),
Binding("shift+down", "cursor_down(True)", "Cursor down select", show=False),
Binding("shift+left", "cursor_left(True)", "Cursor left select", show=False),
Binding("shift+right", "cursor_right(True)", "Cursor right select", show=False),
# Shortcut ways of making selections
# Binding("f5", "select_word", "select word", show=False),
Binding("f6", "select_line", "select line", show=False),
Binding("f7", "select_all", "select all", show=False),
Binding("f6", "select_line", "Select line", show=False),
Binding("f7", "select_all", "Select all", show=False),
# Deletion
Binding("backspace", "delete_left", "delete left", show=False),
Binding("backspace", "delete_left", "Delete character left", show=False),
Binding(
"ctrl+w", "delete_word_left", "delete left to start of word", show=False
"ctrl+w", "delete_word_left", "Delete left to start of word", show=False
),
Binding("delete,ctrl+d", "delete_right", "delete right", show=False),
Binding("delete,ctrl+d", "delete_right", "Delete character right", show=False),
Binding(
"ctrl+f", "delete_word_right", "delete right to start of word", show=False
"ctrl+f", "delete_word_right", "Delete right to start of word", show=False
),
Binding("ctrl+x", "delete_line", "delete line", show=False),
Binding("ctrl+x", "delete_line", "Delete line", show=False),
Binding(
"ctrl+u", "delete_to_start_of_line", "delete to line start", show=False
"ctrl+u", "delete_to_start_of_line", "Delete to line start", show=False
),
Binding(
"ctrl+k",
"delete_to_end_of_line_or_delete_line",
"delete to line end",
"Delete to line end",
show=False,
),
Binding("ctrl+z", "undo", "Undo", show=False),
Expand Down
Loading

0 comments on commit 1e3d018

Please sign in to comment.