const char *dstr = day_to_string(day_of_week(YEAR, MONTH, DAY));
int y = !COMPACT+1;
+ event_t *event;
/* Print Header */
if (COMPACT) wattron(win, A_REVERSE | A_BOLD);
mvwprintw(win, 0, COLS-10, "%d-%02d-%02d", YEAR, MONTH, DAY+1);
if (COMPACT) wattroff(win, A_REVERSE | A_BOLD);
+ /* Print all day events */
+ event = EVENTS;
+ int allday = 0;
+ while (event && before(&event->start, YEAR, MONTH, DAY, 24, 0)) {
+ if (!before(&event->end, YEAR, MONTH, DAY, 0, 1) &&
+ get_mins(&event->start, &event->end) > 23*60)
+ event_line(win, event, y+allday++, 6, COLS, 1);
+ event = event->next;
+ }
+ if (allday && !COMPACT)
+ allday++;
+
/* Resize body */
- wshrink(times, y);
- wshrink(body, y);
+ wshrink(times, y+allday);
+ wshrink(body, y+allday);
+
/* Print times */
mvwprintw(times, 0, 0, "%02d:%02d", ((line/4)-1)%12+1, (line*15)%60);
for (int h = 0; h < 24; h++)
mvwprintw(times, h*4-line, 0, "%02d:%02d", (h-1)%12+1, 0);
/* Print events */
- event_t *event = EVENTS;
+ event = EVENTS;
event_t *active[10] = {};
int ncols = 0;
for (int h = 0; h < 24; h++)
for (int m = 0; m < 60; m+=15)
while (event && before(&event->start,
YEAR, MONTH, DAY, h+(m+15)/60, (m+15)%60)) {
- if (!before(&event->start, YEAR, MONTH, DAY, h, m)) {
+ if (!before(&event->start, YEAR, MONTH, DAY, h, m) &&
+ get_mins(&event->start, &event->end) <= 23*60) {
int col = get_col(active, N_ELEMENTS(active), event, &ncols);
int left = ROUND((col+0.0)*(COLS-6)/ncols) + 1;
int right = ROUND((col+1.0)*(COLS-6)/ncols) + 1;
/* Print lines */
if (!COMPACT)
mvwhline(win, 1, 0, ACS_HLINE, COLS);
+ if (!COMPACT && allday)
+ mvwhline(win, allday+1, 0, ACS_HLINE, COLS);
mvwvline(body, 0, 0, ACS_VLINE, LINES-4+COMPACT+COMPACT);
}
int x = 6;
int y = 3 - COMPACT;
const float hstep = (float)(COLS-x)/7.0;
+ event_t *event;
/* Get start of week */
year_t year = YEAR;
}
wattroff(win, rev);
+ /* Print all day events */
+ int allday = 0;
+ event = EVENTS;
+ add_days(&year, &month, &day, -7);
+ for (int d = 0; d < 7; d++) {
+ int n = 0;
+ while (event && before(&event->start, year, month, day, 24, 0)) {
+ if (!before(&event->end, year, month, day, 0, 1) &&
+ get_mins(&event->start, &event->end) > 23*60) {
+ int s = ROUND(d*hstep);
+ int w = ROUND((d+1)*hstep) - 1 - s;
+ event_line(win, event, y+n++, x+s, w, 0);
+ }
+ event = event->next;
+ if (n > allday)
+ allday = n;
+ }
+ add_days(&year,&month,&day,1);
+ }
+ if (allday && !COMPACT)
+ allday++;
+
/* Resize body */
- wshrink(times, y-!COMPACT);
- wshrink(body, y-!COMPACT);
+ wshrink(times, y+allday-!COMPACT);
+ wshrink(body, y+allday-!COMPACT);
+
/* Print times */
mvwprintw(times, !COMPACT, 0, "%02d:%02d", ((line/4)-1)%12+1, (line*15)%60);
for (int h = 0; h < 24; h++)
mvwprintw(times, !COMPACT+h*4-line, 0, "%02d:%02d", (h-1)%12+1, 0);
/* Print events */
- event_t *event = EVENTS;
+ event = EVENTS;
add_days(&year, &month, &day, -7);
for (int d = 0; d < 7; d++, add_days(&year,&month,&day,1))
for (int h = 0; h < 24; h++)
for (int m = 0; m < 60; m+=15)
while (event && before(&event->start,
year, month, day, h+(m+15)/60, (m+15)%60)) {
- if (!before(&event->start, year, month, day, h, m)) {
+ if (!before(&event->start, year, month, day, h, m) &&
+ get_mins(&event->start, &event->end) <= 23*60) {
int y = h*4 + m/15 - line + !COMPACT;
int x = ROUND(d*hstep) + 1;
int h = (get_mins(&event->start, &event->end)-1)/15+1;
/* Print header lines */
if (!COMPACT)
mvwhline(win, y-1, 0, ACS_HLINE, COLS);
+ if (!COMPACT && allday)
+ mvwhline(win, y-1+allday, 0, ACS_HLINE, COLS);
/* Print day lines */
for (int d = 0; d < 7; d++)
- mvwvline(body, !COMPACT, ROUND(d*hstep), ACS_VLINE, LINES-y-2+COMPACT);
+ mvwvline(body, !COMPACT, ROUND(d*hstep), ACS_VLINE, LINES-y-2+COMPACT-allday);
mvwvline_set(body, 0, l, WACS_T_VLINE, LINES-y-1+COMPACT);
mvwvline_set(body, 0, r, WACS_T_VLINE, LINES-y-1+COMPACT);
for (int h = (line+3)/4; h < 24; h++) {