Improve event display formatting
authorAndy Spencer <andy753421@gmail.com>
Sun, 4 Dec 2016 03:27:48 +0000 (03:27 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 5 Dec 2016 08:28:14 +0000 (08:28 +0000)
Description can be long, so put it at the end.

src/args.c
views/edit.c

index d577fdc..9ad0640 100644 (file)
@@ -125,11 +125,11 @@ void args_main(void)
                        add_days(&start.year, &start.month, &start.day, d);
                        add_days(&end.year,   &end.month,   &end.day,   d);
 
-
                        /* Print day header */
                        wday_t wday = day_of_week(start.year, start.month, start.day);
-                       printf("%s%s, %s %d, %d\n",
-                               d ? "\n" : "",
+                       if (d > 0)
+                               printf("\n");
+                       printf("%s, %s %d, %d\n",
                                day_to_string(wday),
                                month_to_string(start.month),
                                start.day+1,
@@ -142,14 +142,19 @@ void args_main(void)
                        /* Print event info */
                        int printed = 0;
                        while (event && compare(&end, &event->start) > 0) {
-                               printf("%s  %02d:%02d",
-                                       printed ? "\n" : "",
-                                       event->start.hour,
-                                       event->start.min);
+                               if (printed > 0)
+                                       printf("\n");
+                               printf("* %02d:%02d - %02d:%02d",
+                                       event->start.hour, event->start.min,
+                                       event->end.hour,   event->end.min);
+                               if (!event->name)
+                                       printf("\n");
                                if (event->name)
                                        printf("  %s\n", event->name);
+                               if (event->loc)
+                                       printf("  Location:      %s\n", event->loc);
                                if (event->desc)
-                                       printf("\n  %s\n", event->desc);
+                                       printf("  Description:   %s\n", event->desc);
                                printed++;
                                event = event->next;
                        }
index eb810aa..4a92f7d 100644 (file)
@@ -46,12 +46,12 @@ static void draw_event(event_t *event)
        wmove(win, 0, 0);
        wprintw(win, "Edit Event\n");
        wprintw(win, "    Name:        %s\n",  event->name      ?: "[none]");
-       wprintw(win, "    Description: %s\n",  event->desc      ?: "[none]");
-       wprintw(win, "    Location:    %s\n",  event->loc       ?: "[none]");
-       wprintw(win, "    Category:    %s\n",  event->cat       ?: "[none]");
        wprintw(win, "    Start Time:  %s\n",  timestr(event->start));
        wprintw(win, "    End Time:    %s\n",  timestr(event->end));
        wprintw(win, "    Calendar:    %s\n",  event->cal->name ?: "[none]");
+       wprintw(win, "    Category:    %s\n",  event->cat       ?: "[none]");
+       wprintw(win, "    Location:    %s\n",  event->loc       ?: "[none]");
+       wprintw(win, "    Description: %s\n",  event->desc      ?: "[none]");
 }
 
 static int edit_event(event_t *event, int key, mmask_t btn, int row, int col)
@@ -65,12 +65,12 @@ static void draw_todo(todo_t *todo)
        wmove(win, 0, 0);
        wprintw(win, "Edit Todo\n");
        wprintw(win, "    Name:        %s\n",   todo->name      ?: "[none]");
-       wprintw(win, "    Description: %s\n",   todo->desc      ?: "[none]");
-       wprintw(win, "    Category:    %s\n",   todo->cat       ?: "[none]");
-       wprintw(win, "    Completed:   %d%%\n", todo->status);
        wprintw(win, "    Start Time:  %s\n",   timestr(todo->start));
        wprintw(win, "    Due Date:    %s\n",   timestr(todo->due));
        wprintw(win, "    Calendar:    %s\n",   todo->cal->name ?: "[none]");
+       wprintw(win, "    Category:    %s\n",   todo->cat       ?: "[none]");
+       wprintw(win, "    Completed:   %d%%\n", todo->status);
+       wprintw(win, "    Description: %s\n",   todo->desc      ?: "[none]");
 }
 
 static int edit_todo(todo_t *todo, int key, mmask_t btn, int row, int col)