Skip to content

Commit

Permalink
feat: use menus.alert as an alternative to magnify
Browse files Browse the repository at this point in the history
  • Loading branch information
mecaneer23 committed Mar 24, 2024
1 parent 27020f5 commit 7c91dbd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Options:
| <kbd>/</kbd> | Search for a sequence |
| <kbd>Alt</kbd>+<kbd>g</kbd>/<kbd>Alt</kbd>+<kbd>Shift</kbd>+<kbd>g</kbd> | Select all todos above/below |
| <kbd>Alt</kbd>+<kbd>k</kbd>/<kbd>j</kbd> | Move todo up and down |
| <kbd>Backspace</kbd> | Combine with previous todo |
| <kbd>Ctrl</kbd>+<kbd>a</kbd> | Select all todos |
| <kbd>Ctrl</kbd>+<kbd>r</kbd> | Redo change |
| <kbd>Ctrl</kbd>+<kbd>x</kbd>, <kbd>k</kbd> | Toggle `toggle` and `entry` modes |
Expand All @@ -80,6 +81,7 @@ Options:
| <kbd>Shift</kbd>+<kbd>k</kbd>/<kbd>j</kbd> | Select/deselect multiple todos |
| <kbd>Shift</kbd>+<kbd>o</kbd> | Add a todo on current line |
| <kbd>Tab</kbd>/<kbd>Shift</kbd>+<kbd>Tab</kbd> | Indent/unindent selected todo |
| <kbd>a</kbd> | Display selected todo as an alert |
| <kbd>b</kbd> | Make selected todo bigger (magnify) |
| <kbd>c</kbd> | Change selected todo color |
| <kbd>d</kbd> | Remove selected todo |
Expand Down
2 changes: 1 addition & 1 deletion src/get_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from src.working_initscr import wrapper

CONTROLS_BEGIN_INDEX: int = 68
CONTROLS_END_INDEX: int = 96
CONTROLS_END_INDEX: int = 98

_DEFAULT_BULLETS: bool = False
_DEFAULT_ENUMERATE: bool = False
Expand Down
1 change: 1 addition & 0 deletions src/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Key:
K = 75
O = 79
indent_dedent = 90
a = 97
b = 98
c = 99
d = 100
Expand Down
2 changes: 1 addition & 1 deletion src/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def alert(stdscr: curses.window, message: str) -> int:
Press any key to close (pressed key is returned).
"""
set_header(stdscr, "Alert!")
set_header(stdscr, "Alert! Press any key to close")
stdscr.refresh()
border_width = 2
max_y, max_x = stdscr.getmaxyx()
Expand Down
12 changes: 10 additions & 2 deletions todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from src.io import file_string_to_todos, read_file, update_file
from src.keys import Key
from src.menus import (
alert,
color_menu,
get_newwin,
help_menu,
Expand Down Expand Up @@ -405,6 +406,12 @@ def _handle_enter(
return selected.todo_set_to(new_todo_next(stdscr, todos, int(selected), mode=mode))


def _handle_alert(stdscr: curses.window, todos: Todos, selected: int) -> None:
"""Display the selected todo in an alert window"""

alert(stdscr, todos[selected].get_display_text())


def _print_history(history: UndoRedo) -> None:
"""Print passed in `history` to `HISTORY_FILE` if `PRINT_HISTORY` is enabled"""
if PRINT_HISTORY:
Expand All @@ -431,8 +438,8 @@ def _get_main_input(
stdscr: curses.window,
todos: Todos,
keys_esckeys: tuple[
dict[int, tuple[Callable[..., Any], str]],
dict[int, tuple[Callable[..., Any], str]],
dict[int, tuple[Callable[..., Todos | None], str]],
dict[int, tuple[Callable[..., Todos | None], str]],
],
possible_args: dict[str, Any],
) -> int | Todos:
Expand Down Expand Up @@ -585,6 +592,7 @@ def main(stdscr: curses.window) -> int:
Key.J: (selected.multiselect_down, "len(todos)"),
Key.K: (selected.multiselect_up, "None"),
Key.O: (new_todo_current, "stdscr, todos, int(selected)"),
Key.a: (_handle_alert, "stdscr, todos, int(selected)"),
Key.b: (magnify_menu, "stdscr, todos, selected"),
Key.c: (color_todo, "stdscr, todos, selected"),
Key.d: (_handle_delete_todo, "stdscr, todos, selected, copied_todo"),
Expand Down
4 changes: 2 additions & 2 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-m depends on how the program is run, not a huge issue
-y feat: add unit tests?
-g refactor: only return objects (mostly `TodoList`s) when necessary
-c feat: use menus.alert as an alternative to magnify
-c update readme to include new commands (backspace, this, etc)
+c feat: use menus.alert as an alternative to magnify
+c update readme to include new commands (backspace, this, etc)
-b fix: overflow when appending to center of todo
-b fix: keep color on overflow when appending to todo

0 comments on commit 7c91dbd

Please sign in to comment.