Skip to content

Commit

Permalink
fix: fix lines longer than textbox during editing
Browse files Browse the repository at this point in the history
  • Loading branch information
mecaneer23 committed Dec 12, 2023
1 parent 4e70260 commit aae7676
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/class_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,6 @@ def get_extra_data(self) -> str:

def set_extra_data(self, extra_data: str) -> None:
self.extra_data = extra_data

def __repr__(self):
return f"{self.mode} {self.extra_data}"
14 changes: 10 additions & 4 deletions todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,9 @@ def color_todo(stdscr: Any, todos: list[Todo], selected: Cursor) -> list[Todo]:
return todos


def edit_todo(stdscr: Any, todos: list[Todo], selected: int) -> list[Todo]:
def edit_todo(
stdscr: Any, todos: list[Todo], selected: int, mode: SingleLineModeImpl
) -> list[Todo]:
max_y, max_x = stdscr.getmaxyx()
todo = todos[selected].display_text
ncols = (
Expand All @@ -172,6 +174,7 @@ def edit_todo(stdscr: Any, todos: list[Todo], selected: int) -> list[Todo]:
curses.newwin(3, ncols, max_y // 2 - 3, begin_x),
todo=todos[selected],
prev_todo=Todo(),
mode=mode,
)
if edited_todo.is_empty():
return todos
Expand Down Expand Up @@ -278,10 +281,11 @@ def handle_edit(
stdscr: Any,
todos: list[Todo],
selected: Cursor,
mode: SingleLineModeImpl,
):
if len(todos) <= 0:
return todos
return edit_todo(stdscr, todos, int(selected))
return edit_todo(stdscr, todos, int(selected), mode)


def handle_to_top(todos: list[Todo], selected: Cursor) -> None:
Expand Down Expand Up @@ -531,7 +535,7 @@ def main(stdscr: Any) -> int:
Key.d: (handle_delete_todo, "stdscr, todos, selected, copied_todo"),
Key.g: (handle_to_top, "todos, selected"),
Key.h: (help_menu, "stdscr"),
Key.i: (handle_edit, "stdscr, todos, selected"),
Key.i: (handle_edit, "stdscr, todos, selected, single_line_mode"),
Key.j: (handle_cursor_down, "todos, selected"),
Key.k: (handle_cursor_up, "todos, selected"),
Key.o: (handle_new_todo_next, "stdscr, todos, selected, single_line_mode"),
Expand Down Expand Up @@ -579,7 +583,9 @@ def main(stdscr: Any) -> int:
sublist_top = print_todos(stdscr, todos, selected, sublist_top)
stdscr.refresh()
if single_line_state.is_off():
todos = handle_new_todo_next(stdscr, todos, selected, single_line_state, Todo())
todos = handle_new_todo_next(
stdscr, todos, selected, single_line_state, Todo()
)
continue
if single_line_state.is_once():
todos = handle_new_todo_next(
Expand Down
2 changes: 1 addition & 1 deletion todo.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-1 fix strikethrough
-1 fix long lines (longer than width // 2 - 1)
-1 fix moving down onto a toggled line
-2 fix lines longer than textbox during editing
+2 fix lines longer than textbox during editing
-2 fix really long lines (longer than textbox width * 2)
-3 make it work on windows
-3 appears to be a compatibility problem with python3.12
Expand Down

0 comments on commit aae7676

Please sign in to comment.