Skip to content

Commit 146eab0

Browse files
authored
Merge pull request #5340 from Textualize/input-selection
Input selection
2 parents 90d9eb4 + bffbc57 commit 146eab0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2655
-1695
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1818
- Added "tab" border style https://github.com/Textualize/textual/pull/5335
1919
- Added support for XML syntax highlighting https://github.com/Textualize/textual/pull/5320
2020
- Added `TextArea.update_highlight_query` https://github.com/Textualize/textual/pull/5320
21+
- `Input` widget now supports text selection via mouse and keyboard https://github.com/Textualize/textual/pull/5340
22+
- Added new keybinds (hold shift) for text selection in `Input` https://github.com/Textualize/textual/pull/5340
23+
- Added `Input.selection` reactive attribute for reading and updating the current selection https://github.com/Textualize/textual/pull/5340
24+
- Added `Input.select_on_focus` (default `True`) to enable/disable selecting all text in an `Input` on focus https://github.com/Textualize/textual/pull/5340
25+
- Added methods `Input.replace`, `Input.insert`, `Input.delete`, `Input.delete_selection` for editing text https://github.com/Textualize/textual/pull/5340
26+
- Added `Input.selected_text` property for getting the currently selected text https://github.com/Textualize/textual/pull/5340
27+
- `Input` can now be scrolled independently of cursor position (hold shift and scroll with the mouse wheel in supported environments) https://github.com/Textualize/textual/pull/5340
28+
29+
## Changed
30+
31+
- Breaking change: Removed `Input` reactive attributes `view_position`, `cursor_position` (now exists as a property which proxies to the `Input.selection` reactive attribute), https://github.com/Textualize/textual/pull/5340
32+
- `Input.restrict` now checked on all edit operations (rather than just on `insert`) https://github.com/Textualize/textual/pull/5340
2133

2234
## Fixed
2335

docs/guide/design.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ Here's a comprehensive list of these variables, their purposes, and default valu
276276
| `$input-cursor-foreground` | Text color of the input cursor | `$background` |
277277
| `$input-cursor-text-style` | Text style of the input cursor | `"none"` |
278278
| `$input-selection-background` | Background color of selected text | `$primary-lighten-1` with 40% opacity |
279-
| `$input-selection-foreground` | Text color of selected text | `$background` |
280279

281280
### Scrollbar
282281

src/textual/design.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,6 @@ def luminosity_range(spread: float) -> Iterable[tuple[str, float]]:
321321
"input-selection-background",
322322
Color.parse(colors["primary-lighten-1"]).with_alpha(0.4).hex,
323323
)
324-
colors["input-selection-foreground"] = get(
325-
"input-selection-foreground", background.hex
326-
)
327324

328325
# Markdown header styles
329326
colors["markdown-h1-color"] = get("markdown-h1-color", primary.hex)

src/textual/theme.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ def to_color_system(self) -> ColorSystem:
171171
"block-cursor-text-style": "b",
172172
"block-cursor-blurred-text-style": "i",
173173
"input-selection-background": "ansi_blue",
174-
"input-selection-foreground": "ansi_white",
175174
"input-cursor-text-style": "reverse",
176175
"scrollbar": "ansi_blue",
177176
"border-blurred": "ansi_blue",

0 commit comments

Comments
 (0)