textual_enhanced.tools
Provides assorted tools that help with Textual things.
History
History(history=None, max_length=500)
Bases: Generic[HistoryItem]
A class for handling and tracking history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Sequence[HistoryItem] | None
|
Set to the given history. |
None
|
|
int
|
Optional maximum length for the history. |
500
|
can_go_backward
property
can_go_backward
Can history go backward?
can_go_forward
property
can_go_forward
Can history go forward?
current_item
property
current_item
The current item in the history.
If there is no current item in the history the value is None.
current_location
property
current_location
The current integer location in the history.
If there is no valid location the value is None.
__delitem__
__delitem__(index)
Delete an item in history.
__iter__
__iter__()
Support iterating through the history.
__len__
__len__()
The length of the history.
add
add(item)
Add an item to the history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
HistoryItem
|
The item to add. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
Self. |
backward
backward()
Go backward through the history.
Returns:
| Type | Description |
|---|---|
bool
|
|
forward
forward()
Go forward through the history.
Returns:
| Type | Description |
|---|---|
bool
|
|
goto
goto(location)
Jump to a specific location within history.
goto_end
goto_end()
Go to the end of the history.
add_key
Add a key name to a label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The label to add the key to. |
required |
|
str
|
The display name of the key to add. |
required |
|
App[Any] | Widget | None
|
The widget, screen or application. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The label with a display of the key added. |
Notes
By default the key label will use the current theme's accent colour,
if that can't be derived from the context them dim will be used.