Overall indentation fixes.

Use spaces instead of tabs for source code indentation only, strip
trailing whitespaces from lines.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2011-03-14 19:00:08 +01:00
parent 55262a3074
commit 9c9fd5da15
19 changed files with 2259 additions and 2259 deletions

View File

@ -142,11 +142,11 @@ apoint_new (char *mesg, char *note, long start, long dur, char state)
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->start > start) if (*i == 0 || (*i)->start > start)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
break; break;
} }
i = &(*i)->next; i = &(*i)->next;
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
@ -154,7 +154,7 @@ apoint_new (char *mesg, char *note, long start, long dur, char state)
return (o); return (o);
} }
/* /*
* Add an item in either the appointment or the event list, * Add an item in either the appointment or the event list,
* depending if the start time is entered or not. * depending if the start time is entered or not.
*/ */
@ -186,61 +186,61 @@ apoint_add (void)
{ {
status_mesg (mesg_1, ""); status_mesg (mesg_1, "");
if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_ESC) if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_ESC)
{ {
if (strlen (item_time) == 0) if (strlen (item_time) == 0)
{ {
is_appointment = 0; is_appointment = 0;
break; break;
} }
else if (check_time (item_time) != 1) else if (check_time (item_time) != 1)
{ {
status_mesg (format_message_1, enter_str); status_mesg (format_message_1, enter_str);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
} }
else else
(void)sscanf (item_time, "%u:%u", &heures, &minutes); (void)sscanf (item_time, "%u:%u", &heures, &minutes);
} }
else else
return; return;
} }
/* /*
* Check if an event or appointment is entered, * Check if an event or appointment is entered,
* depending on the starting time, and record the * depending on the starting time, and record the
* corresponding item. * corresponding item.
*/ */
if (is_appointment) if (is_appointment)
{ /* Get the appointment duration */ { /* Get the appointment duration */
item_time[0] = '\0'; item_time[0] = '\0';
while (check_time (item_time) == 0) while (check_time (item_time) == 0)
{ {
status_mesg (mesg_2, ""); status_mesg (mesg_2, "");
if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_VALID) if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_VALID)
return; //nothing entered, cancel adding of event return; //nothing entered, cancel adding of event
else if (check_time (item_time) == 0) else if (check_time (item_time) == 0)
{ {
status_mesg (format_message_2, enter_str); status_mesg (format_message_2, enter_str);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
} }
else else
{ {
if (check_time (item_time) == 2) if (check_time (item_time) == 2)
apoint_duration = atoi (item_time); apoint_duration = atoi (item_time);
else if (check_time (item_time) == 1) else if (check_time (item_time) == 1)
{ {
(void)sscanf (item_time, "%u:%u", &end_h, &end_m); (void)sscanf (item_time, "%u:%u", &end_h, &end_m);
if (end_h < heures || ((end_h == heures) && (end_m < minutes))) if (end_h < heures || ((end_h == heures) && (end_m < minutes)))
{ {
apoint_duration = MININSEC - minutes + end_m apoint_duration = MININSEC - minutes + end_m
+ (24 + end_h - (heures + 1)) * MININSEC; + (24 + end_h - (heures + 1)) * MININSEC;
} }
else else
{ {
apoint_duration = MININSEC - minutes apoint_duration = MININSEC - minutes
+ end_m + (end_h - (heures + 1)) * MININSEC; + end_m + (end_h - (heures + 1)) * MININSEC;
} }
} }
} }
} }
} }
else /* Insert the event Id */ else /* Insert the event Id */
Id = 1; Id = 1;
@ -249,19 +249,19 @@ apoint_add (void)
if (getstring (win[STA].p, item_mesg, BUFSIZ, 0, 1) == GETSTRING_VALID) if (getstring (win[STA].p, item_mesg, BUFSIZ, 0, 1) == GETSTRING_VALID)
{ {
if (is_appointment) if (is_appointment)
{ {
apoint_start = date2sec (*calendar_get_slctd_day (), heures, minutes); apoint_start = date2sec (*calendar_get_slctd_day (), heures, minutes);
(void)apoint_new (item_mesg, 0L, apoint_start, (void)apoint_new (item_mesg, 0L, apoint_start,
min2sec (apoint_duration), 0L); min2sec (apoint_duration), 0L);
if (notify_bar ()) if (notify_bar ())
notify_check_added (item_mesg, apoint_start, 0L); notify_check_added (item_mesg, apoint_start, 0L);
} }
else else
(void)event_new (item_mesg, 0L, (void)event_new (item_mesg, 0L,
date2sec (*calendar_get_slctd_day (), 12, 0), Id); date2sec (*calendar_get_slctd_day (), 12, 0), Id);
if (hilt == 0) if (hilt == 0)
hilt++; hilt++;
} }
wins_erase_status_bar (); wins_erase_status_bar ();
} }
@ -286,12 +286,12 @@ apoint_delete (struct conf *conf, unsigned *nb_events, unsigned *nb_apoints)
status_mesg (del_app_str, choices); status_mesg (del_app_str, choices);
answer = wgetch (win[STA].p); answer = wgetch (win[STA].p);
if ((answer == 'y') && (nb_items != 0)) if ((answer == 'y') && (nb_items != 0))
go_for_deletion = 1; go_for_deletion = 1;
else else
{ {
wins_erase_status_bar (); wins_erase_status_bar ();
return; return;
} }
} }
else if (nb_items != 0) else if (nb_items != 0)
go_for_deletion = 1; go_for_deletion = 1;
@ -299,31 +299,31 @@ apoint_delete (struct conf *conf, unsigned *nb_events, unsigned *nb_apoints)
if (go_for_deletion) if (go_for_deletion)
{ {
if (nb_items != 0) if (nb_items != 0)
{ {
deleted_item_type = day_erase_item (date, hilt, ERASE_DONT_FORCE); deleted_item_type = day_erase_item (date, hilt, ERASE_DONT_FORCE);
if (deleted_item_type == EVNT || deleted_item_type == RECUR_EVNT) if (deleted_item_type == EVNT || deleted_item_type == RECUR_EVNT)
{ {
(*nb_events)--; (*nb_events)--;
to_be_removed = 1; to_be_removed = 1;
} }
else if (deleted_item_type == APPT || deleted_item_type == RECUR_APPT) else if (deleted_item_type == APPT || deleted_item_type == RECUR_APPT)
{ {
(*nb_apoints)--; (*nb_apoints)--;
to_be_removed = 3; to_be_removed = 3;
} }
else if (deleted_item_type == 0) else if (deleted_item_type == 0)
return; return;
else else
EXIT (_("no such type")); EXIT (_("no such type"));
/* NOTREACHED */ /* NOTREACHED */
if (hilt > 1) if (hilt > 1)
hilt--; hilt--;
if (apad.first_onscreen >= to_be_removed) if (apad.first_onscreen >= to_be_removed)
apad.first_onscreen = apad.first_onscreen - to_be_removed; apad.first_onscreen = apad.first_onscreen - to_be_removed;
if (nb_items == 1) if (nb_items == 1)
hilt = 0; hilt = 0;
} }
} }
} }
@ -332,7 +332,7 @@ int
apoint_cut (unsigned *nb_events, unsigned *nb_apoints) apoint_cut (unsigned *nb_events, unsigned *nb_apoints)
{ {
const int NBITEMS = *nb_apoints + *nb_events; const int NBITEMS = *nb_apoints + *nb_events;
int item_type, to_be_removed; int item_type, to_be_removed;
long date; long date;
if (NBITEMS == 0) if (NBITEMS == 0)
@ -354,7 +354,7 @@ apoint_cut (unsigned *nb_events, unsigned *nb_apoints)
else else
EXIT (_("no such type")); EXIT (_("no such type"));
/* NOTREACHED */ /* NOTREACHED */
if (hilt > 1) if (hilt > 1)
hilt--; hilt--;
if (apad.first_onscreen >= to_be_removed) if (apad.first_onscreen >= to_be_removed)
@ -380,7 +380,7 @@ apoint_paste (unsigned *nb_events, unsigned *nb_apoints, int cut_item_type)
(*nb_apoints)++; (*nb_apoints)++;
else else
return; return;
if (hilt == 0) if (hilt == 0)
hilt++; hilt++;
} }
@ -488,15 +488,15 @@ apoint_get (long day, int pos)
for (o = alist_p->root; o; o = o->next) for (o = alist_p->root; o; o = o->next)
{ {
if (apoint_inday (o, day)) if (apoint_inday (o, day))
{ {
if (n == pos) if (n == pos)
return (o); return (o);
n++; n++;
} }
} }
EXIT (_("item not found")); EXIT (_("item not found"));
return 0; return 0;
/* NOTREACHED */ /* NOTREACHED */
} }
void void
@ -512,9 +512,9 @@ apoint_delete_bynum (long start, unsigned num, enum eraseflg flag)
for (i = alist_p->root; i != 0; i = i->next) for (i = alist_p->root; i != 0; i = i->next)
{ {
if (apoint_inday (i, start)) if (apoint_inday (i, start))
{ {
if (n == num) if (n == num)
{ {
switch (flag) switch (flag)
{ {
case ERASE_FORCE_ONLY_NOTE: case ERASE_FORCE_ONLY_NOTE:
@ -527,25 +527,25 @@ apoint_delete_bynum (long start, unsigned num, enum eraseflg flag)
erase_note (&i->note, ERASE_FORCE_KEEP_NOTE); erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
if (notify_bar ()) if (notify_bar ())
need_check_notify = notify_same_item (i->start); need_check_notify = notify_same_item (i->start);
*iptr = i->next; *iptr = i->next;
mem_free (i->mesg); mem_free (i->mesg);
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT) if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
erase_note (&i->note, flag); erase_note (&i->note, flag);
mem_free (i); mem_free (i);
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
if (need_check_notify) if (need_check_notify)
notify_check_next_app (); notify_check_next_app ();
break; break;
} }
return; return;
} }
n++; n++;
} }
iptr = &i->next; iptr = &i->next;
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
EXIT (_("no such appointment")); EXIT (_("no such appointment"));
/* NOTREACHED */ /* NOTREACHED */
@ -553,7 +553,7 @@ apoint_delete_bynum (long start, unsigned num, enum eraseflg flag)
/* /*
* Return the line number of an item (either an appointment or an event) in * Return the line number of an item (either an appointment or an event) in
* the appointment panel. This is to help the appointment scroll function * the appointment panel. This is to help the appointment scroll function
* to place beggining of the pad correctly. * to place beggining of the pad correctly.
*/ */
static int static int
@ -570,9 +570,9 @@ get_item_line (int item_nb, int nb_events_inday)
return line; return line;
} }
/* /*
* Update (if necessary) the first displayed pad line to make the * Update (if necessary) the first displayed pad line to make the
* appointment panel scroll down next time pnoutrefresh is called. * appointment panel scroll down next time pnoutrefresh is called.
*/ */
void void
apoint_scroll_pad_down (int nb_events_inday, int win_length) apoint_scroll_pad_down (int nb_events_inday, int win_length)
@ -592,9 +592,9 @@ apoint_scroll_pad_down (int nb_events_inday, int win_length)
apad.first_onscreen = item_last_line - awin_length; apad.first_onscreen = item_last_line - awin_length;
} }
/* /*
* Update (if necessary) the first displayed pad line to make the * Update (if necessary) the first displayed pad line to make the
* appointment panel scroll up next time pnoutrefresh is called. * appointment panel scroll up next time pnoutrefresh is called.
*/ */
void void
apoint_scroll_pad_up (int nb_events_inday) apoint_scroll_pad_up (int nb_events_inday)
@ -619,29 +619,29 @@ apoint_check_next (struct notify_app *app, long start)
for (i = alist_p->root; i != 0; i = i->next) for (i = alist_p->root; i != 0; i = i->next)
{ {
if (i->start > app->time) if (i->start > app->time)
{ {
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
return (app); return (app);
} }
else else
{ {
if (i->start > start) if (i->start > start)
{ {
app->time = i->start; app->time = i->start;
app->txt = mem_strdup (i->mesg); app->txt = mem_strdup (i->mesg);
app->state = i->state; app->state = i->state;
app->got_app = 1; app->got_app = 1;
} }
} }
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
return (app); return (app);
} }
/* /*
* Returns a structure of type struct apoint_list given a structure of type * Returns a structure of type struct apoint_list given a structure of type
* recur_apoint_s * recur_apoint_s
*/ */
struct apoint * struct apoint *
apoint_recur_s2apoint_s (struct recur_apoint *p) apoint_recur_s2apoint_s (struct recur_apoint *p)
@ -687,27 +687,27 @@ apoint_switch_notify (void)
for (apoint = alist_p->root; apoint != 0; apoint = apoint->next) for (apoint = alist_p->root; apoint != 0; apoint = apoint->next)
{ {
if (apoint_inday (apoint, date)) if (apoint_inday (apoint, date))
{ {
if (n == apoint_nb) if (n == apoint_nb)
{ {
apoint->state ^= APOINT_NOTIFY; apoint->state ^= APOINT_NOTIFY;
if (notify_bar ()) if (notify_bar ())
{ {
notify_check_added (apoint->mesg, apoint->start, notify_check_added (apoint->mesg, apoint->start,
apoint->state); apoint->state);
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
if (need_chk_notify) if (need_chk_notify)
notify_check_next_app (); notify_check_next_app ();
return; return;
} }
n++; n++;
} }
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
EXIT (_("no such appointment")); EXIT (_("no such appointment"));
/* NOTREACHED */ /* NOTREACHED */
} }
/* Updates the Appointment panel */ /* Updates the Appointment panel */
@ -735,8 +735,8 @@ apoint_update_panel (int which_pan)
win[APP].h - 2); win[APP].h - 2);
custom_apply_attr (win[APP].p, ATTR_HIGHEST); custom_apply_attr (win[APP].p, ATTR_HIGHEST);
mvwprintw (win[APP].p, title_lines, title_xpos, "%s %s %d, %d", mvwprintw (win[APP].p, title_lines, title_xpos, "%s %s %d, %d",
calendar_get_pom (date), _(monthnames[slctd_date.mm - 1]), calendar_get_pom (date), _(monthnames[slctd_date.mm - 1]),
slctd_date.dd, slctd_date.yyyy); slctd_date.dd, slctd_date.yyyy);
custom_remove_attr (win[APP].p, ATTR_HIGHEST); custom_remove_attr (win[APP].p, ATTR_HIGHEST);
/* Draw the scrollbar if necessary. */ /* Draw the scrollbar if necessary. */
@ -749,16 +749,16 @@ apoint_update_panel (int which_pan)
int sbar_top = highend + title_lines + 1; int sbar_top = highend + title_lines + 1;
if ((sbar_top + sbar_length) > win[APP].h - 1) if ((sbar_top + sbar_length) > win[APP].h - 1)
sbar_length = win[APP].h - 1 - sbar_top; sbar_length = win[APP].h - 1 - sbar_top;
draw_scrollbar (win[APP].p, sbar_top, win[APP].w - 2, sbar_length, draw_scrollbar (win[APP].p, sbar_top, win[APP].w - 2, sbar_length,
title_lines + 1, win[APP].h - 1, hilt_bar); title_lines + 1, win[APP].h - 1, hilt_bar);
} }
wnoutrefresh (win[APP].p); wnoutrefresh (win[APP].p);
pnoutrefresh (apad.ptrwin, apad.first_onscreen, 0, pnoutrefresh (apad.ptrwin, apad.first_onscreen, 0,
win[APP].y + title_lines + 1, win[APP].x + bordr, win[APP].y + title_lines + 1, win[APP].x + bordr,
win[APP].y + win[APP].h - 2 * bordr, win[APP].y + win[APP].h - 2 * bordr,
win[APP].x + win[APP].w - 3 * bordr); win[APP].x + win[APP].w - 3 * bordr);
} }
void void

View File

