From 655218b7df40b3e159119933a4fa18efca2ff940 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 15 May 2014 14:37:49 +0200 Subject: ui-todo: Large-scale refactoring This is a complete overhaul of the TODO list user interface. The new implementation uses the generic list box panel. Signed-off-by: Lukas Fleischer --- src/calcurse.c | 52 +++++++++++++++------------------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) (limited to 'src/calcurse.c') diff --git a/src/calcurse.c b/src/calcurse.c index 98075d9..3bab0af 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -70,10 +70,6 @@ static inline void key_generic_change_view(void) /* Select the event to highlight. */ switch (wins_slctd()) { - case TOD: - if ((ui_todo_hilt() == 0) && (ui_todo_nb() > 0)) - ui_todo_hilt_set(1); - break; case APP: if ((ui_day_hilt() == 0) && ((inday.nb_events + inday.nb_apoints) > 0)) @@ -113,9 +109,8 @@ static inline void key_view_item(void) { if ((wins_slctd() == APP) && (ui_day_hilt() != 0)) day_popup_item(day_get_item(ui_day_hilt())); - else if ((wins_slctd() == TOD) && (ui_todo_hilt() != 0)) - item_in_popup(NULL, NULL, ui_todo_saved_mesg(), - _("TODO:")); + else if (wins_slctd() == TOD) + ui_todo_popup_item(); wins_update(FLAG_ALL); } @@ -137,8 +132,6 @@ static inline void key_generic_add_appt(void) static inline void key_generic_add_todo(void) { ui_todo_add(); - if (ui_todo_hilt() == 0 && ui_todo_nb() == 1) - ui_todo_hilt_increase(1); wins_update(FLAG_TOD | FLAG_STA); } @@ -152,8 +145,6 @@ static inline void key_add_item(void) break; case TOD: ui_todo_add(); - if (ui_todo_hilt() == 0 && ui_todo_nb() == 1) - ui_todo_hilt_increase(1); wins_update(FLAG_TOD | FLAG_STA); break; default: @@ -167,7 +158,7 @@ static inline void key_edit_item(void) ui_day_item_edit(); inday = do_storage(0); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); - } else if (wins_slctd() == TOD && ui_todo_hilt() != 0) { + } else if (wins_slctd() == TOD) { ui_todo_edit(); wins_update(FLAG_TOD | FLAG_STA); } @@ -180,7 +171,7 @@ static inline void key_del_item(void) reg); inday = do_storage(0); wins_update(FLAG_CAL | FLAG_APP | FLAG_STA); - } else if (wins_slctd() == TOD && ui_todo_hilt() != 0) { + } else if (wins_slctd() == TOD) { ui_todo_delete(); wins_update(FLAG_TOD | FLAG_STA); } @@ -219,8 +210,8 @@ static inline void key_flag_item(void) day_item_switch_notify(day_get_item(ui_day_hilt())); inday = do_storage(0); wins_update(FLAG_APP); - } else if (wins_slctd() == TOD && ui_todo_hilt() != 0) { - todo_flag(todo_get_item(ui_todo_hilt())); + } else if (wins_slctd() == TOD) { + ui_todo_flag(); wins_update(FLAG_TOD); } } @@ -229,19 +220,15 @@ static inline void key_pipe_item(void) { if (wins_slctd() == APP && ui_day_hilt() != 0) ui_day_item_pipe(); - else if (wins_slctd() == TOD && ui_todo_hilt() != 0) + else if (wins_slctd() == TOD) ui_todo_pipe(); wins_update(FLAG_ALL); } static inline void change_priority(int diff) { - if (wins_slctd() == TOD && ui_todo_hilt() != 0) { - ui_todo_chg_priority(todo_get_item(ui_todo_hilt()), diff); - if (ui_todo_hilt_pos() < 0) - ui_todo_set_first(ui_todo_hilt()); - else if (ui_todo_hilt_pos() >= win[TOD].h - 4) - ui_todo_set_first(ui_todo_hilt() - win[TOD].h + 5); + if (wins_slctd() == TOD) { + ui_todo_chg_priority(diff); wins_update(FLAG_TOD); } } @@ -261,8 +248,8 @@ static inline void key_edit_note(void) if (wins_slctd() == APP && ui_day_hilt() != 0) { day_edit_note(day_get_item(ui_day_hilt()), conf.editor); inday = do_storage(0); - } else if (wins_slctd() == TOD && ui_todo_hilt() != 0) { - todo_edit_note(todo_get_item(ui_todo_hilt()), conf.editor); + } else if (wins_slctd() == TOD) { + ui_todo_edit_note(); } wins_update(FLAG_ALL); } @@ -271,8 +258,8 @@ static inline void key_view_note(void) { if (wins_slctd() == APP && ui_day_hilt() != 0) day_view_note(day_get_item(ui_day_hilt()), conf.pager); - else if (wins_slctd() == TOD && ui_todo_hilt() != 0) - todo_view_note(todo_get_item(ui_todo_hilt()), conf.pager); + else if (wins_slctd() == TOD) + ui_todo_view_note(); wins_update(FLAG_ALL); } @@ -365,11 +352,7 @@ static inline void key_move_up(void) ui_day_scroll_pad_up(inday.nb_events); wins_update(FLAG_APP); } else if (wins_slctd() == TOD) { - if (count >= ui_todo_hilt()) - count = ui_todo_hilt() - 1; - ui_todo_hilt_decrease(count); - if (ui_todo_hilt_pos() < 0) - ui_todo_first_increase(ui_todo_hilt_pos()); + ui_todo_sel_move(-1); wins_update(FLAG_TOD); } } @@ -395,12 +378,7 @@ static inline void key_move_down(void) ui_day_scroll_pad_down(inday.nb_events, win[APP].h); wins_update(FLAG_APP); } else if (wins_slctd() == TOD) { - if (count > ui_todo_nb() - ui_todo_hilt()) - count = ui_todo_nb() - ui_todo_hilt(); - ui_todo_hilt_increase(count); - if (ui_todo_hilt_pos() >= win[TOD].h - 4) - ui_todo_first_increase(ui_todo_hilt_pos() - - win[TOD].h + 5); + ui_todo_sel_move(1); wins_update(FLAG_TOD); } } -- cgit v1.2.3-54-g00ecf