From 33ab9da5e2c7acad6b8ecca703a113bf0e12dd00 Mon Sep 17 00:00:00 2001 From: kraanzu Date: Fri, 4 Oct 2024 15:50:00 +0530 Subject: [PATCH] bar: better mode widget --- dooit/utils/default_config.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/dooit/utils/default_config.py b/dooit/utils/default_config.py index e411dd2a..1a583c9a 100644 --- a/dooit/utils/default_config.py +++ b/dooit/utils/default_config.py @@ -1,3 +1,4 @@ +from rich.style import Style from dooit.api import Todo, Workspace from dooit.ui.api import events, DooitAPI from dooit.ui.api.widgets import TodoWidget, WorkspaceWidget @@ -6,14 +7,23 @@ from functools import partial -def get_mode(): - mode = " NORMAL " - return Text(f" {mode} ", style="black on white") +def get_mode(api: DooitAPI): + theme = api.app.current_theme + mode = api.app._mode + + MODES = { + "NORMAL": theme.primary, + "INSERT": theme.foreground_1, + } + return Text( + f" {mode} ", + style=Style( + color=theme.background_1, + bgcolor=MODES.get(mode, theme.primary), + ), + ) -bar_widgets = [ - StatusBarWidget(get_mode), -] # Todo formatters @@ -116,4 +126,7 @@ def key_setup(api: DooitAPI): partial(todo_urgency_formatter, api=api), ) + bar_widgets = [ + StatusBarWidget(partial(get_mode, api=api)), + ] api.bar.set(bar_widgets)