Skip to content

Commit

Permalink
feat: save on escape (closes #106)
Browse files Browse the repository at this point in the history
Users can noe decide whether to save or cancel the todo when `escape` is
pressed
This behavior can be customized by changing `SAVE_ON_ESCAPE` var in the
config file
  • Loading branch information
kraanzu committed Aug 15, 2023
1 parent 8e89cba commit 018f12c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dooit/ui/widgets/simple_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
YELLOW = config_man.get("yellow")
GREEN = config_man.get("green")
SEARCH_COLOR = config_man.get("SEARCH_COLOR")
SAVE_ON_ESCAPE = config_man.get("SAVE_ON_ESCAPE")


class Input(Widget):
Expand Down Expand Up @@ -282,7 +283,10 @@ async def keypress(self, key: str) -> None:
await super().keypress(key)

if key == "escape":
await self.cancel_edit()
if SAVE_ON_ESCAPE:
await self.stop_edit()
else:
await self.cancel_edit()

def _colorize_by_status(self, text: str) -> str:
return self._render_text_with_color(
Expand Down
1 change: 1 addition & 0 deletions dooit/utils/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def get_username():
BORDER_TITLE_LIT = white
SEARCH_COLOR = red
YANK_COLOR = blue
SAVE_ON_ESCAPE = False

#################################
# DASHBOARD #
Expand Down

0 comments on commit 018f12c

Please sign in to comment.