Skip to content

Commit b7e11c8

Browse files
committed
Add select_all and action_select_all methods to Input widget
1 parent d935c03 commit b7e11c8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/textual/widgets/_input.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class Input(ScrollView):
107107
show=False,
108108
),
109109
Binding("backspace", "delete_left", "Delete character left", show=False),
110+
Binding("ctrl+shift+a", "select_all", "Select all", show=False),
110111
Binding("home,ctrl+a", "home", "Go to start", show=False),
111112
Binding("end,ctrl+e", "end", "Go to end", show=False),
112113
Binding("shift+home", "home(True)", "Select line start", show=False),
@@ -137,6 +138,7 @@ class Input(ScrollView):
137138
| ctrl+right | Move the cursor one word to the right. |
138139
| backspace | Delete the character to the left of the cursor. |
139140
| ctrl+shift+right | Move cursor right a word and select. |
141+
| ctrl+shift+a | Select all text in the input. |
140142
| home,ctrl+a | Go to the beginning of the input. |
141143
| end,ctrl+e | Go to the end of the input. |
142144
| shift+home | Select up to the input start. |
@@ -870,6 +872,15 @@ def action_cursor_right(self, select: bool = False) -> None:
870872
else:
871873
self.cursor_position = max(start, end)
872874

875+
def select_all(self) -> None:
876+
"""Select all of the text in the Input."""
877+
self.selection = Selection(0, len(self.value))
878+
self._suggestion = ""
879+
880+
def action_select_all(self) -> None:
881+
"""Select all of the text in the Input."""
882+
self.select_all()
883+
873884
def action_home(self, select: bool = False) -> None:
874885
"""Move the cursor to the start of the input.
875886

0 commit comments

Comments
 (0)