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>
This commit is contained in:
parent
f2dca7de3e
commit
8fd6640caf
@ -221,7 +221,8 @@ static inline void key_pipe_item(int key)
|
|||||||
static inline void key_change_priority(int key)
|
static inline void key_change_priority(int key)
|
||||||
{
|
{
|
||||||
if (wins_slctd() == TOD && todo_hilt() != 0) {
|
if (wins_slctd() == TOD && todo_hilt() != 0) {
|
||||||
todo_chg_priority(todo_get_item(todo_hilt()), key);
|
todo_chg_priority(todo_get_item(todo_hilt()),
|
||||||
|
key == KEY_RAISE_PRIORITY ? 1 : -1);
|
||||||
if (todo_hilt_pos() < 0)
|
if (todo_hilt_pos() < 0)
|
||||||
todo_set_first(todo_hilt());
|
todo_set_first(todo_hilt());
|
||||||
else if (todo_hilt_pos() >= win[TOD].h - 4)
|
else if (todo_hilt_pos() >= win[TOD].h - 4)
|
||||||
|
25
src/todo.c
25
src/todo.c
@ -208,7 +208,7 @@ static int todo_get_position(struct todo *needle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Change an item priority by pressing '+' or '-' inside TODO panel. */
|
/* 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];
|
char backup_mesg[BUFSIZ];
|
||||||
int backup_id;
|
int backup_id;
|
||||||
@ -220,23 +220,12 @@ void todo_chg_priority(struct todo *backup, int action)
|
|||||||
strncpy(backup_note, backup->note, MAX_NOTESIZ + 1);
|
strncpy(backup_note, backup->note, MAX_NOTESIZ + 1);
|
||||||
else
|
else
|
||||||
backup_note[0] = '\0';
|
backup_note[0] = '\0';
|
||||||
switch (action) {
|
|
||||||
case KEY_RAISE_PRIORITY:
|
backup_id += diff;
|
||||||
if (backup_id > 1)
|
if (backup_id < 1)
|
||||||
backup_id--;
|
backup_id = 1;
|
||||||
else
|
else if (backup_id > 9)
|
||||||
return;
|
backup_id = 9;
|
||||||
break;
|
|
||||||
case KEY_LOWER_PRIORITY:
|
|
||||||
if (backup_id > 0 && backup_id < 9)
|
|
||||||
backup_id++;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
EXIT(_("no such action"));
|
|
||||||
/* NOTREACHED */
|
|
||||||
}
|
|
||||||
|
|
||||||
todo_delete(todo_get_item(hilt));
|
todo_delete(todo_get_item(hilt));
|
||||||
backup = todo_add(backup_mesg, backup_id, backup_note);
|
backup = todo_add(backup_mesg, backup_id, backup_note);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user