Skip to content

Commit

Permalink
bar: better mode widget
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Oct 4, 2024
1 parent cafbfaf commit 33ab9da
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions dooit/utils/default_config.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)

0 comments on commit 33ab9da

Please sign in to comment.