diff --git a/pyproject.toml b/pyproject.toml index cb2fc9d..65d659d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ authors = [ ] dependencies = [ "httpx>=0.27.2", - "textual>=3.1", + "textual>=6.6", "xdg-base-dirs>=6.0.2", "pytz>=2024.2", "humanize>=4.11.0", diff --git a/src/braindrop/app/widgets/navigation.py b/src/braindrop/app/widgets/navigation.py index 1e9fedf..de6cb92 100644 --- a/src/braindrop/app/widgets/navigation.py +++ b/src/braindrop/app/widgets/navigation.py @@ -4,10 +4,6 @@ # Backward compatibility. from __future__ import annotations -############################################################################## -# Python imports. -from typing import Any - ############################################################################## # Rich imports. from rich.console import Group, RenderableType @@ -17,6 +13,7 @@ ############################################################################## # Textual imports. from textual import on +from textual.content import Content from textual.message import Message from textual.reactive import var from textual.widgets import OptionList @@ -66,7 +63,6 @@ def build_prompt( count: int, indent: int = 0, key: str | None = None, - key_colour: str | None = None, ) -> RenderableType: """The prompt for the option. @@ -74,7 +70,6 @@ def build_prompt( title: The title for the prompt. count: The count for the prompt. key: The optional key for the prompt. - key_colour: The optional colour for the key. Returns: A renderable that is the prompt. @@ -83,8 +78,10 @@ def build_prompt( prompt.add_column(ratio=1) prompt.add_column(justify="right") prompt.add_row( - f"{'[dim]>[/dim] ' * indent}{title}" - + (f" [{key_colour or 'dim'}]\\[{key or ''}][/]" if key else ""), + Content.from_markup( + f"{'[dim]>[/dim] ' * indent}{title}" + + (f" [$footer-key-foreground]\\[{key or ''}][/]" if key else "") + ), f"[dim i]{count}[/]", ) return prompt @@ -111,7 +108,6 @@ def __init__( collection: Collection, indent: int = 0, key: str | None = None, - key_colour: str | None = None, count: int = 0, ) -> None: """Initialise the object. @@ -120,7 +116,6 @@ def __init__( collection: The collection to show. indent: The indent level for the collection. key: The associated with the collection. - key_colour: The colour to show the key in. count: The count of raindrops in the collection. """ self._collection = collection @@ -131,7 +126,6 @@ def __init__( count or collection.count, indent, key, - key_colour, ), id=self.id_of(collection), ) @@ -229,19 +223,6 @@ def __init__( self._api = api """The API client object.""" - def on_mount(self) -> None: - """Configure the widget once the DIM is ready.""" - - def redraw(*_: Any) -> None: - """Force a redraw of the content of the widget.""" - self.active_collection = self.active_collection - - # While the user will almost never notice, if the theme changes the - # accent colour for the keys will go out of sync, so here we watch - # for a theme change and then force a redraw of the content so we do - # keep in sync. - self.app.theme_changed_signal.subscribe(self, redraw) - def highlight_collection(self, collection: Collection) -> None: """Ensure the given collection is highlighted. @@ -285,9 +266,6 @@ def _add_collection( collection, indent, key, - None - if self.app.current_theme is None - else self.app.current_theme.accent, 0 if self.data is None else self.data.collection_size(collection), ) ) diff --git a/uv.lock b/uv.lock index 7186ee1..84f993f 100644 --- a/uv.lock +++ b/uv.lock @@ -144,7 +144,7 @@ requires-dist = [ { name = "humanize", specifier = ">=4.11.0" }, { name = "pyperclip", specifier = ">=1.9.0" }, { name = "pytz", specifier = ">=2024.2" }, - { name = "textual", specifier = ">=3.1" }, + { name = "textual", specifier = ">=6.6" }, { name = "textual-enhanced", specifier = ">=1.0.0" }, { name = "typing-extensions", specifier = ">=4.12.2" }, { name = "xdg-base-dirs", specifier = ">=6.0.2" }, @@ -401,9 +401,6 @@ wheels = [ linkify = [ { name = "linkify-it-py" }, ] -plugins = [ - { name = "mdit-py-plugins" }, -] [[package]] name = "markupsafe" @@ -794,15 +791,15 @@ wheels = [ [[package]] name = "rich" -version = "14.1.0" +version = "14.2.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "markdown-it-py" }, { name = "pygments" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/fe/75/af448d8e52bf1d8fa6a9d089ca6c07ff4453d86c65c145d0a300bb073b9b/rich-14.1.0.tar.gz", hash = "sha256:e497a48b844b0320d45007cdebfeaeed8db2a4f4bcf49f15e455cfc4af11eaa8", size = 224441, upload-time = "2025-07-25T07:32:58.125Z" } +sdist = { url = "https://files.pythonhosted.org/packages/fb/d2/8920e102050a0de7bfabeb4c4614a49248cf8d5d7a8d01885fbb24dc767a/rich-14.2.0.tar.gz", hash = "sha256:73ff50c7c0c1c77c8243079283f4edb376f0f6442433aecb8ce7e6d0b92d1fe4", size = 219990, upload-time = "2025-10-09T14:16:53.064Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/e3/30/3c4d035596d3cf444529e0b2953ad0466f6049528a879d27534700580395/rich-14.1.0-py3-none-any.whl", hash = "sha256:536f5f1785986d6dbdea3c75205c473f970777b4a0d6c6dd1b696aa05a3fa04f", size = 243368, upload-time = "2025-07-25T07:32:56.73Z" }, + { url = "https://files.pythonhosted.org/packages/25/7a/b0178788f8dc6cafce37a212c99565fa1fe7872c70c6c9c1e1a372d9d88f/rich-14.2.0-py3-none-any.whl", hash = "sha256:76bc51fe2e57d2b1be1f96c524b890b816e334ab4c1e45888799bfaab0021edd", size = 243393, upload-time = "2025-10-09T14:16:51.245Z" }, ] [[package]] @@ -842,18 +839,19 @@ wheels = [ [[package]] name = "textual" -version = "5.3.0" +version = "6.6.0" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "markdown-it-py", extra = ["linkify", "plugins"] }, + { name = "markdown-it-py", extra = ["linkify"] }, + { name = "mdit-py-plugins" }, { name = "platformdirs" }, { name = "pygments" }, { name = "rich" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/ba/ce/f0f938d33d9bebbf8629e0020be00c560ddfa90a23ebe727c2e5aa3f30cf/textual-5.3.0.tar.gz", hash = "sha256:1b6128b339adef2e298cc23ab4777180443240ece5c232f29b22960efd658d4d", size = 1557651, upload-time = "2025-08-07T12:36:50.342Z" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/2f/f0b408f227edca21d1996c1cd0b65309f0cbff44264aa40aded3ff9ce2e1/textual-6.6.0.tar.gz", hash = "sha256:53345166d6b0f9fd028ed0217d73b8f47c3a26679a18ba3b67616dcacb470eec", size = 1579327, upload-time = "2025-11-10T17:50:00.038Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/00/2f/f7c8a533bee50fbf5bb37ffc1621e7b2cdd8c9a6301fc51faa35fa50b09d/textual-5.3.0-py3-none-any.whl", hash = "sha256:02a6abc065514c4e21f94e79aaecea1f78a28a85d11d7bfc64abf3392d399890", size = 702671, upload-time = "2025-08-07T12:36:48.272Z" }, + { url = "https://files.pythonhosted.org/packages/53/b3/95ab646b0c908823d71e49ab8b5949ec9f33346cee3897d1af6be28a8d91/textual-6.6.0-py3-none-any.whl", hash = "sha256:5a9484bd15ee8a6fd8ac4ed4849fb25ee56bed2cecc7b8a83c4cd7d5f19515e5", size = 712606, upload-time = "2025-11-10T17:49:58.391Z" }, ] [[package]]