@ -45,7 +45,7 @@
#include "calcurse.h" #include "calcurse.h"
/* /*
* Print Calcurse usage and exit. * Print Calcurse usage and exit.
*/ */
static void static void
@ -74,7 +74,7 @@ version_arg ()
char vtitle[BUFSIZ]; char vtitle[BUFSIZ];
char *vtext = char *vtext =
_("\nCopyright (c) 2004-2010 Frederic Culot.\n" _("\nCopyright (c) 2004-2010 Frederic Culot.\n"
"This is free software; see the source for copying conditions.\n"); "This is free software; see the source for copying conditions.\n");
(void)snprintf (vtitle, BUFSIZ, _("Calcurse %s - text-based organizer\n"), (void)snprintf (vtitle, BUFSIZ, _("Calcurse %s - text-based organizer\n"),
VERSION); VERSION);
@ -82,7 +82,7 @@ version_arg ()
fputs (vtext, stdout); fputs (vtext, stdout);
} }
/* /*
* Print the command line options and exit. * Print the command line options and exit.
*/ */
static void static void
@ -168,7 +168,7 @@ static void
status_arg (void) status_arg (void)
{ {
int cpid, dpid; int cpid, dpid;
cpid = io_get_pid (path_cpid); cpid = io_get_pid (path_cpid);
dpid = io_get_pid (path_dpid); dpid = io_get_pid (path_dpid);
@ -191,7 +191,7 @@ status_arg (void)
* (to be used together with the '-a' or '-t' flag in non-interactive mode). * (to be used together with the '-a' or '-t' flag in non-interactive mode).
* Each line begins with nbtab tabs. * Each line begins with nbtab tabs.
* Print "No note file found", if the notefile does not exists. * Print "No note file found", if the notefile does not exists.
* *
* (patch submitted by Erik Saule). * (patch submitted by Erik Saule).
*/ */
static void static void
@ -212,16 +212,16 @@ print_notefile (FILE *out, char *filename, int nbtab)
if (notefile) if (notefile)
{ {
while (fgets (buffer, BUFSIZ, notefile) != 0) while (fgets (buffer, BUFSIZ, notefile) != 0)
{ {
if (printlinestarter) if (printlinestarter)
{ {
fputs (linestarter, out); fputs (linestarter, out);
printlinestarter = 0; printlinestarter = 0;
} }
fputs (buffer, out); fputs (buffer, out);
if (buffer[strlen (buffer) - 1] == '\n') if (buffer[strlen (buffer) - 1] == '\n')
printlinestarter = 1; printlinestarter = 1;
} }
fputs ("\n", out); fputs ("\n", out);
file_close (notefile, __FILE_POS__); file_close (notefile, __FILE_POS__);
} }
@ -266,12 +266,12 @@ todo_arg (int priority, int print_note, regex_t *regex)
if (print_note && i->note) \ if (print_note && i->note) \
print_notefile (stdout, i->note, 1); \ print_notefile (stdout, i->note, 1); \
} while (0) } while (0)
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != 0; i = i->next)
{ {
if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0) if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0)
continue; continue;
if (i->id < 0) /* completed task */ if (i->id < 0) /* completed task */
{ {
if (priority == 0) if (priority == 0)
@ -291,7 +291,7 @@ todo_arg (int priority, int print_note, regex_t *regex)
} }
#undef DISPLAY_TITLE #undef DISPLAY_TITLE
#undef DISPLAY_TODO #undef DISPLAY_TODO
} }
/* Print the next appointment within the upcoming 24 hours. */ /* Print the next appointment within the upcoming 24 hours. */
@ -323,7 +323,7 @@ next_arg (void)
} }
} }
/* /*
* Print the date on stdout. * Print the date on stdout.
*/ */
static void static void
@ -365,62 +365,62 @@ app_arg (int add_line, struct date *day, long date, int print_note,
else else
today = date; today = date;
/* /*
* Calculate and print the selected date if there is an event for * Calculate and print the selected date if there is an event for
* that date and it is the first one, and then print all the events for * that date and it is the first one, and then print all the events for
* that date. * that date.
*/ */
for (re = recur_elist; re != 0; re = re->next) for (re = recur_elist; re != 0; re = re->next)
{ {
if (recur_item_inday (re->day, re->exc, re->rpt->type, re->rpt->freq, if (recur_item_inday (re->day, re->exc, re->rpt->type, re->rpt->freq,
re->rpt->until, today)) re->rpt->until, today))
{ {
if (regex && regexec (regex, re->mesg, 0, 0, 0) != 0) if (regex && regexec (regex, re->mesg, 0, 0, 0) != 0)
continue; continue;
app_found = 1; app_found = 1;
if (add_line) if (add_line)
{ {
fputs ("\n", stdout); fputs ("\n", stdout);
add_line = 0; add_line = 0;
} }
if (print_date) if (print_date)
{ {
arg_print_date (today, conf); arg_print_date (today, conf);
print_date = 0; print_date = 0;
} }
fputs (" * ", stdout); fputs (" * ", stdout);
fputs (re->mesg, stdout); fputs (re->mesg, stdout);
fputs ("\n", stdout); fputs ("\n", stdout);
if (print_note && re->note) if (print_note && re->note)
print_notefile (stdout, re->note, 2); print_notefile (stdout, re->note, 2);
} }
} }
for (j = eventlist; j != 0; j = j->next) for (j = eventlist; j != 0; j = j->next)
{ {
if (event_inday (j, today)) if (event_inday (j, today))
{ {
if (regex && regexec (regex, j->mesg, 0, 0, 0) != 0) if (regex && regexec (regex, j->mesg, 0, 0, 0) != 0)
continue; continue;
app_found = 1; app_found = 1;
if (add_line) if (add_line)
{ {
fputs ("\n", stdout); fputs ("\n", stdout);
add_line = 0; add_line = 0;
} }
if (print_date) if (print_date)
{ {
arg_print_date (today, conf); arg_print_date (today, conf);
print_date = 0; print_date = 0;
} }
fputs (" * ", stdout); fputs (" * ", stdout);
fputs (j->mesg, stdout); fputs (j->mesg, stdout);
fputs ("\n", stdout); fputs ("\n", stdout);
if (print_note && j->note) if (print_note && j->note)
print_notefile (stdout, j->note, 2); print_notefile (stdout, j->note, 2);
} }
} }
/* Same process is performed but this time on the appointments. */ /* Same process is performed but this time on the appointments. */
@ -429,38 +429,38 @@ app_arg (int add_line, struct date *day, long date, int print_note,
{ {
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type, ra->rpt->freq, if (recur_item_inday (ra->start, ra->exc, ra->rpt->type, ra->rpt->freq,
ra->rpt->until, today)) ra->rpt->until, today))
{ {
struct apoint *apt; struct apoint *apt;
if (regex && regexec (regex, ra->mesg, 0, 0, 0) != 0) if (regex && regexec (regex, ra->mesg, 0, 0, 0) != 0)
continue; continue;
app_found = 1; app_found = 1;
if (add_line) if (add_line)
{ {
fputs ("\n", stdout); fputs ("\n", stdout);
add_line = 0; add_line = 0;
} }
if (print_date) if (print_date)
{ {
arg_print_date (today, conf); arg_print_date (today, conf);
print_date = 0; print_date = 0;
} }
apt = apoint_recur_s2apoint_s (ra); apt = apoint_recur_s2apoint_s (ra);
apoint_sec2str (apt, RECUR_APPT, today, apoint_start_time, apoint_sec2str (apt, RECUR_APPT, today, apoint_start_time,
apoint_end_time); apoint_end_time);
mem_free (apt->mesg); mem_free (apt->mesg);
mem_free (apt); mem_free (apt);
fputs (" - ", stdout); fputs (" - ", stdout);
fputs (apoint_start_time, stdout); fputs (apoint_start_time, stdout);
fputs (" -> ", stdout); fputs (" -> ", stdout);
fputs (apoint_end_time, stdout); fputs (apoint_end_time, stdout);
fputs ("\n\t", stdout); fputs ("\n\t", stdout);
fputs (ra->mesg, stdout); fputs (ra->mesg, stdout);
fputs ("\n", stdout); fputs ("\n", stdout);
if (print_note && ra->note) if (print_note && ra->note)
print_notefile (stdout, ra->note, 2); print_notefile (stdout, ra->note, 2);
} }
} }
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
@ -468,32 +468,32 @@ app_arg (int add_line, struct date *day, long date, int print_note,
for (i = alist_p->root; i != 0; i = i->next) for (i = alist_p->root; i != 0; i = i->next)
{ {
if (apoint_inday (i, today)) if (apoint_inday (i, today))
{ {
if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0) if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0)
continue; continue;
app_found = 1; app_found = 1;
if (add_line) if (add_line)
{ {
fputs ("\n", stdout); fputs ("\n", stdout);
add_line = 0; add_line = 0;
} }
if (print_date) if (print_date)
{ {
arg_print_date (today, conf); arg_print_date (today, conf);
print_date = 0; print_date = 0;
} }
apoint_sec2str (i, APPT, today, apoint_start_time, apoint_end_time); apoint_sec2str (i, APPT, today, apoint_start_time, apoint_end_time);
fputs (" - ", stdout); fputs (" - ", stdout);
fputs (apoint_start_time, stdout); fputs (apoint_start_time, stdout);
fputs (" -> ", stdout); fputs (" -> ", stdout);
fputs (apoint_end_time, stdout); fputs (apoint_end_time, stdout);
fputs ("\n\t", stdout); fputs ("\n\t", stdout);
fputs (i->mesg, stdout); fputs (i->mesg, stdout);
fputs ("\n", stdout); fputs ("\n", stdout);
if (print_note && i->note) if (print_note && i->note)
print_notefile (stdout, i->note, 2); print_notefile (stdout, i->note, 2);
} }
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
@ -509,10 +509,10 @@ more_info (void)
"<misc@calcurse.org>.\n"), stdout); "<misc@calcurse.org>.\n"), stdout);
} }
/* /*
* For a given date, print appointments for each day * For a given date, print appointments for each day
* in the chosen interval. app_found and add_line are used * in the chosen interval. app_found and add_line are used
* to format the output correctly. * to format the output correctly.
*/ */
static void static void
display_app (struct tm *t, int numdays, int add_line, int print_note, display_app (struct tm *t, int numdays, int add_line, int print_note,
@ -549,25 +549,25 @@ date_arg (char *ddate, int add_line, int print_note, struct conf *conf,
static struct tm t; static struct tm t;
time_t timer; time_t timer;
/* /*
* Check (with the argument length) if a date or a number of days * Check (with the argument length) if a date or a number of days
* was entered, and then call app_arg() to print appointments * was entered, and then call app_arg() to print appointments
*/ */
arg_len = strlen (ddate); arg_len = strlen (ddate);
if (arg_len <= 4) if (arg_len <= 4)
{ /* a number of days was entered */ { /* a number of days was entered */
for (i = 0; i <= arg_len - 1; i++) for (i = 0; i <= arg_len - 1; i++)
{ {
if (isdigit (ddate[i])) if (isdigit (ddate[i]))
num_digit++; num_digit++;
} }
if (num_digit == arg_len) if (num_digit == arg_len)
numdays = atoi (ddate); numdays = atoi (ddate);
/* /*
* Get current date, and print appointments for each day * Get current date, and print appointments for each day
* in the chosen interval. app_found and add_line are used * in the chosen interval. app_found and add_line are used
* to format the output correctly. * to format the output correctly.
*/ */
timer = time (NULL); timer = time (NULL);
t = *localtime (&timer); t = *localtime (&timer);
@ -577,25 +577,25 @@ date_arg (char *ddate, int add_line, int print_note, struct conf *conf,
{ /* a date was entered */ { /* a date was entered */
if (parse_date (ddate, conf->input_datefmt, (int *)&day.yyyy, if (parse_date (ddate, conf->input_datefmt, (int *)&day.yyyy,
(int *)&day.mm, (int *)&day.dd, NULL)) (int *)&day.mm, (int *)&day.dd, NULL))
{ {
app_found = app_arg (add_line, &day, 0, print_note, conf, regex); app_found = app_arg (add_line, &day, 0, print_note, conf, regex);
} }
else else
{ {
char outstr[BUFSIZ]; char outstr[BUFSIZ];
fputs (_("Argument to the '-d' flag is not valid\n"), stderr); fputs (_("Argument to the '-d' flag is not valid\n"), stderr);
(void)snprintf (outstr, BUFSIZ, (void)snprintf (outstr, BUFSIZ,
"Possible argument format are: '%s' or 'n'\n", "Possible argument format are: '%s' or 'n'\n",
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf->input_datefmt));
fputs (_(outstr), stdout); fputs (_(outstr), stdout);
more_info (); more_info ();
} }
} }
} }
/* /*
* Print appointment from the given date 'startday' for the 'range' upcoming * Print appointment from the given date 'startday' for the 'range' upcoming
* days. * days.
* If no starday is given (NULL), today is considered * If no starday is given (NULL), today is considered
* If no range is given (NULL), 1 day is considered * If no range is given (NULL), 1 day is considered
* *
@ -609,35 +609,35 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
static struct tm t; static struct tm t;
time_t timer; time_t timer;
/* /*
* Check arguments and extract information * Check arguments and extract information
*/ */
if (range != NULL) if (range != NULL)
{ {
arg_len = strlen (range); arg_len = strlen (range);
for (i = 0; i <= arg_len - 1; i++) for (i = 0; i <= arg_len - 1; i++)
{ {
if (!isdigit (range[i])) if (!isdigit (range[i]))
error = 1; error = 1;
} }
if (!error) if (!error)
numdays = atoi (range); numdays = atoi (range);
} }
timer = time (NULL); timer = time (NULL);
t = *localtime (&timer); t = *localtime (&timer);
if (startday != NULL) if (startday != NULL)
{ {
if (parse_date (startday, conf->input_datefmt, (int *)&t.tm_year, if (parse_date (startday, conf->input_datefmt, (int *)&t.tm_year,
(int *)&t.tm_mon, (int *)&t.tm_mday, NULL)) (int *)&t.tm_mon, (int *)&t.tm_mday, NULL))
{ {
t.tm_year -= 1900; t.tm_year -= 1900;
t.tm_mon--; t.tm_mon--;
(void)mktime (&t); (void)mktime (&t);
} }
else else
{ {
error = 1; error = 1;
} }
} }
if (!error) if (!error)
{ {
@ -657,7 +657,7 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
} }
/* /*
* Parse the command-line arguments and call the appropriate * Parse the command-line arguments and call the appropriate
* routines to handle those arguments. Also initialize the data paths. * routines to handle those arguments. Also initialize the data paths.
*/ */
@ -681,7 +681,7 @@ parse_args (int argc, char **argv, struct conf *conf)
int tflag = 0; /* -t: print todo list */ int tflag = 0; /* -t: print todo list */
int vflag = 0; /* -v: print version number */ int vflag = 0; /* -v: print version number */
int xflag = 0; /* -x: export data */ int xflag = 0; /* -x: export data */
int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag = 0, load_data = 0; int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag = 0, load_data = 0;
char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL; char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL;
char *datadir = NULL, *ifile = NULL; char *datadir = NULL, *ifile = NULL;
@ -691,9 +691,9 @@ parse_args (int argc, char **argv, struct conf *conf)
int statusflag = 0; /* --status: get the status of running instances */ int statusflag = 0; /* --status: get the status of running instances */
enum enum
{ {
STATUS_OPT = CHAR_MAX + 1 STATUS_OPT = CHAR_MAX + 1
}; };
static char *optstr = "hvnNax::t::d:c:r::s::S:D:i:"; static char *optstr = "hvnNax::t::d:c:r::s::S:D:i:";
struct option longopts[] = { struct option longopts[] = {
@ -718,48 +718,48 @@ parse_args (int argc, char **argv, struct conf *conf)
while ((ch = getopt_long (argc, argv, optstr, longopts, NULL)) != -1) while ((ch = getopt_long (argc, argv, optstr, longopts, NULL)) != -1)
{ {
switch (ch) switch (ch)
{ {
case STATUS_OPT: case STATUS_OPT:
statusflag = 1; statusflag = 1;
break; break;
case 'a': case 'a':
aflag = 1; aflag = 1;
multiple_flag++; multiple_flag++;
load_data++; load_data++;
break; break;
case 'c': case 'c':
cflag = 1; cflag = 1;
multiple_flag++; multiple_flag++;
cfile = optarg; cfile = optarg;
load_data++; load_data++;
break; break;
case 'd': case 'd':
dflag = 1; dflag = 1;
multiple_flag++; multiple_flag++;
load_data++; load_data++;
ddate = optarg; ddate = optarg;
break; break;
case 'D': case 'D':
Dflag = 1; Dflag = 1;
datadir = optarg; datadir = optarg;
break; break;
case 'h': case 'h':
hflag = 1; hflag = 1;
break; break;
case 'i': case 'i':
iflag = 1; iflag = 1;
multiple_flag++; multiple_flag++;
load_data++; load_data++;
ifile = optarg; ifile = optarg;
break; break;
case 'n': case 'n':
nflag = 1; nflag = 1;
multiple_flag++; multiple_flag++;
load_data++; load_data++;
break; break;
case 'N': case 'N':
Nflag = 1; Nflag = 1;
break; break;
case 'r': case 'r':
rflag = 1; rflag = 1;
multiple_flag++; multiple_flag++;
@ -780,30 +780,30 @@ parse_args (int argc, char **argv, struct conf *conf)
EXIT (_("Could not compile regular expression.")); EXIT (_("Could not compile regular expression."));
preg = &reg; preg = &reg;
break; break;
case 't': case 't':
tflag = 1; tflag = 1;
multiple_flag++; multiple_flag++;
load_data++; load_data++;
add_line = 1; add_line = 1;
if (optarg != NULL) if (optarg != NULL)
{ {
tnum = atoi (optarg); tnum = atoi (optarg);
if (tnum < 0 || tnum > 9) if (tnum < 0 || tnum > 9)
{ {
usage (); usage ();
usage_try (); usage_try ();
return (EXIT_FAILURE); return (EXIT_FAILURE);
} }
} }
else else
tnum = -1; tnum = -1;
break; break;
case 'v': case 'v':
vflag = 1; vflag = 1;
break; break;
case 'x': case 'x':
xflag = 1; xflag = 1;
multiple_flag++; multiple_flag++;
load_data++; load_data++;
if (optarg != NULL) if (optarg != NULL)
{ {
@ -824,14 +824,14 @@ parse_args (int argc, char **argv, struct conf *conf)
{ {
xfmt = IO_EXPORT_ICAL; xfmt = IO_EXPORT_ICAL;
} }
break; break;
default: default:
usage (); usage ();
usage_try (); usage_try ();
unknown_flag = 1; unknown_flag = 1;
non_interactive = 1; non_interactive = 1;
/* NOTREACHED */ /* NOTREACHED */
} }
} }
argc -= optind; argc -= optind;
argv += optind; argv += optind;
@ -862,37 +862,37 @@ parse_args (int argc, char **argv, struct conf *conf)
else else
{ {
if (unknown_flag) if (unknown_flag)
{ {
non_interactive = 1; non_interactive = 1;
} }
else if (hflag) else if (hflag)
{ {
help_arg (); help_arg ();
non_interactive = 1; non_interactive = 1;
} }
else if (vflag) else if (vflag)
{ {
version_arg (); version_arg ();
non_interactive = 1; non_interactive = 1;
} }
else if (statusflag) else if (statusflag)
{ {
io_init (cfile, datadir); io_init (cfile, datadir);
status_arg (); status_arg ();
non_interactive = 1; non_interactive = 1;
} }
else if (multiple_flag) else if (multiple_flag)
{ {
if (load_data) if (load_data)
{ {
io_init (cfile, datadir); io_init (cfile, datadir);
io_check_dir (path_dir, (int *)0); io_check_dir (path_dir, (int *)0);
io_check_dir (path_notes, (int *)0); io_check_dir (path_notes, (int *)0);
} }
if (iflag) if (iflag)
{ {
io_check_file (path_apts, (int *)0); io_check_file (path_apts, (int *)0);
io_check_file (path_todo, (int *)0); io_check_file (path_todo, (int *)0);
io_load_app (); io_load_app ();
io_load_todo (); io_load_todo ();
io_import_data (IO_IMPORT_ICAL, conf, ifile); io_import_data (IO_IMPORT_ICAL, conf, ifile);
@ -900,34 +900,34 @@ parse_args (int argc, char **argv, struct conf *conf)
io_save_todo (); io_save_todo ();
non_interactive = 1; non_interactive = 1;
} }
if (xflag) if (xflag)
{ {
io_check_file (path_apts, (int *)0); io_check_file (path_apts, (int *)0);
io_check_file (path_todo, (int *)0); io_check_file (path_todo, (int *)0);
io_load_app (); io_load_app ();
io_load_todo (); io_load_todo ();
io_export_data (xfmt, conf); io_export_data (xfmt, conf);
non_interactive = 1; non_interactive = 1;
return non_interactive; return non_interactive;
} }
if (tflag) if (tflag)
{ {
io_check_file (path_todo, (int *)0); io_check_file (path_todo, (int *)0);
io_load_todo (); io_load_todo ();
todo_arg (tnum, Nflag, preg); todo_arg (tnum, Nflag, preg);
non_interactive = 1; non_interactive = 1;
} }
if (nflag) if (nflag)
{ {
io_check_file (path_apts, (int *)0);
io_load_app ();
next_arg ();
non_interactive = 1;
}
if (dflag || rflag || sflag)
{
io_check_file (path_apts, (int *)0); io_check_file (path_apts, (int *)0);
io_check_file (path_conf, (int *)0); io_load_app ();
next_arg ();
non_interactive = 1;
}
if (dflag || rflag || sflag)
{
io_check_file (path_apts, (int *)0);
io_check_file (path_conf, (int *)0);
io_load_app (); io_load_app ();
custom_load_conf (conf, 0); /* To get output date format. */ custom_load_conf (conf, 0); /* To get output date format. */
if (dflag) if (dflag)
@ -935,31 +935,31 @@ parse_args (int argc, char **argv, struct conf *conf)
if (rflag || sflag) if (rflag || sflag)
date_arg_extended (startday, range, add_line, Nflag, conf, date_arg_extended (startday, range, add_line, Nflag, conf,
preg); preg);
non_interactive = 1; non_interactive = 1;
} }
else if (aflag) else if (aflag)
{ {
struct date day; struct date day;
io_check_file (path_apts, (int *)0); io_check_file (path_apts, (int *)0);
io_check_file (path_conf, (int *)0); io_check_file (path_conf, (int *)0);
vars_init (conf); vars_init (conf);
custom_load_conf (conf, 0); /* To get output date format. */ custom_load_conf (conf, 0); /* To get output date format. */
io_load_app (); io_load_app ();
day.dd = day.mm = day.yyyy = 0; day.dd = day.mm = day.yyyy = 0;
app_found = app_arg (add_line, &day, 0, Nflag, conf, preg); app_found = app_arg (add_line, &day, 0, Nflag, conf, preg);
non_interactive = 1; non_interactive = 1;
} }
} }
else else
{ {
non_interactive = 0; non_interactive = 0;
io_init (cfile, datadir); io_init (cfile, datadir);
} }
} }
if (preg) if (preg)
regfree (preg); regfree (preg);
return non_interactive; return non_interactive;
} }

View File

@ -42,7 +42,7 @@
* Calcurse is a text-based personal organizer which helps keeping track * Calcurse is a text-based personal organizer which helps keeping track
* of events and everyday tasks. It contains a calendar, a 'todo' list, * of events and everyday tasks. It contains a calendar, a 'todo' list,
* and puts your appointments in order. The user interface is configurable, * and puts your appointments in order. The user interface is configurable,
* and one can choose between different color schemes and layouts. * and one can choose between different color schemes and layouts.
* All of the commands are documented within an online help system. * All of the commands are documented within an online help system.
*/ */
int int
@ -61,7 +61,7 @@ main (int argc, char **argv)
unsigned day_changed = 0; unsigned day_changed = 0;
char *no_color_support = char *no_color_support =
_("Sorry, colors are not supported by your terminal\n" _("Sorry, colors are not supported by your terminal\n"
"(Press [ENTER] to continue)"); "(Press [ENTER] to continue)");
char *quit_message = _("Do you really want to quit ?"); char *quit_message = _("Do you really want to quit ?");
char choices[] = "[y/n] "; char choices[] = "[y/n] ";
@ -75,7 +75,7 @@ main (int argc, char **argv)
apoint_llist_init (); apoint_llist_init ();
recur_apoint_llist_init (); recur_apoint_llist_init ();
/* /*
* Begin by parsing and handling command line arguments. * Begin by parsing and handling command line arguments.
* The data path is also initialized here. * The data path is also initialized here.
*/ */
@ -88,7 +88,7 @@ main (int argc, char **argv)
dmon_stop (); dmon_stop ();
io_set_lock (); io_set_lock ();
} }
/* Begin of interactive mode with ncurses interface. */ /* Begin of interactive mode with ncurses interface. */
sigs_init (); /* signal handling init */ sigs_init (); /* signal handling init */
initscr (); /* start the curses mode */ initscr (); /* start the curses mode */
@ -109,10 +109,10 @@ main (int argc, char **argv)
#ifdef NCURSES_VERSION #ifdef NCURSES_VERSION
if (use_default_colors () != ERR) if (use_default_colors () != ERR)
{ {
background = -1; background = -1;
foreground = -1; foreground = -1;
} }
#endif /* NCURSES_VERSION */ #endif /* NCURSES_VERSION */
/* Color assignment */ /* Color assignment */
@ -139,7 +139,7 @@ main (int argc, char **argv)
notify_init_bar (); notify_init_bar ();
wins_reset_status_page (); wins_reset_status_page ();
/* /*
* Read the data from files : first the user * Read the data from files : first the user
* configuration (the display is then updated), and then * configuration (the display is then updated), and then
* the todo list, appointments and events. * the todo list, appointments and events.
@ -160,119 +160,119 @@ main (int argc, char **argv)
calendar_start_date_thread (); calendar_start_date_thread ();
if (conf.periodic_save > 0) if (conf.periodic_save > 0)
io_start_psave_thread (&conf); io_start_psave_thread (&conf);
/* User input */ /* User input */
for (;;) for (;;)
{ {
int key; int key;
do_update = 1; do_update = 1;
key = keys_getch (win[STA].p); key = keys_getch (win[STA].p);
switch (key) switch (key)
{ {
case ERR: case ERR:
do_update = 0; do_update = 0;
break; break;
case KEY_GENERIC_REDRAW: case KEY_GENERIC_REDRAW:
case KEY_RESIZE: case KEY_RESIZE:
do_update = 0; do_update = 0;
wins_reset (); wins_reset ();
break; break;
case KEY_GENERIC_CHANGE_VIEW: case KEY_GENERIC_CHANGE_VIEW:
wins_reset_status_page (); wins_reset_status_page ();
/* Need to save the previously highlighted event. */ /* Need to save the previously highlighted event. */
switch (wins_slctd ()) switch (wins_slctd ())
{ {
case TOD: case TOD:
sav_hilt_tod = todo_hilt (); sav_hilt_tod = todo_hilt ();
todo_hilt_set (0); todo_hilt_set (0);
break; break;
case APP: case APP:
sav_hilt_app = apoint_hilt (); sav_hilt_app = apoint_hilt ();
apoint_hilt_set (0); apoint_hilt_set (0);
break; break;
default: default:
break; break;
} }
wins_slctd_next (); wins_slctd_next ();
/* Select the event to highlight. */ /* Select the event to highlight. */
switch (wins_slctd ()) switch (wins_slctd ())
{ {
case TOD: case TOD:
if ((sav_hilt_tod == 0) && (todo_nb () != 0)) if ((sav_hilt_tod == 0) && (todo_nb () != 0))
todo_hilt_set (1); todo_hilt_set (1);
else else
todo_hilt_set (sav_hilt_tod); todo_hilt_set (sav_hilt_tod);
break; break;
case APP: case APP:
if ((sav_hilt_app == 0) if ((sav_hilt_app == 0)
&& ((inday.nb_events + inday.nb_apoints) != 0)) && ((inday.nb_events + inday.nb_apoints) != 0))
apoint_hilt_set (1); apoint_hilt_set (1);
else else
apoint_hilt_set (sav_hilt_app); apoint_hilt_set (sav_hilt_app);
break; break;
default: default:
break; break;
} }
break; break;
case KEY_GENERIC_OTHER_CMD: case KEY_GENERIC_OTHER_CMD:
wins_other_status_page (wins_slctd ()); wins_other_status_page (wins_slctd ());
break; break;
case KEY_GENERIC_GOTO: case KEY_GENERIC_GOTO:
case KEY_GENERIC_GOTO_TODAY: case KEY_GENERIC_GOTO_TODAY:
wins_erase_status_bar (); wins_erase_status_bar ();
calendar_set_current_date (); calendar_set_current_date ();
if (key == KEY_GENERIC_GOTO_TODAY) if (key == KEY_GENERIC_GOTO_TODAY)
calendar_goto_today (); calendar_goto_today ();
else else
calendar_change_day (conf.input_datefmt); calendar_change_day (conf.input_datefmt);
do_storage = 1; do_storage = 1;
day_changed = 1; day_changed = 1;
break; break;
case KEY_VIEW_ITEM: case KEY_VIEW_ITEM:
if ((wins_slctd () == APP) && (apoint_hilt () != 0)) if ((wins_slctd () == APP) && (apoint_hilt () != 0))
day_popup_item (); day_popup_item ();
else if ((wins_slctd () == TOD) && (todo_hilt () != 0)) else if ((wins_slctd () == TOD) && (todo_hilt () != 0))
item_in_popup (NULL, NULL, todo_saved_mesg (), _("To do :")); item_in_popup (NULL, NULL, todo_saved_mesg (), _("To do :"));
break; break;
case KEY_GENERIC_CONFIG_MENU: case KEY_GENERIC_CONFIG_MENU:
wins_erase_status_bar (); wins_erase_status_bar ();
custom_config_bar (); custom_config_bar ();
while ((key = wgetch (win[STA].p)) != 'q') while ((key = wgetch (win[STA].p)) != 'q')
{ {
switch (key) switch (key)
{ {
case 'C': case 'C':
case 'c': case 'c':
if (has_colors ()) if (has_colors ())
custom_color_config (); custom_color_config ();
else else
{ {
colorize = 0; colorize = 0;
wins_erase_status_bar (); wins_erase_status_bar ();
mvwprintw (win[STA].p, 0, 0, _(no_color_support)); mvwprintw (win[STA].p, 0, 0, _(no_color_support));
wgetch (win[STA].p); wgetch (win[STA].p);
} }
break; break;
case 'L': case 'L':
case 'l': case 'l':
custom_layout_config (); custom_layout_config ();
break; break;
case 'G': case 'G':
case 'g': case 'g':
custom_general_config (&conf); custom_general_config (&conf);
break; break;
case 'N': case 'N':
case 'n': case 'n':
notify_config_bar (); notify_config_bar ();
break; break;
case 'K': case 'K':
case 'k': case 'k':
custom_keys_config (); custom_keys_config ();
@ -281,59 +281,59 @@ main (int argc, char **argv)
case 'S': case 'S':
custom_sidebar_config (); custom_sidebar_config ();
break; break;
} }
wins_reset (); wins_reset ();
wins_update (); wins_update ();
do_storage = 1; do_storage = 1;
wins_erase_status_bar (); wins_erase_status_bar ();
custom_config_bar (); custom_config_bar ();
} }
wins_update (); wins_update ();
break; break;
case KEY_GENERIC_ADD_APPT: case KEY_GENERIC_ADD_APPT:
apoint_add (); apoint_add ();
do_storage = 1; do_storage = 1;
break; break;
case KEY_GENERIC_ADD_TODO: case KEY_GENERIC_ADD_TODO:
todo_new_item (); todo_new_item ();
if (todo_hilt () == 0 && todo_nb () == 1) if (todo_hilt () == 0 && todo_nb () == 1)
todo_hilt_increase (); todo_hilt_increase ();
break; break;
case KEY_ADD_ITEM: case KEY_ADD_ITEM:
switch (wins_slctd ()) switch (wins_slctd ())
{ {
case APP: case APP:
apoint_add (); apoint_add ();
do_storage = 1; do_storage = 1;
break; break;
case TOD: case TOD:
todo_new_item (); todo_new_item ();
if (todo_hilt () == 0 && todo_nb () == 1) if (todo_hilt () == 0 && todo_nb () == 1)
todo_hilt_increase (); todo_hilt_increase ();
break; break;
default: default:
break; break;
} }
break; break;
case KEY_EDIT_ITEM: case KEY_EDIT_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
day_edit_item (&conf); day_edit_item (&conf);
else if (wins_slctd () == TOD && todo_hilt () != 0) else if (wins_slctd () == TOD && todo_hilt () != 0)
todo_edit_item (); todo_edit_item ();
do_storage = 1; do_storage = 1;
break; break;
case KEY_DEL_ITEM: case KEY_DEL_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
apoint_delete (&conf, &inday.nb_events, &inday.nb_apoints); apoint_delete (&conf, &inday.nb_events, &inday.nb_apoints);
else if (wins_slctd () == TOD && todo_hilt () != 0) else if (wins_slctd () == TOD && todo_hilt () != 0)
todo_delete (&conf); todo_delete (&conf);
do_storage = 1; do_storage = 1;
break; break;
case KEY_GENERIC_CUT: case KEY_GENERIC_CUT:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
@ -351,116 +351,116 @@ main (int argc, char **argv)
do_storage = 1; do_storage = 1;
} }
break; break;
case KEY_REPEAT_ITEM: case KEY_REPEAT_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
recur_repeat_item (&conf); recur_repeat_item (&conf);
do_storage = 1; do_storage = 1;
break; break;
case KEY_FLAG_ITEM: case KEY_FLAG_ITEM:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
apoint_switch_notify (); apoint_switch_notify ();
else if (wins_slctd () == TOD && todo_hilt () != 0) else if (wins_slctd () == TOD && todo_hilt () != 0)
todo_flag (); todo_flag ();
do_storage = 1; do_storage = 1;
break; break;
case KEY_RAISE_PRIORITY: case KEY_RAISE_PRIORITY:
case KEY_LOWER_PRIORITY: case KEY_LOWER_PRIORITY:
if (wins_slctd () == TOD && todo_hilt () != 0) if (wins_slctd () == TOD && todo_hilt () != 0)
{ {
todo_chg_priority (key); todo_chg_priority (key);
if (todo_hilt_pos () < 0) if (todo_hilt_pos () < 0)
todo_set_first (todo_hilt ()); todo_set_first (todo_hilt ());
else if (todo_hilt_pos () >= win[TOD].h - 4) else if (todo_hilt_pos () >= win[TOD].h - 4)
todo_set_first (todo_hilt () - win[TOD].h + 5); todo_set_first (todo_hilt () - win[TOD].h + 5);
} }
break; break;
case KEY_EDIT_NOTE: case KEY_EDIT_NOTE:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
day_edit_note (conf.editor); day_edit_note (conf.editor);
else if (wins_slctd () == TOD && todo_hilt () != 0) else if (wins_slctd () == TOD && todo_hilt () != 0)
todo_edit_note (conf.editor); todo_edit_note (conf.editor);
do_storage = 1; do_storage = 1;
break; break;
case KEY_VIEW_NOTE: case KEY_VIEW_NOTE:
if (wins_slctd () == APP && apoint_hilt () != 0) if (wins_slctd () == APP && apoint_hilt () != 0)
day_view_note (conf.pager); day_view_note (conf.pager);
else if (wins_slctd () == TOD && todo_hilt () != 0) else if (wins_slctd () == TOD && todo_hilt () != 0)
todo_view_note (conf.pager); todo_view_note (conf.pager);
break; break;
case KEY_GENERIC_HELP: case KEY_GENERIC_HELP:
wins_status_bar (); wins_status_bar ();
help_screen (); help_screen ();
break; break;
case KEY_GENERIC_SAVE: case KEY_GENERIC_SAVE:
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR); io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
break; break;
case KEY_GENERIC_IMPORT: case KEY_GENERIC_IMPORT:
wins_erase_status_bar (); wins_erase_status_bar ();
io_import_data (IO_IMPORT_ICAL, &conf, NULL); io_import_data (IO_IMPORT_ICAL, &conf, NULL);
do_storage = 1; do_storage = 1;
break; break;
case KEY_GENERIC_EXPORT: case KEY_GENERIC_EXPORT:
wins_erase_status_bar (); wins_erase_status_bar ();
io_export_bar (); io_export_bar ();
while ((key = wgetch (win[STA].p)) != 'q') while ((key = wgetch (win[STA].p)) != 'q')
{ {
switch (key) switch (key)
{ {
case 'I': case 'I':
case 'i': case 'i':
io_export_data (IO_EXPORT_ICAL, &conf); io_export_data (IO_EXPORT_ICAL, &conf);
break; break;
case 'P': case 'P':
case 'p': case 'p':
io_export_data (IO_EXPORT_PCAL, &conf); io_export_data (IO_EXPORT_PCAL, &conf);
break; break;
} }
wins_reset (); wins_reset ();
wins_update (); wins_update ();
do_storage = 1; do_storage = 1;
wins_erase_status_bar (); wins_erase_status_bar ();
io_export_bar (); io_export_bar ();
} }
wins_update (); wins_update ();
break; break;
case KEY_GENERIC_NEXT_DAY: case KEY_GENERIC_NEXT_DAY:
case KEY_MOVE_RIGHT: case KEY_MOVE_RIGHT:
if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_DAY) if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_DAY)
{ {
do_storage = 1; do_storage = 1;
day_changed = 1; day_changed = 1;
calendar_move (RIGHT); calendar_move (RIGHT);
} }
break; break;
case KEY_GENERIC_PREV_DAY: case KEY_GENERIC_PREV_DAY:
case KEY_MOVE_LEFT: case KEY_MOVE_LEFT:
if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_DAY) if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_DAY)
{ {
do_storage = 1; do_storage = 1;
day_changed = 1; day_changed = 1;
calendar_move (LEFT); calendar_move (LEFT);
} }
break; break;
case KEY_GENERIC_PREV_WEEK: case KEY_GENERIC_PREV_WEEK:
case KEY_MOVE_UP: case KEY_MOVE_UP:
if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_WEEK) if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_WEEK)
{ {
do_storage = 1; do_storage = 1;
day_changed = 1; day_changed = 1;
calendar_move (UP); calendar_move (UP);
} }
else if ((wins_slctd () == APP) && (apoint_hilt () > 1)) else if ((wins_slctd () == APP) && (apoint_hilt () > 1))
{ {
apoint_hilt_decrease (); apoint_hilt_decrease ();
@ -476,12 +476,12 @@ main (int argc, char **argv)
case KEY_GENERIC_NEXT_WEEK: case KEY_GENERIC_NEXT_WEEK:
case KEY_MOVE_DOWN: case KEY_MOVE_DOWN:
if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_WEEK) if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_WEEK)
{ {
do_storage = 1; do_storage = 1;
day_changed = 1; day_changed = 1;
calendar_move (DOWN); calendar_move (DOWN);
} }
else if ((wins_slctd () == APP) && else if ((wins_slctd () == APP) &&
(apoint_hilt () < inday.nb_events + inday.nb_apoints)) (apoint_hilt () < inday.nb_events + inday.nb_apoints))
{ {
@ -498,20 +498,20 @@ main (int argc, char **argv)
case KEY_START_OF_WEEK: case KEY_START_OF_WEEK:
if (wins_slctd () == CAL) if (wins_slctd () == CAL)
{ {
do_storage = 1; do_storage = 1;
day_changed = 1; day_changed = 1;
calendar_move (WEEK_START); calendar_move (WEEK_START);
} }
break; break;
case KEY_END_OF_WEEK: case KEY_END_OF_WEEK:
if (wins_slctd () == CAL) if (wins_slctd () == CAL)
{ {
do_storage = 1; do_storage = 1;
day_changed = 1; day_changed = 1;
calendar_move (WEEK_END); calendar_move (WEEK_END);
} }
break; break;
case KEY_GENERIC_SCROLL_UP: case KEY_GENERIC_SCROLL_UP:
@ -523,47 +523,47 @@ main (int argc, char **argv)
if (wins_slctd () == CAL) if (wins_slctd () == CAL)
calendar_view_next (); calendar_view_next ();
break; break;
case KEY_GENERIC_QUIT:
if (conf.auto_save)
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
if (conf.confirm_quit) case KEY_GENERIC_QUIT:
{ if (conf.auto_save)
status_mesg (_(quit_message), choices); io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
key = wgetch (win[STA].p);
if (key == 'y')
exit_calcurse (EXIT_SUCCESS);
else
{
wins_erase_status_bar ();
break;
}
}
else
exit_calcurse (EXIT_SUCCESS);
break;
default: if (conf.confirm_quit)
do_update = 0; {
break; status_mesg (_(quit_message), choices);
} key = wgetch (win[STA].p);
if (key == 'y')
exit_calcurse (EXIT_SUCCESS);
else
{
wins_erase_status_bar ();
break;
}
}
else
exit_calcurse (EXIT_SUCCESS);
break;
default:
do_update = 0;
break;
}
if (do_storage) if (do_storage)
{ {
inday = *day_process_storage (calendar_get_slctd_day (), inday = *day_process_storage (calendar_get_slctd_day (),
day_changed, &inday); day_changed, &inday);
do_storage = !do_storage; do_storage = !do_storage;
if (day_changed) if (day_changed)
{ {
sav_hilt_app = 0; sav_hilt_app = 0;
day_changed = !day_changed; day_changed = !day_changed;
if ((wins_slctd () == APP) && if ((wins_slctd () == APP) &&
(inday.nb_events + inday.nb_apoints != 0)) (inday.nb_events + inday.nb_apoints != 0))
apoint_hilt_set (1); apoint_hilt_set (1);
} }
} }
if (do_update) if (do_update)
wins_update (); wins_update ();
} }
} }

