From f4f5d4fd431ccb3aed9c12c665ec1c561c2f987f Mon Sep 17 00:00:00 2001 From: gaurav-cheema Date: Sat, 7 Oct 2023 19:50:13 -0700 Subject: [PATCH] 1. Added Feature to strikethrough TODO items 2. Requires adding -DNCURSES_WIDECHAR=1 to CFLAGS in src/Makefile 3. Made change so that priority cannot be changed on Completed TODO items. Signed-off-by: gaurav-cheema --- src/ui-todo.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/ui-todo.c b/src/ui-todo.c index 46933b3..0880690 100644 --- a/src/ui-todo.c +++ b/src/ui-todo.c @@ -228,8 +228,29 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data) } mesg = buf; } + + /* wbuf stores the wide char string + requires 4 extra chars: */ + // have to add CFLAG: -DNCURSES_WIDECHAR=1 + wchar_t wbuf[(strlen(mesg)+2)*2]; + if (todo->completed) { + wcscpy(wbuf, L"X"); + todo->note ? wcscat(wbuf, L">") : wcscat(wbuf, L"."); + wcscat(wbuf, L" "); + + wchar_t temp[2]; + temp[1] = L'\0'; + + for (size_t i = 0; i < strlen(mesg); i++) { + mbstowcs(&temp[0], &mesg[i], 1); + wcscat(wbuf, L"\u0336"); + wcscat(wbuf, temp); + } + } - mvwprintw(win, y, 0, "%s%s", mark, mesg); + if (todo->completed) { + mvwaddnwstr(win, y, 0, wbuf, -1); + } else { mvwprintw(win, y, 0, "%s%s", mark, mesg); } if (hilt) custom_remove_attr(win, ATTR_HIGHEST); @@ -295,6 +316,9 @@ void ui_todo_chg_priority(int diff) if (!item) return; + if (item->completed) + return; + int id = item->id + diff; struct todo *item_new;