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));
@ -186,22 +186,22 @@ 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,
@ -212,35 +212,35 @@ apoint_add (void)
{ /* 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;
} }
} }
} }
@ -488,11 +488,11 @@ 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;
@ -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,22 +527,22 @@ 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;
} }
@ -619,20 +619,20 @@ 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));
@ -687,22 +687,22 @@ 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));
@ -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

@ -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);
@ -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__);
} }
@ -374,53 +374,53 @@ app_arg (int add_line, struct date *day, long date, int print_note,
{ {
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));
@ -557,12 +557,12 @@ date_arg (char *ddate, int add_line, int print_note, struct conf *conf,
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
@ -577,19 +577,19 @@ 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 ();
} }
} }
} }
@ -616,28 +616,28 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
{ {
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)
{ {
@ -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,19 +862,19 @@ 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);
@ -882,13 +882,13 @@ parse_args (int argc, char **argv, struct conf *conf)
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);
@ -900,32 +900,32 @@ 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_check_file (path_apts, (int *)0);
io_load_app (); io_load_app ();
next_arg (); next_arg ();
non_interactive = 1; non_interactive = 1;
} }
if (dflag || rflag || sflag) 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_check_file (path_conf, (int *)0);
io_load_app (); io_load_app ();
@ -935,27 +935,27 @@ 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)

View File

@ -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] ";
@ -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 */
@ -169,110 +169,110 @@ main (int argc, char **argv)
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)
@ -353,54 +353,54 @@ main (int argc, char **argv)
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 ();
@ -412,55 +412,55 @@ main (int argc, char **argv)
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:
@ -525,45 +525,45 @@ main (int argc, char **argv)
break; break;
case KEY_GENERIC_QUIT: case KEY_GENERIC_QUIT:
if (conf.auto_save) if (conf.auto_save)
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR); io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
if (conf.confirm_quit) if (conf.confirm_quit)
{ {
status_mesg (_(quit_message), choices); status_mesg (_(quit_message), choices);
key = wgetch (win[STA].p); key = wgetch (win[STA].p);
if (key == 'y') if (key == 'y')
exit_calcurse (EXIT_SUCCESS); exit_calcurse (EXIT_SUCCESS);
else else
{ {
wins_erase_status_bar (); wins_erase_status_bar ();
break; break;
} }
} }
else else
exit_calcurse (EXIT_SUCCESS); exit_calcurse (EXIT_SUCCESS);
break; break;
default: default:
do_update = 0; do_update = 0;
break; 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

@ -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);
} }
@ -515,7 +515,7 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
/* 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. */
@ -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:
@ -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 */

View File