View File

@ -270,7 +270,7 @@ ymd_to_scalar (unsigned year, unsigned month, unsigned day)
return (scalar); return (scalar);
} }
/* /*
* Used to change date by adding a certain amount of days or weeks. * Used to change date by adding a certain amount of days or weeks.
* Returns 0 on success, 1 otherwise. * Returns 0 on success, 1 otherwise.
*/ */
@ -328,7 +328,7 @@ draw_monthly_view (struct window *cwin, struct date *current_day,
custom_apply_attr (cwin->p, ATTR_HIGHEST); custom_apply_attr (cwin->p, ATTR_HIGHEST);
mvwprintw (cwin->p, ofs_y, mvwprintw (cwin->p, ofs_y,
(SBAR_WIDTH - (strlen (_(monthnames[mo - 1])) + 5)) / 2, (SBAR_WIDTH - (strlen (_(monthnames[mo - 1])) + 5)) / 2,
"%s %d", _(monthnames[mo - 1]), slctd_day.yyyy); "%s %d", _(monthnames[mo - 1]), slctd_day.yyyy);
custom_remove_attr (cwin->p, ATTR_HIGHEST); custom_remove_attr (cwin->p, ATTR_HIGHEST);
++ofs_y; ++ofs_y;
@ -337,7 +337,7 @@ draw_monthly_view (struct window *cwin, struct date *current_day,
for (j = 0; j < WEEKINDAYS; j++) for (j = 0; j < WEEKINDAYS; j++)
{ {
mvwprintw (cwin->p, ofs_y, ofs_x + 4 * j, "%s", mvwprintw (cwin->p, ofs_y, ofs_x + 4 * j, "%s",
_(daynames[1 + j - sunday_first])); _(daynames[1 + j - sunday_first]));
} }
custom_remove_attr (cwin->p, ATTR_HIGHEST); custom_remove_attr (cwin->p, ATTR_HIGHEST);
@ -354,42 +354,42 @@ draw_monthly_view (struct window *cwin, struct date *current_day,
/* Go to next line, the week is over. */ /* Go to next line, the week is over. */
if (!c_day_1 && 1 != c_day) if (!c_day_1 && 1 != c_day)
{ {
ofs_y++; ofs_y++;
ofs_x = OFFX - day_1_sav - 4 * c_day; ofs_x = OFFX - day_1_sav - 4 * c_day;
} }
/* This is today, so print it in yellow. */ /* This is today, so print it in yellow. */
if (c_day == current_day->dd if (c_day == current_day->dd
&& current_day->mm == slctd_day.mm && current_day->mm == slctd_day.mm
&& current_day->yyyy == slctd_day.yyyy && current_day->yyyy == slctd_day.yyyy
&& current_day->dd != slctd_day.dd) && current_day->dd != slctd_day.dd)
{ {
custom_apply_attr (cwin->p, ATTR_LOWEST); custom_apply_attr (cwin->p, ATTR_LOWEST);
mvwprintw (cwin->p, ofs_y + 1, mvwprintw (cwin->p, ofs_y + 1,
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day); ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
custom_remove_attr (cwin->p, ATTR_LOWEST); custom_remove_attr (cwin->p, ATTR_LOWEST);
} }
else if (c_day == slctd_day.dd) else if (c_day == slctd_day.dd)
{ {
/* This is the selected day, print it according to user's theme. */ /* This is the selected day, print it according to user's theme. */
custom_apply_attr (cwin->p, ATTR_HIGHEST); custom_apply_attr (cwin->p, ATTR_HIGHEST);
mvwprintw (cwin->p, ofs_y + 1, mvwprintw (cwin->p, ofs_y + 1,
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
c_day); c_day);
custom_remove_attr (cwin->p, ATTR_HIGHEST); custom_remove_attr (cwin->p, ATTR_HIGHEST);
} }
else if (item_this_day) else if (item_this_day)
{ {
custom_apply_attr (cwin->p, ATTR_LOW); custom_apply_attr (cwin->p, ATTR_LOW);
mvwprintw (cwin->p, ofs_y + 1, mvwprintw (cwin->p, ofs_y + 1,
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
c_day); c_day);
custom_remove_attr (cwin->p, ATTR_LOW); custom_remove_attr (cwin->p, ATTR_LOW);
} }
else else
/* otherwise, print normal days in black */ /* otherwise, print normal days in black */
mvwprintw (cwin->p, ofs_y + 1, mvwprintw (cwin->p, ofs_y + 1,
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
c_day); c_day);
} }
@ -411,7 +411,7 @@ weeknum (const struct tm *t, int firstweekday)
wnum = ((t->tm_yday + WEEKINDAYS - wday) / WEEKINDAYS); wnum = ((t->tm_yday + WEEKINDAYS - wday) / WEEKINDAYS);
if (wnum < 0) if (wnum < 0)
wnum = 0; wnum = 0;
return wnum; return wnum;
} }
@ -445,7 +445,7 @@ ISO8601weeknum (const struct tm *t)
{ {
/* Get week number of last week of last year. */ /* Get week number of last week of last year. */
struct tm dec31ly; /* 12/31 last year */ struct tm dec31ly; /* 12/31 last year */
dec31ly = *t; dec31ly = *t;
dec31ly.tm_year--; dec31ly.tm_year--;
dec31ly.tm_mon = 11; dec31ly.tm_mon = 11;
@ -477,21 +477,21 @@ static void
draw_weekly_view (struct window *cwin, struct date *current_day, draw_weekly_view (struct window *cwin, struct date *current_day,
unsigned sunday_first) unsigned sunday_first)
{ {
#define DAYSLICESNO 6 #define DAYSLICESNO 6
const int WCALWIDTH = 30; const int WCALWIDTH = 30;
const int OFFY = 2 + (CALHEIGHT - 9) / 2; const int OFFY = 2 + (CALHEIGHT - 9) / 2;
struct tm t; struct tm t;
int OFFX, j, c_wday, days_to_remove, weeknum; int OFFX, j, c_wday, days_to_remove, weeknum;
OFFX = (wins_sbar_width () - WCALWIDTH) / 2 + 1; OFFX = (wins_sbar_width () - WCALWIDTH) / 2 + 1;
/* Fill in a tm structure with the first day of the selected week. */ /* Fill in a tm structure with the first day of the selected week. */
c_wday = calendar_get_wday (&slctd_day); c_wday = calendar_get_wday (&slctd_day);
if (sunday_first) if (sunday_first)
days_to_remove = c_wday; days_to_remove = c_wday;
else else
days_to_remove = c_wday == 0 ? WEEKINDAYS - 1 : c_wday - 1; days_to_remove = c_wday == 0 ? WEEKINDAYS - 1 : c_wday - 1;
(void)memset (&t, 0, sizeof (struct tm)); (void)memset (&t, 0, sizeof (struct tm));
t.tm_mday = slctd_day.dd; t.tm_mday = slctd_day.dd;
t.tm_mon = slctd_day.mm - 1; t.tm_mon = slctd_day.mm - 1;
@ -501,21 +501,21 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
/* Print the week number. */ /* Print the week number. */
weeknum = ISO8601weeknum (&t); weeknum = ISO8601weeknum (&t);
custom_apply_attr (cwin->p, ATTR_HIGHEST); custom_apply_attr (cwin->p, ATTR_HIGHEST);
mvwprintw (cwin->p, 2, cwin->w - 9, "(# %02d)", weeknum); mvwprintw (cwin->p, 2, cwin->w - 9, "(# %02d)", weeknum);
custom_remove_attr (cwin->p, ATTR_HIGHEST); custom_remove_attr (cwin->p, ATTR_HIGHEST);
/* Now draw calendar view. */ /* Now draw calendar view. */
for (j = 0; j < WEEKINDAYS; j++) for (j = 0; j < WEEKINDAYS; j++)
{ {
struct date date; struct date date;
unsigned attr, item_this_day; unsigned attr, item_this_day;
int i, slices[DAYSLICESNO]; int i, slices[DAYSLICESNO];
/* print the day names, with regards to the first day of the week */ /* print the day names, with regards to the first day of the week */
custom_apply_attr (cwin->p, ATTR_HIGHEST); custom_apply_attr (cwin->p, ATTR_HIGHEST);
mvwprintw (cwin->p, OFFY, OFFX + 4 * j, "%s", mvwprintw (cwin->p, OFFY, OFFX + 4 * j, "%s",
_(daynames[1 + j - sunday_first])); _(daynames[1 + j - sunday_first]));
custom_remove_attr (cwin->p, ATTR_HIGHEST); custom_remove_attr (cwin->p, ATTR_HIGHEST);
/* Check if the day to be printed has an item or not. */ /* Check if the day to be printed has an item or not. */
@ -523,7 +523,7 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
date.mm = t.tm_mon + 1; date.mm = t.tm_mon + 1;
date.yyyy = t.tm_year + 1900; date.yyyy = t.tm_year + 1900;
item_this_day = day_check_if_item (date); item_this_day = day_check_if_item (date);
/* Print the day numbers with appropriate decoration. */ /* Print the day numbers with appropriate decoration. */
if (t.tm_mday == current_day->dd if (t.tm_mday == current_day->dd
&& current_day->mm == slctd_day.mm && current_day->mm == slctd_day.mm
@ -563,11 +563,11 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
mvwprintw (cwin->p, OFFY + 2 + i, OFFX + 2 + 4 * j, " "); mvwprintw (cwin->p, OFFY + 2 + i, OFFX + 2 + 4 * j, " ");
wattroff (cwin->p, A_REVERSE); wattroff (cwin->p, A_REVERSE);
if (highlight) if (highlight)
custom_remove_attr (cwin->p, attr); custom_remove_attr (cwin->p, attr);
} }
} }
} }
/* get next day */ /* get next day */
(void)date_change (&t, 0, 1); (void)date_change (&t, 0, 1);
} }
@ -579,7 +579,7 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
OFFX + WCALWIDTH - 3, ACS_S9, 1); OFFX + WCALWIDTH - 3, ACS_S9, 1);
custom_remove_attr (cwin->p, ATTR_HIGHEST); custom_remove_attr (cwin->p, ATTR_HIGHEST);
#undef DAYSLICESNO #undef DAYSLICESNO
} }
/* Function used to display the calendar panel. */ /* Function used to display the calendar panel. */
@ -611,7 +611,7 @@ calendar_goto_today (void)
slctd_day.yyyy = today.yyyy; slctd_day.yyyy = today.yyyy;
} }
/* /*
* Ask for a date to jump to, then check the correctness of that date * Ask for a date to jump to, then check the correctness of that date
* and jump to it. * and jump to it.
* If the entered date is empty, automatically jump to the current date. * If the entered date is empty, automatically jump to the current date.
@ -636,29 +636,29 @@ calendar_change_day (int datefmt)
(void)snprintf (outstr, BUFSIZ, request_date, DATEFMT_DESC (datefmt)); (void)snprintf (outstr, BUFSIZ, request_date, DATEFMT_DESC (datefmt));
status_mesg (_(outstr), ""); status_mesg (_(outstr), "");
if (getstring (win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC) if (getstring (win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC)
return; return;
else else
{ {
if (strlen (selected_day) == 0) if (strlen (selected_day) == 0)
{ {
wrong_day = 0; wrong_day = 0;
calendar_goto_today (); calendar_goto_today ();
} }
else if (parse_date (selected_day, datefmt, &dyear, &dmonth, &dday, else if (parse_date (selected_day, datefmt, &dyear, &dmonth, &dday,
calendar_get_slctd_day ())) calendar_get_slctd_day ()))
{ {
wrong_day = 0; wrong_day = 0;
/* go to chosen day */ /* go to chosen day */
slctd_day.dd = dday; slctd_day.dd = dday;
slctd_day.mm = dmonth; slctd_day.mm = dmonth;
slctd_day.yyyy = dyear; slctd_day.yyyy = dyear;
} }
if (wrong_day) if (wrong_day)
{ {
status_mesg (mesg_line1, mesg_line2); status_mesg (mesg_line1, mesg_line2);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
} }
} }
} }
return; return;
@ -681,25 +681,25 @@ calendar_move (enum move move)
case UP: case UP:
if ((slctd_day.dd <= 7) && (slctd_day.mm == 1) if ((slctd_day.dd <= 7) && (slctd_day.mm == 1)
&& (slctd_day.yyyy == 1902)) && (slctd_day.yyyy == 1902))
return; return;
ret = date_change (&t, 0, -WEEKINDAYS); ret = date_change (&t, 0, -WEEKINDAYS);
break; break;
case DOWN: case DOWN:
if ((slctd_day.dd > days[slctd_day.mm - 1] - 7) if ((slctd_day.dd > days[slctd_day.mm - 1] - 7)
&& (slctd_day.mm == 12) && (slctd_day.yyyy == 2037)) && (slctd_day.mm == 12) && (slctd_day.yyyy == 2037))
return; return;
ret = date_change (&t, 0, WEEKINDAYS); ret = date_change (&t, 0, WEEKINDAYS);
break; break;
case LEFT: case LEFT:
if ((slctd_day.dd == 1) && (slctd_day.mm == 1) if ((slctd_day.dd == 1) && (slctd_day.mm == 1)
&& (slctd_day.yyyy == 1902)) && (slctd_day.yyyy == 1902))
return; return;
ret = date_change (&t, 0, -1); ret = date_change (&t, 0, -1);
break; break;
case RIGHT: case RIGHT:
if ((slctd_day.dd == 31) && (slctd_day.mm == 12) if ((slctd_day.dd == 31) && (slctd_day.mm == 12)
&& (slctd_day.yyyy == 2037)) && (slctd_day.yyyy == 2037))
return; return;
ret = date_change (&t, 0, 1); ret = date_change (&t, 0, 1);
break; break;
case WEEK_START: case WEEK_START:
@ -771,7 +771,7 @@ calendar_end_of_year (void)
} }
/* /*
* The pom, potm, dotr, adj360 are used to compute the current * The pom, potm, dotr, adj360 are used to compute the current
* phase of the moon. * phase of the moon.
* The code is based on the OpenBSD version of pom(6). * The code is based on the OpenBSD version of pom(6).
* Below is reported the copyright notice. * Below is reported the copyright notice.
@ -891,7 +891,7 @@ pom (time_t tmpt)
pom = NO_POM; pom = NO_POM;
GMT = gmtime (&tmpt); GMT = gmtime (&tmpt);
days = (GMT->tm_yday + 1) + ((GMT->tm_hour + (GMT->tm_min / 60.0) + days = (GMT->tm_yday + 1) + ((GMT->tm_hour + (GMT->tm_min / 60.0) +
(GMT->tm_sec / 3600.0)) / 24.0); (GMT->tm_sec / 3600.0)) / 24.0);
for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt) for (cnt = EPOCH; cnt < GMT->tm_year; ++cnt)
days += isleap (cnt + TM_YEAR_BASE) ? 366 : 365; days += isleap (cnt + TM_YEAR_BASE) ? 366 : 365;
/* Selected time could be before EPOCH */ /* Selected time could be before EPOCH */

File diff suppressed because it is too large Load Diff

542
src/day.c
View File

