From ec4e6af84b65144124594d9d413cbace6406c399 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Thu, 26 Sep 2024 14:51:44 +0100 Subject: [PATCH 1/6] Add descriptions for bindings in RadioSet --- src/textual/widgets/_radio_set.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/textual/widgets/_radio_set.py b/src/textual/widgets/_radio_set.py index b820575aa5..d371acd661 100644 --- a/src/textual/widgets/_radio_set.py +++ b/src/textual/widgets/_radio_set.py @@ -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 | From 6afad2fa16d55f11d2957715800023610339e741 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Thu, 26 Sep 2024 14:55:24 +0100 Subject: [PATCH 2/6] Add description to Select widget --- src/textual/widgets/_select.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/textual/widgets/_select.py b/src/textual/widgets/_select.py index ea5f2fafa2..284668723f 100644 --- a/src/textual/widgets/_select.py +++ b/src/textual/widgets/_select.py @@ -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 | From 808994ddfe7879704ecfa04a334f6410764b4e19 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Thu, 26 Sep 2024 14:59:00 +0100 Subject: [PATCH 3/6] Add/update missing binding descriptions --- src/textual/command.py | 22 ++++++++++++++++------ src/textual/widgets/_input.py | 28 +++++++++++++++------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/textual/command.py b/src/textual/command.py index 9360daf0d9..f2b54ea826 100644 --- a/src/textual/command.py +++ b/src/textual/command.py @@ -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 | diff --git a/src/textual/widgets/_input.py b/src/textual/widgets/_input.py index 75920e7692..bcf5235664 100644 --- a/src/textual/widgets/_input.py +++ b/src/textual/widgets/_input.py @@ -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 | From 1ab1299997ca010cbc9cf2c5ce3b7464d7beb251 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Thu, 26 Sep 2024 15:05:11 +0100 Subject: [PATCH 4/6] Reviewing more binding descriptions --- src/textual/widgets/_button.py | 2 +- src/textual/widgets/_data_table.py | 12 +++--- src/textual/widgets/_list_view.py | 4 +- src/textual/widgets/_option_list.py | 4 +- src/textual/widgets/_select.py | 2 +- src/textual/widgets/_selection_list.py | 2 +- src/textual/widgets/_text_area.py | 54 +++++++++++++------------- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/textual/widgets/_button.py b/src/textual/widgets/_button.py index df39c5e491..dc9b4c84f6 100644 --- a/src/textual/widgets/_button.py +++ b/src/textual/widgets/_button.py @@ -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.""" diff --git a/src/textual/widgets/_data_table.py b/src/textual/widgets/_data_table.py index 951dc133c7..5d9da649ca 100644 --- a/src/textual/widgets/_data_table.py +++ b/src/textual/widgets/_data_table.py @@ -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), diff --git a/src/textual/widgets/_list_view.py b/src/textual/widgets/_list_view.py index 3e95f7fdbf..a60ddf8468 100644 --- a/src/textual/widgets/_list_view.py +++ b/src/textual/widgets/_list_view.py @@ -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 | diff --git a/src/textual/widgets/_option_list.py b/src/textual/widgets/_option_list.py index 10221cbfc9..5963052c80 100644 --- a/src/textual/widgets/_option_list.py +++ b/src/textual/widgets/_option_list.py @@ -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), ] """ diff --git a/src/textual/widgets/_select.py b/src/textual/widgets/_select.py index 284668723f..aa78f31b31 100644 --- a/src/textual/widgets/_select.py +++ b/src/textual/widgets/_select.py @@ -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 { diff --git a/src/textual/widgets/_selection_list.py b/src/textual/widgets/_selection_list.py index 00f3a09b92..8e9422948c 100644 --- a/src/textual/widgets/_selection_list.py +++ b/src/textual/widgets/_selection_list.py @@ -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")] """ | Key(s) | Description | | :- | :- | diff --git a/src/textual/widgets/_text_area.py b/src/textual/widgets/_text_area.py index 970e5f5feb..b147c27ee5 100644 --- a/src/textual/widgets/_text_area.py +++ b/src/textual/widgets/_text_area.py @@ -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), From daf61e7855fbb490b3af3d81d994f81014c6e4bc Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Mon, 30 Sep 2024 11:03:26 +0100 Subject: [PATCH 5/6] Fix snapshots --- src/textual/widgets/_selection_list.py | 2 +- .../test_snapshots/test_help_panel.svg | 148 +++++++++--------- 2 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/textual/widgets/_selection_list.py b/src/textual/widgets/_selection_list.py index 8e9422948c..22ac20b0a5 100644 --- a/src/textual/widgets/_selection_list.py +++ b/src/textual/widgets/_selection_list.py @@ -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", "Toggle option")] + BINDINGS = [Binding("space", "select", "Toggle option", show=False)] """ | Key(s) | Description | | :- | :- | diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots/test_help_panel.svg b/tests/snapshot_tests/__snapshots__/test_snapshots/test_help_panel.svg index e2b6c68e23..4e5460a362 100644 --- a/tests/snapshot_tests/__snapshots__/test_snapshots/test_help_panel.svg +++ b/tests/snapshot_tests/__snapshots__/test_snapshots/test_help_panel.svg @@ -19,162 +19,162 @@ font-weight: 700; } - .terminal-4153672952-matrix { + .terminal-112346627-matrix { font-family: Fira Code, monospace; font-size: 20px; line-height: 24.4px; font-variant-east-asian: full-width; } - .terminal-4153672952-title { + .terminal-112346627-title { font-size: 18px; font-weight: bold; font-family: arial; } - .terminal-4153672952-r1 { fill: #1e1e1e } -.terminal-4153672952-r2 { fill: #0178d4 } -.terminal-4153672952-r3 { fill: #5c5c5c } -.terminal-4153672952-r4 { fill: #c5c8c6 } -.terminal-4153672952-r5 { fill: #fea62b;font-weight: bold } -.terminal-4153672952-r6 { fill: #ededed } -.terminal-4153672952-r7 { fill: #e1e1e1 } -.terminal-4153672952-r8 { fill: #9a9a9a } + .terminal-112346627-r1 { fill: #1e1e1e } +.terminal-112346627-r2 { fill: #0178d4 } +.terminal-112346627-r3 { fill: #5c5c5c } +.terminal-112346627-r4 { fill: #c5c8c6 } +.terminal-112346627-r5 { fill: #fea62b;font-weight: bold } +.terminal-112346627-r6 { fill: #ededed } +.terminal-112346627-r7 { fill: #e1e1e1 } +.terminal-112346627-r8 { fill: #9a9a9a } - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - HelpPanelApp + HelpPanelApp - - - - ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ -        ←cursor left        -▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁       ^←cursor left word   -        →cursor right       -       ^→cursor right word  -        ⌫delete left        -  home ^ahome               -   end ^eend                -   del ^ddelete right       -        ⏎submit             -       ^wdelete left to     -start of word      -       ^udelete all to the  -left               -       ^fdelete right to    -start of word      -       ^kdelete all to the  -right              - -      tabFocus Next         -shift+tabFocus Previous     - -       ^cQuit               -       ^ppalette Open  -command palette - - - - - + + + + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ +        ←Move cursor left   +▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁       ^←Move cursor left a +word               +        →Move cursor right  +       ^→Move cursor right  +a word             +        ⌫Delete character   +left               +  home ^aGo to start        +   end ^eGo to end          +   del ^dDelete character   +right              +        ⏎Submit             +       ^wDelete left to     +start of word      +       ^uDelete all to the  +left               +       ^fDelete right to    +start of word      +       ^kDelete all to the  +right              + +      tabFocus Next         +shift+tabFocus Previous     + +       ^cQuit               +       ^ppalette Open  +command palette + From 9de08569894d409747718c736039f299fffce314 Mon Sep 17 00:00:00 2001 From: Darren Burns Date: Mon, 30 Sep 2024 11:10:46 +0100 Subject: [PATCH 6/6] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c1a044677..95d73ae2e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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