Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `DOMNode.displayed_children` https://github.com/Textualize/textual/pull/6070
- Added `TextArea.UserInsert` message https://github.com/Textualize/textual/pull/6070
- Added `TextArea.hide_suggestion_on_blur` boolean https://github.com/Textualize/textual/pull/6070
- Added `OptionList.highlighted_option` property https://github.com/Textualize/textual/pull/6090
- Added `TextArea.update_suggestion` method https://github.com/Textualize/textual/pull/6090

### Changed

Expand Down
2 changes: 2 additions & 0 deletions src/textual/widgets/_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ def compose(self) -> ComposeResult:
self.app.get_key_display(binding),
"",
binding.action,
disabled=not enabled,
tooltip=tooltip or binding.description,
classes="-grouped",
).data_bind(Footer.compact)
yield FooterLabel(group.description)
Expand Down
12 changes: 12 additions & 0 deletions src/textual/widgets/_option_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ def option_count(self) -> int:
"""The number of options."""
return len(self._options)

@property
def highlighted_option(self) -> Option | None:
"""The currently highlighted options, or `None` if no option is highlighted,

Returns:
An Option, or `None`.
"""
if self.highlighted is not None:
return self.options[self.highlighted]
else:
return None

def clear_options(self) -> Self:
"""Clear the content of the option list.

Expand Down
7 changes: 4 additions & 3 deletions src/textual/widgets/_text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,7 @@ def notify_style_update(self) -> None:
super().notify_style_update()

def update_suggestion(self) -> None:
"""A hook called after edits, to allow subclasses to update the
[`suggestion`][textual.widgets.TextArea.suggestion] attribute.
"""
"""A hook to update the [`suggestion`][textual.widgets.TextArea.suggestion] attribute."""

def check_consume_key(self, key: str, character: str | None = None) -> bool:
"""Check if the widget may consume the given key.
Expand Down Expand Up @@ -1079,6 +1077,7 @@ def load_text(self, text: str) -> None:
self.history.clear()
self._set_document(text, self.language)
self.post_message(self.Changed(self).set_sender(self))
self.update_suggestion()

def _on_resize(self) -> None:
self._rewrap_and_refresh_virtual_size()
Expand Down Expand Up @@ -1625,6 +1624,7 @@ def _undo_batch(self, edits: Sequence[Edit]) -> None:
edit.after(self)
self._build_highlight_map()
self.post_message(self.Changed(self))
self.update_suggestion()

def _redo_batch(self, edits: Sequence[Edit]) -> None:
"""Redo a batch of Edits in order.
Expand Down Expand Up @@ -1673,6 +1673,7 @@ def _redo_batch(self, edits: Sequence[Edit]) -> None:
edit.after(self)
self._build_highlight_map()
self.post_message(self.Changed(self))
self.update_suggestion()

async def _on_key(self, event: events.Key) -> None:
"""Handle key presses which correspond to document inserts."""
Expand Down
Loading