@ -106,37 +106,37 @@ custom_load_color (char *color, int background)
{ {
/* New version configuration */ /* New version configuration */
if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS) if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS)
{ {
EXIT (_("missing colors in config file")); EXIT (_("missing colors in config file"));
/* NOTREACHED */ /* NOTREACHED */
} }
for (i = 0; i < AWAITED_COLORS; i++) for (i = 0; i < AWAITED_COLORS; i++)
{ {
if (!strncmp (c[i], "black", 5)) if (!strncmp (c[i], "black", 5))
colr[i] = COLOR_BLACK; colr[i] = COLOR_BLACK;
else if (!strncmp (c[i], "red", 3)) else if (!strncmp (c[i], "red", 3))
colr[i] = COLOR_RED; colr[i] = COLOR_RED;
else if (!strncmp (c[i], "green", 5)) else if (!strncmp (c[i], "green", 5))
colr[i] = COLOR_GREEN; colr[i] = COLOR_GREEN;
else if (!strncmp (c[i], "yellow", 6)) else if (!strncmp (c[i], "yellow", 6))
colr[i] = COLOR_YELLOW; colr[i] = COLOR_YELLOW;
else if (!strncmp (c[i], "blue", 4)) else if (!strncmp (c[i], "blue", 4))
colr[i] = COLOR_BLUE; colr[i] = COLOR_BLUE;
else if (!strncmp (c[i], "magenta", 7)) else if (!strncmp (c[i], "magenta", 7))
colr[i] = COLOR_MAGENTA; colr[i] = COLOR_MAGENTA;
else if (!strncmp (c[i], "cyan", 4)) else if (!strncmp (c[i], "cyan", 4))
colr[i] = COLOR_CYAN; colr[i] = COLOR_CYAN;
else if (!strncmp (c[i], "white", 5)) else if (!strncmp (c[i], "white", 5))
colr[i] = COLOR_WHITE; colr[i] = COLOR_WHITE;
else if (!strncmp (c[i], "default", 7)) else if (!strncmp (c[i], "default", 7))
colr[i] = background; colr[i] = background;
else else
{ {
EXIT (_("wrong color name")); EXIT (_("wrong color name"));
/* NOTREACHED */ /* NOTREACHED */
} }
} }
init_pair (COLR_CUSTOM, colr[0], colr[1]); init_pair (COLR_CUSTOM, colr[0], colr[1]);
} }
else if (len > 0 && len < 2) else if (len > 0 && len < 2)
@ -145,38 +145,38 @@ custom_load_color (char *color, int background)
color_num = atoi (color); color_num = atoi (color);
switch (color_num) switch (color_num)
{ {
case 0: case 0:
colorize = 0; colorize = 0;
break; break;
case 1: case 1:
init_pair (COLR_CUSTOM, COLOR_RED, background); init_pair (COLR_CUSTOM, COLOR_RED, background);
break; break;
case 2: case 2:
init_pair (COLR_CUSTOM, COLOR_GREEN, background); init_pair (COLR_CUSTOM, COLOR_GREEN, background);
break; break;
case 3: case 3:
init_pair (COLR_CUSTOM, COLOR_BLUE, background); init_pair (COLR_CUSTOM, COLOR_BLUE, background);
break; break;
case 4: case 4:
init_pair (COLR_CUSTOM, COLOR_CYAN, background); init_pair (COLR_CUSTOM, COLOR_CYAN, background);
break; break;
case 5: case 5:
init_pair (COLR_CUSTOM, COLOR_YELLOW, background); init_pair (COLR_CUSTOM, COLOR_YELLOW, background);
break; break;
case 6: case 6:
init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_GREEN); init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_GREEN);
break; break;
case 7: case 7:
init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_YELLOW); init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_YELLOW);
break; break;
case 8: case 8:
init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE); init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
break; break;
default: default:
EXIT (_("wrong color number")); EXIT (_("wrong color number"));
/* NOTREACHED */ /* NOTREACHED */
} }
} }
else else
{ {
@ -256,144 +256,144 @@ custom_load_conf (struct conf *conf, int background)
for (;;) for (;;)
{ {
if (fgets (buf, sizeof buf, data_file) == NULL) if (fgets (buf, sizeof buf, data_file) == NULL)
{ {
break; break;
} }
io_extract_data (e_conf, buf, sizeof buf); io_extract_data (e_conf, buf, sizeof buf);
switch (var) switch (var)
{ {
case CUSTOM_CONF_NOVARIABLE: case CUSTOM_CONF_NOVARIABLE:
break; break;
case CUSTOM_CONF_AUTOSAVE: case CUSTOM_CONF_AUTOSAVE:
conf->auto_save = fill_config_var (e_conf); conf->auto_save = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_PERIODICSAVE: case CUSTOM_CONF_PERIODICSAVE:
conf->periodic_save = atoi (e_conf); conf->periodic_save = atoi (e_conf);
if (conf->periodic_save < 0) if (conf->periodic_save < 0)
conf->periodic_save = 0; conf->periodic_save = 0;
var = 0; var = 0;
break; break;
case CUSTOM_CONF_CONFIRMQUIT: case CUSTOM_CONF_CONFIRMQUIT:
conf->confirm_quit = fill_config_var (e_conf); conf->confirm_quit = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_CONFIRMDELETE: case CUSTOM_CONF_CONFIRMDELETE:
conf->confirm_delete = fill_config_var (e_conf); conf->confirm_delete = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_SKIPSYSTEMDIALOGS: case CUSTOM_CONF_SKIPSYSTEMDIALOGS:
conf->skip_system_dialogs = fill_config_var (e_conf); conf->skip_system_dialogs = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_SKIPPROGRESSBAR: case CUSTOM_CONF_SKIPPROGRESSBAR:
conf->skip_progress_bar = fill_config_var (e_conf); conf->skip_progress_bar = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_CALENDAR_DEFAULTVIEW: case CUSTOM_CONF_CALENDAR_DEFAULTVIEW:
calendar_set_view (atoi (e_conf)); calendar_set_view (atoi (e_conf));
var = 0; var = 0;
break; break;
case CUSTOM_CONF_WEEKBEGINSONMONDAY: case CUSTOM_CONF_WEEKBEGINSONMONDAY:
if (fill_config_var (e_conf)) if (fill_config_var (e_conf))
calendar_set_first_day_of_week (MONDAY); calendar_set_first_day_of_week (MONDAY);
else else
calendar_set_first_day_of_week (SUNDAY); calendar_set_first_day_of_week (SUNDAY);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_COLORTHEME: case CUSTOM_CONF_COLORTHEME:
custom_load_color (e_conf, background); custom_load_color (e_conf, background);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_LAYOUT: case CUSTOM_CONF_LAYOUT:
wins_set_layout (atoi (e_conf)); wins_set_layout (atoi (e_conf));
var = 0; var = 0;
break; break;
case CUSTOM_CONF_SBAR_WIDTH: case CUSTOM_CONF_SBAR_WIDTH:
wins_set_sbar_width (atoi (e_conf)); wins_set_sbar_width (atoi (e_conf));
var = 0; var = 0;
break; break;
case CUSTOM_CONF_NOTIFYBARSHOW: case CUSTOM_CONF_NOTIFYBARSHOW:
nbar.show = fill_config_var (e_conf); nbar.show = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_NOTIFYBARDATE: case CUSTOM_CONF_NOTIFYBARDATE:
(void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1); (void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_NOTIFYBARCLOCK: case CUSTOM_CONF_NOTIFYBARCLOCK:
(void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1); (void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_NOTIFYBARWARNING: case CUSTOM_CONF_NOTIFYBARWARNING:
nbar.cntdwn = atoi (e_conf); nbar.cntdwn = atoi (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_NOTIFYBARCOMMAND: case CUSTOM_CONF_NOTIFYBARCOMMAND:
(void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1); (void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_OUTPUTDATEFMT: case CUSTOM_CONF_OUTPUTDATEFMT:
if (e_conf[0] != '\0') if (e_conf[0] != '\0')
(void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1); (void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_INPUTDATEFMT: case CUSTOM_CONF_INPUTDATEFMT:
conf->input_datefmt = atoi (e_conf); conf->input_datefmt = atoi (e_conf);
if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS) if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS)
conf->input_datefmt = 1; conf->input_datefmt = 1;
var = 0; var = 0;
break; break;
case CUSTOM_CONF_DMON_ENABLE: case CUSTOM_CONF_DMON_ENABLE:
dmon.enable = fill_config_var (e_conf); dmon.enable = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
case CUSTOM_CONF_DMON_LOG: case CUSTOM_CONF_DMON_LOG:
dmon.log = fill_config_var (e_conf); dmon.log = fill_config_var (e_conf);
var = 0; var = 0;
break; break;
default: default:
EXIT (_("configuration variable unknown")); EXIT (_("configuration variable unknown"));
/* NOTREACHED */ /* NOTREACHED */
} }
if (strncmp (e_conf, "auto_save=", 10) == 0) if (strncmp (e_conf, "auto_save=", 10) == 0)
var = CUSTOM_CONF_AUTOSAVE; var = CUSTOM_CONF_AUTOSAVE;
else if (strncmp (e_conf, "periodic_save=", 14) == 0) else if (strncmp (e_conf, "periodic_save=", 14) == 0)
var = CUSTOM_CONF_PERIODICSAVE; var = CUSTOM_CONF_PERIODICSAVE;
else if (strncmp (e_conf, "confirm_quit=", 13) == 0) else if (strncmp (e_conf, "confirm_quit=", 13) == 0)
var = CUSTOM_CONF_CONFIRMQUIT; var = CUSTOM_CONF_CONFIRMQUIT;
else if (strncmp (e_conf, "confirm_delete=", 15) == 0) else if (strncmp (e_conf, "confirm_delete=", 15) == 0)
var = CUSTOM_CONF_CONFIRMDELETE; var = CUSTOM_CONF_CONFIRMDELETE;
else if (strncmp (e_conf, "skip_system_dialogs=", 20) == 0) else if (strncmp (e_conf, "skip_system_dialogs=", 20) == 0)
var = CUSTOM_CONF_SKIPSYSTEMDIALOGS; var = CUSTOM_CONF_SKIPSYSTEMDIALOGS;
else if (strncmp (e_conf, "skip_progress_bar=", 18) == 0) else if (strncmp (e_conf, "skip_progress_bar=", 18) == 0)
var = CUSTOM_CONF_SKIPPROGRESSBAR; var = CUSTOM_CONF_SKIPPROGRESSBAR;
else if (strncmp (e_conf, "calendar_default_view=", 22) == 0) else if (strncmp (e_conf, "calendar_default_view=", 22) == 0)
var = CUSTOM_CONF_CALENDAR_DEFAULTVIEW; var = CUSTOM_CONF_CALENDAR_DEFAULTVIEW;
else if (strncmp (e_conf, "week_begins_on_monday=", 22) == 0) else if (strncmp (e_conf, "week_begins_on_monday=", 22) == 0)
var = CUSTOM_CONF_WEEKBEGINSONMONDAY; var = CUSTOM_CONF_WEEKBEGINSONMONDAY;
else if (strncmp (e_conf, "color-theme=", 12) == 0) else if (strncmp (e_conf, "color-theme=", 12) == 0)
var = CUSTOM_CONF_COLORTHEME; var = CUSTOM_CONF_COLORTHEME;
else if (strncmp (e_conf, "layout=", 7) == 0) else if (strncmp (e_conf, "layout=", 7) == 0)
var = CUSTOM_CONF_LAYOUT; var = CUSTOM_CONF_LAYOUT;
else if (strncmp (e_conf, "side-bar_width=", 15) == 0) else if (strncmp (e_conf, "side-bar_width=", 15) == 0)
var = CUSTOM_CONF_SBAR_WIDTH; var = CUSTOM_CONF_SBAR_WIDTH;
else if (strncmp (e_conf, "notify-bar_show=", 16) == 0) else if (strncmp (e_conf, "notify-bar_show=", 16) == 0)
var = CUSTOM_CONF_NOTIFYBARSHOW; var = CUSTOM_CONF_NOTIFYBARSHOW;
else if (strncmp (e_conf, "notify-bar_date=", 16) == 0) else if (strncmp (e_conf, "notify-bar_date=", 16) == 0)
var = CUSTOM_CONF_NOTIFYBARDATE; var = CUSTOM_CONF_NOTIFYBARDATE;
else if (strncmp (e_conf, "notify-bar_clock=", 17) == 0) else if (strncmp (e_conf, "notify-bar_clock=", 17) == 0)
var = CUSTOM_CONF_NOTIFYBARCLOCK; var = CUSTOM_CONF_NOTIFYBARCLOCK;
else if (strncmp (e_conf, "notify-bar_warning=", 19) == 0) else if (strncmp (e_conf, "notify-bar_warning=", 19) == 0)
var = CUSTOM_CONF_NOTIFYBARWARNING; var = CUSTOM_CONF_NOTIFYBARWARNING;
else if (strncmp (e_conf, "notify-bar_command=", 19) == 0) else if (strncmp (e_conf, "notify-bar_command=", 19) == 0)
var = CUSTOM_CONF_NOTIFYBARCOMMAND; var = CUSTOM_CONF_NOTIFYBARCOMMAND;
else if (strncmp (e_conf, "output_datefmt=", 15) == 0) else if (strncmp (e_conf, "output_datefmt=", 15) == 0)
var = CUSTOM_CONF_OUTPUTDATEFMT; var = CUSTOM_CONF_OUTPUTDATEFMT;
else if (strncmp (e_conf, "input_datefmt=", 14) == 0) else if (strncmp (e_conf, "input_datefmt=", 14) == 0)
var = CUSTOM_CONF_INPUTDATEFMT; var = CUSTOM_CONF_INPUTDATEFMT;
else if (strncmp (e_conf, "notify-daemon_enable=", 21) == 0) else if (strncmp (e_conf, "notify-daemon_enable=", 21) == 0)
var = CUSTOM_CONF_DMON_ENABLE; var = CUSTOM_CONF_DMON_ENABLE;
else if (strncmp (e_conf, "notify-daemon_log=", 18) == 0) else if (strncmp (e_conf, "notify-daemon_log=", 18) == 0)
@ -547,13 +547,13 @@ custom_layout_config (void)
{ {
need_reset = 0; need_reset = 0;
switch (ch) switch (ch)
{ {
case KEY_RESIZE: case KEY_RESIZE:
endwin (); endwin ();
wins_refresh (); wins_refresh ();
curs_set (0); curs_set (0);
need_reset = 1; need_reset = 1;
break; break;
case KEY_GENERIC_HELP: case KEY_GENERIC_HELP:
help_wins_init (&hwin, 0, 0, help_wins_init (&hwin, 0, 0,
(notify_bar ()) ? row - 3 : row - 2, col); (notify_bar ()) ? row - 3 : row - 2, col);
@ -564,29 +564,29 @@ custom_layout_config (void)
wins_scrollwin_delete (&hwin); wins_scrollwin_delete (&hwin);
need_reset = 1; need_reset = 1;
break; break;
case KEY_GENERIC_SELECT: case KEY_GENERIC_SELECT:
mark = cursor; mark = cursor;
break; break;
case KEY_MOVE_DOWN: case KEY_MOVE_DOWN:
if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1) if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1)
cursor++; cursor++;
break; break;
case KEY_MOVE_UP: case KEY_MOVE_UP:
if (cursor % LAYOUTSPERCOL > 0) if (cursor % LAYOUTSPERCOL > 0)
cursor--; cursor--;
break; break;
case KEY_MOVE_LEFT: case KEY_MOVE_LEFT:
if (cursor >= LAYOUTSPERCOL) if (cursor >= LAYOUTSPERCOL)
cursor -= LAYOUTSPERCOL; cursor -= LAYOUTSPERCOL;
break; break;
case KEY_MOVE_RIGHT: case KEY_MOVE_RIGHT:
if (cursor < NBLAYOUTS - LAYOUTSPERCOL) if (cursor < NBLAYOUTS - LAYOUTSPERCOL)
cursor += LAYOUTSPERCOL; cursor += LAYOUTSPERCOL;
break; break;
case KEY_GENERIC_CANCEL: case KEY_GENERIC_CANCEL:
need_reset = 1; need_reset = 1;
break; break;
} }
display_layout_config (&conf_win, mark, cursor, need_reset); display_layout_config (&conf_win, mark, cursor, need_reset);
} }
wins_set_layout (mark + 1); wins_set_layout (mark + 1);
@ -713,7 +713,7 @@ color_selection_bar (void)
*/ */
static void static void
display_color_config (struct window *cwin, int *mark_fore, int *mark_back, display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
int cursor, int need_reset, int theme_changed) int cursor, int need_reset, int theme_changed)
{ {
#define SIZE (2 * (NBUSERCOLORS + 1)) #define SIZE (2 * (NBUSERCOLORS + 1))
#define DEFAULTCOLOR 255 #define DEFAULTCOLOR 255
@ -764,34 +764,34 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
if (colorize) if (colorize)
{ {
if (theme_changed) if (theme_changed)
{ {
pair_content (colr[*mark_fore], &colr_fore, 0L); pair_content (colr[*mark_fore], &colr_fore, 0L);
if (colr_fore == 255) if (colr_fore == 255)
colr_fore = -1; colr_fore = -1;
pair_content (colr[*mark_back], &colr_back, 0L); pair_content (colr[*mark_back], &colr_back, 0L);
if (colr_back == 255) if (colr_back == 255)
colr_back = -1; colr_back = -1;
init_pair (COLR_CUSTOM, colr_fore, colr_back); init_pair (COLR_CUSTOM, colr_fore, colr_back);
} }
else else
{ {
/* Retrieve the actual color theme. */ /* Retrieve the actual color theme. */
pair_content (COLR_CUSTOM, &colr_fore, &colr_back); pair_content (COLR_CUSTOM, &colr_fore, &colr_back);
if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT)) if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT))
*mark_fore = NBUSERCOLORS; *mark_fore = NBUSERCOLORS;
else else
for (i = 0; i < NBUSERCOLORS + 1; i++) for (i = 0; i < NBUSERCOLORS + 1; i++)
if (colr_fore == colr[i]) if (colr_fore == colr[i])
*mark_fore = i; *mark_fore = i;
if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT)) if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT))
*mark_back = SIZE - 1; *mark_back = SIZE - 1;
else else
for (i = 0; i < NBUSERCOLORS + 1; i++) for (i = 0; i < NBUSERCOLORS + 1; i++)
if (colr_back == colr[NBUSERCOLORS + 1 + i]) if (colr_back == colr[NBUSERCOLORS + 1 + i])
*mark_back = NBUSERCOLORS + 1 + i; *mark_back = NBUSERCOLORS + 1 + i;
} }
} }
/* color boxes */ /* color boxes */
@ -810,9 +810,9 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
mvwprintw (cwin->p, pos[i][YPOS], pos[i][XPOS] + XOFST, bar); mvwprintw (cwin->p, pos[i][YPOS], pos[i][XPOS] + XOFST, bar);
wattroff (cwin->p, COLOR_PAIR (colr[i])); wattroff (cwin->p, COLOR_PAIR (colr[i]));
mvwprintw (cwin->p, pos[NBUSERCOLORS][YPOS] + 1, mvwprintw (cwin->p, pos[NBUSERCOLORS][YPOS] + 1,
pos[NBUSERCOLORS][XPOS] + XOFST, default_txt); pos[NBUSERCOLORS][XPOS] + XOFST, default_txt);
mvwprintw (cwin->p, pos[SIZE - 1][YPOS] + 1, mvwprintw (cwin->p, pos[SIZE - 1][YPOS] + 1,
pos[SIZE - 1][XPOS] + XOFST, default_txt); pos[SIZE - 1][XPOS] + XOFST, default_txt);
custom_apply_attr (cwin->p, ATTR_HIGHEST); custom_apply_attr (cwin->p, ATTR_HIGHEST);
mvwprintw (cwin->p, Y, XFORE + XOFST, fore_txt); mvwprintw (cwin->p, Y, XFORE + XOFST, fore_txt);
@ -822,9 +822,9 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
if (colorize) if (colorize)
{ {
mvwaddch (cwin->p, pos[*mark_fore][YPOS], mvwaddch (cwin->p, pos[*mark_fore][YPOS],
pos[*mark_fore][XPOS] + 1, MARK); pos[*mark_fore][XPOS] + 1, MARK);
mvwaddch (cwin->p, pos[*mark_back][YPOS], mvwaddch (cwin->p, pos[*mark_back][YPOS],
pos[*mark_back][XPOS] + 1, MARK); pos[*mark_back][XPOS] + 1, MARK);
} }
mvwaddch (cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR); mvwaddch (cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR);
@ -853,7 +853,7 @@ custom_color_config (void)
conf_win.p = 0; conf_win.p = 0;
set_confwin_attr (&conf_win); set_confwin_attr (&conf_win);
display_color_config (&conf_win, &mark_fore, &mark_back, cursor, display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
need_reset, theme_changed); need_reset, theme_changed);
while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT) while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
{ {
@ -861,51 +861,51 @@ custom_color_config (void)
theme_changed = 0; theme_changed = 0;
switch (ch) switch (ch)
{ {
case KEY_RESIZE: case KEY_RESIZE:
endwin (); endwin ();
wins_refresh (); wins_refresh ();
curs_set (0); curs_set (0);
need_reset = 1; need_reset = 1;
break; break;
case KEY_GENERIC_SELECT: case KEY_GENERIC_SELECT:
colorize = 1; colorize = 1;
need_reset = 1; need_reset = 1;
theme_changed = 1; theme_changed = 1;
if (cursor > NBUSERCOLORS) if (cursor > NBUSERCOLORS)
mark_back = cursor; mark_back = cursor;
else else
mark_fore = cursor; mark_fore = cursor;
break; break;
case KEY_MOVE_DOWN: case KEY_MOVE_DOWN:
if (cursor < SIZE - 1) if (cursor < SIZE - 1)
++cursor; ++cursor;
break; break;
case KEY_MOVE_UP: case KEY_MOVE_UP:
if (cursor > 0) if (cursor > 0)
--cursor; --cursor;
break; break;
case KEY_MOVE_LEFT: case KEY_MOVE_LEFT:
if (cursor > NBUSERCOLORS) if (cursor > NBUSERCOLORS)
cursor -= (NBUSERCOLORS + 1); cursor -= (NBUSERCOLORS + 1);
break; break;
case KEY_MOVE_RIGHT: case KEY_MOVE_RIGHT:
if (cursor <= NBUSERCOLORS) if (cursor <= NBUSERCOLORS)
cursor += (NBUSERCOLORS + 1); cursor += (NBUSERCOLORS + 1);
break; break;
case KEY_GENERIC_CANCEL: case KEY_GENERIC_CANCEL:
colorize = 0; colorize = 0;
need_reset = 1; need_reset = 1;
break; break;
} }
display_color_config (&conf_win, &mark_fore, &mark_back, cursor, display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
need_reset, theme_changed); need_reset, theme_changed);
} }
delwin (conf_win.p); delwin (conf_win.p);
} }
@ -947,17 +947,17 @@ custom_color_theme_name (char *theme_name)
{ {
pair_content (COLR_CUSTOM, &color[0], &color[1]); pair_content (COLR_CUSTOM, &color[0], &color[1]);
for (i = 0; i < NBCOLORS; i++) for (i = 0; i < NBCOLORS; i++)
{ {
if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT)) if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT))
color_name[i] = default_color; color_name[i] = default_color;
else if (color[i] >= 0 && color[i] <= MAXCOLORS) else if (color[i] >= 0 && color[i] <= MAXCOLORS)
color_name[i] = name[color[i]]; color_name[i] = name[color[i]];
else else
{ {
EXIT (_("unknown color")); EXIT (_("unknown color"));
/* NOTREACHED */ /* NOTREACHED */
} }
} }
(void)snprintf (theme_name, BUFSIZ, "%s on %s", color_name[0], (void)snprintf (theme_name, BUFSIZ, "%s on %s", color_name[0],
color_name[1]); color_name[1]);
} }
@ -999,7 +999,7 @@ print_general_options (WINDOW *win, struct conf *conf)
print_bool_option_incolor (win, conf->auto_save, y, print_bool_option_incolor (win, conf->auto_save, y,
XPOS + 4 + strlen (opt[AUTO_SAVE])); XPOS + 4 + strlen (opt[AUTO_SAVE]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, automatic save is done when quitting)")); _("(if set to YES, automatic save is done when quitting)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[2] %s ", opt[PERIODIC_SAVE]); mvwprintw (win, y, XPOS, "[2] %s ", opt[PERIODIC_SAVE]);
custom_apply_attr (win, ATTR_HIGHEST); custom_apply_attr (win, ATTR_HIGHEST);
@ -1007,41 +1007,41 @@ print_general_options (WINDOW *win, struct conf *conf)
conf->periodic_save); conf->periodic_save);
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if not null, automatically save data every 'periodic_save' " _("(if not null, automatically save data every 'periodic_save' "
"minutes)")); "minutes)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[3] %s ", opt[CONFIRM_QUIT]); mvwprintw (win, y, XPOS, "[3] %s ", opt[CONFIRM_QUIT]);
print_bool_option_incolor (win, conf->confirm_quit, y, print_bool_option_incolor (win, conf->confirm_quit, y,
XPOS + 4 + strlen (opt[CONFIRM_QUIT])); XPOS + 4 + strlen (opt[CONFIRM_QUIT]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, confirmation is required before quitting)")); _("(if set to YES, confirmation is required before quitting)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_DELETE]); mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_DELETE]);
print_bool_option_incolor (win, conf->confirm_delete, y, print_bool_option_incolor (win, conf->confirm_delete, y,
XPOS + 4 + strlen (opt[CONFIRM_DELETE])); XPOS + 4 + strlen (opt[CONFIRM_DELETE]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, confirmation is required " _("(if set to YES, confirmation is required "
"before deleting an event)")); "before deleting an event)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[5] %s ", opt[SKIP_SYSTEM_DIAGS]); mvwprintw (win, y, XPOS, "[5] %s ", opt[SKIP_SYSTEM_DIAGS]);
print_bool_option_incolor (win, conf->skip_system_dialogs, y, print_bool_option_incolor (win, conf->skip_system_dialogs, y,
XPOS + 4 + strlen (opt[SKIP_SYSTEM_DIAGS])); XPOS + 4 + strlen (opt[SKIP_SYSTEM_DIAGS]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, messages about loaded " _("(if set to YES, messages about loaded "
"and saved data will not be displayed)")); "and saved data will not be displayed)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_PROGRESS_BAR]); mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_PROGRESS_BAR]);
print_bool_option_incolor (win, conf->skip_progress_bar, y, print_bool_option_incolor (win, conf->skip_progress_bar, y,
XPOS + 4 + strlen (opt[SKIP_PROGRESS_BAR])); XPOS + 4 + strlen (opt[SKIP_PROGRESS_BAR]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, progress bar will not be displayed " _("(if set to YES, progress bar will not be displayed "
"when saving data)")); "when saving data)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[7] %s ", opt[WEEK_BEGINS_MONDAY]); mvwprintw (win, y, XPOS, "[7] %s ", opt[WEEK_BEGINS_MONDAY]);
print_bool_option_incolor (win, calendar_week_begins_on_monday (), y, print_bool_option_incolor (win, calendar_week_begins_on_monday (), y,
XPOS + 4 + strlen (opt[WEEK_BEGINS_MONDAY])); XPOS + 4 + strlen (opt[WEEK_BEGINS_MONDAY]));
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(if set to YES, monday is the first day of the week, " _("(if set to YES, monday is the first day of the week, "
"else it is sunday)")); "else it is sunday)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[8] %s ", opt[OUTPUT_DATE_FMT]); mvwprintw (win, y, XPOS, "[8] %s ", opt[OUTPUT_DATE_FMT]);
@ -1050,7 +1050,7 @@ print_general_options (WINDOW *win, struct conf *conf)
conf->output_datefmt); conf->output_datefmt);
custom_remove_attr (win, ATTR_HIGHEST); custom_remove_attr (win, ATTR_HIGHEST);
mvwprintw (win, y + 1, XPOS, mvwprintw (win, y + 1, XPOS,
_("(Format of the date to be displayed in non-interactive mode)")); _("(Format of the date to be displayed in non-interactive mode)"));
y += YOFF; y += YOFF;
mvwprintw (win, y, XPOS, "[9] %s ", opt[INPUT_DATE_FMT]); mvwprintw (win, y, XPOS, "[9] %s ", opt[INPUT_DATE_FMT]);
custom_apply_attr (win, ATTR_HIGHEST); custom_apply_attr (win, ATTR_HIGHEST);
@ -1112,84 +1112,84 @@ custom_general_config (struct conf *conf)
buf[0] = '\0'; buf[0] = '\0';
switch (ch) switch (ch)
{ {
case KEY_RESIZE: case KEY_RESIZE:
wins_get_config (); wins_get_config ();
wins_reset (); wins_reset ();
wins_scrollwin_delete (&cwin); wins_scrollwin_delete (&cwin);
wins_scrollwin_init (&cwin); wins_scrollwin_init (&cwin);
custom_set_swsiz (&cwin); custom_set_swsiz (&cwin);
wins_show (cwin.win.p, cwin.label); wins_show (cwin.win.p, cwin.label);
cwin.first_visible_line = 0; cwin.first_visible_line = 0;
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':
conf->auto_save = !conf->auto_save; conf->auto_save = !conf->auto_save;
break; break;
case '2': case '2':
status_mesg (periodic_save_str, ""); status_mesg (periodic_save_str, "");
if (updatestring (win[STA].p, &buf, 0, 1) == 0) if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{ {
int val = atoi (buf); int val = atoi (buf);
if (val >= 0) if (val >= 0)
conf->periodic_save = val; conf->periodic_save = val;
if (conf->periodic_save > 0) if (conf->periodic_save > 0)
io_start_psave_thread (conf); io_start_psave_thread (conf);
else if (conf->periodic_save == 0) else if (conf->periodic_save == 0)
io_stop_psave_thread (); io_stop_psave_thread ();
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
break; break;
case '3': case '3':
conf->confirm_quit = !conf->confirm_quit; conf->confirm_quit = !conf->confirm_quit;
break; break;
case '4': case '4':
conf->confirm_delete = !conf->confirm_delete; conf->confirm_delete = !conf->confirm_delete;
break; break;
case '5': case '5':
conf->skip_system_dialogs = !conf->skip_system_dialogs; conf->skip_system_dialogs = !conf->skip_system_dialogs;
break; break;
case '6': case '6':
conf->skip_progress_bar = !conf->skip_progress_bar; conf->skip_progress_bar = !conf->skip_progress_bar;
break; break;
case '7': case '7':
calendar_change_first_day_of_week (); calendar_change_first_day_of_week ();
break; break;
case '8': case '8':
status_mesg (output_datefmt_str, ""); status_mesg (output_datefmt_str, "");
(void)strncpy (buf, conf->output_datefmt, (void)strncpy (buf, conf->output_datefmt,
strlen (conf->output_datefmt) + 1); strlen (conf->output_datefmt) + 1);
if (updatestring (win[STA].p, &buf, 0, 1) == 0) if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{ {
(void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1); (void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1);
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
break; break;
case '9': case '9':
status_mesg (input_datefmt_str, ""); status_mesg (input_datefmt_str, "");
if (updatestring (win[STA].p, &buf, 0, 1) == 0) if (updatestring (win[STA].p, &buf, 0, 1) == 0)
{ {
int val = atoi (buf); int val = atoi (buf);
if (val > 0 && val <= DATE_FORMATS) if (val > 0 && val <= DATE_FORMATS)
conf->input_datefmt = val; conf->input_datefmt = val;
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
break; break;
} }
status_mesg (number_str, keys); status_mesg (number_str, keys);
cwin.total_lines = print_general_options (cwin.pad.p, conf); cwin.total_lines = print_general_options (cwin.pad.p, conf);
wins_scrollwin_display (&cwin); wins_scrollwin_display (&cwin);
@ -1314,7 +1314,7 @@ custom_keys_config (void)
ch = keys_getch (win[STA].p); ch = keys_getch (win[STA].p);
switch (ch) switch (ch)
{ {
case KEY_MOVE_UP: case KEY_MOVE_UP:
if (selrow > 0) if (selrow > 0)
{ {
@ -1327,8 +1327,8 @@ custom_keys_config (void)
wins_scrollwin_up (&kwin, LINESPERKEY); wins_scrollwin_up (&kwin, LINESPERKEY);
} }
} }
break; break;
case KEY_MOVE_DOWN: case KEY_MOVE_DOWN:
if (selrow < NBKEYS - 1) if (selrow < NBKEYS - 1)
{ {
selrow++; selrow++;
@ -1340,7 +1340,7 @@ custom_keys_config (void)
wins_scrollwin_down (&kwin, LINESPERKEY); wins_scrollwin_down (&kwin, LINESPERKEY);
} }
} }
break; break;
case KEY_MOVE_LEFT: case KEY_MOVE_LEFT:
if (selelm > 0) if (selelm > 0)
selelm--; selelm--;
@ -1418,7 +1418,7 @@ custom_keys_config (void)
} }
wins_scrollwin_delete (&kwin); wins_scrollwin_delete (&kwin);
return; return;
} }
custom_keys_config_bar (); custom_keys_config_bar ();
werase (kwin.pad.p); werase (kwin.pad.p);
nbrowelm = print_keys_bindings (kwin.pad.p, selrow, selelm, LINESPERKEY); nbrowelm = print_keys_bindings (kwin.pad.p, selrow, selelm, LINESPERKEY);

