summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2013-02-14 11:49:15 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2013-02-14 11:49:15 +0100
commitabca2f10b599d714932002d13847b9aa502c27a6 (patch)
tree3fe9c233c2983da34eb75acf84bc474192ad3efe /src
parent8de7399360e64d292198251da8fc8ae2ffbb7a7d (diff)
downloadcalcurse-abca2f10b599d714932002d13847b9aa502c27a6.tar.gz
calcurse-abca2f10b599d714932002d13847b9aa502c27a6.zip
ui-todo.c: Refactor ui_todo_chg_priority()
Add the new item *before* deleting the old one and get rid of temporary buffers for the item message and note. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src')
-rw-r--r--src/ui-todo.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/ui-todo.c b/src/ui-todo.c
index 145d911..d034881 100644
--- a/src/ui-todo.c
+++ b/src/ui-todo.c
@@ -294,26 +294,17 @@ void ui_todo_update_panel(int which_pan)
}
/* Change an item priority by pressing '+' or '-' inside TODO panel. */
-void ui_todo_chg_priority(struct todo *backup, int diff)
+void ui_todo_chg_priority(struct todo *todo, int diff)
{
- char backup_mesg[BUFSIZ];
- int backup_id;
- char backup_note[MAX_NOTESIZ + 1];
-
- strncpy(backup_mesg, backup->mesg, strlen(backup->mesg) + 1);
- backup_id = backup->id;
- if (backup->note)
- strncpy(backup_note, backup->note, MAX_NOTESIZ + 1);
- else
- backup_note[0] = '\0';
+ int id = todo->id + diff;
+ struct todo *todo_new;
- backup_id += diff;
- if (backup_id < 1)
- backup_id = 1;
- else if (backup_id > 9)
- backup_id = 9;
+ if (id < 1)
+ id = 1;
+ else if (id > 9)
+ id = 9;
- todo_delete(todo_get_item(hilt));
- backup = todo_add(backup_mesg, backup_id, backup_note);
- hilt = todo_get_position(backup);
+ todo_new = todo_add(todo->mesg, id, todo->note);
+ todo_delete(todo);
+ hilt = todo_get_position(todo_new);
}