Skip to content

Commit

Permalink
add mode property to vars
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Nov 9, 2024
1 parent 5eb7e2c commit 8d8b9ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dooit/ui/api/api_components/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def __init__(self, app: "Dooit") -> None:
super().__init__()
self.app = app

@property
def mode(self) -> str:
return self.app.current_mode

@property
def theme(self) -> DooitThemeBase:
return self.app.current_theme
Expand Down
16 changes: 16 additions & 0 deletions site/docs/configuration/vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
This api component exposes some of the stuff running on dooit + act as a global register to tweak settings \
Its still developing and I'll add more stuff to it as per demand!

## mode

```py
def mode(self) -> str
```

Returns the current mode of the app (`NORMAL/INSERT/SORT/CONFIRM/DATE/SEARCH`)

```py{6}
from dooit.ui.api.events import DooitEvent
from dooit.ui.api import DooitAPI, subscribe

@subscribe(DooitEvent)
def foo(api: DooitAPI, event: DooitEvent):
mode = api.vars.mode
```
## theme

```py
Expand Down

0 comments on commit 8d8b9ff

Please sign in to comment.