484
src/day.c
View File

@ -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,19 +122,19 @@ 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;
@ -157,10 +157,10 @@ 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;
@ -183,11 +183,11 @@ 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;
@ -211,11 +211,11 @@ 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));
@ -241,14 +241,14 @@ 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));
@ -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;
@ -341,7 +341,7 @@ day_item_s2apoint_s (struct apoint *a, struct day_item *p)
*/ */
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];
@ -371,7 +371,7 @@ display_item_date (int incolor, struct apoint *i, int type, long date,
*/ */
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;
@ -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,7 +470,7 @@ 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 */
@ -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));
@ -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;
@ -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,48 +838,48 @@ 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;
} }
} }
@ -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;
@ -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

@ -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,11 +175,11 @@ 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;
@ -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,17 +212,17 @@ 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"));

360
src/io.c
View File

@ -226,16 +226,16 @@ get_export_stream (enum export_type type)
status_mesg (question, ""); status_mesg (question, "");
cancel = updatestring (win[STA].p, &stream_name, 0, 1); cancel = updatestring (win[STA].p, &stream_name, 0, 1);
if (cancel) if (cancel)
{ {
mem_free (stream_name); mem_free (stream_name);
return (NULL); return (NULL);
} }
stream = fopen (stream_name, "w"); stream = fopen (stream_name, "w");
if (stream == NULL) if (stream == NULL)
{ {
status_mesg (wrong_name, press_enter); status_mesg (wrong_name, press_enter);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
} }
} }
mem_free (stream_name); mem_free (stream_name);
@ -354,24 +354,24 @@ ical_export_recur_events (FILE *stream)
ical_recur_type[i->rpt->type], i->rpt->freq); ical_recur_type[i->rpt->type], i->rpt->freq);
if (i->rpt->until != 0) if (i->rpt->until != 0)
{ {
date_sec2date_fmt (i->rpt->until, ICALDATEFMT, ical_date); date_sec2date_fmt (i->rpt->until, ICALDATEFMT, ical_date);
(void)fprintf (stream, ";UNTIL=%s\n", ical_date); (void)fprintf (stream, ";UNTIL=%s\n", ical_date);
} }
else else
(void)fprintf (stream, "\n"); (void)fprintf (stream, "\n");
if (i->exc != NULL) if (i->exc != NULL)
{ {
date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date); date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date);
(void)fprintf (stream, "EXDATE:%s", ical_date); (void)fprintf (stream, "EXDATE:%s", ical_date);
for (day = i->exc->next; day; day = day->next) for (day = i->exc->next; day; day = day->next)
{ {
date_sec2date_fmt (day->st, ICALDATEFMT, ical_date); date_sec2date_fmt (day->st, ICALDATEFMT, ical_date);
(void)fprintf (stream, ",%s", ical_date); (void)fprintf (stream, ",%s", ical_date);
} }
(void)fprintf (stream, "\n"); (void)fprintf (stream, "\n");
} }
(void)fprintf (stream, "SUMMARY:%s\n", i->mesg); (void)fprintf (stream, "SUMMARY:%s\n", i->mesg);
(void)fprintf (stream, "END:VEVENT\n"); (void)fprintf (stream, "END:VEVENT\n");
@ -504,28 +504,28 @@ ical_export_recur_apoints (FILE *stream)
ical_recur_type[i->rpt->type], i->rpt->freq); ical_recur_type[i->rpt->type], i->rpt->freq);
if (i->rpt->until != 0) if (i->rpt->until != 0)
{ {
date_sec2date_fmt (i->rpt->until + HOURINSEC, ICALDATEFMT, ical_date); date_sec2date_fmt (i->rpt->until + HOURINSEC, ICALDATEFMT, ical_date);
(void)fprintf (stream, ";UNTIL=%s\n", ical_date); (void)fprintf (stream, ";UNTIL=%s\n", ical_date);
} }
else else
(void)fprintf (stream, "\n"); (void)fprintf (stream, "\n");
if (i->exc != NULL) if (i->exc != NULL)
{ {
date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date); date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date);
(void)fprintf (stream, "EXDATE:%s", ical_date); (void)fprintf (stream, "EXDATE:%s", ical_date);
for (day = i->exc->next; day; day = day->next) for (day = i->exc->next; day; day = day->next)
{ {
date_sec2date_fmt (day->st, ICALDATEFMT, ical_date); date_sec2date_fmt (day->st, ICALDATEFMT, ical_date);
(void)fprintf (stream, ",%s", ical_date); (void)fprintf (stream, ",%s", ical_date);
} }
(void)fprintf (stream, "\n"); (void)fprintf (stream, "\n");
} }
(void)fprintf (stream, "SUMMARY:%s\n", i->mesg); (void)fprintf (stream, "SUMMARY:%s\n", i->mesg);
if (i->state & APOINT_NOTIFY) if (i->state & APOINT_NOTIFY)
ical_export_valarm (stream); ical_export_valarm (stream);
(void)fprintf (stream, "END:VEVENT\n"); (void)fprintf (stream, "END:VEVENT\n");
} }
pthread_mutex_unlock (&(recur_alist_p->mutex)); pthread_mutex_unlock (&(recur_alist_p->mutex));
@ -605,7 +605,7 @@ ical_export_apoints (FILE *stream)
(void)fprintf (stream, "DURATION:PT0H0M%ldS\n", i->dur); (void)fprintf (stream, "DURATION:PT0H0M%ldS\n", i->dur);
(void)fprintf (stream, "SUMMARY:%s\n", i->mesg); (void)fprintf (stream, "SUMMARY:%s\n", i->mesg);
if (i->state & APOINT_NOTIFY) if (i->state & APOINT_NOTIFY)
ical_export_valarm (stream); ical_export_valarm (stream);
(void)fprintf (stream, "END:VEVENT\n"); (void)fprintf (stream, "END:VEVENT\n");
} }
pthread_mutex_unlock (&(alist_p->mutex)); pthread_mutex_unlock (&(alist_p->mutex));
@ -787,7 +787,7 @@ io_extract_data (char *dst_data, const char *org, int len)
for (i = 0; i < len - 1; i++) for (i = 0; i < len - 1; i++)
{ {
if (*org == '\n' || *org == '\0') if (*org == '\n' || *org == '\0')
break; break;
*dst_data++ = *org++; *dst_data++ = *org++;
} }
*dst_data = '\0'; *dst_data = '\0';
@ -1096,17 +1096,17 @@ io_load_app (void)
is_appointment = is_event = is_recursive = 0; is_appointment = is_event = is_recursive = 0;
c = getc (data_file); c = getc (data_file);
if (c == EOF) if (c == EOF)
break; break;
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
/* Read the date first: it is common to both events /* Read the date first: it is common to both events
* and appointments. * and appointments.
*/ */
if (fscanf (data_file, "%u / %u / %u ", if (fscanf (data_file, "%u / %u / %u ",
&start.tm_mon, &start.tm_mday, &start.tm_year) != 3) &start.tm_mon, &start.tm_mday, &start.tm_year) != 3)
{ {
EXIT (_("syntax error in the item date")); EXIT (_("syntax error in the item date"));
} }
/* Read the next character : if it is an '@' then we have /* Read the next character : if it is an '@' then we have
* an appointment, else if it is an '[' we have en event. * an appointment, else if it is an '[' we have en event.
@ -1114,144 +1114,144 @@ io_load_app (void)
c = getc (data_file); c = getc (data_file);
if (c == '@') if (c == '@')
is_appointment = 1; is_appointment = 1;
else if (c == '[') else if (c == '[')
is_event = 1; is_event = 1;
else else
{ {
EXIT (_("no event nor appointment found")); EXIT (_("no event nor appointment found"));
} }
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
/* Read the remaining informations. */ /* Read the remaining informations. */
if (is_appointment) if (is_appointment)
{ {
fscanf (data_file, "@ %u : %u -> %u / %u / %u @ %u : %u ", fscanf (data_file, "@ %u : %u -> %u / %u / %u @ %u : %u ",
&start.tm_hour, &start.tm_min, &start.tm_hour, &start.tm_min,
&end.tm_mon, &end.tm_mday, &end.tm_year, &end.tm_mon, &end.tm_mday, &end.tm_year,
&end.tm_hour, &end.tm_min); &end.tm_hour, &end.tm_min);
} }
else if (is_event) else if (is_event)
{ {
fscanf (data_file, "[%d] ", &id); fscanf (data_file, "[%d] ", &id);
} }
else else
{ {
EXIT (_("wrong format in the appointment or event")); EXIT (_("wrong format in the appointment or event"));
/* NOTREACHED */ /* NOTREACHED */
} }
/* Check if we have a recursive item. */ /* Check if we have a recursive item. */
c = getc (data_file); c = getc (data_file);
if (c == '{') if (c == '{')
{ {
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
is_recursive = 1; is_recursive = 1;
fscanf (data_file, "{ %d%c ", &freq, &type); fscanf (data_file, "{ %d%c ", &freq, &type);
c = getc (data_file); c = getc (data_file);
if (c == '}') if (c == '}')
{ /* endless recurrent item */ { /* endless recurrent item */
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
fscanf (data_file, "} "); fscanf (data_file, "} ");
until.tm_year = 0; until.tm_year = 0;
} }
else if (c == '-') else if (c == '-')
{ {
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
fscanf (data_file, " -> %u / %u / %u ", fscanf (data_file, " -> %u / %u / %u ",
&until.tm_mon, &until.tm_mday, &until.tm_year); &until.tm_mon, &until.tm_mday, &until.tm_year);
c = getc (data_file); c = getc (data_file);
if (c == '!') if (c == '!')
{ {
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
exc = recur_exc_scan (data_file); exc = recur_exc_scan (data_file);
c = getc (data_file); c = getc (data_file);
} }
else else
{ {
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
fscanf (data_file, "} "); fscanf (data_file, "} ");
} }
} }
else if (c == '!') else if (c == '!')
{ // endless item with exceptions { // endless item with exceptions
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
exc = recur_exc_scan (data_file); exc = recur_exc_scan (data_file);
c = getc (data_file); c = getc (data_file);
until.tm_year = 0; until.tm_year = 0;
} }
else else
{ {
EXIT (_("wrong format in the appointment or event")); EXIT (_("wrong format in the appointment or event"));
/* NOTREACHED */ /* NOTREACHED */
} }
} }
else else
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
/* Check if a note is attached to the item. */ /* Check if a note is attached to the item. */
c = getc (data_file); c = getc (data_file);
if (c == '>') if (c == '>')
{ {
(void)fgets (note, NOTESIZ + 1, data_file); (void)fgets (note, NOTESIZ + 1, data_file);
note[NOTESIZ] = '\0'; note[NOTESIZ] = '\0';
notep = note; notep = note;
getc (data_file); getc (data_file);
} }
else else
{ {
notep = NULL; notep = NULL;
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
} }
/* /*
* Last: read the item description and load it into its * Last: read the item description and load it into its
* corresponding linked list, depending on the item type. * corresponding linked list, depending on the item type.
*/ */
if (is_appointment) if (is_appointment)
{ {
c = getc (data_file); c = getc (data_file);
if (c == '!') if (c == '!')
{ {
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
fscanf (data_file, " ! "); fscanf (data_file, " ! ");
state |= APOINT_NOTIFY; state |= APOINT_NOTIFY;
} }
else else
{ {
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
fscanf (data_file, " | "); fscanf (data_file, " | ");
state = 0L; state = 0L;
} }
if (is_recursive) if (is_recursive)
{ {
recur_apoint_scan (data_file, start, end, recur_apoint_scan (data_file, start, end,
type, freq, until, notep, &exc, state); type, freq, until, notep, &exc, state);
} }
else else
{ {
apoint_scan (data_file, start, end, state, notep); apoint_scan (data_file, start, end, state, notep);
} }
} }
else if (is_event) else if (is_event)
{ {
if (is_recursive) if (is_recursive)
{ {
recur_event_scan (data_file, start, id, type, recur_event_scan (data_file, start, id, type,
freq, until, notep, &exc); freq, until, notep, &exc);
} }
else else
{ {
event_scan (data_file, start, id, notep); event_scan (data_file, start, id, notep);
} }
} }
else else
{ {
EXIT (_("wrong format in the appointment or event")); EXIT (_("wrong format in the appointment or event"));
/* NOTREACHED */ /* NOTREACHED */
} }
} }
file_close (data_file, __FILE_POS__); file_close (data_file, __FILE_POS__);
} }
@ -1278,28 +1278,28 @@ io_load_todo (void)
{ {
c = getc (data_file); c = getc (data_file);
if (c == EOF) if (c == EOF)
{ {
break; break;
} }
else if (c == '[') else if (c == '[')
{ /* new style with id */ { /* new style with id */
fscanf (data_file, "%d]", &id); fscanf (data_file, "%d]", &id);
} }
else else
{ {
id = 9; id = 9;
(void)ungetc (c, data_file); (void)ungetc (c, data_file);
} }
/* Now read the attached note, if any. */ /* Now read the attached note, if any. */
c = getc (data_file); c = getc (data_file);
if (c == '>') if (c == '>')
{ {
(void)fgets (note, NOTESIZ + 1, data_file); (void)fgets (note, NOTESIZ + 1, data_file);
note[NOTESIZ] = '\0'; note[NOTESIZ] = '\0';
getc (data_file); getc (data_file);
} }
else else
note[0] = '\0'; note[0] = '\0';
/* Then read todo description. */ /* Then read todo description. */
(void)fgets (buf, sizeof buf, data_file); (void)fgets (buf, sizeof buf, data_file);
newline = strchr (buf, '\n'); newline = strchr (buf, '\n');
@ -1494,11 +1494,11 @@ io_check_dir (char *dir, int *missing)
if (mkdir (dir, 0700) != 0) if (mkdir (dir, 0700) != 0)
{ {
if (errno != EEXIST) if (errno != EEXIST)
{ {
(void)fprintf (stderr, _("FATAL ERROR: could not create %s: %s\n"), (void)fprintf (stderr, _("FATAL ERROR: could not create %s: %s\n"),
dir, strerror (errno)); dir, strerror (errno));
exit_calcurse (EXIT_FAILURE); exit_calcurse (EXIT_FAILURE);
} }
} }
else else
{ {
@ -1534,11 +1534,11 @@ io_check_file (char *file, int *missing)
if (missing) if (missing)
(*missing)++; (*missing)++;
if ((fd = fopen (file, "w")) == NULL) if ((fd = fopen (file, "w")) == NULL)
{ {
(void)fprintf (stderr, _("FATAL ERROR: could not create %s: %s\n"), (void)fprintf (stderr, _("FATAL ERROR: could not create %s: %s\n"),
file, strerror (errno)); file, strerror (errno));
exit_calcurse (EXIT_FAILURE); exit_calcurse (EXIT_FAILURE);
} }
file_close (fd, __FILE_POS__); file_close (fd, __FILE_POS__);
} }
} }
@ -2706,16 +2706,16 @@ get_import_stream (enum export_type type)
status_mesg (ask_fname, ""); status_mesg (ask_fname, "");
cancel = updatestring (win[STA].p, &stream_name, 0, 1); cancel = updatestring (win[STA].p, &stream_name, 0, 1);
if (cancel) if (cancel)
{ {
mem_free (stream_name); mem_free (stream_name);
return NULL; return NULL;
} }
stream = fopen (stream_name, "r"); stream = fopen (stream_name, "r");
if (stream == NULL) if (stream == NULL)
{ {
status_mesg (wrong_file, press_enter); status_mesg (wrong_file, press_enter);
(void)wgetch (win[STA].p); (void)wgetch (win[STA].p);
} }
} }
mem_free (stream_name); mem_free (stream_name);

