44# Backward compatibility.
55from __future__ import annotations
66
7- ##############################################################################
8- # Python imports.
9- from typing import Any
10-
117##############################################################################
128# Rich imports.
139from rich .console import Group , RenderableType
1713##############################################################################
1814# Textual imports.
1915from textual import on
16+ from textual .content import Content
2017from textual .message import Message
2118from textual .reactive import var
2219from textual .widgets import OptionList
@@ -66,15 +63,13 @@ def build_prompt(
6663 count : int ,
6764 indent : int = 0 ,
6865 key : str | None = None ,
69- key_colour : str | None = None ,
7066 ) -> RenderableType :
7167 """The prompt for the option.
7268
7369 Args:
7470 title: The title for the prompt.
7571 count: The count for the prompt.
7672 key: The optional key for the prompt.
77- key_colour: The optional colour for the key.
7873
7974 Returns:
8075 A renderable that is the prompt.
@@ -83,8 +78,10 @@ def build_prompt(
8378 prompt .add_column (ratio = 1 )
8479 prompt .add_column (justify = "right" )
8580 prompt .add_row (
86- f"{ '[dim]>[/dim] ' * indent } { title } "
87- + (f" [{ key_colour or 'dim' } ]\\ [{ key or '' } ][/]" if key else "" ),
81+ Content .from_markup (
82+ f"{ '[dim]>[/dim] ' * indent } { title } "
83+ + (f" [$footer-key-foreground]\\ [{ key or '' } ][/]" if key else "" )
84+ ),
8885 f"[dim i]{ count } [/]" ,
8986 )
9087 return prompt
@@ -111,7 +108,6 @@ def __init__(
111108 collection : Collection ,
112109 indent : int = 0 ,
113110 key : str | None = None ,
114- key_colour : str | None = None ,
115111 count : int = 0 ,
116112 ) -> None :
117113 """Initialise the object.
@@ -120,7 +116,6 @@ def __init__(
120116 collection: The collection to show.
121117 indent: The indent level for the collection.
122118 key: The associated with the collection.
123- key_colour: The colour to show the key in.
124119 count: The count of raindrops in the collection.
125120 """
126121 self ._collection = collection
@@ -131,7 +126,6 @@ def __init__(
131126 count or collection .count ,
132127 indent ,
133128 key ,
134- key_colour ,
135129 ),
136130 id = self .id_of (collection ),
137131 )
@@ -229,19 +223,6 @@ def __init__(
229223 self ._api = api
230224 """The API client object."""
231225
232- def on_mount (self ) -> None :
233- """Configure the widget once the DIM is ready."""
234-
235- def redraw (* _ : Any ) -> None :
236- """Force a redraw of the content of the widget."""
237- self .active_collection = self .active_collection
238-
239- # While the user will almost never notice, if the theme changes the
240- # accent colour for the keys will go out of sync, so here we watch
241- # for a theme change and then force a redraw of the content so we do
242- # keep in sync.
243- self .app .theme_changed_signal .subscribe (self , redraw )
244-
245226 def highlight_collection (self , collection : Collection ) -> None :
246227 """Ensure the given collection is highlighted.
247228
@@ -285,9 +266,6 @@ def _add_collection(
285266 collection ,
286267 indent ,
287268 key ,
288- None
289- if self .app .current_theme is None
290- else self .app .current_theme .accent ,
291269 0 if self .data is None else self .data .collection_size (collection ),
292270 )
293271 )
0 commit comments