aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-18 18:09:32 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-18 18:09:32 +0100
commit4bd8717d8087f77926c91fb52250bd8ec533af1a (patch)
tree8da5e228c8c0415208ee8b2459aed5fe6996ca55 /src
parent1b75acf01b2f5a8d828aca3376022e156f1444ff (diff)
downloadcalcurse-4bd8717d8087f77926c91fb52250bd8ec533af1a.tar.gz
calcurse-4bd8717d8087f77926c91fb52250bd8ec533af1a.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/ui-todo.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/ui-todo.c b/src/ui-todo.c
index 971c69d..da5ec3e 100644
--- a/src/ui-todo.c
+++ b/src/ui-todo.c
@@ -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);
struct todo *todo = LLIST_TS_GET_DATA(i);
- int mark[2];
- int width = lb_todo.sw.w;
+ char mark[] = { 0, 0, 0, 0 };
+ int width = lb_todo.sw.w - 2;
char buf[width * UTF8_MAXLEN];
+ char *mesg;
int j;
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[1] = todo->note ? '>' : '.';
+ mark[0] = todo->completed ? 'X' : (todo->id > 0 ? '0' + todo->id : 0);
+ 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);
@@ -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);
if (utf8_strwidth(todo->mesg) < width) {
- mvwprintw(win, y, 0, "%c%c %s", mark[0], mark[1], todo->mesg);
+ mesg = todo->mesg;
} else {
+ width -= 3;
for (j = 0; todo->mesg[j] && width > 0; j++) {
if (!UTF8_ISCONT(todo->mesg[j]))
width -= utf8_width(&todo->mesg[j]);
buf[j] = todo->mesg[j];
}
- if (j)
- buf[j - 1] = 0;
- else
+ if (j) {
+ buf[j - 1] = '.';
+ buf[j] = '.';
+ buf[j + 1] = '.';
+ buf[j + 2] = '\0';
+ } else {
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)
custom_remove_attr(win, ATTR_HIGHEST);