View File

@ -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);

View File

@ -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); hours_left = (time_left / HOURINSEC);
minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC; minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC;
pthread_mutex_lock (&nbar.mutex); pthread_mutex_lock (&nbar.mutex);
if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY)) if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY))
blinking = 1; blinking = 1;
else else
blinking = 0; blinking = 0;
if (blinking) if (blinking)
wattron (notify.win, A_BLINK); wattron (notify.win, A_BLINK);
if (too_long) if (too_long)
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s.. <", mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s.. <",
hours_left, minutes_left, buf); hours_left, minutes_left, buf);
else else
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s <", mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s <",
hours_left, minutes_left, notify_app.txt); hours_left, minutes_left, notify_app.txt);
if (blinking) if (blinking)
wattroff (notify.win, A_BLINK); wattroff (notify.win, A_BLINK);
if (blinking) 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);
} }
@ -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;
@ -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
@ -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

@ -236,7 +236,7 @@ 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;
@ -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,7 +278,7 @@ 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;
@ -303,11 +303,11 @@ 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);
@ -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;
@ -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;
@ -687,20 +687,20 @@ recur_item_inday (long item_start, struct days *item_exc, int 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:
@ -738,7 +738,7 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
*/ */
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,12 +747,12 @@ 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:
@ -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,19 +778,19 @@ 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"));
@ -803,7 +803,7 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
*/ */
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
{ {
@ -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 */

View File

@ -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);

View File

@ -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++;
} }
@ -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);
@ -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;
@ -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

@ -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) {
@ -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)
@ -598,7 +598,7 @@ draw_scrollbar (WINDOW *win, int y, int x, int length,
*/ */
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);
@ -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;
} }