diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-11-18 21:50:15 +0100 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-11-18 22:48:31 +0100 |
commit | 8fd6640caf1961c71c66a9c559f340d86cf17893 (patch) | |
tree | aae95ed461be3c3c0924e9d46ef79ec053db9824 /src/todo.c | |
parent | f2dca7de3e8b164a4b3af3d58dde2f6776bfbee6 (diff) | |
download | calcurse-8fd6640caf1961c71c66a9c559f340d86cf17893.zip |
Refactor todo_chg_priority()
Instead of passing a key, pass the number of steps to increase the
priority by.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/todo.c')
-rw-r--r-- | src/todo.c | 25 |
1 files changed, 7 insertions, 18 deletions
@@ -208,7 +208,7 @@ static int todo_get_position(struct todo *needle) } /* Change an item priority by pressing '+' or '-' inside TODO panel. */ -void todo_chg_priority(struct todo *backup, int action) +void todo_chg_priority(struct todo *backup, int diff) { char backup_mesg[BUFSIZ]; int backup_id; @@ -220,23 +220,12 @@ void todo_chg_priority(struct todo *backup, int action) strncpy(backup_note, backup->note, MAX_NOTESIZ + 1); else backup_note[0] = '\0'; - switch (action) { - case KEY_RAISE_PRIORITY: - if (backup_id > 1) - backup_id--; - else - return; - break; - case KEY_LOWER_PRIORITY: - if (backup_id > 0 && backup_id < 9) - backup_id++; - else - return; - break; - default: - EXIT(_("no such action")); - /* NOTREACHED */ - } + + backup_id += diff; + if (backup_id < 1) + backup_id = 1; + else if (backup_id > 9) + backup_id = 9; todo_delete(todo_get_item(hilt)); backup = todo_add(backup_mesg, backup_id, backup_note); |