mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Add delete-to-start to Input
And in doing so bind it to Ctrl+U (readline-common). Right now I'm not aware of a common combo for this on Windows, but we can add a binding for this if one becomes apparent. See #1310.
This commit is contained in:
@@ -88,6 +88,7 @@ class Input(Widget, can_focus=True):
|
||||
Binding("ctrl+d,delete", "delete_right", "delete right", show=False),
|
||||
Binding("enter", "submit", "submit", show=False),
|
||||
Binding("ctrl+k", "delete_to_end", "delete to end", show=False),
|
||||
Binding("ctrl+u", "delete_to_start", "delete to start", show=False),
|
||||
]
|
||||
|
||||
COMPONENT_CLASSES = {"input--cursor", "input--placeholder"}
|
||||
@@ -332,6 +333,12 @@ class Input(Widget, can_focus=True):
|
||||
"""Delete from the cursor location to the end of input."""
|
||||
self.value = self.value[: self.cursor_position]
|
||||
|
||||
def action_delete_to_start(self) -> None:
|
||||
"""Delete from the cursor location to the start of input."""
|
||||
if self.cursor_position > 0:
|
||||
self.value = self.value[self.cursor_position :]
|
||||
self.cursor_position = 0
|
||||
|
||||
async def action_submit(self) -> None:
|
||||
await self.emit(self.Submitted(self, self.value))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user