Hide "0." prefix of todo items with undefined priority
In the todo panel, all uncompleted items are currently prefixed with their priorities. Drop this prefix from items with priority 0, i.e. undefined priority. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
1b75acf01b
commit
4bd8717d80
@ -157,9 +157,10 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data)
|
|||||||
{
|
{
|
||||||
llist_item_t *i = *((llist_item_t **)cb_data);
|
llist_item_t *i = *((llist_item_t **)cb_data);
|
||||||
struct todo *todo = LLIST_TS_GET_DATA(i);
|
struct todo *todo = LLIST_TS_GET_DATA(i);
|
||||||
int mark[2];
|
char mark[] = { 0, 0, 0, 0 };
|
||||||
int width = lb_todo.sw.w;
|
int width = lb_todo.sw.w - 2;
|
||||||
char buf[width * UTF8_MAXLEN];
|
char buf[width * UTF8_MAXLEN];
|
||||||
|
char *mesg;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
if (ui_todo_view == TODO_HIDE_COMPLETED_VIEW) {
|
if (ui_todo_view == TODO_HIDE_COMPLETED_VIEW) {
|
||||||
@ -170,8 +171,20 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mark[0] = todo->completed ? 'X' : '0' + todo->id;
|
mark[0] = todo->completed ? 'X' : (todo->id > 0 ? '0' + todo->id : 0);
|
||||||
mark[1] = todo->note ? '>' : '.';
|
if (todo->note) {
|
||||||
|
if (mark[0] == '\0') {
|
||||||
|
mark[0] = '>';
|
||||||
|
mark[1] = ' ';
|
||||||
|
} else {
|
||||||
|
mark[1] = '>';
|
||||||
|
mark[2] = ' ';
|
||||||
|
}
|
||||||
|
} else if (mark[0] != '\0') {
|
||||||
|
mark[1] = '.';
|
||||||
|
mark[2] = ' ';
|
||||||
|
}
|
||||||
|
width -= strlen(mark);
|
||||||
|
|
||||||
hilt = hilt && (wins_slctd() == TOD);
|
hilt = hilt && (wins_slctd() == TOD);
|
||||||
|
|
||||||
@ -179,20 +192,27 @@ void ui_todo_draw(int n, WINDOW *win, int y, int hilt, void *cb_data)
|
|||||||
custom_apply_attr(win, ATTR_HIGHEST);
|
custom_apply_attr(win, ATTR_HIGHEST);
|
||||||
|
|
||||||
if (utf8_strwidth(todo->mesg) < width) {
|
if (utf8_strwidth(todo->mesg) < width) {
|
||||||
mvwprintw(win, y, 0, "%c%c %s", mark[0], mark[1], todo->mesg);
|
mesg = todo->mesg;
|
||||||
} else {
|
} else {
|
||||||
|
width -= 3;
|
||||||
for (j = 0; todo->mesg[j] && width > 0; j++) {
|
for (j = 0; todo->mesg[j] && width > 0; j++) {
|
||||||
if (!UTF8_ISCONT(todo->mesg[j]))
|
if (!UTF8_ISCONT(todo->mesg[j]))
|
||||||
width -= utf8_width(&todo->mesg[j]);
|
width -= utf8_width(&todo->mesg[j]);
|
||||||
buf[j] = todo->mesg[j];
|
buf[j] = todo->mesg[j];
|
||||||
}
|
}
|
||||||
if (j)
|
if (j) {
|
||||||
buf[j - 1] = 0;
|
buf[j - 1] = '.';
|
||||||
else
|
buf[j] = '.';
|
||||||
|
buf[j + 1] = '.';
|
||||||
|
buf[j + 2] = '\0';
|
||||||
|
} else {
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
mvwprintw(win, y, 0, "%c%c %s...", mark[0], mark[1], buf);
|
}
|
||||||
|
mesg = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mvwprintw(win, y, 0, "%s%s", mark, mesg);
|
||||||
|
|
||||||
if (hilt)
|
if (hilt)
|
||||||
custom_remove_attr(win, ATTR_HIGHEST);
|
custom_remove_attr(win, ATTR_HIGHEST);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user