Support todo items with an undefined priority
In addition to priorities 1-9, support todo items without any specific priority, internally represented by priority 0. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
beea88e5fe
commit
e3ac5542aa
13
src/ical.c
13
src/ical.c
@ -1054,11 +1054,10 @@ ical_read_todo(FILE * fdi, FILE * log, int list, unsigned *notodos,
|
|||||||
unsigned *noskipped, char *buf, char *lstore,
|
unsigned *noskipped, char *buf, char *lstore,
|
||||||
unsigned *lineno)
|
unsigned *lineno)
|
||||||
{
|
{
|
||||||
const int LOWEST = 9;
|
|
||||||
const int ITEMLINE = *lineno;
|
const int ITEMLINE = *lineno;
|
||||||
struct {
|
struct {
|
||||||
char *mesg, *note;
|
char *mesg, *note;
|
||||||
int has_priority, priority;
|
int priority;
|
||||||
int completed;
|
int completed;
|
||||||
} vtodo;
|
} vtodo;
|
||||||
int skip_alarm;
|
int skip_alarm;
|
||||||
@ -1077,8 +1076,6 @@ ical_read_todo(FILE * fdi, FILE * log, int list, unsigned *notodos,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (starts_with_ci(buf, "END:VTODO")) {
|
if (starts_with_ci(buf, "END:VTODO")) {
|
||||||
if (!vtodo.has_priority)
|
|
||||||
vtodo.priority = LOWEST;
|
|
||||||
if (!vtodo.mesg) {
|
if (!vtodo.mesg) {
|
||||||
ical_log(log, ICAL_VTODO, ITEMLINE,
|
ical_log(log, ICAL_VTODO, ITEMLINE,
|
||||||
_("could not retrieve item summary."));
|
_("could not retrieve item summary."));
|
||||||
@ -1093,12 +1090,10 @@ ical_read_todo(FILE * fdi, FILE * log, int list, unsigned *notodos,
|
|||||||
|
|
||||||
if (starts_with_ci(buf, "PRIORITY:")) {
|
if (starts_with_ci(buf, "PRIORITY:")) {
|
||||||
sscanf(buf, "%d", &vtodo.priority);
|
sscanf(buf, "%d", &vtodo.priority);
|
||||||
if (vtodo.priority >= 1 && vtodo.priority <= 9) {
|
if (vtodo.priority < 0 || vtodo.priority > 9) {
|
||||||
vtodo.has_priority = 1;
|
|
||||||
} else {
|
|
||||||
ical_log(log, ICAL_VTODO, ITEMLINE,
|
ical_log(log, ICAL_VTODO, ITEMLINE,
|
||||||
_("item priority is not acceptable "
|
_("item priority is invalid "
|
||||||
"(must be between 1 and 9)."));
|
"(must be between 0 and 9)."));
|
||||||
}
|
}
|
||||||
} else if (starts_with_ci(buf, "STATUS:COMPLETED")) {
|
} else if (starts_with_ci(buf, "STATUS:COMPLETED")) {
|
||||||
vtodo.completed = 1;
|
vtodo.completed = 1;
|
||||||
|
@ -50,13 +50,13 @@ void ui_todo_add(void)
|
|||||||
int ch = 0;
|
int ch = 0;
|
||||||
const char *mesg = _("Enter the new TODO item:");
|
const char *mesg = _("Enter the new TODO item:");
|
||||||
const char *mesg_id =
|
const char *mesg_id =
|
||||||
_("Enter the TODO priority [1 (highest) - 9 (lowest)]:");
|
_("Enter the TODO priority [0 (none), 1 (highest) - 9 (lowest)]:");
|
||||||
char todo_input[BUFSIZ] = "";
|
char todo_input[BUFSIZ] = "";
|
||||||
|
|
||||||
status_mesg(mesg, "");
|
status_mesg(mesg, "");
|
||||||
if (getstring(win[STA].p, todo_input, BUFSIZ, 0, 1) ==
|
if (getstring(win[STA].p, todo_input, BUFSIZ, 0, 1) ==
|
||||||
GETSTRING_VALID) {
|
GETSTRING_VALID) {
|
||||||
while ((ch < '1') || (ch > '9')) {
|
while ((ch < '0') || (ch > '9')) {
|
||||||
status_mesg(mesg_id, "");
|
status_mesg(mesg_id, "");
|
||||||
ch = wgetch(win[KEY].p);
|
ch = wgetch(win[KEY].p);
|
||||||
}
|
}
|
||||||
@ -259,8 +259,8 @@ void ui_todo_chg_priority(int diff)
|
|||||||
int id = item->id + diff;
|
int id = item->id + diff;
|
||||||
struct todo *item_new;
|
struct todo *item_new;
|
||||||
|
|
||||||
if (id < 1)
|
if (id < 0)
|
||||||
id = 1;
|
id = 0;
|
||||||
else if (id > 9)
|
else if (id > 9)
|
||||||
id = 9;
|
id = 9;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user