From 2a5a1a2b744263d88c73f4694a1cc2bcfd759ed4 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 18 Nov 2012 22:07:23 +0100 Subject: calcurse.c: Break up key_change_priority() Split up key_change_priority() into key_raise_priority(), key_lower_priority() which are wrappers around a new convenience function change_priority(). Signed-off-by: Lukas Fleischer --- src/calcurse.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/calcurse.c b/src/calcurse.c index 6a91e74..fefe18e 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -224,11 +224,10 @@ static inline void key_pipe_item(int key) wins_update(FLAG_ALL); } -static inline void key_change_priority(int key) +static inline void change_priority(int diff) { if (wins_slctd() == TOD && todo_hilt() != 0) { - todo_chg_priority(todo_get_item(todo_hilt()), - key == KEY_RAISE_PRIORITY ? 1 : -1); + todo_chg_priority(todo_get_item(todo_hilt()), diff); if (todo_hilt_pos() < 0) todo_set_first(todo_hilt()); else if (todo_hilt_pos() >= win[TOD].h - 4) @@ -237,6 +236,16 @@ static inline void key_change_priority(int key) } } +static inline void key_raise_priority(int key) +{ + change_priority(1); +} + +static inline void key_lower_priority(int key) +{ + change_priority(-1); +} + static inline void key_edit_note(int key) { if (wins_slctd() == APP && apoint_hilt() != 0) { @@ -584,8 +593,8 @@ int main(int argc, char **argv) HANDLE_KEY(KEY_REPEAT_ITEM, key_repeat_item); HANDLE_KEY(KEY_FLAG_ITEM, key_flag_item); HANDLE_KEY(KEY_PIPE_ITEM, key_pipe_item); - HANDLE_KEY(KEY_RAISE_PRIORITY, key_change_priority); - HANDLE_KEY(KEY_LOWER_PRIORITY, key_change_priority); + HANDLE_KEY(KEY_RAISE_PRIORITY, key_raise_priority); + HANDLE_KEY(KEY_LOWER_PRIORITY, key_lower_priority); HANDLE_KEY(KEY_EDIT_NOTE, key_edit_note); HANDLE_KEY(KEY_VIEW_NOTE, key_view_note); HANDLE_KEY(KEY_GENERIC_HELP, key_generic_help); -- cgit v1.2.3-70-g09d2