More work on the weekly calendar view.
This commit is contained in:
parent
a90f680d70
commit
abc03bb86f
@ -1,3 +1,10 @@
|
||||
2009-10-08 Frederic Culot <frederic@culot.org>
|
||||
|
||||
* src/day.c (day_chk_busy_slices, fill_slices): new functions
|
||||
|
||||
* src/calendar.c (draw_weekly_view): draw slices indicating
|
||||
appointment times in the calendar weekly view
|
||||
|
||||
2009-08-25 Frederic Culot <frederic@culot.org>
|
||||
|
||||
* src/calendar.c (weeknum, ISO8601weeknum): new functions to print
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $calcurse: calendar.c,v 1.27 2009/08/25 14:51:41 culot Exp $ */
|
||||
/* $calcurse: calendar.c,v 1.28 2009/10/08 16:28:06 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -483,12 +483,15 @@ draw_weekly_view (window_t *cwin, date_t *current_day, unsigned sunday_first)
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
mvwprintw (cwin->p, 2, cwin->w - 9, "(# %02d)", weeknum);
|
||||
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
||||
|
||||
#define DAYSLICESNO 6
|
||||
|
||||
/* Now draw calendar view. */
|
||||
for (j = 0; j < WEEKINDAYS; j++)
|
||||
{
|
||||
date_t date;
|
||||
unsigned attr, item_this_day;
|
||||
int i, slices[DAYSLICESNO];
|
||||
|
||||
/* print the day names, with regards to the first day of the week */
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
@ -520,10 +523,25 @@ draw_weekly_view (window_t *cwin, date_t *current_day, unsigned sunday_first)
|
||||
mvwprintw (cwin->p, 4, 2 + 4 * j, "%02d", t.tm_mday);
|
||||
if (attr)
|
||||
custom_remove_attr (cwin->p, attr);
|
||||
|
||||
/* Draw slices indicating appointment times. */
|
||||
bzero (slices, DAYSLICESNO * sizeof *slices);
|
||||
if (day_chk_busy_slices (date, DAYSLICESNO, slices))
|
||||
{
|
||||
for (i = 0; i < DAYSLICESNO; i++)
|
||||
if (slices[i])
|
||||
{
|
||||
wattron (cwin->p, A_REVERSE);
|
||||
mvwprintw (cwin->p, 5 + i, 3 + 4 * j, " ");
|
||||
wattroff (cwin->p, A_REVERSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* get next day */
|
||||
(void)date_change (&t, 0, 1);
|
||||
}
|
||||
|
||||
#undef DAYSLICESNO
|
||||
}
|
||||
|
||||
/* Function used to display the calendar panel. */
|
||||
|
67
src/day.c
67
src/day.c
@ -1,4 +1,4 @@
|
||||
/* $calcurse: day.c,v 1.50 2009/07/12 16:22:00 culot Exp $ */
|
||||
/* $calcurse: day.c,v 1.51 2009/10/08 16:28:06 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -520,6 +520,71 @@ day_check_if_item (date_t day)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static unsigned
|
||||
fill_slices (int *slices, int slicesno, int first, int last)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (first < 0 || last < first)
|
||||
return 0;
|
||||
|
||||
if (last >= slicesno)
|
||||
last = slicesno - 1; /* Appointment spanning more than one day. */
|
||||
|
||||
for (i = first; i <= last; i++)
|
||||
slices[i] = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in the 'slices' vector given as an argument with 1 if there is an
|
||||
* appointment in the corresponding time slice, 0 otherwise.
|
||||
* A 24 hours day is divided into 'slicesno' number of time slices.
|
||||
*/
|
||||
unsigned
|
||||
day_chk_busy_slices (date_t day, int slicesno, int *slices)
|
||||
{
|
||||
recur_apoint_llist_node_t *ra;
|
||||
apoint_llist_node_t *a;
|
||||
int slicelen;
|
||||
const long date = date2sec (day, 0, 0);
|
||||
|
||||
slicelen = DAYINSEC / slicesno;
|
||||
|
||||
#define SLICENUM(tsec) ((tsec) / slicelen % slicesno)
|
||||
|
||||
pthread_mutex_lock (&(recur_alist_p->mutex));
|
||||
for (ra = recur_alist_p->root; ra != 0; ra = ra->next)
|
||||
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type,
|
||||
ra->rpt->freq, ra->rpt->until, date))
|
||||
{
|
||||
if (!fill_slices (slices, slicesno, SLICENUM (ra->start),
|
||||
SLICENUM (ra->start + ra->dur)))
|
||||
{
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
|
||||
pthread_mutex_lock (&(alist_p->mutex));
|
||||
for (a = alist_p->root; a != 0; a = a->next)
|
||||
if (apoint_inday (a, date))
|
||||
{
|
||||
if (!fill_slices (slices, slicesno, SLICENUM (a->start),
|
||||
SLICENUM (a->start + a->dur)))
|
||||
{
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
|
||||
#undef SLICENUM
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Request the user to enter a new time. */
|
||||
static char *
|
||||
day_edit_time (long time)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $calcurse: day.h,v 1.24 2009/07/12 16:22:00 culot Exp $ */
|
||||
/* $calcurse: day.h,v 1.25 2009/10/08 16:28:06 culot Exp $ */
|
||||
|
||||
/*
|
||||
* Calcurse - text-based organizer
|
||||
@ -84,6 +84,7 @@ day_items_nb_t *day_process_storage (date_t *, unsigned, day_items_nb_t *);
|
||||
void day_write_pad (long, int, int, int);
|
||||
void day_popup_item (void);
|
||||
int day_check_if_item (date_t);
|
||||
unsigned day_chk_busy_slices (date_t, int, int *);
|
||||
void day_edit_item (conf_t *);
|
||||
int day_erase_item (long, int, erase_flag_e);
|
||||
int day_cut_item (long, int);
|
||||
|
Loading…
x
Reference in New Issue
Block a user