@ -78,7 +78,7 @@ static struct day_item *
day_add_event (int type, char *mesg, char *note, long day, int id) day_add_event (int type, char *mesg, char *note, long day, int id)
{ {
struct day_item *o, **i; struct day_item *o, **i;
o = mem_malloc (sizeof (struct day_item)); o = mem_malloc (sizeof (struct day_item));
o->mesg = mesg; o->mesg = mesg;
o->note = note; o->note = note;
@ -91,11 +91,11 @@ day_add_event (int type, char *mesg, char *note, long day, int id)
for (;;) for (;;)
{ {
if (*i == 0) if (*i == 0)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
break; break;
} }
i = &(*i)->next; i = &(*i)->next;
} }
return (o); return (o);
@ -104,7 +104,7 @@ day_add_event (int type, char *mesg, char *note, long day, int id)
/* Add an appointment in the current day list. */ /* Add an appointment in the current day list. */
static struct day_item * static struct day_item *
day_add_apoint (int type, char *mesg, char *note, long start, long dur, day_add_apoint (int type, char *mesg, char *note, long start, long dur,
char state, int real_pos) char state, int real_pos)
{ {
struct day_item *o, **i; struct day_item *o, **i;
int insert_item = 0; int insert_item = 0;
@ -122,29 +122,29 @@ day_add_apoint (int type, char *mesg, char *note, long start, long dur,
for (;;) for (;;)
{ {
if (*i == 0) if (*i == 0)
{ {
insert_item = 1; insert_item = 1;
} }
else if (((*i)->start > start) && ((*i)->type > EVNT)) else if (((*i)->start > start) && ((*i)->type > EVNT))
{ {
insert_item = 1; insert_item = 1;
} }
if (insert_item) if (insert_item)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
break; break;
} }
i = &(*i)->next; i = &(*i)->next;
} }
return o; return o;
} }
/* /*
* Store the events for the selected day in structure pointed * Store the events for the selected day in structure pointed
* by day_items_ptr. This is done by copying the events * by day_items_ptr. This is done by copying the events
* from the general structure pointed by eventlist to the structure * from the general structure pointed by eventlist to the structure
* dedicated to the selected day. * dedicated to the selected day.
* Returns the number of events for the selected day. * Returns the number of events for the selected day.
*/ */
static int static int
@ -157,20 +157,20 @@ day_store_events (long date)
for (j = eventlist; j != 0; j = j->next) for (j = eventlist; j != 0; j = j->next)
{ {
if (event_inday (j, date)) if (event_inday (j, date))
{ {
e_nb++; e_nb++;
ptr = day_add_event (EVNT, j->mesg, j->note, j->day, j->id); ptr = day_add_event (EVNT, j->mesg, j->note, j->day, j->id);
} }
} }
return e_nb; return e_nb;
} }
/* /*
* Store the recurrent events for the selected day in structure pointed * Store the recurrent events for the selected day in structure pointed
* by day_items_ptr. This is done by copying the recurrent events * by day_items_ptr. This is done by copying the recurrent events
* from the general structure pointed by recur_elist to the structure * from the general structure pointed by recur_elist to the structure
* dedicated to the selected day. * dedicated to the selected day.
* Returns the number of recurrent events for the selected day. * Returns the number of recurrent events for the selected day.
*/ */
static int static int
@ -183,21 +183,21 @@ day_store_recur_events (long date)
for (j = recur_elist; j != 0; j = j->next) for (j = recur_elist; j != 0; j = j->next)
{ {
if (recur_item_inday (j->day, j->exc, j->rpt->type, j->rpt->freq, if (recur_item_inday (j->day, j->exc, j->rpt->type, j->rpt->freq,
j->rpt->until, date)) j->rpt->until, date))
{ {
e_nb++; e_nb++;
ptr = day_add_event (RECUR_EVNT, j->mesg, j->note, j->day, j->id); ptr = day_add_event (RECUR_EVNT, j->mesg, j->note, j->day, j->id);
} }
} }
return e_nb; return e_nb;
} }
/* /*
* Store the apoints for the selected day in structure pointed * Store the apoints for the selected day in structure pointed
* by day_items_ptr. This is done by copying the appointments * by day_items_ptr. This is done by copying the appointments
* from the general structure pointed by alist_p->root to the * from the general structure pointed by alist_p->root to the
* structure dedicated to the selected day. * structure dedicated to the selected day.
* Returns the number of appointments for the selected day. * Returns the number of appointments for the selected day.
*/ */
static int static int
@ -211,22 +211,22 @@ day_store_apoints (long date)
for (j = alist_p->root; j != 0; j = j->next) for (j = alist_p->root; j != 0; j = j->next)
{ {
if (apoint_inday (j, date)) if (apoint_inday (j, date))
{ {
a_nb++; a_nb++;
ptr = day_add_apoint (APPT, j->mesg, j->note, j->start, ptr = day_add_apoint (APPT, j->mesg, j->note, j->start,
j->dur, j->state, 0); j->dur, j->state, 0);
} }
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
return a_nb; return a_nb;
} }
/* /*
* Store the recurrent apoints for the selected day in structure pointed * Store the recurrent apoints for the selected day in structure pointed
* by day_items_ptr. This is done by copying the appointments * by day_items_ptr. This is done by copying the appointments
* from the general structure pointed by recur_alist_p->root to the * from the general structure pointed by recur_alist_p->root to the
* structure dedicated to the selected day. * structure dedicated to the selected day.
* Returns the number of recurrent appointments for the selected day. * Returns the number of recurrent appointments for the selected day.
*/ */
static int static int
@ -241,23 +241,23 @@ day_store_recur_apoints (long date)
for (j = recur_alist_p->root; j != 0; j = j->next) for (j = recur_alist_p->root; j != 0; j = j->next)
{ {
if ((real_start = recur_item_inday (j->start, j->exc, if ((real_start = recur_item_inday (j->start, j->exc,
j->rpt->type, j->rpt->freq, j->rpt->type, j->rpt->freq,
j->rpt->until, date))) j->rpt->until, date)))
{ {
a_nb++; a_nb++;
ptr = day_add_apoint (RECUR_APPT, j->mesg, j->note, ptr = day_add_apoint (RECUR_APPT, j->mesg, j->note,
real_start, j->dur, j->state, n); real_start, j->dur, j->state, n);
n++; n++;
} }
} }
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
return a_nb; return a_nb;
} }
/* /*
* Store all of the items to be displayed for the selected day. * Store all of the items to be displayed for the selected day.
* Items are of four types: recursive events, normal events, * Items are of four types: recursive events, normal events,
* recursive appointments and normal appointments. * recursive appointments and normal appointments.
* The items are stored in the linked list pointed by *day_items_ptr * The items are stored in the linked list pointed by *day_items_ptr
* and the length of the new pad to write is returned. * and the length of the new pad to write is returned.
@ -296,7 +296,7 @@ day_store_items (long date, unsigned *pnb_events, unsigned *pnb_apoints)
*/ */
struct day_items_nb * struct day_items_nb *
day_process_storage (struct date *slctd_date, unsigned day_changed, day_process_storage (struct date *slctd_date, unsigned day_changed,
struct day_items_nb *inday) struct day_items_nb *inday)
{ {
long date; long date;
struct date day; struct date day;
@ -324,8 +324,8 @@ day_process_storage (struct date *slctd_date, unsigned day_changed,
} }
/* /*
* Returns a structure of type apoint_llist_node_t given a structure of type * Returns a structure of type apoint_llist_node_t given a structure of type
* day_item_s * day_item_s
*/ */
static void static void
day_item_s2apoint_s (struct apoint *a, struct day_item *p) day_item_s2apoint_s (struct apoint *a, struct day_item *p)
@ -336,12 +336,12 @@ day_item_s2apoint_s (struct apoint *a, struct day_item *p)
a->mesg = p->mesg; a->mesg = p->mesg;
} }
/* /*
* Print an item date in the appointment panel. * Print an item date in the appointment panel.
*/ */
static void static void
display_item_date (int incolor, struct apoint *i, int type, long date, display_item_date (int incolor, struct apoint *i, int type, long date,
int y, int x) int y, int x)
{ {
WINDOW *win; WINDOW *win;
char a_st[100], a_end[100]; char a_st[100], a_end[100];
@ -366,12 +366,12 @@ display_item_date (int incolor, struct apoint *i, int type, long date,
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
} }
/* /*
* Print an item description in the corresponding panel window. * Print an item description in the corresponding panel window.
*/ */
static void static void
display_item (int incolor, char *msg, int recur, int note, int len, int y, display_item (int incolor, char *msg, int recur, int note, int len, int y,
int x) int x)
{ {
WINDOW *win; WINDOW *win;
int ch_recur, ch_note; int ch_recur, ch_note;
@ -394,7 +394,7 @@ display_item (int incolor, char *msg, int recur, int note, int len, int y,
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
} }
/* /*
* Write the appointments and events for the selected day in a pad. * Write the appointments and events for the selected day in a pad.
* An horizontal line is drawn between events and appointments, and the * An horizontal line is drawn between events and appointments, and the
* item selected by user is highlighted. This item is also saved inside * item selected by user is highlighted. This item is also saved inside
@ -416,49 +416,49 @@ day_write_pad (long date, int width, int length, int incolor)
for (p = day_items_ptr; p != 0; p = p->next) for (p = day_items_ptr; p != 0; p = p->next)
{ {
if (p->type == RECUR_EVNT || p->type == RECUR_APPT) if (p->type == RECUR_EVNT || p->type == RECUR_APPT)
recur = 1; recur = 1;
else else
recur = 0; recur = 0;
/* First print the events for current day. */ /* First print the events for current day. */
if (p->type < RECUR_APPT) if (p->type < RECUR_APPT)
{ {
item_number++; item_number++;
if (item_number - incolor == 0) if (item_number - incolor == 0)
{ {
day_saved_item.type = p->type; day_saved_item.type = p->type;
day_saved_item.mesg = p->mesg; day_saved_item.mesg = p->mesg;
} }
display_item (item_number - incolor, p->mesg, recur, display_item (item_number - incolor, p->mesg, recur,
(p->note != NULL) ? 1 : 0, width - 7, line, x_pos); (p->note != NULL) ? 1 : 0, width - 7, line, x_pos);
line++; line++;
draw_line = 1; draw_line = 1;
} }
else else
{ {
/* Draw a line between events and appointments. */ /* Draw a line between events and appointments. */
if (line > 0 && draw_line) if (line > 0 && draw_line)
{ {
wmove (apad.ptrwin, line, 0); wmove (apad.ptrwin, line, 0);
whline (apad.ptrwin, 0, width); whline (apad.ptrwin, 0, width);
draw_line = 0; draw_line = 0;
} }
/* Last print the appointments for current day. */ /* Last print the appointments for current day. */
item_number++; item_number++;
day_item_s2apoint_s (&a, p); day_item_s2apoint_s (&a, p);
if (item_number - incolor == 0) if (item_number - incolor == 0)
{ {
day_saved_item.type = p->type; day_saved_item.type = p->type;
day_saved_item.mesg = p->mesg; day_saved_item.mesg = p->mesg;
apoint_sec2str (&a, p->type, date, apoint_sec2str (&a, p->type, date,
day_saved_item.start, day_saved_item.end); day_saved_item.start, day_saved_item.end);
} }
display_item_date (item_number - incolor, &a, p->type, display_item_date (item_number - incolor, &a, p->type,
date, line + 1, x_pos); date, line + 1, x_pos);
display_item (item_number - incolor, p->mesg, 0, display_item (item_number - incolor, p->mesg, 0,
(p->note != NULL) ? 1 : 0, width - 7, line + 2, (p->note != NULL) ? 1 : 0, width - 7, line + 2,
x_pos); x_pos);
line += 3; line += 3;
} }
} }
} }
@ -470,13 +470,13 @@ day_popup_item (void)
item_in_popup (NULL, NULL, day_saved_item.mesg, _("Event :")); item_in_popup (NULL, NULL, day_saved_item.mesg, _("Event :"));
else if (day_saved_item.type == APPT || day_saved_item.type == RECUR_APPT) else if (day_saved_item.type == APPT || day_saved_item.type == RECUR_APPT)
item_in_popup (day_saved_item.start, day_saved_item.end, item_in_popup (day_saved_item.start, day_saved_item.end,
day_saved_item.mesg, _("Appointment :")); day_saved_item.mesg, _("Appointment :"));
else else
EXIT (_("unknown item type")); EXIT (_("unknown item type"));
/* NOTREACHED */ /* NOTREACHED */
} }
/* /*
* Need to know if there is an item for the current selected day inside * Need to know if there is an item for the current selected day inside
* calendar. This is used to put the correct colors inside calendar panel. * calendar. This is used to put the correct colors inside calendar panel.
*/ */
@ -491,16 +491,16 @@ day_check_if_item (struct date day)
for (re = recur_elist; re != 0; re = re->next) for (re = recur_elist; re != 0; re = re->next)
if (recur_item_inday (re->day, re->exc, re->rpt->type, if (recur_item_inday (re->day, re->exc, re->rpt->type,
re->rpt->freq, re->rpt->until, date)) re->rpt->freq, re->rpt->until, date))
return (1); return (1);
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (ra = recur_alist_p->root; ra != 0; ra = ra->next) for (ra = recur_alist_p->root; ra != 0; ra = ra->next)
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type, if (recur_item_inday (ra->start, ra->exc, ra->rpt->type,
ra->rpt->freq, ra->rpt->until, date)) ra->rpt->freq, ra->rpt->until, date))
{ {
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
return (1); return (1);
} }
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
@ -512,8 +512,8 @@ day_check_if_item (struct date day)
for (a = alist_p->root; a != 0; a = a->next) for (a = alist_p->root; a != 0; a = a->next)
if (apoint_inday (a, date)) if (apoint_inday (a, date))
{ {
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
return (1); return (1);
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
@ -527,13 +527,13 @@ fill_slices (int *slices, int slicesno, int first, int last)
if (first < 0 || last < first) if (first < 0 || last < first)
return 0; return 0;
if (last >= slicesno) if (last >= slicesno)
last = slicesno - 1; /* Appointment spanning more than one day. */ last = slicesno - 1; /* Appointment spanning more than one day. */
for (i = first; i <= last; i++) for (i = first; i <= last; i++)
slices[i] = 1; slices[i] = 1;
return 1; return 1;
} }
@ -547,7 +547,7 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices)
{ {
struct recur_apoint *ra; struct recur_apoint *ra;
struct apoint *a; struct apoint *a;
int slicelen; int slicelen;
const long date = date2sec (day, 0, 0); const long date = date2sec (day, 0, 0);
slicelen = DAYINSEC / slicesno; slicelen = DAYINSEC / slicesno;
@ -557,7 +557,7 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices)
pthread_mutex_lock (&(recur_alist_p->mutex)); pthread_mutex_lock (&(recur_alist_p->mutex));
for (ra = recur_alist_p->root; ra != 0; ra = ra->next) for (ra = recur_alist_p->root; ra != 0; ra = ra->next)
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type, if (recur_item_inday (ra->start, ra->exc, ra->rpt->type,
ra->rpt->freq, ra->rpt->until, date)) ra->rpt->freq, ra->rpt->until, date))
{ {
long start, end; long start, end;
@ -587,7 +587,7 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices)
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
#undef SLICENUM #undef SLICENUM
return 1; return 1;
} }
@ -606,12 +606,12 @@ day_edit_time (long time)
timestr = date_sec2date_str (time, "%H:%M"); timestr = date_sec2date_str (time, "%H:%M");
updatestring (win[STA].p, &timestr, 0, 1); updatestring (win[STA].p, &timestr, 0, 1);
if (check_time (timestr) != 1 || strlen (timestr) == 0) if (check_time (timestr) != 1 || strlen (timestr) == 0)
{ {
status_mesg (fmt_msg, enter_str); status_mesg (fmt_msg, enter_str);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
} }
else else
return (timestr); return (timestr);
} }
} }
@ -632,17 +632,17 @@ update_start_time (long *start, long *dur)
mem_free (timestr); mem_free (timestr);
newtime = update_time_in_date (*start, hr, mn); newtime = update_time_in_date (*start, hr, mn);
if (newtime < *start + *dur) if (newtime < *start + *dur)
{ {
*dur -= (newtime - *start); *dur -= (newtime - *start);
*start = newtime; *start = newtime;
valid_date = 1; valid_date = 1;
} }
else else
{ {
status_mesg (msg_wrong_time, msg_enter); status_mesg (msg_wrong_time, msg_enter);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
valid_date = 0; valid_date = 0;
} }
} }
while (valid_date == 0); while (valid_date == 0);
} }
@ -693,15 +693,15 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
(void)snprintf (typstr, SINGLECHAR, "%c", recur_def2char ((*rpt)->type)); (void)snprintf (typstr, SINGLECHAR, "%c", recur_def2char ((*rpt)->type));
cancel = updatestring (win[STA].p, &typstr, 0, 1); cancel = updatestring (win[STA].p, &typstr, 0, 1);
if (cancel) if (cancel)
{ {
mem_free (typstr); mem_free (typstr);
return; return;
} }
else else
{ {
ch = toupper (*typstr); ch = toupper (*typstr);
mem_free (typstr); mem_free (typstr);
} }
} }
while ((ch != 'D') && (ch != 'W') && (ch != 'M') && (ch != 'Y')); while ((ch != 'D') && (ch != 'W') && (ch != 'M') && (ch != 'Y'));
@ -712,20 +712,20 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
(void)snprintf (freqstr, BUFSIZ, "%d", (*rpt)->freq); (void)snprintf (freqstr, BUFSIZ, "%d", (*rpt)->freq);
cancel = updatestring (win[STA].p, &freqstr, 0, 1); cancel = updatestring (win[STA].p, &freqstr, 0, 1);
if (cancel) if (cancel)
{ {
mem_free (freqstr); mem_free (freqstr);
return; return;
} }
else else
{ {
newfreq = atoi (freqstr); newfreq = atoi (freqstr);
mem_free (freqstr); mem_free (freqstr);
if (newfreq == 0) if (newfreq == 0)
{ {
status_mesg (msg_wrong_freq, msg_enter); status_mesg (msg_wrong_freq, msg_enter);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
} }
} }
} }
while (newfreq == 0); while (newfreq == 0);
@ -735,52 +735,52 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf->input_datefmt));
status_mesg (_(outstr), ""); status_mesg (_(outstr), "");
timstr = timstr =
date_sec2date_str ((*rpt)->until, DATEFMT (conf->input_datefmt)); date_sec2date_str ((*rpt)->until, DATEFMT (conf->input_datefmt));
cancel = updatestring (win[STA].p, &timstr, 0, 1); cancel = updatestring (win[STA].p, &timstr, 0, 1);
if (cancel) if (cancel)
{ {
mem_free (timstr); mem_free (timstr);
return; return;
} }
if (strcmp (timstr, "0") == 0) if (strcmp (timstr, "0") == 0)
{ {
newuntil = 0; newuntil = 0;
date_entered = 1; date_entered = 1;
} }
else else
{ {
struct tm *lt; struct tm *lt;
time_t t; time_t t;
struct date new_date; struct date new_date;
int newmonth, newday, newyear; int newmonth, newday, newyear;
if (parse_date (timstr, conf->input_datefmt, if (parse_date (timstr, conf->input_datefmt,
&newyear, &newmonth, &newday, calendar_get_slctd_day ())) &newyear, &newmonth, &newday, calendar_get_slctd_day ()))
{ {
t = start; t = start;
lt = localtime (&t); lt = localtime (&t);
new_date.dd = newday; new_date.dd = newday;
new_date.mm = newmonth; new_date.mm = newmonth;
new_date.yyyy = newyear; new_date.yyyy = newyear;
newuntil = date2sec (new_date, lt->tm_hour, lt->tm_min); newuntil = date2sec (new_date, lt->tm_hour, lt->tm_min);
if (newuntil < start) if (newuntil < start)
{ {
status_mesg (msg_wrong_time, msg_enter); status_mesg (msg_wrong_time, msg_enter);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
date_entered = 0; date_entered = 0;
} }
else else
date_entered = 1; date_entered = 1;
} }
else else
{ {
(void)snprintf (outstr, BUFSIZ, msg_fmts, (void)snprintf (outstr, BUFSIZ, msg_fmts,
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf->input_datefmt));
status_mesg (msg_wrong_date, _(outstr)); status_mesg (msg_wrong_date, _(outstr));
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
date_entered = 0; date_entered = 0;
} }
} }
} }
while (date_entered == 0); while (date_entered == 0);
@ -818,18 +818,18 @@ day_edit_item (struct conf *conf)
re = recur_get_event (date, day_item_nb (date, item_num, RECUR_EVNT)); re = recur_get_event (date, day_item_nb (date, item_num, RECUR_EVNT));
status_mesg (_("Edit: (1)Description or (2)Repetition?"), "[1/2] "); status_mesg (_("Edit: (1)Description or (2)Repetition?"), "[1/2] ");
while (ch != '1' && ch != '2' && ch != KEY_GENERIC_CANCEL) while (ch != '1' && ch != '2' && ch != KEY_GENERIC_CANCEL)
ch = wgetch (win[STA].p); ch = wgetch (win[STA].p);
switch (ch) switch (ch)
{ {
case '1': case '1':
update_desc (&re->mesg); update_desc (&re->mesg);
break; break;
case '2': case '2':
update_rept (&re->rpt, re->day, conf); update_rept (&re->rpt, re->day, conf);
break; break;
default: default:
return; return;
} }
break; break;
case EVNT: case EVNT:
e = event_get (date, day_item_nb (date, item_num, EVNT)); e = event_get (date, day_item_nb (date, item_num, EVNT));
@ -838,55 +838,55 @@ day_edit_item (struct conf *conf)
case RECUR_APPT: case RECUR_APPT:
ra = recur_get_apoint (date, day_item_nb (date, item_num, RECUR_APPT)); ra = recur_get_apoint (date, day_item_nb (date, item_num, RECUR_APPT));
status_mesg (_("Edit: (1)Start time, (2)End time, " status_mesg (_("Edit: (1)Start time, (2)End time, "
"(3)Description or (4)Repetition?"), "[1/2/3/4] "); "(3)Description or (4)Repetition?"), "[1/2/3/4] ");
while (ch != STRT && ch != END && ch != DESC && while (ch != STRT && ch != END && ch != DESC &&
ch != REPT && ch != KEY_GENERIC_CANCEL) ch != REPT && ch != KEY_GENERIC_CANCEL)
ch = wgetch (win[STA].p); ch = wgetch (win[STA].p);
switch (ch) switch (ch)
{ {
case STRT: case STRT:
update_start_time (&ra->start, &ra->dur); update_start_time (&ra->start, &ra->dur);
break; break;
case END: case END:
update_duration (&ra->start, &ra->dur); update_duration (&ra->start, &ra->dur);
break; break;
case DESC: case DESC:
update_desc (&ra->mesg); update_desc (&ra->mesg);
break; break;
case REPT: case REPT:
update_rept (&ra->rpt, ra->start, conf); update_rept (&ra->rpt, ra->start, conf);
break; break;
case KEY_GENERIC_CANCEL: case KEY_GENERIC_CANCEL:
return; return;
} }
break; break;
case APPT: case APPT:
a = apoint_get (date, day_item_nb (date, item_num, APPT)); a = apoint_get (date, day_item_nb (date, item_num, APPT));
status_mesg (_("Edit: (1)Start time, (2)End time " status_mesg (_("Edit: (1)Start time, (2)End time "
"or (3)Description?"), "[1/2/3] "); "or (3)Description?"), "[1/2/3] ");
while (ch != STRT && ch != END && ch != DESC && ch != KEY_GENERIC_CANCEL) while (ch != STRT && ch != END && ch != DESC && ch != KEY_GENERIC_CANCEL)
ch = wgetch (win[STA].p); ch = wgetch (win[STA].p);
switch (ch) switch (ch)
{ {
case STRT: case STRT:
update_start_time (&a->start, &a->dur); update_start_time (&a->start, &a->dur);
break; break;
case END: case END:
update_duration (&a->start, &a->dur); update_duration (&a->start, &a->dur);
break; break;
case DESC: case DESC:
update_desc (&a->mesg); update_desc (&a->mesg);
break; break;
case KEY_GENERIC_CANCEL: case KEY_GENERIC_CANCEL:
return; return;
} }
break; break;
} }
} }
/* /*
* In order to erase an item, we need to count first the number of * In order to erase an item, we need to count first the number of
* items for each type (in order: recurrent events, events, * items for each type (in order: recurrent events, events,
* recurrent appointments and appointments) and then to test the * recurrent appointments and appointments) and then to test the
* type of the item to be deleted. * type of the item to be deleted.
*/ */
@ -896,10 +896,10 @@ day_erase_item (long date, int item_number, enum eraseflg flag)
struct day_item *p; struct day_item *p;
char *erase_warning = char *erase_warning =
_("This item is recurrent. " _("This item is recurrent. "
"Delete (a)ll occurences or just this (o)ne ?"); "Delete (a)ll occurences or just this (o)ne ?");
char *note_warning = char *note_warning =
_("This item has a note attached to it. " _("This item has a note attached to it. "
"Delete (i)tem or just its (n)ote ?"); "Delete (i)tem or just its (n)ote ?");
char *note_choice = _("[i/n] "); char *note_choice = _("[i/n] ");
char *erase_choice = _("[a/o] "); char *erase_choice = _("[a/o] ");
int ch, ans; int ch, ans;
@ -911,16 +911,16 @@ day_erase_item (long date, int item_number, enum eraseflg flag)
{ {
ans = 0; ans = 0;
if (p->note == NULL) if (p->note == NULL)
ans = 'i'; ans = 'i';
while (ans != 'i' && ans != 'n') while (ans != 'i' && ans != 'n')
{ {
status_mesg (note_warning, note_choice); status_mesg (note_warning, note_choice);
ans = wgetch (win[STA].p); ans = wgetch (win[STA].p);
} }
if (ans == 'i') if (ans == 'i')
flag = ERASE_FORCE; flag = ERASE_FORCE;
else else
flag = ERASE_FORCE_ONLY_NOTE; flag = ERASE_FORCE_ONLY_NOTE;
} }
if (p->type == EVNT) if (p->type == EVNT)
{ {
@ -933,33 +933,33 @@ day_erase_item (long date, int item_number, enum eraseflg flag)
else else
{ {
if (flag == ERASE_FORCE_ONLY_NOTE) if (flag == ERASE_FORCE_ONLY_NOTE)
ch = 'a'; ch = 'a';
while ((ch != 'a') && (ch != 'o') && (ch != KEY_GENERIC_CANCEL)) while ((ch != 'a') && (ch != 'o') && (ch != KEY_GENERIC_CANCEL))
{ {
status_mesg (erase_warning, erase_choice); status_mesg (erase_warning, erase_choice);
ch = wgetch (win[STA].p); ch = wgetch (win[STA].p);
} }
if (ch == 'a') if (ch == 'a')
{ {
delete_whole = 1; delete_whole = 1;
} }
else if (ch == 'o') else if (ch == 'o')
{ {
delete_whole = 0; delete_whole = 0;
} }
else else
{ {
return (0); return (0);
} }
if (p->type == RECUR_EVNT) if (p->type == RECUR_EVNT)
{ {
recur_event_erase (date, day_item_nb (date, item_number, RECUR_EVNT), recur_event_erase (date, day_item_nb (date, item_number, RECUR_EVNT),
delete_whole, flag); delete_whole, flag);
} }
else else
{ {
recur_apoint_erase (date, p->appt_pos, delete_whole, flag); recur_apoint_erase (date, p->appt_pos, delete_whole, flag);
} }
} }
if (flag == ERASE_FORCE_ONLY_NOTE) if (flag == ERASE_FORCE_ONLY_NOTE)
return 0; return 0;
@ -973,13 +973,13 @@ day_cut_item (long date, int item_number)
{ {
const int DELETE_WHOLE = 1; const int DELETE_WHOLE = 1;
struct day_item *p; struct day_item *p;
p = day_get_item (item_number); p = day_get_item (item_number);
switch (p->type) switch (p->type)
{ {
case EVNT: case EVNT:
event_delete_bynum (date, day_item_nb (date, item_number, EVNT), event_delete_bynum (date, day_item_nb (date, item_number, EVNT),
ERASE_CUT); ERASE_CUT);
break; break;
case RECUR_EVNT: case RECUR_EVNT:
recur_event_erase (date, day_item_nb (date, item_number, RECUR_EVNT), recur_event_erase (date, day_item_nb (date, item_number, RECUR_EVNT),
@ -1086,9 +1086,9 @@ day_edit_note (char *editor)
if (p->note == NULL) if (p->note == NULL)
{ {
if ((filename = new_tempfile (path_notes, NOTESIZ)) == NULL) if ((filename = new_tempfile (path_notes, NOTESIZ)) == NULL)
return; return;
else else
p->note = filename; p->note = filename;
} }
(void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, p->note); (void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, p->note);
wins_launch_external (fullname, editor); wins_launch_external (fullname, editor);

View File

@ -69,7 +69,7 @@ dmon_sigs_hdlr (int sig)
{ {
if (data_loaded) if (data_loaded)
free_user_data (); free_user_data ();
DMON_LOG (_("terminated at %s with signal %d\n"), nowstr (), sig); DMON_LOG (_("terminated at %s with signal %d\n"), nowstr (), sig);
if (unlink (path_dpid) != 0) if (unlink (path_dpid) != 0)
@ -78,7 +78,7 @@ dmon_sigs_hdlr (int sig)
strerror (errno)); strerror (errno));
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }
@ -86,7 +86,7 @@ static unsigned
daemonize (int status) daemonize (int status)
{ {
int fd; int fd;
/* /*
* Operate in the background: Daemonizing. * Operate in the background: Daemonizing.
* *
@ -127,7 +127,7 @@ daemonize (int status)
strerror (errno)); strerror (errno));
return 0; return 0;
} }
/* Redirect standard file descriptors to /dev/null. */ /* Redirect standard file descriptors to /dev/null. */
if ((fd = open (_PATH_DEVNULL, O_RDWR, 0)) != -1) if ((fd = open (_PATH_DEVNULL, O_RDWR, 0)) != -1)
{ {
@ -155,7 +155,7 @@ void
dmon_start (int parent_exit_status) dmon_start (int parent_exit_status)
{ {
struct conf conf; struct conf conf;
if (!daemonize (parent_exit_status)) if (!daemonize (parent_exit_status))
DMON_ABRT (_("Cannot daemonize, aborting\n")); DMON_ABRT (_("Cannot daemonize, aborting\n"));
@ -166,7 +166,7 @@ dmon_start (int parent_exit_status)
DMON_ABRT (_("Could not access \"%s\": %s\n"), DMON_ABRT (_("Could not access \"%s\": %s\n"),
path_conf, strerror (errno)); path_conf, strerror (errno));
custom_load_conf (&conf, 0); custom_load_conf (&conf, 0);
if (!io_file_exist (path_apts)) if (!io_file_exist (path_apts))
DMON_ABRT (_("Could not access \"%s\": %s\n"), DMON_ABRT (_("Could not access \"%s\": %s\n"),
path_apts, strerror (errno)); path_apts, strerror (errno));
@ -179,7 +179,7 @@ dmon_start (int parent_exit_status)
for (;;) for (;;)
{ {
int left; int left;
if (!notify_get_next_bkgd ()) if (!notify_get_next_bkgd ())
DMON_ABRT (_("error loading next appointment\n")); DMON_ABRT (_("error loading next appointment\n"));
@ -191,7 +191,7 @@ dmon_start (int parent_exit_status)
if (!notify_launch_cmd ()) if (!notify_launch_cmd ())
DMON_LOG (_("error while sending notification\n")); DMON_LOG (_("error while sending notification\n"));
} }
DMON_LOG (_("sleeping at %s for %d seconds\n"), nowstr (), DMON_LOG (_("sleeping at %s for %d seconds\n"), nowstr (),
DMON_SLEEP_TIME); DMON_SLEEP_TIME);
psleep (DMON_SLEEP_TIME); psleep (DMON_SLEEP_TIME);

View File

@ -97,11 +97,11 @@ event_new (char *mesg, char *note, long day, int id)
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->day > day) if (*i == 0 || (*i)->day > day)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
break; break;
} }
i = &(*i)->next; i = &(*i)->next;
} }
return (o); return (o);
@ -175,15 +175,15 @@ event_get (long day, int pos)
for (o = eventlist; o; o = o->next) for (o = eventlist; o; o = o->next)
{ {
if (event_inday (o, day)) if (event_inday (o, day))
{ {
if (n == pos) if (n == pos)
return o; return o;
n++; n++;
} }
} }
EXIT (_("event not found")); EXIT (_("event not found"));
return 0; return 0;
/* NOTREACHED */ /* NOTREACHED */
} }
/* Delete an event from the list. */ /* Delete an event from the list. */
@ -198,9 +198,9 @@ event_delete_bynum (long start, unsigned num, enum eraseflg flag)
for (i = eventlist; i != 0; i = i->next) for (i = eventlist; i != 0; i = i->next)
{ {
if (event_inday (i, start)) if (event_inday (i, start))
{ {
if (n == num) if (n == num)
{ {
switch (flag) switch (flag)
{ {
case ERASE_FORCE_ONLY_NOTE: case ERASE_FORCE_ONLY_NOTE:
@ -212,21 +212,21 @@ event_delete_bynum (long start, unsigned num, enum eraseflg flag)
erase_note (&i->note, ERASE_FORCE_KEEP_NOTE); erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
*iptr = i->next; *iptr = i->next;
mem_free (i->mesg); mem_free (i->mesg);
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT) if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
erase_note (&i->note, flag); erase_note (&i->note, flag);
mem_free (i); mem_free (i);
break; break;
} }
return; return;
} }
n++; n++;
} }
iptr = &i->next; iptr = &i->next;
} }
EXIT (_("event not found")); EXIT (_("event not found"));
/* NOTREACHED */ /* NOTREACHED */
} }
void void

View File

@ -91,9 +91,9 @@ get_help_lines (char *text)
return newline + 1; return newline + 1;
} }
/* /*
* Write the desired help text inside the help pad, and return the number * Write the desired help text inside the help pad, and return the number
* of lines that were written. * of lines that were written.
*/ */
static int static int
help_write_pad (struct window *win, char *title, char *text, enum key action) help_write_pad (struct window *win, char *title, char *text, enum key action)
@ -136,16 +136,16 @@ help_write_pad (struct window *win, char *title, char *text, enum key action)
} }
} }
colnum = 0; colnum = 0;
rownum += get_help_lines (title); rownum += get_help_lines (title);
custom_remove_attr (win->p, ATTR_HIGHEST); custom_remove_attr (win->p, ATTR_HIGHEST);
mvwprintw (win->p, rownum, colnum, "%s", text); mvwprintw (win->p, rownum, colnum, "%s", text);
rownum += get_help_lines (text); rownum += get_help_lines (text);
return rownum; return rownum;
} }
/* /*
* Create and init help screen and its pad, which is used to make the scrolling * Create and init help screen and its pad, which is used to make the scrolling
* faster. * faster.
*/ */
void void
help_wins_init (struct scrollwin *hwin, int x, int y, int h, int w) help_wins_init (struct scrollwin *hwin, int x, int y, int h, int w)
@ -168,7 +168,7 @@ help_wins_init (struct scrollwin *hwin, int x, int y, int h, int w)
wins_show (hwin->win.p, hwin->label); wins_show (hwin->win.p, hwin->label);
} }
/* /*
* Delete the existing windows and recreate them with their new * Delete the existing windows and recreate them with their new
* size and placement. * size and placement.
*/ */
@ -233,7 +233,7 @@ wanted_page (int ch)
case KEY_GENERIC_IMPORT: case KEY_GENERIC_IMPORT:
page = HELP_IMPORT; page = HELP_IMPORT;
break; break;
case KEY_GENERIC_EXPORT: case KEY_GENERIC_EXPORT:
page = HELP_EXPORT; page = HELP_EXPORT;
break; break;
@ -263,7 +263,7 @@ wanted_page (int ch)
case KEY_GENERIC_PASTE: case KEY_GENERIC_PASTE:
page = HELP_CUT_PASTE; page = HELP_CUT_PASTE;
break; break;
case KEY_EDIT_ITEM: case KEY_EDIT_ITEM:
page = HELP_EDIT; page = HELP_EDIT;
break; break;
@ -330,7 +330,7 @@ help_screen (void)
int page, oldpage; int page, oldpage;
help_page_t hscr[HELPSCREENS]; help_page_t hscr[HELPSCREENS];
char keystr[DIRECTIONS][BUFSIZ]; char keystr[DIRECTIONS][BUFSIZ];
hscr[HELP_MAIN].title = hscr[HELP_MAIN].title =
_(" Welcome to Calcurse. This is the main help screen.\n"); _(" Welcome to Calcurse. This is the main help screen.\n");
(void)snprintf (hscr[HELP_MAIN].text, HELPTEXTSIZ, (void)snprintf (hscr[HELP_MAIN].text, HELPTEXTSIZ,
@ -383,7 +383,7 @@ help_screen (void)
"In this report is shown one item per line, with the line in the input\n" "In this report is shown one item per line, with the line in the input\n"
"stream at which this item begins, together with the description of why\n" "stream at which this item begins, together with the description of why\n"
"the item could not be imported.\n")); "the item could not be imported.\n"));
hscr[HELP_EXPORT].title = _("Export\n"); hscr[HELP_EXPORT].title = _("Export\n");
(void)snprintf (hscr[HELP_EXPORT].text, HELPTEXTSIZ, (void)snprintf (hscr[HELP_EXPORT].text, HELPTEXTSIZ,
_("Export calcurse data (appointments, events and todos).\n" _("Export calcurse data (appointments, events and todos).\n"
@ -432,7 +432,7 @@ help_screen (void)
keystr[MOVE_UP], keystr[MOVE_LEFT], keystr[MOVE_UP], keystr[MOVE_LEFT],
keystr[MOVE_RIGHT], keystr[MOVE_DOWN], keystr[MOVE_RIGHT], keystr[MOVE_DOWN],
keys_action_firstkey (KEY_START_OF_WEEK), keys_action_firstkey (KEY_START_OF_WEEK),
keys_action_firstkey (KEY_END_OF_WEEK)); keys_action_firstkey (KEY_END_OF_WEEK));
hscr[HELP_VIEW].title = _("View\n"); hscr[HELP_VIEW].title = _("View\n");
(void)snprintf (hscr[HELP_VIEW].text, HELPTEXTSIZ, (void)snprintf (hscr[HELP_VIEW].text, HELPTEXTSIZ,
@ -458,7 +458,7 @@ help_screen (void)
"\nNotice that at the bottom of the screen the list of possible actions\n" "\nNotice that at the bottom of the screen the list of possible actions\n"
"change while pressing '%s', so you always know what action can be\n" "change while pressing '%s', so you always know what action can be\n"
"performed on the selected panel."), "performed on the selected panel."),
keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW), keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW),
keys_action_firstkey (KEY_ADD_ITEM), keys_action_firstkey (KEY_ADD_ITEM),
keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW)); keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW));
@ -520,7 +520,7 @@ help_screen (void)
" event next time you launch Calcurse."), " event next time you launch Calcurse."),
keys_action_firstkey (KEY_ADD_ITEM), keys_action_firstkey (KEY_ADD_ITEM),
keys_action_firstkey (KEY_RAISE_PRIORITY), keys_action_firstkey (KEY_RAISE_PRIORITY),
keys_action_firstkey (KEY_LOWER_PRIORITY), keys_action_firstkey (KEY_LOWER_PRIORITY),
keys_action_firstkey (KEY_ADD_ITEM), keys_action_firstkey (KEY_ADD_ITEM),
keys_action_firstkey (KEY_ADD_ITEM)); keys_action_firstkey (KEY_ADD_ITEM));
@ -539,7 +539,7 @@ help_screen (void)
"with its associated note if it had one."), "with its associated note if it had one."),
keys_action_firstkey (KEY_GENERIC_CUT), keys_action_firstkey (KEY_GENERIC_CUT),
keys_action_firstkey (KEY_GENERIC_PASTE)); keys_action_firstkey (KEY_GENERIC_PASTE));
hscr[HELP_EDIT].title = _("Edit Item\n"); hscr[HELP_EDIT].title = _("Edit Item\n");
(void)snprintf (hscr[HELP_EDIT].text, HELPTEXTSIZ, (void)snprintf (hscr[HELP_EDIT].text, HELPTEXTSIZ,
_("Edit the item which is currently selected.\n" _("Edit the item which is currently selected.\n"
@ -596,7 +596,7 @@ help_screen (void)
"Calcurse."), "Calcurse."),
keys_action_firstkey (KEY_EDIT_NOTE), keys_action_firstkey (KEY_EDIT_NOTE),
keys_action_firstkey (KEY_VIEW_NOTE)); keys_action_firstkey (KEY_VIEW_NOTE));
hscr[HELP_PRIORITY].title = _("Priority\n"); hscr[HELP_PRIORITY].title = _("Priority\n");
(void)snprintf (hscr[HELP_PRIORITY].text, HELPTEXTSIZ, (void)snprintf (hscr[HELP_PRIORITY].text, HELPTEXTSIZ,
_("Change the priority of the currently selected item in the ToDo list.\n" _("Change the priority of the currently selected item in the ToDo list.\n"
@ -612,9 +612,9 @@ help_screen (void)
"panel may change,\ndepending on the priority of the items above it.\n\n" "panel may change,\ndepending on the priority of the items above it.\n\n"
"At the opposite, to lower a todo priority, press '%s'. The todo position" "At the opposite, to lower a todo priority, press '%s'. The todo position"
"\nmay also change depending on the priority of the items below."), "\nmay also change depending on the priority of the items below."),
keys_action_firstkey (KEY_RAISE_PRIORITY), keys_action_firstkey (KEY_RAISE_PRIORITY),
keys_action_firstkey (KEY_LOWER_PRIORITY)); keys_action_firstkey (KEY_LOWER_PRIORITY));
hscr[HELP_REPEAT].title = _("Repeat\n"); hscr[HELP_REPEAT].title = _("Repeat\n");
(void)snprintf (hscr[HELP_REPEAT].text, HELPTEXTSIZ, (void)snprintf (hscr[HELP_REPEAT].text, HELPTEXTSIZ,
_("Repeat an event or an appointment.\n" _("Repeat an event or an appointment.\n"
@ -640,7 +640,7 @@ help_screen (void)
" o the 'Repeat' and 'Delete' command can be mixed to create\n" " o the 'Repeat' and 'Delete' command can be mixed to create\n"
" complicated configurations, as it is possible to delete only\n" " complicated configurations, as it is possible to delete only\n"
" one occurence of a repeated item."), " one occurence of a repeated item."),
keys_action_firstkey (KEY_REPEAT_ITEM)); keys_action_firstkey (KEY_REPEAT_ITEM));
hscr[HELP_FLAG].title = _("Flag Item\n"); hscr[HELP_FLAG].title = _("Flag Item\n");
(void)snprintf (hscr[HELP_FLAG].text, HELPTEXTSIZ, (void)snprintf (hscr[HELP_FLAG].text, HELPTEXTSIZ,
@ -711,7 +711,7 @@ help_screen (void)
"Once the last status bar page is reached, pressing '%s' another time\n" "Once the last status bar page is reached, pressing '%s' another time\n"
"leads you back to the first page."), "leads you back to the first page."),
keys_action_firstkey (KEY_GENERIC_OTHER_CMD), keys_action_firstkey (KEY_GENERIC_OTHER_CMD),
keys_action_firstkey (KEY_GENERIC_OTHER_CMD)); keys_action_firstkey (KEY_GENERIC_OTHER_CMD));
hscr[HELP_CREDITS].title = _("Calcurse - text-based organizer"); hscr[HELP_CREDITS].title = _("Calcurse - text-based organizer");
(void)snprintf (hscr[HELP_CREDITS].text, HELPTEXTSIZ, (void)snprintf (hscr[HELP_CREDITS].text, HELPTEXTSIZ,
@ -737,7 +737,7 @@ help_screen (void)
help_wins_init (&hwin, 0, 0, (notify_bar ()) ? row - 3 : row - 2, col); help_wins_init (&hwin, 0, 0, (notify_bar ()) ? row - 3 : row - 2, col);
page = oldpage = HELP_MAIN; page = oldpage = HELP_MAIN;
need_resize = 0; need_resize = 0;
/* Display the help screen related to user input. */ /* Display the help screen related to user input. */
while (ch != KEY_GENERIC_QUIT) while (ch != KEY_GENERIC_QUIT)
{ {

546
src/io.c

File diff suppressed because it is too large Load Diff

View File

@ -78,9 +78,9 @@ static struct keydef_s keydef[NBKEYS] = {
{"generic-next-week", "C-j"}, {"generic-next-week", "C-j"},
{"generic-prev-week", "C-k"}, {"generic-prev-week", "C-k"},
{"generic-scroll-down", "C-n"}, {"generic-scroll-down", "C-n"},
{"generic-scroll-up", "C-p"}, {"generic-scroll-up", "C-p"},
{"generic-goto-today", "C-g"}, {"generic-goto-today", "C-g"},
{"move-right", "l L"}, {"move-right", "l L"},
{"move-left", "h H"}, {"move-left", "h H"},
{"move-down", "j J"}, {"move-down", "j J"},
@ -164,7 +164,7 @@ keys_dump_defaults (char *file)
{ {
FILE *fd; FILE *fd;
int i; int i;
fd = fopen (file, "w"); fd = fopen (file, "w");
EXIT_IF (fd == NULL, _("FATAL ERROR: could not create default keys file.")); EXIT_IF (fd == NULL, _("FATAL ERROR: could not create default keys file."));
@ -196,7 +196,7 @@ enum key
keys_getch (WINDOW *win) keys_getch (WINDOW *win)
{ {
int ch; int ch;
ch = wgetch (win); ch = wgetch (win);
switch (ch) switch (ch)
{ {
@ -211,7 +211,7 @@ static void
add_key_str (enum key action, int key) add_key_str (enum key action, int key)
{ {
struct key_str_s *new, **i; struct key_str_s *new, **i;
if (action < 0 || action > NBKEYS) if (action < 0 || action > NBKEYS)
return; return;
@ -245,7 +245,7 @@ keys_assign_binding (int key, enum key action)
actions[key] = action; actions[key] = action;
add_key_str (action, key); add_key_str (action, key);
} }
return 0; return 0;
} }
@ -254,7 +254,7 @@ del_key_str (enum key action, int key)
{ {
struct key_str_s *old, **i; struct key_str_s *old, **i;
char oldstr[BUFSIZ]; char oldstr[BUFSIZ];
if (action < 0 || action > NBKEYS) if (action < 0 || action > NBKEYS)
return; return;
@ -265,7 +265,7 @@ del_key_str (enum key action, int key)
{ {
old = *i; old = *i;
*i = old->next; *i = old->next;
mem_free (old->str); mem_free (old->str);
mem_free (old); mem_free (old);
break; break;
} }
@ -289,7 +289,7 @@ keys_str2int (char *key)
{ {
const struct string CONTROL_KEY = STRING_BUILD ("C-"); const struct string CONTROL_KEY = STRING_BUILD ("C-");
const struct string TAB_KEY = STRING_BUILD ("TAB"); const struct string TAB_KEY = STRING_BUILD ("TAB");
const struct string SPACE_KEY = STRING_BUILD ("SPC"); const struct string SPACE_KEY = STRING_BUILD ("SPC");
const struct string ESCAPE_KEY = STRING_BUILD ("ESC"); const struct string ESCAPE_KEY = STRING_BUILD ("ESC");
const struct string CURSES_KEY_UP = STRING_BUILD ("UP"); const struct string CURSES_KEY_UP = STRING_BUILD ("UP");
const struct string CURSES_KEY_DOWN = STRING_BUILD ("DWN"); const struct string CURSES_KEY_DOWN = STRING_BUILD ("DWN");
@ -375,7 +375,7 @@ keys_action_count_keys (enum key action)
char * char *
keys_action_firstkey (enum key action) keys_action_firstkey (enum key action)
{ {
return (keys[action] != NULL) ? keys[action]->str : "XXX"; return (keys[action] != NULL) ? keys[action]->str : "XXX";
} }
char * char *
@ -400,10 +400,10 @@ keys_action_allkeys (enum key action)
static char keystr[BUFSIZ]; static char keystr[BUFSIZ];
struct key_str_s *i; struct key_str_s *i;
const char *CHAR_SPACE = " "; const char *CHAR_SPACE = " ";
if (keys[action] == NULL) if (keys[action] == NULL)
return NULL; return NULL;
keystr[0] = '\0'; keystr[0] = '\0';
for (i = keys[action]; i; i = i->next) for (i = keys[action]; i; i = i->next)
{ {
const int MAXLEN = sizeof (keystr) - 1 - strlen (keystr); const int MAXLEN = sizeof (keystr) - 1 - strlen (keystr);
@ -454,7 +454,7 @@ keys_display_bindings_bar (WINDOW *win, struct binding **binding, int first_key,
cmdlen = KEYS_KEYLEN + 1 + KEYS_LABELEN; cmdlen = KEYS_KEYLEN + 1 + KEYS_LABELEN;
space_between_cmds = floor (col / KEYS_CMDS_PER_LINE - cmdlen); space_between_cmds = floor (col / KEYS_CMDS_PER_LINE - cmdlen);
cmdlen += space_between_cmds; cmdlen += space_between_cmds;
j = 0; j = 0;
wins_erase_status_bar (); wins_erase_status_bar ();
for (i = first_key; i < last_key; i += 2) for (i = first_key; i < last_key; i += 2)
@ -479,7 +479,7 @@ keys_display_bindings_bar (WINDOW *win, struct binding **binding, int first_key,
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
mvwprintw (win, 0, LABEL_POS, binding[i]->label); mvwprintw (win, 0, LABEL_POS, binding[i]->label);
if (i + 1 != last_key) if (i + 1 != last_key)
mvwprintw (win, 1, LABEL_POS, binding[i + 1]->label); mvwprintw (win, 1, LABEL_POS, binding[i + 1]->label);
j++; j++;
} }
wnoutrefresh (win); wnoutrefresh (win);
@ -494,7 +494,7 @@ keys_popup_info (enum key key)
{ {
char *info[NBKEYS]; char *info[NBKEYS];
WINDOW *infowin; WINDOW *infowin;
info[KEY_GENERIC_CANCEL] = info[KEY_GENERIC_CANCEL] =
_("Cancel the ongoing action."); _("Cancel the ongoing action.");
info[KEY_GENERIC_SELECT] = info[KEY_GENERIC_SELECT] =
@ -574,8 +574,8 @@ keys_popup_info (enum key key)
info[KEY_RAISE_PRIORITY] = info[KEY_RAISE_PRIORITY] =
_("Raise a task priority inside the todo panel."); _("Raise a task priority inside the todo panel.");
info[KEY_LOWER_PRIORITY] = info[KEY_LOWER_PRIORITY] =
_("Lower a task priority inside the todo panel."); _("Lower a task priority inside the todo panel.");
if (key < 0 || key > NBKEYS) if (key < 0 || key > NBKEYS)
return; return;
@ -593,7 +593,7 @@ void
keys_save_bindings (FILE *fd) keys_save_bindings (FILE *fd)
{ {
int i; int i;
EXIT_IF (fd == NULL, _("FATAL ERROR: null file pointer.")); EXIT_IF (fd == NULL, _("FATAL ERROR: null file pointer."));
dump_intro (fd); dump_intro (fd);
for (i = 0; i < NBKEYS; i++) for (i = 0; i < NBKEYS; i++)
@ -604,7 +604,7 @@ int
keys_check_missing_bindings (void) keys_check_missing_bindings (void)
{ {
int i; int i;
for (i = 0; i < NBKEYS; i++) for (i = 0; i < NBKEYS; i++)
{ {
if (keys[i] == 0) if (keys[i] == 0)
@ -624,7 +624,7 @@ keys_fill_missing (void)
{ {
char *p, tmpbuf[BUFSIZ]; char *p, tmpbuf[BUFSIZ];
(void)strncpy (tmpbuf, keydef[i].binding, BUFSIZ); (void)strncpy (tmpbuf, keydef[i].binding, BUFSIZ);
p = tmpbuf; p = tmpbuf;
for (;;) for (;;)
{ {
@ -635,7 +635,7 @@ keys_fill_missing (void)
if (sscanf (p, "%s", key_ch) == 1) if (sscanf (p, "%s", key_ch) == 1)
{ {
int ch, used; int ch, used;
ch = keys_str2int (key_ch); ch = keys_str2int (key_ch);
used = keys_assign_binding (ch, i); used = keys_assign_binding (ch, i);
if (used) if (used)

View File

@ -77,11 +77,11 @@ stats_add_blk (size_t size, const char *pos)
EXIT_IF (o == 0, _("could not allocate memory to store block info")); EXIT_IF (o == 0, _("could not allocate memory to store block info"));
mstats.ncall++; mstats.ncall++;
o->pos = pos; o->pos = pos;
o->size = (unsigned)size; o->size = (unsigned)size;
o->next = 0; o->next = 0;
i = &mstats.blk; i = &mstats.blk;
for (i = &mstats.blk; *i; i = &(*i)->next) for (i = &mstats.blk; *i; i = &(*i)->next)
; ;
@ -111,14 +111,14 @@ stats_del_blk (unsigned id)
} }
EXIT (_("Block not found")); EXIT (_("Block not found"));
/* NOTREACHED */ /* NOTREACHED */
} }
void * void *
xmalloc (size_t size) xmalloc (size_t size)
{ {
void *p; void *p;
EXIT_IF (size == 0, _("xmalloc: zero size")); EXIT_IF (size == 0, _("xmalloc: zero size"));
p = malloc (size); p = malloc (size);
EXIT_IF (p == 0, _("xmalloc: out of memory")); EXIT_IF (p == 0, _("xmalloc: out of memory"));
@ -177,13 +177,13 @@ void *
dbg_malloc (size_t size, const char *pos) dbg_malloc (size_t size, const char *pos)
{ {
unsigned *buf; unsigned *buf;
if (size == 0) if (size == 0)
return (void *)0; return (void *)0;
size = EXTRA_SPACE + (size + sizeof (unsigned) - 1) / sizeof (unsigned); size = EXTRA_SPACE + (size + sizeof (unsigned) - 1) / sizeof (unsigned);
buf = xmalloc (size * sizeof (unsigned)); buf = xmalloc (size * sizeof (unsigned));
buf[BLK_STATE] = MAGIC_ALLOC; /* state of the block */ buf[BLK_STATE] = MAGIC_ALLOC; /* state of the block */
buf[BLK_SIZE] = size; /* size of the block */ buf[BLK_SIZE] = size; /* size of the block */
buf[BLK_ID] = stats_add_blk (size, pos); /* identify a block by its id */ buf[BLK_ID] = stats_add_blk (size, pos); /* identify a block by its id */
@ -198,10 +198,10 @@ void *
dbg_calloc (size_t nmemb, size_t size, const char *pos) dbg_calloc (size_t nmemb, size_t size, const char *pos)
{ {
void *buf; void *buf;
if (!nmemb || !size) if (!nmemb || !size)
return (void *)0; return (void *)0;
EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos); EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos);
size *= nmemb; size *= nmemb;
@ -217,25 +217,25 @@ void *
dbg_realloc (void *ptr, size_t nmemb, size_t size, const char *pos) dbg_realloc (void *ptr, size_t nmemb, size_t size, const char *pos)
{ {
unsigned *buf, old_size, new_size, cpy_size; unsigned *buf, old_size, new_size, cpy_size;
if (ptr == 0) if (ptr == 0)
return (void *)0; return (void *)0;
new_size = nmemb *size; new_size = nmemb *size;
if (new_size == 0) if (new_size == 0)
return (void *)0; return (void *)0;
EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos); EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos);
if ((buf = dbg_malloc (new_size, pos)) == 0) if ((buf = dbg_malloc (new_size, pos)) == 0)
return (void *)0; return (void *)0;
old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_SIZE); old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_SIZE);
cpy_size = (old_size > new_size) ? new_size : old_size; cpy_size = (old_size > new_size) ? new_size : old_size;
bcopy (ptr, buf, cpy_size); bcopy (ptr, buf, cpy_size);
mem_free (ptr); mem_free (ptr);
return (void *)buf; return (void *)buf;
} }
@ -244,7 +244,7 @@ dbg_strdup (const char *s, const char *pos)
{ {
size_t size; size_t size;
char *buf; char *buf;
if (s == 0) if (s == 0)
return (char *)0; return (char *)0;
@ -264,19 +264,19 @@ dbg_free (void *ptr, const char *pos)
buf = (unsigned *)ptr - EXTRA_SPACE_START; buf = (unsigned *)ptr - EXTRA_SPACE_START;
size = buf[BLK_SIZE]; size = buf[BLK_SIZE];
EXIT_IF (buf[BLK_STATE] == MAGIC_FREE, EXIT_IF (buf[BLK_STATE] == MAGIC_FREE,
_("block seems already freed at %s"), pos); _("block seems already freed at %s"), pos);
EXIT_IF (buf[BLK_STATE] != MAGIC_ALLOC, EXIT_IF (buf[BLK_STATE] != MAGIC_ALLOC,
_("corrupt block header at %s"), pos); _("corrupt block header at %s"), pos);
EXIT_IF (buf[size - 1] != buf[BLK_ID], EXIT_IF (buf[size - 1] != buf[BLK_ID],
_("corrupt block end at %s, (end = %u, should be %d)"), pos, _("corrupt block end at %s, (end = %u, should be %d)"), pos,
buf[size - 1], buf[BLK_ID]); buf[size - 1], buf[BLK_ID]);
buf[0] = MAGIC_FREE; buf[0] = MAGIC_FREE;
stats_del_blk (buf[BLK_ID]); stats_del_blk (buf[BLK_ID]);
free (buf); free (buf);
mstats.nfree += size; mstats.nfree += size;
} }
@ -289,10 +289,10 @@ dump_block_info (struct mem_blk *blk)
{ {
if (blk == 0) if (blk == 0)
return; return;
printf (_("---==== MEMORY BLOCK ====----------------\n")); printf (_("---==== MEMORY BLOCK ====----------------\n"));
printf (_(" id: %u\n"), blk->id); printf (_(" id: %u\n"), blk->id);
printf (_(" size: %u\n"), blk->size); printf (_(" size: %u\n"), blk->size);
printf (_(" allocated in: %s\n"), blk->pos); printf (_(" allocated in: %s\n"), blk->pos);
printf (_("-----------------------------------------\n")); printf (_("-----------------------------------------\n"));
} }
@ -301,7 +301,7 @@ void
mem_stats (void) mem_stats (void)
{ {
printf ("\n"); printf ("\n");
printf (_("+------------------------------+\n")); printf (_("+------------------------------+\n"));
printf (_("| calcurse memory usage report |\n")); printf (_("| calcurse memory usage report |\n"));
printf (_("+------------------------------+\n")); printf (_("+------------------------------+\n"));
printf (_(" number of calls: %u\n"), mstats.ncall); printf (_(" number of calls: %u\n"), mstats.ncall);

View File

@ -65,7 +65,7 @@ notify_time_left (void)
{ {
struct tm *ntime; struct tm *ntime;
time_t ntimer; time_t ntimer;
int left; int left;
ntimer = time (NULL); ntimer = time (NULL);
ntime = localtime (&ntimer); ntime = localtime (&ntimer);
@ -99,7 +99,7 @@ notify_update_app (long start, char state, char *msg)
notify_free_app (); notify_free_app ();
notify_app.got_app = 1; notify_app.got_app = 1;
notify_app.time = start; notify_app.time = start;
notify_app.state = state; notify_app.state = state;
notify_app.txt = mem_strdup (msg); notify_app.txt = mem_strdup (msg);
} }
@ -155,10 +155,10 @@ extract_aptsfile (void)
} }
} }
/* /*
* Create the notification bar, by initializing all the variables and * Create the notification bar, by initializing all the variables and
* creating the notification window (l is the number of lines, c the * creating the notification window (l is the number of lines, c the
* number of columns, y and x are its coordinates). * number of columns, y and x are its coordinates).
*/ */
void void
notify_init_bar (void) notify_init_bar (void)
@ -193,9 +193,9 @@ notify_stop_main_thread (void)
pthread_cancel (notify_t_main); pthread_cancel (notify_t_main);
} }
/* /*
* The calcurse window geometry has changed so we need to reset the * The calcurse window geometry has changed so we need to reset the
* notification window. * notification window.
*/ */
void void
notify_reinit_bar (void) notify_reinit_bar (void)
@ -212,9 +212,9 @@ notify_launch_cmd (void)
if (notify_app.state & APOINT_NOTIFIED) if (notify_app.state & APOINT_NOTIFIED)
return 1; return 1;
notify_app.state |= APOINT_NOTIFIED; notify_app.state |= APOINT_NOTIFIED;
pid = fork (); pid = fork ();
if (pid < 0) if (pid < 0)
@ -236,7 +236,7 @@ notify_launch_cmd (void)
return 1; return 1;
} }
/* /*
* Update the notification bar. This is useful when changing color theme * Update the notification bar. This is useful when changing color theme
* for example. * for example.
*/ */
@ -259,58 +259,58 @@ notify_update_bar (void)
wattron (notify.win, A_UNDERLINE | A_REVERSE); wattron (notify.win, A_UNDERLINE | A_REVERSE);
mvwhline (notify.win, 0, 0, ACS_HLINE, col); mvwhline (notify.win, 0, 0, ACS_HLINE, col);
mvwprintw (notify.win, 0, date_pos, "[ %s | %s ]", mvwprintw (notify.win, 0, date_pos, "[ %s | %s ]",
notify.date, notify.time); notify.date, notify.time);
mvwprintw (notify.win, 0, file_pos, "(%s)", notify.apts_file); mvwprintw (notify.win, 0, file_pos, "(%s)", notify.apts_file);
pthread_mutex_lock (&notify_app.mutex); pthread_mutex_lock (&notify_app.mutex);
if (notify_app.got_app) if (notify_app.got_app)
{ {
if (strlen (notify_app.txt) > txt_max_len) if (strlen (notify_app.txt) > txt_max_len)
{ {
int shrink_len; int shrink_len;
too_long = 1; too_long = 1;
shrink_len = txt_max_len > 3 ? txt_max_len - 3 : 1; shrink_len = txt_max_len > 3 ? txt_max_len - 3 : 1;
(void)strncpy (buf, notify_app.txt, shrink_len); (void)strncpy (buf, notify_app.txt, shrink_len);
buf[shrink_len] = '\0'; buf[shrink_len] = '\0';
} }
time_left = notify_time_left (); time_left = notify_time_left ();
if (time_left > 0) if (time_left > 0)
{ {
int hours_left, minutes_left; int hours_left, minutes_left;
hours_left = (time_left / HOURINSEC);
minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC;
pthread_mutex_lock (&nbar.mutex);
if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY)) hours_left = (time_left / HOURINSEC);
blinking = 1; minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC;
else pthread_mutex_lock (&nbar.mutex);
blinking = 0;
if (blinking) if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY))
wattron (notify.win, A_BLINK); blinking = 1;
if (too_long) else
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s.. <", blinking = 0;
hours_left, minutes_left, buf);
else
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s <",
hours_left, minutes_left, notify_app.txt);
if (blinking)
wattroff (notify.win, A_BLINK);
if (blinking) if (blinking)
wattron (notify.win, A_BLINK);
if (too_long)
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s.. <",
hours_left, minutes_left, buf);
else
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s <",
hours_left, minutes_left, notify_app.txt);
if (blinking)
wattroff (notify.win, A_BLINK);
if (blinking)
(void)notify_launch_cmd (); (void)notify_launch_cmd ();
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
} }
else else
{ {
notify_app.got_app = 0; notify_app.got_app = 0;
pthread_mutex_unlock (&notify_app.mutex); pthread_mutex_unlock (&notify_app.mutex);
pthread_mutex_unlock (&notify.mutex); pthread_mutex_unlock (&notify.mutex);
notify_check_next_app (); notify_check_next_app ();
return; return;
} }
} }
pthread_mutex_unlock (&notify_app.mutex); pthread_mutex_unlock (&notify_app.mutex);
@ -349,14 +349,14 @@ notify_main_thread (void *arg)
psleep (thread_sleep); psleep (thread_sleep);
elapse += thread_sleep; elapse += thread_sleep;
if (elapse >= check_app) if (elapse >= check_app)
{ {
elapse = 0; elapse = 0;
pthread_mutex_lock (&notify_app.mutex); pthread_mutex_lock (&notify_app.mutex);
got_app = notify_app.got_app; got_app = notify_app.got_app;
pthread_mutex_unlock (&notify_app.mutex); pthread_mutex_unlock (&notify_app.mutex);
if (!got_app) if (!got_app)
notify_check_next_app (); notify_check_next_app ();
} }
} }
pthread_exit ((void *) 0); pthread_exit ((void *) 0);
} }
@ -366,10 +366,10 @@ unsigned
notify_get_next (struct notify_app *a) notify_get_next (struct notify_app *a)
{ {
time_t current_time; time_t current_time;
if (!a) if (!a)
return 0; return 0;
current_time = time (NULL); current_time = time (NULL);
a->time = current_time + DAYINSEC; a->time = current_time + DAYINSEC;
@ -409,7 +409,7 @@ notify_get_next_bkgd (void)
if (a.txt) if (a.txt)
mem_free (a.txt); mem_free (a.txt);
return 1; return 1;
} }
@ -432,23 +432,23 @@ notify_thread_app (void *arg)
if (!notify_get_next (&tmp_app)) if (!notify_get_next (&tmp_app))
pthread_exit ((void *)0); pthread_exit ((void *)0);
if (!tmp_app.got_app) if (!tmp_app.got_app)
{ {
pthread_mutex_lock (&notify_app.mutex); pthread_mutex_lock (&notify_app.mutex);
notify_free_app (); notify_free_app ();
pthread_mutex_unlock (&notify_app.mutex); pthread_mutex_unlock (&notify_app.mutex);
} }
else else
{ {
if (!notify_same_item (tmp_app.time)) if (!notify_same_item (tmp_app.time))
{ {
pthread_mutex_lock (&notify_app.mutex); pthread_mutex_lock (&notify_app.mutex);
notify_update_app (tmp_app.time, tmp_app.state, tmp_app.txt); notify_update_app (tmp_app.time, tmp_app.state, tmp_app.txt);
pthread_mutex_unlock (&notify_app.mutex); pthread_mutex_unlock (&notify_app.mutex);
} }
} }
if (tmp_app.txt) if (tmp_app.txt)
mem_free (tmp_app.txt); mem_free (tmp_app.txt);
notify_update_bar (); notify_update_bar ();
@ -481,7 +481,7 @@ notify_check_added (char *mesg, long start, char state)
{ {
gap = start - current_time; gap = start - current_time;
if (gap >= 0 && gap <= DAYINSEC) if (gap >= 0 && gap <= DAYINSEC)
update_notify = 1; update_notify = 1;
} }
else if (start < notify_app.time && start >= current_time) else if (start < notify_app.time && start >= current_time)
{ {
@ -509,22 +509,22 @@ notify_check_repeated (struct recur_apoint *i)
current_time = time (NULL); current_time = time (NULL);
pthread_mutex_lock (&notify_app.mutex); pthread_mutex_lock (&notify_app.mutex);
if ((real_app_time = recur_item_inday (i->start, i->exc, i->rpt->type, if ((real_app_time = recur_item_inday (i->start, i->exc, i->rpt->type,
i->rpt->freq, i->rpt->until, i->rpt->freq, i->rpt->until,
get_today ()) > current_time)) get_today ()) > current_time))
{ {
if (!notify_app.got_app) if (!notify_app.got_app)
{ {
if (real_app_time - current_time <= DAYINSEC) if (real_app_time - current_time <= DAYINSEC)
update_notify = 1; update_notify = 1;
} }
else if (real_app_time < notify_app.time && else if (real_app_time < notify_app.time &&
real_app_time >= current_time) real_app_time >= current_time)
{ {
update_notify = 1; update_notify = 1;
} }
else if (real_app_time == notify_app.time && else if (real_app_time == notify_app.time &&
i->state != notify_app.state) i->state != notify_app.state)
update_notify = 1; update_notify = 1;
} }
if (update_notify) if (update_notify)
{ {
@ -554,7 +554,7 @@ notify_same_recur_item (struct recur_apoint *i)
long item_start = 0; long item_start = 0;
item_start = recur_item_inday (i->start, i->exc, i->rpt->type, item_start = recur_item_inday (i->start, i->exc, i->rpt->type,
i->rpt->freq, i->rpt->until, get_today ()); i->rpt->freq, i->rpt->until, get_today ());
pthread_mutex_lock (&notify_app.mutex); pthread_mutex_lock (&notify_app.mutex);
if (notify_app.got_app && item_start == notify_app.time) if (notify_app.got_app && item_start == notify_app.time)
same = 1; same = 1;
@ -583,7 +583,7 @@ print_option (WINDOW *win, unsigned x, unsigned y, char *name,
const int XOFF = 4; const int XOFF = 4;
const int MAXCOL = col - 3; const int MAXCOL = col - 3;
int x_opt, len; int x_opt, len;
x_opt = x + XOFF + strlen (name); x_opt = x + XOFF + strlen (name);
mvwprintw (win, y, x, "[%u] %s", num, name); mvwprintw (win, y, x, "[%u] %s", num, name);
erase_window_part (win, x_opt, y, MAXCOL, y); erase_window_part (win, x_opt, y, MAXCOL, y);
@ -594,15 +594,15 @@ print_option (WINDOW *win, unsigned x, unsigned y, char *name,
maxlen = MAXCOL - x_opt - 2; maxlen = MAXCOL - x_opt - 2;
custom_apply_attr (win, ATTR_HIGHEST); custom_apply_attr (win, ATTR_HIGHEST);
if (len < maxlen) if (len < maxlen)
mvwprintw (win, y, x_opt, "%s", valstr); mvwprintw (win, y, x_opt, "%s", valstr);
else else
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
(void)strncpy (buf, valstr, maxlen - 1); (void)strncpy (buf, valstr, maxlen - 1);
buf[maxlen - 1] = '\0'; buf[maxlen - 1] = '\0';
mvwprintw (win, y, x_opt, "%s...", buf); mvwprintw (win, y, x_opt, "%s...", buf);
} }
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
} }
else else
@ -617,7 +617,7 @@ print_config_options (WINDOW *optwin)
const int XORIG = 3; const int XORIG = 3;
const int YORIG = 0; const int YORIG = 0;
const int YOFF = 3; const int YOFF = 3;
enum enum
{ SHOW, DATE, CLOCK, WARN, CMD, DMON, DMON_LOG, NB_OPT }; { SHOW, DATE, CLOCK, WARN, CMD, DMON, DMON_LOG, NB_OPT };
@ -633,23 +633,23 @@ print_config_options (WINDOW *optwin)
opt[SHOW].name = _("notify-bar_show = "); opt[SHOW].name = _("notify-bar_show = ");
opt[SHOW].desc = _("(if set to YES, notify-bar will be displayed)"); opt[SHOW].desc = _("(if set to YES, notify-bar will be displayed)");
opt[DATE].name = _("notify-bar_date = "); opt[DATE].name = _("notify-bar_date = ");
opt[DATE].desc = _("(Format of the date to be displayed inside notify-bar)"); opt[DATE].desc = _("(Format of the date to be displayed inside notify-bar)");
opt[CLOCK].name = _("notify-bar_clock = "); opt[CLOCK].name = _("notify-bar_clock = ");
opt[CLOCK].desc = _("(Format of the time to be displayed inside notify-bar)"); opt[CLOCK].desc = _("(Format of the time to be displayed inside notify-bar)");
opt[WARN].name = _("notify-bar_warning = "); opt[WARN].name = _("notify-bar_warning = ");
opt[WARN].desc = _("(Warn user if an appointment is within next " opt[WARN].desc = _("(Warn user if an appointment is within next "
"'notify-bar_warning' seconds)"); "'notify-bar_warning' seconds)");
opt[CMD].name = _("notify-bar_command = "); opt[CMD].name = _("notify-bar_command = ");
opt[CMD].desc = _("(Command used to notify user of an upcoming appointment)"); opt[CMD].desc = _("(Command used to notify user of an upcoming appointment)");
opt[DMON].name = _("notify-daemon_enable = "); opt[DMON].name = _("notify-daemon_enable = ");
opt[DMON].desc = _("(Run in background to get notifications after exiting)"); opt[DMON].desc = _("(Run in background to get notifications after exiting)");
opt[DMON_LOG].name = _("notify-daemon_log = "); opt[DMON_LOG].name = _("notify-daemon_log = ");
opt[DMON_LOG].desc = _("(Log activity when running in background)"); opt[DMON_LOG].desc = _("(Log activity when running in background)");
@ -664,16 +664,16 @@ print_config_options (WINDOW *optwin)
/* Boolean options */ /* Boolean options */
opt[SHOW].valnum = nbar.show; opt[SHOW].valnum = nbar.show;
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
opt[DMON].valnum = dmon.enable; opt[DMON].valnum = dmon.enable;
opt[DMON_LOG].valnum = dmon.log; opt[DMON_LOG].valnum = dmon.log;
opt[SHOW].valstr[0] = opt[DMON].valstr[0] = opt[DMON_LOG].valstr[0] = '\0'; opt[SHOW].valstr[0] = opt[DMON].valstr[0] = opt[DMON_LOG].valstr[0] = '\0';
for (i = 0; i < NB_OPT; i++) for (i = 0; i < NB_OPT; i++)
{ {
int y; int y;
y = YORIG + i * YOFF; y = YORIG + i * YOFF;
print_option (optwin, XORIG, y, opt[i].name, opt[i].valstr, print_option (optwin, XORIG, y, opt[i].name, opt[i].valstr,
opt[i].valnum, opt[i].desc, i + 1); opt[i].valnum, opt[i].desc, i + 1);
@ -689,7 +689,7 @@ reinit_conf_win (struct scrollwin *win)
first_line = win->first_visible_line; first_line = win->first_visible_line;
wins_scrollwin_delete (win); wins_scrollwin_delete (win);
custom_set_swsiz (win); custom_set_swsiz (win);
wins_scrollwin_init (win); wins_scrollwin_init (win);
wins_show (win->win.p, win->label); wins_show (win->win.p, win->label);
win->first_visible_line = first_line; win->first_visible_line = first_line;
@ -714,7 +714,7 @@ notify_config_bar (void)
char *cmd_str = _("Enter the notification command "); char *cmd_str = _("Enter the notification command ");
int ch; int ch;
clear (); clear ();
custom_set_swsiz (&cwin); custom_set_swsiz (&cwin);
(void)snprintf (cwin.label, BUFSIZ, _("notification options")); (void)snprintf (cwin.label, BUFSIZ, _("notification options"));
wins_scrollwin_init (&cwin); wins_scrollwin_init (&cwin);
@ -723,8 +723,8 @@ notify_config_bar (void)
cwin.total_lines = print_config_options (cwin.pad.p); cwin.total_lines = print_config_options (cwin.pad.p);
wins_scrollwin_display (&cwin); wins_scrollwin_display (&cwin);
buf = mem_malloc (BUFSIZ); buf = mem_malloc (BUFSIZ);
while ((ch = wgetch (win[STA].p)) != 'q') while ((ch = wgetch (win[STA].p)) != 'q')
{ {
buf[0] = '\0'; buf[0] = '\0';
@ -734,88 +734,88 @@ notify_config_bar (void)
wins_get_config (); wins_get_config ();
wins_reset (); wins_reset ();
reinit_conf_win (&cwin); reinit_conf_win (&cwin);
delwin (win[STA].p); delwin (win[STA].p);
win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y, win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y,
win[STA].x); win[STA].x);
keypad (win[STA].p, TRUE); keypad (win[STA].p, TRUE);
if (notify_bar ()) if (notify_bar ())
{ {
notify_reinit_bar (); notify_reinit_bar ();
notify_update_bar (); notify_update_bar ();
} }
break; break;
case CTRL ('N'): case CTRL ('N'):
wins_scrollwin_down (&cwin, 1); wins_scrollwin_down (&cwin, 1);
break; break;
case CTRL ('P'): case CTRL ('P'):
wins_scrollwin_up (&cwin, 1); wins_scrollwin_up (&cwin, 1);
break; break;
case '1': case '1':
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
nbar.show = !nbar.show; nbar.show = !nbar.show;
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
if (notify_bar ()) if (notify_bar ())
notify_start_main_thread (); notify_start_main_thread ();
else else
notify_stop_main_thread (); notify_stop_main_thread ();
wins_scrollwin_delete (&cwin); wins_scrollwin_delete (&cwin);
reinit_conf_win (&cwin); reinit_conf_win (&cwin);
break; break;
case '2': case '2':
status_mesg (date_str, ""); status_mesg (date_str, "");
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
(void)strncpy (buf, nbar.datefmt, strlen (nbar.datefmt) + 1); (void)strncpy (buf, nbar.datefmt, strlen (nbar.datefmt) + 1);
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
if (updatestring (win[STA].p, &buf, 0, 1) == 0) if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{ {
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
(void)strncpy (nbar.datefmt, buf, strlen (buf) + 1); (void)strncpy (nbar.datefmt, buf, strlen (buf) + 1);
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
} }
break; break;
case '3': case '3':
status_mesg (time_str, ""); status_mesg (time_str, "");
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
(void)strncpy (buf, nbar.timefmt, strlen (nbar.timefmt) + 1); (void)strncpy (buf, nbar.timefmt, strlen (nbar.timefmt) + 1);
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
if (updatestring (win[STA].p, &buf, 0, 1) == 0) if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{ {
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
(void)strncpy (nbar.timefmt, buf, strlen (buf) + 1); (void)strncpy (nbar.timefmt, buf, strlen (buf) + 1);
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
} }
break; break;
case '4': case '4':
status_mesg (count_str, ""); status_mesg (count_str, "");
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
printf (buf, "%d", nbar.cntdwn); printf (buf, "%d", nbar.cntdwn);
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
if (updatestring (win[STA].p, &buf, 0, 1) == 0 && if (updatestring (win[STA].p, &buf, 0, 1) == 0 &&
is_all_digit (buf) && atoi (buf) >= 0 && atoi (buf) <= DAYINSEC) is_all_digit (buf) && atoi (buf) >= 0 && atoi (buf) <= DAYINSEC)
{ {
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
nbar.cntdwn = atoi (buf); nbar.cntdwn = atoi (buf);
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
} }
break; break;
case '5': case '5':
status_mesg (cmd_str, ""); status_mesg (cmd_str, "");
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
(void)strncpy (buf, nbar.cmd, strlen (nbar.cmd) + 1); (void)strncpy (buf, nbar.cmd, strlen (nbar.cmd) + 1);
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
if (updatestring (win[STA].p, &buf, 0, 1) == 0) if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{ {
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
(void)strncpy (nbar.cmd, buf, strlen (buf) + 1); (void)strncpy (nbar.cmd, buf, strlen (buf) + 1);
pthread_mutex_unlock (&nbar.mutex); pthread_mutex_unlock (&nbar.mutex);
} }
break; break;
case '6': case '6':
dmon.enable = !dmon.enable; dmon.enable = !dmon.enable;
break; break;
case '7': case '7':
dmon.log = !dmon.log; dmon.log = !dmon.log;
break; break;
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
cwin.total_lines = print_config_options (cwin.pad.p); cwin.total_lines = print_config_options (cwin.pad.p);

View File

@ -66,7 +66,7 @@ static void
recur_add_exc (struct days **exc, long day) recur_add_exc (struct days **exc, long day)
{ {
struct days **i, *o; struct days **i, *o;
o = mem_malloc (sizeof (struct days)); o = mem_malloc (sizeof (struct days));
o->st = day; o->st = day;
i = exc; i = exc;
@ -86,7 +86,7 @@ static void
exc_dup (struct days **in, struct days *exc) exc_dup (struct days **in, struct days *exc)
{ {
struct days *p; struct days *p;
for (p = exc; p; p = p->next) for (p = exc; p; p = p->next)
recur_add_exc (in, p->st); recur_add_exc (in, p->st);
} }
@ -141,7 +141,7 @@ recur_event_dup (struct recur_event *in, struct recur_event *bkp)
bkp->id = in->id; bkp->id = in->id;
bkp->day = in->day; bkp->day = in->day;
bkp->mesg = mem_strdup (in->mesg); bkp->mesg = mem_strdup (in->mesg);
bkp->rpt = mem_malloc (sizeof (struct rpt)); bkp->rpt = mem_malloc (sizeof (struct rpt));
bkp->rpt->type = in->rpt->type; bkp->rpt->type = in->rpt->type;
bkp->rpt->freq = in->rpt->freq; bkp->rpt->freq = in->rpt->freq;
@ -163,7 +163,7 @@ recur_apoint_dup (struct recur_apoint *in, struct recur_apoint *bkp)
bkp->dur = in->dur; bkp->dur = in->dur;
bkp->state = in->state; bkp->state = in->state;
bkp->mesg = mem_strdup (in->mesg); bkp->mesg = mem_strdup (in->mesg);
bkp->rpt = mem_malloc (sizeof (struct rpt)); bkp->rpt = mem_malloc (sizeof (struct rpt));
bkp->rpt->type = in->rpt->type; bkp->rpt->type = in->rpt->type;
bkp->rpt->freq = in->rpt->freq; bkp->rpt->freq = in->rpt->freq;
@ -174,7 +174,7 @@ recur_apoint_dup (struct recur_apoint *in, struct recur_apoint *bkp)
if (in->note) if (in->note)
bkp->note = mem_strdup (in->note); bkp->note = mem_strdup (in->note);
} }
void void
recur_apoint_llist_init (void) recur_apoint_llist_init (void)
@ -236,10 +236,10 @@ recur_event_llist_free (void)
/* Insert a new recursive appointment in the general linked list */ /* Insert a new recursive appointment in the general linked list */
struct recur_apoint * struct recur_apoint *
recur_apoint_new (char *mesg, char *note, long start, long dur, char state, recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
int type, int freq, long until, struct days **except) int type, int freq, long until, struct days **except)
{ {
struct recur_apoint *o, **i; struct recur_apoint *o, **i;
o = mem_malloc (sizeof (struct recur_apoint)); o = mem_malloc (sizeof (struct recur_apoint));
o->rpt = mem_malloc (sizeof (struct rpt)); o->rpt = mem_malloc (sizeof (struct rpt));
o->mesg = mem_strdup (mesg); o->mesg = mem_strdup (mesg);
@ -263,11 +263,11 @@ recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->start > start) if (*i == 0 || (*i)->start > start)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
break; break;
} }
i = &(*i)->next; i = &(*i)->next;
} }
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
@ -278,14 +278,14 @@ recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
/* Insert a new recursive event in the general linked list */ /* Insert a new recursive event in the general linked list */
struct recur_event * struct recur_event *
recur_event_new (char *mesg, char *note, long day, int id, int type, int freq, recur_event_new (char *mesg, char *note, long day, int id, int type, int freq,
long until, struct days **except) long until, struct days **except)
{ {
struct recur_event *o, **i; struct recur_event *o, **i;
o = mem_malloc (sizeof (struct recur_event)); o = mem_malloc (sizeof (struct recur_event));
o->rpt = mem_malloc (sizeof (struct rpt)); o->rpt = mem_malloc (sizeof (struct rpt));
o->mesg = mem_strdup (mesg); o->mesg = mem_strdup (mesg);
o->note = (note != 0) ? mem_strdup (note) : 0; o->note = (note != 0) ? mem_strdup (note) : 0;
o->day = day; o->day = day;
o->id = id; o->id = id;
o->rpt->type = type; o->rpt->type = type;
@ -303,19 +303,19 @@ recur_event_new (char *mesg, char *note, long day, int id, int type, int freq,
for (;;) for (;;)
{ {
if (*i == 0 || (*i)->day > day) if (*i == 0 || (*i)->day > day)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
break; break;
} }
i = &(*i)->next; i = &(*i)->next;
} }
return (o); return (o);
} }
/* /*
* Correspondance between the defines on recursive type, * Correspondance between the defines on recursive type,
* and the letter to be written in file. * and the letter to be written in file.
*/ */
char char
recur_def2char (enum recur_type define) recur_def2char (enum recur_type define)
@ -344,7 +344,7 @@ recur_def2char (enum recur_type define)
return (recur_char); return (recur_char);
} }
/* /*
* Correspondance between the letters written in file and the defines * Correspondance between the letters written in file and the defines
* concerning the recursive type. * concerning the recursive type.
*/ */
@ -397,8 +397,8 @@ recur_write_exc (struct days *exc, FILE *f)
/* Load the recursive appointment description */ /* Load the recursive appointment description */
struct recur_apoint * struct recur_apoint *
recur_apoint_scan (FILE *f, struct tm start, struct tm end, char type, recur_apoint_scan (FILE *f, struct tm start, struct tm end, char type,
int freq, struct tm until, char *note, struct days **exc, int freq, struct tm until, char *note, struct days **exc,
char state) char state)
{ {
struct tm *lt; struct tm *lt;
char buf[BUFSIZ], *nl; char buf[BUFSIZ], *nl;
@ -441,13 +441,13 @@ recur_apoint_scan (FILE *f, struct tm start, struct tm end, char type,
_("date error in appointment")); _("date error in appointment"));
return (recur_apoint_new (buf, note, tstart, tend - tstart, state, return (recur_apoint_new (buf, note, tstart, tend - tstart, state,
recur_char2def (type), freq, tuntil, exc)); recur_char2def (type), freq, tuntil, exc));
} }
/* Load the recursive events from file */ /* Load the recursive events from file */
struct recur_event * struct recur_event *
recur_event_scan (FILE *f, struct tm start, int id, char type, int freq, recur_event_scan (FILE *f, struct tm start, int id, char type, int freq,
struct tm until, char *note, struct days **exc) struct tm until, char *note, struct days **exc)
{ {
char buf[BUFSIZ], *nl; char buf[BUFSIZ], *nl;
time_t tstart, tuntil; time_t tstart, tuntil;
@ -646,7 +646,7 @@ diff_years (struct tm lt_start, struct tm lt_end)
return lt_end.tm_year - lt_start.tm_year; return lt_end.tm_year - lt_start.tm_year;
} }
/* /*
* Check if the recurrent item belongs to the selected day, * Check if the recurrent item belongs to the selected day,
* and if yes, return the real start time. * and if yes, return the real start time.
* *
@ -657,7 +657,7 @@ diff_years (struct tm lt_start, struct tm lt_end)
*/ */
unsigned unsigned
recur_item_inday (long item_start, struct days *item_exc, int rpt_type, recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
int rpt_freq, long rpt_until, long day_start) int rpt_freq, long rpt_until, long day_start)
{ {
struct date start_date; struct date start_date;
long day_end, diff; long day_end, diff;
@ -668,7 +668,7 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
day_end = day_start + DAYINSEC; day_end = day_start + DAYINSEC;
t = day_start; t = day_start;
lt_day = *localtime (&t); lt_day = *localtime (&t);
for (exc = item_exc; exc != 0; exc = exc->next) for (exc = item_exc; exc != 0; exc = exc->next)
if (exc->st < day_end && exc->st >= day_start) if (exc->st < day_end && exc->st >= day_start)
return (0); return (0);
@ -681,26 +681,26 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
t = item_start; t = item_start;
lt_item = *localtime (&t); lt_item = *localtime (&t);
switch (rpt_type) switch (rpt_type)
{ {
case RECUR_DAILY: case RECUR_DAILY:
diff = diff_days (lt_item, lt_day); diff = diff_days (lt_item, lt_day);
if (diff % rpt_freq != 0) if (diff % rpt_freq != 0)
return (0); return (0);
lt_item.tm_mday = lt_day.tm_mday; lt_item.tm_mday = lt_day.tm_mday;
lt_item.tm_mon = lt_day.tm_mon; lt_item.tm_mon = lt_day.tm_mon;
lt_item.tm_year = lt_day.tm_year; lt_item.tm_year = lt_day.tm_year;
break; break;
case RECUR_WEEKLY: case RECUR_WEEKLY:
if (lt_item.tm_wday != lt_day.tm_wday) if (lt_item.tm_wday != lt_day.tm_wday)
return (0); return (0);
else else
{ {
diff = diff_weeks (lt_item, lt_day); diff = diff_weeks (lt_item, lt_day);
if (diff % rpt_freq != 0) if (diff % rpt_freq != 0)
return (0); return (0);
} }
lt_item.tm_mday = lt_day.tm_mday; lt_item.tm_mday = lt_day.tm_mday;
lt_item.tm_mon = lt_day.tm_mon; lt_item.tm_mon = lt_day.tm_mon;
lt_item.tm_year = lt_day.tm_year; lt_item.tm_year = lt_day.tm_year;
@ -708,14 +708,14 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
case RECUR_MONTHLY: case RECUR_MONTHLY:
diff = diff_months (lt_item, lt_day); diff = diff_months (lt_item, lt_day);
if (diff % rpt_freq != 0) if (diff % rpt_freq != 0)
return (0); return (0);
lt_item.tm_mon = lt_day.tm_mon; lt_item.tm_mon = lt_day.tm_mon;
lt_item.tm_year = lt_day.tm_year; lt_item.tm_year = lt_day.tm_year;
break; break;
case RECUR_YEARLY: case RECUR_YEARLY:
diff = diff_years (lt_item, lt_day); diff = diff_years (lt_item, lt_day);
if (diff % rpt_freq != 0) if (diff % rpt_freq != 0)
return (0); return (0);
lt_item.tm_year = lt_day.tm_year; lt_item.tm_year = lt_day.tm_year;
break; break;
default: default:
@ -732,13 +732,13 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
return (0); return (0);
} }
/* /*
* Delete a recurrent event from the list (if delete_whole is not null), * Delete a recurrent event from the list (if delete_whole is not null),
* or delete only one occurence of the recurrent event. * or delete only one occurence of the recurrent event.
*/ */
void void
recur_event_erase (long start, unsigned num, unsigned delete_whole, recur_event_erase (long start, unsigned num, unsigned delete_whole,
enum eraseflg flag) enum eraseflg flag)
{ {
unsigned n = 0; unsigned n = 0;
struct recur_event *i, **iptr; struct recur_event *i, **iptr;
@ -747,16 +747,16 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
for (i = recur_elist; i != 0; i = i->next) for (i = recur_elist; i != 0; i = i->next)
{ {
if (recur_item_inday (i->day, i->exc, i->rpt->type, if (recur_item_inday (i->day, i->exc, i->rpt->type,
i->rpt->freq, i->rpt->until, start)) i->rpt->freq, i->rpt->until, start))
{ {
if (n == num) if (n == num)
{ {
if (delete_whole) if (delete_whole)
{ {
switch (flag) switch (flag)
{ {
case ERASE_FORCE_ONLY_NOTE: case ERASE_FORCE_ONLY_NOTE:
erase_note (&i->note, flag); erase_note (&i->note, flag);
break; break;
case ERASE_CUT: case ERASE_CUT:
recur_event_free_bkp (ERASE_FORCE); recur_event_free_bkp (ERASE_FORCE);
@ -764,8 +764,8 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
erase_note (&i->note, ERASE_FORCE_KEEP_NOTE); erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
*iptr = i->next; *iptr = i->next;
mem_free (i->mesg); mem_free (i->mesg);
if (i->rpt) if (i->rpt)
{ {
mem_free (i->rpt); mem_free (i->rpt);
@ -778,32 +778,32 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
} }
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT) if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
erase_note (&i->note, flag); erase_note (&i->note, flag);
mem_free (i); mem_free (i);
break; break;
} }
return; return;
} }
else else
{ {
recur_add_exc (&i->exc, start); recur_add_exc (&i->exc, start);
return; return;
} }
} }
n++; n++;
} }
iptr = &i->next; iptr = &i->next;
} }
EXIT (_("event not found")); EXIT (_("event not found"));
/* NOTREACHED */ /* NOTREACHED */
} }
/* /*
* Delete a recurrent appointment from the list (if delete_whole is not null), * Delete a recurrent appointment from the list (if delete_whole is not null),
* or delete only one occurence of the recurrent appointment. * or delete only one occurence of the recurrent appointment.
*/ */
void void
recur_apoint_erase (long start, unsigned num, unsigned delete_whole, recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
enum eraseflg flag) enum eraseflg flag)
{ {
unsigned n = 0; unsigned n = 0;
struct recur_apoint *i, **iptr; struct recur_apoint *i, **iptr;
@ -814,14 +814,14 @@ recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
for (i = recur_alist_p->root; i != 0; i = i->next) for (i = recur_alist_p->root; i != 0; i = i->next)
{ {
if (recur_item_inday (i->start, i->exc, i->rpt->type, if (recur_item_inday (i->start, i->exc, i->rpt->type,
i->rpt->freq, i->rpt->until, start)) i->rpt->freq, i->rpt->until, start))
{ {
if (n == num) if (n == num)
{ {
if (notify_bar () && flag != ERASE_FORCE_ONLY_NOTE) if (notify_bar () && flag != ERASE_FORCE_ONLY_NOTE)
need_check_notify = notify_same_recur_item (i); need_check_notify = notify_same_recur_item (i);
if (delete_whole) if (delete_whole)
{ {
switch (flag) switch (flag)
{ {
case ERASE_FORCE_ONLY_NOTE: case ERASE_FORCE_ONLY_NOTE:
@ -833,8 +833,8 @@ recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
erase_note (&i->note, ERASE_FORCE_KEEP_NOTE); erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
/* FALLTHROUGH */ /* FALLTHROUGH */
default: default:
*iptr = i->next; *iptr = i->next;
mem_free (i->mesg); mem_free (i->mesg);
if (i->rpt) if (i->rpt)
{ {
mem_free (i->rpt); mem_free (i->rpt);
@ -847,25 +847,25 @@ recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
} }
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT) if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
erase_note (&i->note, flag); erase_note (&i->note, flag);
mem_free (i); mem_free (i);
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
if (need_check_notify) if (need_check_notify)
notify_check_next_app (); notify_check_next_app ();
break; break;
} }
return; return;
} }
else else
{ {
recur_add_exc (&i->exc, start); recur_add_exc (&i->exc, start);
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
if (need_check_notify) if (need_check_notify)
notify_check_next_app (); notify_check_next_app ();
return; return;
} }
} }
n++; n++;
} }
iptr = &i->next; iptr = &i->next;
} }
EXIT (_("appointment not found")); EXIT (_("appointment not found"));
@ -921,7 +921,7 @@ recur_repeat_item (struct conf *conf)
} }
while ((ch != 'D') && (ch != 'W') && (ch != 'M') while ((ch != 'D') && (ch != 'W') && (ch != 'M')
&& (ch != 'Y') && (ch != ESCAPE)) && (ch != 'Y') && (ch != ESCAPE))
{ {
status_mesg (mesg_type_1, mesg_type_2); status_mesg (mesg_type_1, mesg_type_2);
ch = wgetch (win[STA].p); ch = wgetch (win[STA].p);
@ -941,17 +941,17 @@ recur_repeat_item (struct conf *conf)
{ {
status_mesg (mesg_freq_1, ""); status_mesg (mesg_freq_1, "");
if (getstring (win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID) if (getstring (win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID)
{ {
freq = atoi (user_input); freq = atoi (user_input);
if (freq == 0) if (freq == 0)
{ {
status_mesg (mesg_wrong_freq, wrong_type_2); status_mesg (mesg_wrong_freq, wrong_type_2);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
} }
user_input[0] = '\0'; user_input[0] = '\0';
} }
else else
return; return;
} }
while (!date_entered) while (!date_entered)
@ -960,60 +960,60 @@ recur_repeat_item (struct conf *conf)
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf->input_datefmt));
status_mesg (_(outstr), ""); status_mesg (_(outstr), "");
if (getstring (win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID) if (getstring (win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID)
{ {
if (strlen (user_input) == 1 && strncmp (user_input, "0", 1) == 0) if (strlen (user_input) == 1 && strncmp (user_input, "0", 1) == 0)
{ {
until = 0; until = 0;
date_entered = 1; date_entered = 1;
} }
else else
{ {
if (parse_date (user_input, conf->input_datefmt, if (parse_date (user_input, conf->input_datefmt,
&year, &month, &day, calendar_get_slctd_day ())) &year, &month, &day, calendar_get_slctd_day ()))
{ {
t = p->start; t = p->start;
lt = localtime (&t); lt = localtime (&t);
until_date.dd = day; until_date.dd = day;
until_date.mm = month; until_date.mm = month;
until_date.yyyy = year; until_date.yyyy = year;
until = date2sec (until_date, lt->tm_hour, lt->tm_min); until = date2sec (until_date, lt->tm_hour, lt->tm_min);
if (until < p->start) if (until < p->start)
{ {
status_mesg (mesg_older, wrong_type_2); status_mesg (mesg_older, wrong_type_2);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
date_entered = 0; date_entered = 0;
} }
else else
{ {
date_entered = 1; date_entered = 1;
} }
} }
else else
{ {
(void)snprintf (outstr, BUFSIZ, mesg_wrong_2, (void)snprintf (outstr, BUFSIZ, mesg_wrong_2,
DATEFMT_DESC (conf->input_datefmt)); DATEFMT_DESC (conf->input_datefmt));
status_mesg (mesg_wrong_1, _(outstr)); status_mesg (mesg_wrong_1, _(outstr));
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
date_entered = 0; date_entered = 0;
} }
} }
} }
else else
return; return;
} }
date = calendar_get_slctd_day_sec (); date = calendar_get_slctd_day_sec ();
if (p->type == EVNT) if (p->type == EVNT)
{ {
re = recur_event_new (p->mesg, p->note, p->start, p->evnt_id, re = recur_event_new (p->mesg, p->note, p->start, p->evnt_id,
type, freq, until, NULL); type, freq, until, NULL);
} }
else if (p->type == APPT) else if (p->type == APPT)
{ {
ra = recur_apoint_new (p->mesg, p->note, p->start, p->appt_dur, ra = recur_apoint_new (p->mesg, p->note, p->start, p->appt_dur,
p->state, type, freq, until, NULL); p->state, type, freq, until, NULL);
if (notify_bar ()) if (notify_bar ())
notify_check_repeated (ra); notify_check_repeated (ra);
} }
else else
{ {
@ -1023,7 +1023,7 @@ recur_repeat_item (struct conf *conf)
day_erase_item (date, item_nb, ERASE_FORCE_KEEP_NOTE); day_erase_item (date, item_nb, ERASE_FORCE_KEEP_NOTE);
} }
/* /*
* Read days for which recurrent items must not be repeated * Read days for which recurrent items must not be repeated
* (such days are called exceptions). * (such days are called exceptions).
*/ */
@ -1039,10 +1039,10 @@ recur_exc_scan (FILE *data_file)
{ {
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
if (fscanf (data_file, "!%u / %u / %u ", if (fscanf (data_file, "!%u / %u / %u ",
&day.tm_mon, &day.tm_mday, &day.tm_year) != 3) &day.tm_mon, &day.tm_mday, &day.tm_year) != 3)
{ {
EXIT (_("syntax error in item date")); EXIT (_("syntax error in item date"));
} }
day.tm_hour = 12; day.tm_hour = 12;
day.tm_min = day.tm_sec = 0; day.tm_min = day.tm_sec = 0;
day.tm_isdst = -1; day.tm_isdst = -1;
@ -1070,23 +1070,23 @@ recur_apoint_check_next (struct notify_app *app, long start, long day)
for (i = recur_alist_p->root; i != 0; i = i->next) for (i = recur_alist_p->root; i != 0; i = i->next)
{ {
if (i->start > app->time) if (i->start > app->time)
{ {
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
return (app); return (app);
} }
else else
{ {
real_recur_start_time = real_recur_start_time =
recur_item_inday (i->start, i->exc, i->rpt->type, i->rpt->freq, recur_item_inday (i->start, i->exc, i->rpt->type, i->rpt->freq,
i->rpt->until, day); i->rpt->until, day);
if (real_recur_start_time > start) if (real_recur_start_time > start)
{ {
app->time = real_recur_start_time; app->time = real_recur_start_time;
app->txt = mem_strdup (i->mesg); app->txt = mem_strdup (i->mesg);
app->state = i->state; app->state = i->state;
app->got_app = 1; app->got_app = 1;
} }
} }
} }
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
@ -1104,15 +1104,15 @@ recur_get_apoint (long date, int num)
for (o = recur_alist_p->root; o != 0; o = o->next) for (o = recur_alist_p->root; o != 0; o = o->next)
{ {
if (recur_item_inday (o->start, o->exc, o->rpt->type, if (recur_item_inday (o->start, o->exc, o->rpt->type,
o->rpt->freq, o->rpt->until, date)) o->rpt->freq, o->rpt->until, date))
{ {
if (n == num) if (n == num)
{ {
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
return (o); return (o);
} }
n++; n++;
} }
} }
EXIT (_("item not found")); EXIT (_("item not found"));
return 0; return 0;
@ -1129,14 +1129,14 @@ recur_get_event (long date, int num)
for (o = recur_elist; o != 0; o = o->next) for (o = recur_elist; o != 0; o = o->next)
{ {
if (recur_item_inday (o->day, o->exc, o->rpt->type, if (recur_item_inday (o->day, o->exc, o->rpt->type,
o->rpt->freq, o->rpt->until, date)) o->rpt->freq, o->rpt->until, date))
{ {
if (n == num) if (n == num)
{ {
return (o); return (o);
} }
n++; n++;
} }
} }
EXIT (_("item not found")); EXIT (_("item not found"));
return 0; return 0;
@ -1157,22 +1157,22 @@ recur_apoint_switch_notify (long date, int recur_nb)
for (o = recur_alist_p->root; o != 0; o = o->next) for (o = recur_alist_p->root; o != 0; o = o->next)
{ {
if (recur_item_inday (o->start, o->exc, o->rpt->type, if (recur_item_inday (o->start, o->exc, o->rpt->type,
o->rpt->freq, o->rpt->until, date)) o->rpt->freq, o->rpt->until, date))
{ {
if (n == recur_nb) if (n == recur_nb)
{ {
o->state ^= APOINT_NOTIFY; o->state ^= APOINT_NOTIFY;
if (notify_bar ()) if (notify_bar ())
notify_check_repeated (o); notify_check_repeated (o);
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
if (need_chk_notify) if (need_chk_notify)
notify_check_next_app (); notify_check_next_app ();
return; return;
} }
n++; n++;
} }
} }
EXIT (_("item not found")); EXIT (_("item not found"));
/* NOTREACHED */ /* NOTREACHED */
@ -1192,11 +1192,11 @@ recur_event_paste_item (void)
if (bkp_cut_recur_event.exc) if (bkp_cut_recur_event.exc)
{ {
struct days *exc; struct days *exc;
for (exc = bkp_cut_recur_event.exc; exc != 0; exc = exc->next) for (exc = bkp_cut_recur_event.exc; exc != 0; exc = exc->next)
exc->st += time_shift; exc->st += time_shift;
} }
(void)recur_event_new (bkp_cut_recur_event.mesg, bkp_cut_recur_event.note, (void)recur_event_new (bkp_cut_recur_event.mesg, bkp_cut_recur_event.note,
bkp_cut_recur_event.day, bkp_cut_recur_event.id, bkp_cut_recur_event.day, bkp_cut_recur_event.id,
bkp_cut_recur_event.rpt->type, bkp_cut_recur_event.rpt->type,
@ -1222,11 +1222,11 @@ recur_apoint_paste_item (void)
if (bkp_cut_recur_apoint.exc) if (bkp_cut_recur_apoint.exc)
{ {
struct days *exc; struct days *exc;
for (exc = bkp_cut_recur_apoint.exc; exc != 0; exc = exc->next) for (exc = bkp_cut_recur_apoint.exc; exc != 0; exc = exc->next)
exc->st += time_shift; exc->st += time_shift;
} }
(void)recur_apoint_new (bkp_cut_recur_apoint.mesg, bkp_cut_recur_apoint.note, (void)recur_apoint_new (bkp_cut_recur_apoint.mesg, bkp_cut_recur_apoint.note,
bkp_cut_recur_apoint.start, bkp_cut_recur_apoint.dur, bkp_cut_recur_apoint.start, bkp_cut_recur_apoint.dur,
bkp_cut_recur_apoint.state, bkp_cut_recur_apoint.state,

View File

@ -43,7 +43,7 @@
#include "calcurse.h" #include "calcurse.h"
/* /*
* General signal handling routine. * General signal handling routine.
* Catch return values from children (user-defined notification commands). * Catch return values from children (user-defined notification commands).
* This is needed to avoid zombie processes running on system. * This is needed to avoid zombie processes running on system.
@ -56,7 +56,7 @@ generic_hdlr (int sig)
{ {
case SIGCHLD: case SIGCHLD:
while (waitpid (WAIT_MYPGRP, NULL, WNOHANG) > 0) while (waitpid (WAIT_MYPGRP, NULL, WNOHANG) > 0)
; ;
break; break;
case SIGWINCH: case SIGWINCH:
clearok (curscr, TRUE); clearok (curscr, TRUE);
@ -98,7 +98,7 @@ sigs_init ()
{ {
if (!sigs_set_hdlr (SIGCHLD, generic_hdlr) if (!sigs_set_hdlr (SIGCHLD, generic_hdlr)
|| !sigs_set_hdlr (SIGWINCH, generic_hdlr) || !sigs_set_hdlr (SIGWINCH, generic_hdlr)
|| !sigs_set_hdlr (SIGTERM, generic_hdlr) || !sigs_set_hdlr (SIGTERM, generic_hdlr)
|| !sigs_set_hdlr (SIGINT, SIG_IGN)) || !sigs_set_hdlr (SIGINT, SIG_IGN))
exit_calcurse (1); exit_calcurse (1);
} }

View File

@ -120,9 +120,9 @@ todo_first_decrease (void)
first--; first--;
} }
/* /*
* Return the position of the hilghlighted item, relative to the first one * Return the position of the hilghlighted item, relative to the first one
* displayed. * displayed.
*/ */
int int
todo_hilt_pos (void) todo_hilt_pos (void)
@ -150,10 +150,10 @@ todo_new_item (void)
if (getstring (win[STA].p, todo_input, BUFSIZ, 0, 1) == GETSTRING_VALID) if (getstring (win[STA].p, todo_input, BUFSIZ, 0, 1) == GETSTRING_VALID)
{ {
while ((ch < '1') || (ch > '9')) while ((ch < '1') || (ch > '9'))
{ {
status_mesg (mesg_id, ""); status_mesg (mesg_id, "");
ch = wgetch (win[STA].p); ch = wgetch (win[STA].p);
} }
todo_add (todo_input, ch - '0', NULL); todo_add (todo_input, ch - '0', NULL);
todos++; todos++;
} }
@ -167,7 +167,7 @@ todo_add (char *mesg, int id, char *note)
{ {
struct todo *o, **i; struct todo *o, **i;
int absid; int absid;
o = mem_malloc (sizeof (struct todo)); o = mem_malloc (sizeof (struct todo));
o->mesg = mem_strdup (mesg); o->mesg = mem_strdup (mesg);
o->id = id; o->id = id;
@ -183,11 +183,11 @@ todo_add (char *mesg, int id, char *note)
for (;;) for (;;)
{ {
if (*i == 0 || abs ((*i)->id) > absid) if (*i == 0 || abs ((*i)->id) > absid)
{ {
o->next = *i; o->next = *i;
*i = o; *i = o;
break; break;
} }
i = &(*i)->next; i = &(*i)->next;
} }
return (o); return (o);
@ -205,12 +205,12 @@ todo_delete_note_bynum (unsigned num)
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != 0; i = i->next)
{ {
if (n == num) if (n == num)
{ {
if (i->note == NULL) if (i->note == NULL)
EXIT (_("no note attached")); EXIT (_("no note attached"));
erase_note (&i->note, ERASE_FORCE_ONLY_NOTE); erase_note (&i->note, ERASE_FORCE_ONLY_NOTE);
return; return;
} }
iptr = &i->next; iptr = &i->next;
n++; n++;
} }
@ -230,13 +230,13 @@ todo_delete_bynum (unsigned num, enum eraseflg flag)
for (i = todolist; i != 0; i = i->next) for (i = todolist; i != 0; i = i->next)
{ {
if (n == num) if (n == num)
{ {
*iptr = i->next; *iptr = i->next;
mem_free (i->mesg); mem_free (i->mesg);
erase_note (&i->note, flag); erase_note (&i->note, flag);
mem_free (i); mem_free (i);
return; return;
} }
iptr = &i->next; iptr = &i->next;
n++; n++;
} }
@ -267,7 +267,7 @@ todo_delete (struct conf *conf)
char *del_todo_str = _("Do you really want to delete this task ?"); char *del_todo_str = _("Do you really want to delete this task ?");
char *erase_warning = char *erase_warning =
_("This item has a note attached to it. " _("This item has a note attached to it. "
"Delete (t)odo or just its (n)ote ?"); "Delete (t)odo or just its (n)ote ?");
char *erase_choice = _("[t/n] "); char *erase_choice = _("[t/n] ");
unsigned go_for_todo_del = 0; unsigned go_for_todo_del = 0;
int answer, has_note; int answer, has_note;
@ -277,14 +277,14 @@ todo_delete (struct conf *conf)
status_mesg (del_todo_str, choices); status_mesg (del_todo_str, choices);
answer = wgetch (win[STA].p); answer = wgetch (win[STA].p);
if ((answer == 'y') && (todos > 0)) if ((answer == 'y') && (todos > 0))
{ {
go_for_todo_del = 1; go_for_todo_del = 1;
} }
else else
{ {
wins_erase_status_bar (); wins_erase_status_bar ();
return; return;
} }
} }
else if (todos > 0) else if (todos > 0)
go_for_todo_del = 1; go_for_todo_del = 1;
@ -312,11 +312,11 @@ todo_delete (struct conf *conf)
todo_delete_bynum (hilt - 1, ERASE_FORCE); todo_delete_bynum (hilt - 1, ERASE_FORCE);
todos--; todos--;
if (hilt > 1) if (hilt > 1)
hilt--; hilt--;
if (todos == 0) if (todos == 0)
hilt = 0; hilt = 0;
if (hilt - first < 0) if (hilt - first < 0)
first--; first--;
break; break;
case 'n': case 'n':
todo_delete_note_bynum (hilt - 1); todo_delete_note_bynum (hilt - 1);
@ -327,7 +327,7 @@ todo_delete (struct conf *conf)
} }
} }
/* /*
* Returns the position into the linked list corresponding to the * Returns the position into the linked list corresponding to the
* given todo item. * given todo item.
*/ */
@ -340,10 +340,10 @@ todo_get_position (struct todo *i)
for (o = todolist; o; o = o->next) for (o = todolist; o; o = o->next)
{ {
if (o == i) if (o == i)
{ {
found = 1; found = 1;
break; break;
} }
n++; n++;
} }
if (found) if (found)
@ -409,7 +409,7 @@ todo_edit_item (void)
/* Display todo items in the corresponding panel. */ /* Display todo items in the corresponding panel. */
static void static void
display_todo_item (int incolor, char *msg, int prio, int note, int len, int y, display_todo_item (int incolor, char *msg, int prio, int note, int len, int y,
int x) int x)
{ {
WINDOW *w; WINDOW *w;
int ch_note; int ch_note;
@ -421,7 +421,7 @@ display_todo_item (int incolor, char *msg, int prio, int note, int len, int y,
snprintf (priostr, sizeof priostr, "%d", prio); snprintf (priostr, sizeof priostr, "%d", prio);
else else
snprintf (priostr, sizeof priostr, "X"); snprintf (priostr, sizeof priostr, "X");
if (incolor == 0) if (incolor == 0)
custom_apply_attr (w, ATTR_HIGHEST); custom_apply_attr (w, ATTR_HIGHEST);
if (strlen (msg) < len) if (strlen (msg) < len)
@ -459,14 +459,14 @@ todo_update_panel (int which_pan)
t_realpos = num_todo - first; t_realpos = num_todo - first;
incolor = num_todo - hilt; incolor = num_todo - hilt;
if (incolor == 0) if (incolor == 0)
msgsav = i->mesg; msgsav = i->mesg;
if (t_realpos >= 0 && t_realpos < max_items) if (t_realpos >= 0 && t_realpos < max_items)
{ {
display_todo_item (incolor, i->mesg, i->id, display_todo_item (incolor, i->mesg, i->id,
(i->note != NULL) ? 1 : 0, len, y_offset, (i->note != NULL) ? 1 : 0, len, y_offset,
x_offset); x_offset);
y_offset = y_offset + todo_lines; y_offset = y_offset + todo_lines;
} }
} }
/* Draw the scrollbar if necessary. */ /* Draw the scrollbar if necessary. */
@ -479,9 +479,9 @@ todo_update_panel (int which_pan)
int sbar_top = highend + title_lines; int sbar_top = highend + title_lines;
if ((sbar_top + sbar_length) > win[TOD].h - 1) if ((sbar_top + sbar_length) > win[TOD].h - 1)
sbar_length = win[TOD].h - 1 - sbar_top; sbar_length = win[TOD].h - 1 - sbar_top;
draw_scrollbar (win[TOD].p, sbar_top, win[TOD].w - 2, draw_scrollbar (win[TOD].p, sbar_top, win[TOD].w - 2,
sbar_length, title_lines, win[TOD].h - 1, hilt_bar); sbar_length, title_lines, win[TOD].h - 1, hilt_bar);
} }
wnoutrefresh (win[TOD].p); wnoutrefresh (win[TOD].p);
@ -499,9 +499,9 @@ todo_edit_note (char *editor)
if (i->note == NULL) if (i->note == NULL)
{ {
if ((filename = new_tempfile (path_notes, NOTESIZ)) != NULL) if ((filename = new_tempfile (path_notes, NOTESIZ)) != NULL)
i->note = filename; i->note = filename;
else else
return; return;
} }
(void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, i->note); (void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, i->note);
wins_launch_external (fullname, editor); wins_launch_external (fullname, editor);

View File

@ -52,7 +52,7 @@ void
exit_calcurse (int status) exit_calcurse (int status)
{ {
int was_interactive; int was_interactive;
if (ui_mode == UI_CURSES) if (ui_mode == UI_CURSES)
{ {
notify_stop_main_thread (); notify_stop_main_thread ();
@ -64,7 +64,7 @@ exit_calcurse (int status)
} }
else else
was_interactive = 0; was_interactive = 0;
calendar_stop_date_thread (); calendar_stop_date_thread ();
io_stop_psave_thread (); io_stop_psave_thread ();
free_user_data (); free_user_data ();
@ -78,7 +78,7 @@ exit_calcurse (int status)
if (dmon.enable) if (dmon.enable)
dmon_start (status); dmon_start (status);
} }
exit (status); exit (status);
} }
@ -112,7 +112,7 @@ fatalbox (const char *errmsg)
if (errmsg == 0) if (errmsg == 0)
return; return;
(void)strncpy (msg, errmsg, MSGLEN); (void)strncpy (msg, errmsg, MSGLEN);
errwin = newwin (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2); errwin = newwin (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
custom_apply_attr (errwin, ATTR_HIGHEST); custom_apply_attr (errwin, ATTR_HIGHEST);
@ -132,14 +132,14 @@ warnbox (const char *msg)
{ {
WINDOW *warnwin; WINDOW *warnwin;
char *label = "/!\\"; char *label = "/!\\";
const int WINROW = 10; const int WINROW = 10;
const int WINCOL = col - 2; const int WINCOL = col - 2;
const int MSGLEN = WINCOL - 2; const int MSGLEN = WINCOL - 2;
char displmsg[MSGLEN]; char displmsg[MSGLEN];
if (msg == 0) if (msg == 0)
return; return;
(void)strncpy (displmsg, msg, MSGLEN); (void)strncpy (displmsg, msg, MSGLEN);
warnwin = newwin (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2); warnwin = newwin (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
custom_apply_attr (warnwin, ATTR_HIGHEST); custom_apply_attr (warnwin, ATTR_HIGHEST);
@ -153,7 +153,7 @@ warnbox (const char *msg)
wins_doupdate (); wins_doupdate ();
} }
/* /*
* Print a message in the status bar. * Print a message in the status bar.
* Message texts for first line and second line are to be provided. * Message texts for first line and second line are to be provided.
*/ */
@ -204,7 +204,7 @@ popup (int pop_row, int pop_col, int pop_y, int pop_x, char *title, char *msg,
any_key); any_key);
custom_remove_attr (popup_win, ATTR_HIGHEST); custom_remove_attr (popup_win, ATTR_HIGHEST);
wins_wrefresh (popup_win); wins_wrefresh (popup_win);
return popup_win; return popup_win;
} }
@ -275,7 +275,7 @@ bell (void)
printf ("\a"); printf ("\a");
} }
/* /*
* Getstring allows to get user input and to print it on a window, * Getstring allows to get user input and to print it on a window,
* even if noecho() is on. This function is also used to modify an existing * even if noecho() is on. This function is also used to modify an existing
* text (the variable string can be non-NULL). * text (the variable string can be non-NULL).
@ -319,7 +319,7 @@ getstring (WINDOW *win, char *str, int l, int x, int y)
del_char (curpos, str); del_char (curpos, str);
len--; len--;
} }
else bell (); else bell ();
break; break;
case CTRL ('W'): /* delete a word */ case CTRL ('W'): /* delete a word */
if (curpos > 0) { if (curpos > 0) {
@ -377,7 +377,7 @@ updatestring (WINDOW *win, char **str, int x, int y)
enum getstr ret; enum getstr ret;
EXIT_IF (len + 1 > BUFSIZ, _("Internal error: line too long")); EXIT_IF (len + 1 > BUFSIZ, _("Internal error: line too long"));
buf = mem_malloc (BUFSIZ); buf = mem_malloc (BUFSIZ);
(void)memcpy (buf, *str, len + 1); (void)memcpy (buf, *str, len + 1);
@ -470,7 +470,7 @@ date_sec2date_fmt (long sec, const char *fmt, char *datef)
strftime (datef, BUFSIZ, fmt, lt); strftime (datef, BUFSIZ, fmt, lt);
} }
/* /*
* Used to change date by adding a certain amount of days or weeks. * Used to change date by adding a certain amount of days or weeks.
*/ */
long long
@ -478,7 +478,7 @@ date_sec_change (long date, int delta_month, int delta_day)
{ {
struct tm *lt; struct tm *lt;
time_t t; time_t t;
t = date; t = date;
lt = localtime (&t); lt = localtime (&t);
lt->tm_mon += delta_month; lt->tm_mon += delta_month;
@ -490,7 +490,7 @@ date_sec_change (long date, int delta_month, int delta_day)
return t; return t;
} }
/* /*
* Return a long containing the date which is updated taking into account * Return a long containing the date which is updated taking into account
* the new time and date entered by the user. * the new time and date entered by the user.
*/ */
@ -510,7 +510,7 @@ update_time_in_date (long date, unsigned hr, unsigned mn)
return (new_date); return (new_date);
} }
/* /*
* Returns the date in seconds from year 1900. * Returns the date in seconds from year 1900.
* If no date is entered, current date is chosen. * If no date is entered, current date is chosen.
*/ */
@ -545,11 +545,11 @@ min2sec (unsigned minutes)
return (minutes * MININSEC); return (minutes * MININSEC);
} }
/* /*
* Checks if a time has a good format. * Checks if a time has a good format.
* The format could be either HH:MM or H:MM or MM, and we should have: * The format could be either HH:MM or H:MM or MM, and we should have:
* 0 <= HH <= 24 and 0 <= MM < 999. * 0 <= HH <= 24 and 0 <= MM < 999.
* This function returns 1 if the entered time is correct and in * This function returns 1 if the entered time is correct and in
* [h:mm] or [hh:mm] format, and 2 if the entered time is correct and entered * [h:mm] or [hh:mm] format, and 2 if the entered time is correct and entered
* in [mm] format. * in [mm] format.
*/ */
@ -579,7 +579,7 @@ check_time (char *string)
*/ */
void void
draw_scrollbar (WINDOW *win, int y, int x, int length, draw_scrollbar (WINDOW *win, int y, int x, int length,
int bar_top, int bar_bottom, unsigned hilt) int bar_top, int bar_bottom, unsigned hilt)
{ {
mvwvline (win, bar_top, x, ACS_VLINE, bar_bottom - bar_top); mvwvline (win, bar_top, x, ACS_VLINE, bar_bottom - bar_top);
if (hilt) if (hilt)
@ -592,13 +592,13 @@ draw_scrollbar (WINDOW *win, int y, int x, int length,
} }
/* /*
* Print an item (either an appointment, event, or todo) in a * Print an item (either an appointment, event, or todo) in a
* popup window. This is useful if an item description is too * popup window. This is useful if an item description is too
* long to fit in its corresponding panel window. * long to fit in its corresponding panel window.
*/ */
void void
item_in_popup (char *saved_a_start, char *saved_a_end, char *msg, item_in_popup (char *saved_a_start, char *saved_a_end, char *msg,
char *pop_title) char *pop_title)
{ {
WINDOW *popup_win, *pad; WINDOW *popup_win, *pad;
const int margin_left = 4, margin_top = 4; const int margin_left = 4, margin_top = 4;
@ -610,7 +610,7 @@ item_in_popup (char *saved_a_start, char *saved_a_end, char *msg,
if (strncmp (pop_title, _("Appointment"), 11) == 0) if (strncmp (pop_title, _("Appointment"), 11) == 0)
{ {
mvwprintw (popup_win, margin_top, margin_left, "- %s -> %s", mvwprintw (popup_win, margin_top, margin_left, "- %s -> %s",
saved_a_start, saved_a_end); saved_a_start, saved_a_end);
} }
mvwprintw (pad, 0, margin_left, "%s", msg); mvwprintw (pad, 0, margin_left, "%s", msg);
wmove (win[STA].p, 0, 0); wmove (win[STA].p, 0, 0);
@ -650,7 +650,7 @@ now (void)
char * char *
nowstr (void) nowstr (void)
{ {
static char buf[BUFSIZ]; static char buf[BUFSIZ];
time_t t = now (); time_t t = now ();
(void)strftime (buf, sizeof buf, "%a %b %d %T %Y", localtime (&t)); (void)strftime (buf, sizeof buf, "%a %b %d %T %Y", localtime (&t));
@ -701,9 +701,9 @@ print_bool_option_incolor (WINDOW *win, unsigned option, int pos_y, int pos_x)
wins_doupdate (); wins_doupdate ();
} }
/* /*
* Create a new unique file, and return a newly allocated string which contains * Create a new unique file, and return a newly allocated string which contains
* the random part of the file name. * the random part of the file name.
*/ */
char * char *
new_tempfile (const char *prefix, int trailing_len) new_tempfile (const char *prefix, int trailing_len)
@ -724,10 +724,10 @@ new_tempfile (const char *prefix, int trailing_len)
if ((fd = mkstemp (fullname)) == -1 || (file = fdopen (fd, "w+")) == NULL) if ((fd = mkstemp (fullname)) == -1 || (file = fdopen (fd, "w+")) == NULL)
{ {
if (fd != -1) if (fd != -1)
{ {
unlink (fullname); unlink (fullname);
close (fd); close (fd);
} }
ERROR_MSG (_("temporary file \"%s\" could not be created"), fullname); ERROR_MSG (_("temporary file \"%s\" could not be created"), fullname);
return (char *)0; return (char *)0;
} }

View File

@ -84,9 +84,9 @@ char *daynames[8] = {
N_("Sun") N_("Sun")
}; };
/* /*
* variables to store data path names, which are initialized in * variables to store data path names, which are initialized in
* io_init() * io_init()
*/ */
char path_dir[] = ""; char path_dir[] = "";
char path_todo[] = ""; char path_todo[] = "";
@ -108,7 +108,7 @@ struct nbar nbar;
struct dmon_conf dmon; struct dmon_conf dmon;
/* /*
* Variables init * Variables init
*/ */
void void
vars_init (struct conf *conf) vars_init (struct conf *conf)

View File

@ -82,7 +82,7 @@ int
wins_refresh (void) wins_refresh (void)
{ {
int rc; int rc;
if (!screen_acquire ()) if (!screen_acquire ())
return ERR; return ERR;
rc = refresh (); rc = refresh ();
@ -95,7 +95,7 @@ int
wins_wrefresh (WINDOW *win) wins_wrefresh (WINDOW *win)
{ {
int rc; int rc;
if (!win || !screen_acquire ()) if (!win || !screen_acquire ())
return ERR; return ERR;
rc = wrefresh (win); rc = wrefresh (win);
@ -148,7 +148,7 @@ wins_sbar_wperc (void)
unsigned perc; unsigned perc;
perc = col ? (unsigned)(100 * sbarwidth / col + 1): 0; perc = col ? (unsigned)(100 * sbarwidth / col + 1): 0;
return perc > SBARMAXWIDTHPERC ? SBARMAXWIDTHPERC : perc; return perc > SBARMAXWIDTHPERC ? SBARMAXWIDTHPERC : perc;
} }
@ -225,7 +225,7 @@ static void
wins_init_panels (void) wins_init_panels (void)
{ {
char label[BUFSIZ]; char label[BUFSIZ];
win[CAL].p = newwin (CALHEIGHT, wins_sbar_width (), win[CAL].y, win[CAL].x); win[CAL].p = newwin (CALHEIGHT, wins_sbar_width (), win[CAL].y, win[CAL].x);
(void)snprintf (label, BUFSIZ, _("Calendar")); (void)snprintf (label, BUFSIZ, _("Calendar"));
wins_show (win[CAL].p, label); wins_show (win[CAL].p, label);
@ -240,7 +240,7 @@ wins_init_panels (void)
(void)snprintf (label, BUFSIZ, _("ToDo")); (void)snprintf (label, BUFSIZ, _("ToDo"));
wins_show (win[TOD].p, label); wins_show (win[TOD].p, label);
/* Enable function keys (i.e. arrow keys) in those windows */ /* Enable function keys (i.e. arrow keys) in those windows */
keypad (win[CAL].p, TRUE); keypad (win[CAL].p, TRUE);
keypad (win[APP].p, TRUE); keypad (win[APP].p, TRUE);
keypad (win[TOD].p, TRUE); keypad (win[TOD].p, TRUE);
@ -259,7 +259,7 @@ wins_init (void)
ui_mode = UI_CURSES; ui_mode = UI_CURSES;
} }
/* /*
* Create a new window and its associated pad, which is used to make the * Create a new window and its associated pad, which is used to make the
* scrolling faster. * scrolling faster.
*/ */
@ -287,7 +287,7 @@ void
wins_scrollwin_display (struct scrollwin *sw) wins_scrollwin_display (struct scrollwin *sw)
{ {
const int visible_lines = sw->win.h - sw->pad.y - 1; const int visible_lines = sw->win.h - sw->pad.y - 1;
if (sw->total_lines > visible_lines) if (sw->total_lines > visible_lines)
{ {
float ratio = ((float) visible_lines) / ((float) sw->total_lines); float ratio = ((float) visible_lines) / ((float) sw->total_lines);
@ -333,7 +333,7 @@ wins_reinit_panels (void)
wins_init_panels (); wins_init_panels ();
} }
/* /*
* Delete the existing windows and recreate them with their new * Delete the existing windows and recreate them with their new
* size and placement. * size and placement.
*/ */
@ -368,7 +368,7 @@ wins_show (WINDOW *win, char *label)
print_in_middle (win, 1, 0, width, label); print_in_middle (win, 1, 0, width, label);
} }
/* /*
* Get the screen size and recalculate the windows configurations. * Get the screen size and recalculate the windows configurations.
*/ */
void void
@ -400,7 +400,7 @@ wins_get_config (void)
win[CAL].w = wins_sbar_width (); win[CAL].w = wins_sbar_width ();
win[CAL].h = CALHEIGHT; win[CAL].h = CALHEIGHT;
if (layout <= 4) if (layout <= 4)
{ /* APPOINTMENT is the biggest panel */ { /* APPOINTMENT is the biggest panel */
win[APP].w = col - win[CAL].w; win[APP].w = col - win[CAL].w;
@ -575,7 +575,7 @@ wins_update_panels (void)
calendar_update_panel (&win[CAL]); calendar_update_panel (&win[CAL]);
} }
/* /*
* Update all of the three windows and put a border around the * Update all of the three windows and put a border around the
* selected window. * selected window.
*/ */
@ -613,7 +613,7 @@ wins_launch_external (const char *file, const char *cmd)
int len; int len;
/* Beware of space between cmd and file. */ /* Beware of space between cmd and file. */
len = strlen (file) + strlen (cmd) + 2; len = strlen (file) + strlen (cmd) + 2;
p = (char *) mem_calloc (len, sizeof (char)); p = (char *) mem_calloc (len, sizeof (char));
if (snprintf (p, len, "%s %s", cmd, file) == -1) if (snprintf (p, len, "%s %s", cmd, file) == -1)
@ -643,12 +643,12 @@ wins_launch_external (const char *file, const char *cmd)
#define NB_APP_CMDS 31 /* same thing while in appointment view */ #define NB_APP_CMDS 31 /* same thing while in appointment view */
#define NB_TOD_CMDS 30 /* same thing while in todo view */ #define NB_TOD_CMDS 30 /* same thing while in todo view */
#define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS #define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS
#define CMDS_PER_LINE 6 /* max number of commands per line */ #define CMDS_PER_LINE 6 /* max number of commands per line */
static unsigned status_page; static unsigned status_page;
/* /*
* Draws the status bar. * Draws the status bar.
* To add a keybinding, insert a new binding_t item, add it in the *binding * To add a keybinding, insert a new binding_t item, add it in the *binding
* table, and update the NB_CAL_CMDS, NB_APP_CMDS or NB_TOD_CMDS defines, * table, and update the NB_CAL_CMDS, NB_APP_CMDS or NB_TOD_CMDS defines,
* depending on which panel the added keybind is assigned to. * depending on which panel the added keybind is assigned to.
@ -666,13 +666,13 @@ wins_status_bar (void)
struct binding quit = {_("Quit"), KEY_GENERIC_QUIT}; struct binding quit = {_("Quit"), KEY_GENERIC_QUIT};
struct binding save = {_("Save"), KEY_GENERIC_SAVE}; struct binding save = {_("Save"), KEY_GENERIC_SAVE};
struct binding cut = {_("Cut"), KEY_GENERIC_CUT}; struct binding cut = {_("Cut"), KEY_GENERIC_CUT};
struct binding paste = {_("Paste"), KEY_GENERIC_PASTE}; struct binding paste = {_("Paste"), KEY_GENERIC_PASTE};
struct binding chgvu = {_("Chg Win"), KEY_GENERIC_CHANGE_VIEW}; struct binding chgvu = {_("Chg Win"), KEY_GENERIC_CHANGE_VIEW};
struct binding import = {_("Import"), KEY_GENERIC_IMPORT}; struct binding import = {_("Import"), KEY_GENERIC_IMPORT};
struct binding export = {_("Export"), KEY_GENERIC_EXPORT}; struct binding export = {_("Export"), KEY_GENERIC_EXPORT};
struct binding togo = {_("Go to"), KEY_GENERIC_GOTO}; struct binding togo = {_("Go to"), KEY_GENERIC_GOTO};
struct binding othr = {_("OtherCmd"), KEY_GENERIC_OTHER_CMD}; struct binding othr = {_("OtherCmd"), KEY_GENERIC_OTHER_CMD};
struct binding conf = {_("Config"), KEY_GENERIC_CONFIG_MENU}; struct binding conf = {_("Config"), KEY_GENERIC_CONFIG_MENU};
struct binding draw = {_("Redraw"), KEY_GENERIC_REDRAW}; struct binding draw = {_("Redraw"), KEY_GENERIC_REDRAW};
struct binding appt = {_("Add Appt"), KEY_GENERIC_ADD_APPT}; struct binding appt = {_("Add Appt"), KEY_GENERIC_ADD_APPT};
struct binding todo = {_("Add Todo"), KEY_GENERIC_ADD_TODO}; struct binding todo = {_("Add Todo"), KEY_GENERIC_ADD_TODO};
@ -684,22 +684,22 @@ wins_status_bar (void)
struct binding nview = {_("Nxt View"), KEY_GENERIC_SCROLL_DOWN}; struct binding nview = {_("Nxt View"), KEY_GENERIC_SCROLL_DOWN};
struct binding pview = {_("Prv View"), KEY_GENERIC_SCROLL_UP}; struct binding pview = {_("Prv View"), KEY_GENERIC_SCROLL_UP};
struct binding up = {_("Up"), KEY_MOVE_UP}; struct binding up = {_("Up"), KEY_MOVE_UP};
struct binding down = {_("Down"), KEY_MOVE_DOWN}; struct binding down = {_("Down"), KEY_MOVE_DOWN};
struct binding left = {_("Left"), KEY_MOVE_LEFT}; struct binding left = {_("Left"), KEY_MOVE_LEFT};
struct binding right = {_("Right"), KEY_MOVE_RIGHT}; struct binding right = {_("Right"), KEY_MOVE_RIGHT};
struct binding weekb = {_("beg Week"), KEY_START_OF_WEEK}; struct binding weekb = {_("beg Week"), KEY_START_OF_WEEK};
struct binding weeke = {_("end Week"), KEY_END_OF_WEEK}; struct binding weeke = {_("end Week"), KEY_END_OF_WEEK};
struct binding add = {_("Add Item"), KEY_ADD_ITEM}; struct binding add = {_("Add Item"), KEY_ADD_ITEM};
struct binding del = {_("Del Item"), KEY_DEL_ITEM}; struct binding del = {_("Del Item"), KEY_DEL_ITEM};
struct binding edit = {_("Edit Itm"), KEY_EDIT_ITEM}; struct binding edit = {_("Edit Itm"), KEY_EDIT_ITEM};
struct binding view = {_("View"), KEY_VIEW_ITEM}; struct binding view = {_("View"), KEY_VIEW_ITEM};
struct binding flag = {_("Flag Itm"), KEY_FLAG_ITEM}; struct binding flag = {_("Flag Itm"), KEY_FLAG_ITEM};
struct binding rept = {_("Repeat"), KEY_REPEAT_ITEM}; struct binding rept = {_("Repeat"), KEY_REPEAT_ITEM};
struct binding enote = {_("EditNote"), KEY_EDIT_NOTE}; struct binding enote = {_("EditNote"), KEY_EDIT_NOTE};
struct binding vnote = {_("ViewNote"), KEY_VIEW_NOTE}; struct binding vnote = {_("ViewNote"), KEY_VIEW_NOTE};
struct binding rprio = {_("Prio.+"), KEY_RAISE_PRIORITY}; struct binding rprio = {_("Prio.+"), KEY_RAISE_PRIORITY};
struct binding lprio = {_("Prio.-"), KEY_LOWER_PRIORITY}; struct binding lprio = {_("Prio.-"), KEY_LOWER_PRIORITY};
struct binding *binding[TOTAL_CMDS] = { struct binding *binding[TOTAL_CMDS] = {
/* calendar keys */ /* calendar keys */
&help, &quit, &save, &chgvu, &nview, &pview, &up, &down, &left, &right, &help, &quit, &save, &chgvu, &nview, &pview, &up, &down, &left, &right,