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:
parent
55262a3074
commit
9c9fd5da15
270
src/apoint.c
270
src/apoint.c
@ -142,11 +142,11 @@ apoint_new (char *mesg, char *note, long start, long dur, char state)
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0 || (*i)->start > start)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
}
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
@ -186,22 +186,22 @@ apoint_add (void)
|
||||
{
|
||||
status_mesg (mesg_1, "");
|
||||
if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_ESC)
|
||||
{
|
||||
if (strlen (item_time) == 0)
|
||||
{
|
||||
is_appointment = 0;
|
||||
break;
|
||||
}
|
||||
else if (check_time (item_time) != 1)
|
||||
{
|
||||
status_mesg (format_message_1, enter_str);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
else
|
||||
(void)sscanf (item_time, "%u:%u", &heures, &minutes);
|
||||
}
|
||||
{
|
||||
if (strlen (item_time) == 0)
|
||||
{
|
||||
is_appointment = 0;
|
||||
break;
|
||||
}
|
||||
else if (check_time (item_time) != 1)
|
||||
{
|
||||
status_mesg (format_message_1, enter_str);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
else
|
||||
(void)sscanf (item_time, "%u:%u", &heures, &minutes);
|
||||
}
|
||||
else
|
||||
return;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* Check if an event or appointment is entered,
|
||||
@ -212,35 +212,35 @@ apoint_add (void)
|
||||
{ /* Get the appointment duration */
|
||||
item_time[0] = '\0';
|
||||
while (check_time (item_time) == 0)
|
||||
{
|
||||
status_mesg (mesg_2, "");
|
||||
if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_VALID)
|
||||
return; //nothing entered, cancel adding of event
|
||||
else if (check_time (item_time) == 0)
|
||||
{
|
||||
status_mesg (format_message_2, enter_str);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (check_time (item_time) == 2)
|
||||
apoint_duration = atoi (item_time);
|
||||
else if (check_time (item_time) == 1)
|
||||
{
|
||||
(void)sscanf (item_time, "%u:%u", &end_h, &end_m);
|
||||
if (end_h < heures || ((end_h == heures) && (end_m < minutes)))
|
||||
{
|
||||
apoint_duration = MININSEC - minutes + end_m
|
||||
{
|
||||
status_mesg (mesg_2, "");
|
||||
if (getstring (win[STA].p, item_time, LTIME, 0, 1) != GETSTRING_VALID)
|
||||
return; //nothing entered, cancel adding of event
|
||||
else if (check_time (item_time) == 0)
|
||||
{
|
||||
status_mesg (format_message_2, enter_str);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (check_time (item_time) == 2)
|
||||
apoint_duration = atoi (item_time);
|
||||
else if (check_time (item_time) == 1)
|
||||
{
|
||||
(void)sscanf (item_time, "%u:%u", &end_h, &end_m);
|
||||
if (end_h < heures || ((end_h == heures) && (end_m < minutes)))
|
||||
{
|
||||
apoint_duration = MININSEC - minutes + end_m
|
||||
+ (24 + end_h - (heures + 1)) * MININSEC;
|
||||
}
|
||||
else
|
||||
{
|
||||
apoint_duration = MININSEC - minutes
|
||||
}
|
||||
else
|
||||
{
|
||||
apoint_duration = MININSEC - minutes
|
||||
+ end_m + (end_h - (heures + 1)) * MININSEC;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* Insert the event Id */
|
||||
Id = 1;
|
||||
@ -249,19 +249,19 @@ apoint_add (void)
|
||||
if (getstring (win[STA].p, item_mesg, BUFSIZ, 0, 1) == GETSTRING_VALID)
|
||||
{
|
||||
if (is_appointment)
|
||||
{
|
||||
apoint_start = date2sec (*calendar_get_slctd_day (), heures, minutes);
|
||||
(void)apoint_new (item_mesg, 0L, apoint_start,
|
||||
{
|
||||
apoint_start = date2sec (*calendar_get_slctd_day (), heures, minutes);
|
||||
(void)apoint_new (item_mesg, 0L, apoint_start,
|
||||
min2sec (apoint_duration), 0L);
|
||||
if (notify_bar ())
|
||||
notify_check_added (item_mesg, apoint_start, 0L);
|
||||
}
|
||||
if (notify_bar ())
|
||||
notify_check_added (item_mesg, apoint_start, 0L);
|
||||
}
|
||||
else
|
||||
(void)event_new (item_mesg, 0L,
|
||||
(void)event_new (item_mesg, 0L,
|
||||
date2sec (*calendar_get_slctd_day (), 12, 0), Id);
|
||||
|
||||
if (hilt == 0)
|
||||
hilt++;
|
||||
hilt++;
|
||||
}
|
||||
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);
|
||||
answer = wgetch (win[STA].p);
|
||||
if ((answer == 'y') && (nb_items != 0))
|
||||
go_for_deletion = 1;
|
||||
go_for_deletion = 1;
|
||||
else
|
||||
{
|
||||
wins_erase_status_bar ();
|
||||
return;
|
||||
}
|
||||
{
|
||||
wins_erase_status_bar ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (nb_items != 0)
|
||||
go_for_deletion = 1;
|
||||
@ -299,31 +299,31 @@ apoint_delete (struct conf *conf, unsigned *nb_events, unsigned *nb_apoints)
|
||||
if (go_for_deletion)
|
||||
{
|
||||
if (nb_items != 0)
|
||||
{
|
||||
deleted_item_type = day_erase_item (date, hilt, ERASE_DONT_FORCE);
|
||||
if (deleted_item_type == EVNT || deleted_item_type == RECUR_EVNT)
|
||||
{
|
||||
(*nb_events)--;
|
||||
to_be_removed = 1;
|
||||
}
|
||||
else if (deleted_item_type == APPT || deleted_item_type == RECUR_APPT)
|
||||
{
|
||||
(*nb_apoints)--;
|
||||
to_be_removed = 3;
|
||||
}
|
||||
else if (deleted_item_type == 0)
|
||||
{
|
||||
deleted_item_type = day_erase_item (date, hilt, ERASE_DONT_FORCE);
|
||||
if (deleted_item_type == EVNT || deleted_item_type == RECUR_EVNT)
|
||||
{
|
||||
(*nb_events)--;
|
||||
to_be_removed = 1;
|
||||
}
|
||||
else if (deleted_item_type == APPT || deleted_item_type == RECUR_APPT)
|
||||
{
|
||||
(*nb_apoints)--;
|
||||
to_be_removed = 3;
|
||||
}
|
||||
else if (deleted_item_type == 0)
|
||||
return;
|
||||
else
|
||||
else
|
||||
EXIT (_("no such type"));
|
||||
/* NOTREACHED */
|
||||
/* NOTREACHED */
|
||||
|
||||
if (hilt > 1)
|
||||
hilt--;
|
||||
if (apad.first_onscreen >= to_be_removed)
|
||||
apad.first_onscreen = apad.first_onscreen - to_be_removed;
|
||||
if (nb_items == 1)
|
||||
hilt = 0;
|
||||
}
|
||||
if (hilt > 1)
|
||||
hilt--;
|
||||
if (apad.first_onscreen >= to_be_removed)
|
||||
apad.first_onscreen = apad.first_onscreen - to_be_removed;
|
||||
if (nb_items == 1)
|
||||
hilt = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,11 +488,11 @@ apoint_get (long day, int pos)
|
||||
for (o = alist_p->root; o; o = o->next)
|
||||
{
|
||||
if (apoint_inday (o, day))
|
||||
{
|
||||
if (n == pos)
|
||||
return (o);
|
||||
n++;
|
||||
}
|
||||
{
|
||||
if (n == pos)
|
||||
return (o);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
EXIT (_("item not found"));
|
||||
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)
|
||||
{
|
||||
if (apoint_inday (i, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
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);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
if (notify_bar ())
|
||||
need_check_notify = notify_same_item (i->start);
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
if (notify_bar ())
|
||||
need_check_notify = notify_same_item (i->start);
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
|
||||
erase_note (&i->note, flag);
|
||||
mem_free (i);
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
if (need_check_notify)
|
||||
notify_check_next_app ();
|
||||
mem_free (i);
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
if (need_check_notify)
|
||||
notify_check_next_app ();
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (i->start > app->time)
|
||||
{
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
return (app);
|
||||
}
|
||||
{
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
return (app);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->start > start)
|
||||
{
|
||||
app->time = i->start;
|
||||
app->txt = mem_strdup (i->mesg);
|
||||
app->state = i->state;
|
||||
app->got_app = 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (i->start > start)
|
||||
{
|
||||
app->time = i->start;
|
||||
app->txt = mem_strdup (i->mesg);
|
||||
app->state = i->state;
|
||||
app->got_app = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
|
||||
@ -687,22 +687,22 @@ apoint_switch_notify (void)
|
||||
for (apoint = alist_p->root; apoint != 0; apoint = apoint->next)
|
||||
{
|
||||
if (apoint_inday (apoint, date))
|
||||
{
|
||||
if (n == apoint_nb)
|
||||
{
|
||||
apoint->state ^= APOINT_NOTIFY;
|
||||
if (notify_bar ())
|
||||
{
|
||||
if (n == apoint_nb)
|
||||
{
|
||||
apoint->state ^= APOINT_NOTIFY;
|
||||
if (notify_bar ())
|
||||
{
|
||||
notify_check_added (apoint->mesg, apoint->start,
|
||||
apoint->state);
|
||||
}
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
if (need_chk_notify)
|
||||
notify_check_next_app ();
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
if (need_chk_notify)
|
||||
notify_check_next_app ();
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
@ -735,8 +735,8 @@ apoint_update_panel (int which_pan)
|
||||
win[APP].h - 2);
|
||||
custom_apply_attr (win[APP].p, ATTR_HIGHEST);
|
||||
mvwprintw (win[APP].p, title_lines, title_xpos, "%s %s %d, %d",
|
||||
calendar_get_pom (date), _(monthnames[slctd_date.mm - 1]),
|
||||
slctd_date.dd, slctd_date.yyyy);
|
||||
calendar_get_pom (date), _(monthnames[slctd_date.mm - 1]),
|
||||
slctd_date.dd, slctd_date.yyyy);
|
||||
custom_remove_attr (win[APP].p, ATTR_HIGHEST);
|
||||
|
||||
/* Draw the scrollbar if necessary. */
|
||||
@ -749,16 +749,16 @@ apoint_update_panel (int which_pan)
|
||||
int sbar_top = highend + title_lines + 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,
|
||||
title_lines + 1, win[APP].h - 1, hilt_bar);
|
||||
title_lines + 1, win[APP].h - 1, hilt_bar);
|
||||
}
|
||||
|
||||
wnoutrefresh (win[APP].p);
|
||||
pnoutrefresh (apad.ptrwin, apad.first_onscreen, 0,
|
||||
win[APP].y + title_lines + 1, win[APP].x + bordr,
|
||||
win[APP].y + win[APP].h - 2 * bordr,
|
||||
win[APP].x + win[APP].w - 3 * bordr);
|
||||
win[APP].y + title_lines + 1, win[APP].x + bordr,
|
||||
win[APP].y + win[APP].h - 2 * bordr,
|
||||
win[APP].x + win[APP].w - 3 * bordr);
|
||||
}
|
||||
|
||||
void
|
||||
|
448
src/args.c
448
src/args.c
@ -74,7 +74,7 @@ version_arg ()
|
||||
char vtitle[BUFSIZ];
|
||||
char *vtext =
|
||||
_("\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"),
|
||||
VERSION);
|
||||
@ -212,16 +212,16 @@ print_notefile (FILE *out, char *filename, int nbtab)
|
||||
if (notefile)
|
||||
{
|
||||
while (fgets (buffer, BUFSIZ, notefile) != 0)
|
||||
{
|
||||
if (printlinestarter)
|
||||
{
|
||||
fputs (linestarter, out);
|
||||
printlinestarter = 0;
|
||||
}
|
||||
fputs (buffer, out);
|
||||
if (buffer[strlen (buffer) - 1] == '\n')
|
||||
printlinestarter = 1;
|
||||
}
|
||||
{
|
||||
if (printlinestarter)
|
||||
{
|
||||
fputs (linestarter, out);
|
||||
printlinestarter = 0;
|
||||
}
|
||||
fputs (buffer, out);
|
||||
if (buffer[strlen (buffer) - 1] == '\n')
|
||||
printlinestarter = 1;
|
||||
}
|
||||
fputs ("\n", out);
|
||||
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,
|
||||
re->rpt->until, today))
|
||||
{
|
||||
{
|
||||
if (regex && regexec (regex, re->mesg, 0, 0, 0) != 0)
|
||||
continue;
|
||||
|
||||
app_found = 1;
|
||||
if (add_line)
|
||||
{
|
||||
fputs ("\n", stdout);
|
||||
add_line = 0;
|
||||
}
|
||||
if (print_date)
|
||||
{
|
||||
arg_print_date (today, conf);
|
||||
print_date = 0;
|
||||
}
|
||||
fputs (" * ", stdout);
|
||||
fputs (re->mesg, stdout);
|
||||
fputs ("\n", stdout);
|
||||
if (print_note && re->note)
|
||||
print_notefile (stdout, re->note, 2);
|
||||
}
|
||||
app_found = 1;
|
||||
if (add_line)
|
||||
{
|
||||
fputs ("\n", stdout);
|
||||
add_line = 0;
|
||||
}
|
||||
if (print_date)
|
||||
{
|
||||
arg_print_date (today, conf);
|
||||
print_date = 0;
|
||||
}
|
||||
fputs (" * ", stdout);
|
||||
fputs (re->mesg, stdout);
|
||||
fputs ("\n", stdout);
|
||||
if (print_note && re->note)
|
||||
print_notefile (stdout, re->note, 2);
|
||||
}
|
||||
}
|
||||
|
||||
for (j = eventlist; j != 0; j = j->next)
|
||||
{
|
||||
if (event_inday (j, today))
|
||||
{
|
||||
{
|
||||
if (regex && regexec (regex, j->mesg, 0, 0, 0) != 0)
|
||||
continue;
|
||||
|
||||
app_found = 1;
|
||||
if (add_line)
|
||||
{
|
||||
fputs ("\n", stdout);
|
||||
add_line = 0;
|
||||
}
|
||||
if (print_date)
|
||||
{
|
||||
arg_print_date (today, conf);
|
||||
print_date = 0;
|
||||
}
|
||||
fputs (" * ", stdout);
|
||||
fputs (j->mesg, stdout);
|
||||
fputs ("\n", stdout);
|
||||
if (print_note && j->note)
|
||||
print_notefile (stdout, j->note, 2);
|
||||
}
|
||||
app_found = 1;
|
||||
if (add_line)
|
||||
{
|
||||
fputs ("\n", stdout);
|
||||
add_line = 0;
|
||||
}
|
||||
if (print_date)
|
||||
{
|
||||
arg_print_date (today, conf);
|
||||
print_date = 0;
|
||||
}
|
||||
fputs (" * ", stdout);
|
||||
fputs (j->mesg, stdout);
|
||||
fputs ("\n", stdout);
|
||||
if (print_note && j->note)
|
||||
print_notefile (stdout, j->note, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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,
|
||||
ra->rpt->until, today))
|
||||
{
|
||||
{
|
||||
struct apoint *apt;
|
||||
|
||||
if (regex && regexec (regex, ra->mesg, 0, 0, 0) != 0)
|
||||
continue;
|
||||
|
||||
app_found = 1;
|
||||
if (add_line)
|
||||
{
|
||||
fputs ("\n", stdout);
|
||||
add_line = 0;
|
||||
}
|
||||
if (print_date)
|
||||
{
|
||||
arg_print_date (today, conf);
|
||||
print_date = 0;
|
||||
}
|
||||
app_found = 1;
|
||||
if (add_line)
|
||||
{
|
||||
fputs ("\n", stdout);
|
||||
add_line = 0;
|
||||
}
|
||||
if (print_date)
|
||||
{
|
||||
arg_print_date (today, conf);
|
||||
print_date = 0;
|
||||
}
|
||||
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);
|
||||
mem_free (apt->mesg);
|
||||
mem_free (apt);
|
||||
fputs (" - ", stdout);
|
||||
fputs (apoint_start_time, stdout);
|
||||
fputs (" -> ", stdout);
|
||||
fputs (apoint_end_time, stdout);
|
||||
fputs ("\n\t", stdout);
|
||||
fputs (ra->mesg, stdout);
|
||||
fputs ("\n", stdout);
|
||||
if (print_note && ra->note)
|
||||
print_notefile (stdout, ra->note, 2);
|
||||
}
|
||||
fputs (" - ", stdout);
|
||||
fputs (apoint_start_time, stdout);
|
||||
fputs (" -> ", stdout);
|
||||
fputs (apoint_end_time, stdout);
|
||||
fputs ("\n\t", stdout);
|
||||
fputs (ra->mesg, stdout);
|
||||
fputs ("\n", stdout);
|
||||
if (print_note && ra->note)
|
||||
print_notefile (stdout, ra->note, 2);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (apoint_inday (i, today))
|
||||
{
|
||||
{
|
||||
if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0)
|
||||
continue;
|
||||
|
||||
app_found = 1;
|
||||
if (add_line)
|
||||
{
|
||||
fputs ("\n", stdout);
|
||||
add_line = 0;
|
||||
}
|
||||
if (print_date)
|
||||
{
|
||||
arg_print_date (today, conf);
|
||||
print_date = 0;
|
||||
}
|
||||
apoint_sec2str (i, APPT, today, apoint_start_time, apoint_end_time);
|
||||
fputs (" - ", stdout);
|
||||
fputs (apoint_start_time, stdout);
|
||||
fputs (" -> ", stdout);
|
||||
fputs (apoint_end_time, stdout);
|
||||
fputs ("\n\t", stdout);
|
||||
fputs (i->mesg, stdout);
|
||||
fputs ("\n", stdout);
|
||||
if (print_note && i->note)
|
||||
print_notefile (stdout, i->note, 2);
|
||||
}
|
||||
app_found = 1;
|
||||
if (add_line)
|
||||
{
|
||||
fputs ("\n", stdout);
|
||||
add_line = 0;
|
||||
}
|
||||
if (print_date)
|
||||
{
|
||||
arg_print_date (today, conf);
|
||||
print_date = 0;
|
||||
}
|
||||
apoint_sec2str (i, APPT, today, apoint_start_time, apoint_end_time);
|
||||
fputs (" - ", stdout);
|
||||
fputs (apoint_start_time, stdout);
|
||||
fputs (" -> ", stdout);
|
||||
fputs (apoint_end_time, stdout);
|
||||
fputs ("\n\t", stdout);
|
||||
fputs (i->mesg, stdout);
|
||||
fputs ("\n", stdout);
|
||||
if (print_note && i->note)
|
||||
print_notefile (stdout, i->note, 2);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{ /* a number of days was entered */
|
||||
for (i = 0; i <= arg_len - 1; i++)
|
||||
{
|
||||
if (isdigit (ddate[i]))
|
||||
num_digit++;
|
||||
}
|
||||
{
|
||||
if (isdigit (ddate[i]))
|
||||
num_digit++;
|
||||
}
|
||||
if (num_digit == arg_len)
|
||||
numdays = atoi (ddate);
|
||||
numdays = atoi (ddate);
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
if (parse_date (ddate, conf->input_datefmt, (int *)&day.yyyy,
|
||||
(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
|
||||
{
|
||||
char outstr[BUFSIZ];
|
||||
fputs (_("Argument to the '-d' flag is not valid\n"), stderr);
|
||||
(void)snprintf (outstr, BUFSIZ,
|
||||
{
|
||||
char outstr[BUFSIZ];
|
||||
fputs (_("Argument to the '-d' flag is not valid\n"), stderr);
|
||||
(void)snprintf (outstr, BUFSIZ,
|
||||
"Possible argument format are: '%s' or 'n'\n",
|
||||
DATEFMT_DESC (conf->input_datefmt));
|
||||
fputs (_(outstr), stdout);
|
||||
fputs (_(outstr), stdout);
|
||||
more_info ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -616,28 +616,28 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
|
||||
{
|
||||
arg_len = strlen (range);
|
||||
for (i = 0; i <= arg_len - 1; i++)
|
||||
{
|
||||
if (!isdigit (range[i]))
|
||||
error = 1;
|
||||
}
|
||||
{
|
||||
if (!isdigit (range[i]))
|
||||
error = 1;
|
||||
}
|
||||
if (!error)
|
||||
numdays = atoi (range);
|
||||
numdays = atoi (range);
|
||||
}
|
||||
timer = time (NULL);
|
||||
t = *localtime (&timer);
|
||||
if (startday != NULL)
|
||||
{
|
||||
if (parse_date (startday, conf->input_datefmt, (int *)&t.tm_year,
|
||||
(int *)&t.tm_mon, (int *)&t.tm_mday, NULL))
|
||||
{
|
||||
t.tm_year -= 1900;
|
||||
t.tm_mon--;
|
||||
(void)mktime (&t);
|
||||
}
|
||||
(int *)&t.tm_mon, (int *)&t.tm_mday, NULL))
|
||||
{
|
||||
t.tm_year -= 1900;
|
||||
t.tm_mon--;
|
||||
(void)mktime (&t);
|
||||
}
|
||||
else
|
||||
{
|
||||
error = 1;
|
||||
}
|
||||
{
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
switch (ch)
|
||||
{
|
||||
{
|
||||
case STATUS_OPT:
|
||||
statusflag = 1;
|
||||
break;
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
multiple_flag++;
|
||||
case 'a':
|
||||
aflag = 1;
|
||||
multiple_flag++;
|
||||
load_data++;
|
||||
break;
|
||||
case 'c':
|
||||
cflag = 1;
|
||||
multiple_flag++;
|
||||
cfile = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
cflag = 1;
|
||||
multiple_flag++;
|
||||
cfile = optarg;
|
||||
load_data++;
|
||||
break;
|
||||
case 'd':
|
||||
dflag = 1;
|
||||
multiple_flag++;
|
||||
break;
|
||||
case 'd':
|
||||
dflag = 1;
|
||||
multiple_flag++;
|
||||
load_data++;
|
||||
ddate = optarg;
|
||||
break;
|
||||
ddate = optarg;
|
||||
break;
|
||||
case 'D':
|
||||
Dflag = 1;
|
||||
datadir = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
hflag = 1;
|
||||
break;
|
||||
case 'h':
|
||||
hflag = 1;
|
||||
break;
|
||||
case 'i':
|
||||
iflag = 1;
|
||||
multiple_flag++;
|
||||
load_data++;
|
||||
ifile = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
multiple_flag++;
|
||||
case 'n':
|
||||
nflag = 1;
|
||||
multiple_flag++;
|
||||
load_data++;
|
||||
break;
|
||||
case 'N':
|
||||
Nflag = 1;
|
||||
break;
|
||||
break;
|
||||
case 'N':
|
||||
Nflag = 1;
|
||||
break;
|
||||
case 'r':
|
||||
rflag = 1;
|
||||
multiple_flag++;
|
||||
@ -780,30 +780,30 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
EXIT (_("Could not compile regular expression."));
|
||||
preg = ®
|
||||
break;
|
||||
case 't':
|
||||
tflag = 1;
|
||||
multiple_flag++;
|
||||
case 't':
|
||||
tflag = 1;
|
||||
multiple_flag++;
|
||||
load_data++;
|
||||
add_line = 1;
|
||||
if (optarg != NULL)
|
||||
{
|
||||
tnum = atoi (optarg);
|
||||
if (tnum < 0 || tnum > 9)
|
||||
{
|
||||
usage ();
|
||||
usage_try ();
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
else
|
||||
tnum = -1;
|
||||
break;
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
case 'x':
|
||||
xflag = 1;
|
||||
multiple_flag++;
|
||||
add_line = 1;
|
||||
if (optarg != NULL)
|
||||
{
|
||||
tnum = atoi (optarg);
|
||||
if (tnum < 0 || tnum > 9)
|
||||
{
|
||||
usage ();
|
||||
usage_try ();
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
else
|
||||
tnum = -1;
|
||||
break;
|
||||
case 'v':
|
||||
vflag = 1;
|
||||
break;
|
||||
case 'x':
|
||||
xflag = 1;
|
||||
multiple_flag++;
|
||||
load_data++;
|
||||
if (optarg != NULL)
|
||||
{
|
||||
@ -824,14 +824,14 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
{
|
||||
xfmt = IO_EXPORT_ICAL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
usage_try ();
|
||||
unknown_flag = 1;
|
||||
non_interactive = 1;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
usage_try ();
|
||||
unknown_flag = 1;
|
||||
non_interactive = 1;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
@ -862,19 +862,19 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
else
|
||||
{
|
||||
if (unknown_flag)
|
||||
{
|
||||
non_interactive = 1;
|
||||
}
|
||||
{
|
||||
non_interactive = 1;
|
||||
}
|
||||
else if (hflag)
|
||||
{
|
||||
help_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
{
|
||||
help_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
else if (vflag)
|
||||
{
|
||||
version_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
{
|
||||
version_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
else if (statusflag)
|
||||
{
|
||||
io_init (cfile, datadir);
|
||||
@ -882,13 +882,13 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
non_interactive = 1;
|
||||
}
|
||||
else if (multiple_flag)
|
||||
{
|
||||
if (load_data)
|
||||
{
|
||||
io_init (cfile, datadir);
|
||||
{
|
||||
if (load_data)
|
||||
{
|
||||
io_init (cfile, datadir);
|
||||
io_check_dir (path_dir, (int *)0);
|
||||
io_check_dir (path_notes, (int *)0);
|
||||
}
|
||||
}
|
||||
if (iflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
@ -900,32 +900,32 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
io_save_todo ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (xflag)
|
||||
{
|
||||
if (xflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_todo, (int *)0);
|
||||
io_load_app ();
|
||||
io_load_todo ();
|
||||
io_export_data (xfmt, conf);
|
||||
non_interactive = 1;
|
||||
return non_interactive;
|
||||
}
|
||||
if (tflag)
|
||||
{
|
||||
io_export_data (xfmt, conf);
|
||||
non_interactive = 1;
|
||||
return non_interactive;
|
||||
}
|
||||
if (tflag)
|
||||
{
|
||||
io_check_file (path_todo, (int *)0);
|
||||
io_load_todo ();
|
||||
todo_arg (tnum, Nflag, preg);
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (nflag)
|
||||
{
|
||||
todo_arg (tnum, Nflag, preg);
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (nflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_load_app ();
|
||||
next_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (dflag || rflag || sflag)
|
||||
{
|
||||
next_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (dflag || rflag || sflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_conf, (int *)0);
|
||||
io_load_app ();
|
||||
@ -935,27 +935,27 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
if (rflag || sflag)
|
||||
date_arg_extended (startday, range, add_line, Nflag, conf,
|
||||
preg);
|
||||
non_interactive = 1;
|
||||
}
|
||||
else if (aflag)
|
||||
{
|
||||
struct date day;
|
||||
non_interactive = 1;
|
||||
}
|
||||
else if (aflag)
|
||||
{
|
||||
struct date day;
|
||||
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_conf, (int *)0);
|
||||
vars_init (conf);
|
||||
custom_load_conf (conf, 0); /* To get output date format. */
|
||||
io_load_app ();
|
||||
day.dd = day.mm = day.yyyy = 0;
|
||||
app_found = app_arg (add_line, &day, 0, Nflag, conf, preg);
|
||||
non_interactive = 1;
|
||||
}
|
||||
}
|
||||
day.dd = day.mm = day.yyyy = 0;
|
||||
app_found = app_arg (add_line, &day, 0, Nflag, conf, preg);
|
||||
non_interactive = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
non_interactive = 0;
|
||||
{
|
||||
non_interactive = 0;
|
||||
io_init (cfile, datadir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (preg)
|
||||
|
514
src/calcurse.c
514
src/calcurse.c
@ -61,7 +61,7 @@ main (int argc, char **argv)
|
||||
unsigned day_changed = 0;
|
||||
char *no_color_support =
|
||||
_("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 choices[] = "[y/n] ";
|
||||
|
||||
@ -109,10 +109,10 @@ main (int argc, char **argv)
|
||||
|
||||
#ifdef NCURSES_VERSION
|
||||
if (use_default_colors () != ERR)
|
||||
{
|
||||
background = -1;
|
||||
foreground = -1;
|
||||
}
|
||||
{
|
||||
background = -1;
|
||||
foreground = -1;
|
||||
}
|
||||
#endif /* NCURSES_VERSION */
|
||||
|
||||
/* Color assignment */
|
||||
@ -169,110 +169,110 @@ main (int argc, char **argv)
|
||||
do_update = 1;
|
||||
key = keys_getch (win[STA].p);
|
||||
switch (key)
|
||||
{
|
||||
case ERR:
|
||||
do_update = 0;
|
||||
break;
|
||||
{
|
||||
case ERR:
|
||||
do_update = 0;
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_REDRAW:
|
||||
case KEY_RESIZE:
|
||||
do_update = 0;
|
||||
wins_reset ();
|
||||
break;
|
||||
case KEY_GENERIC_REDRAW:
|
||||
case KEY_RESIZE:
|
||||
do_update = 0;
|
||||
wins_reset ();
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_CHANGE_VIEW:
|
||||
wins_reset_status_page ();
|
||||
/* Need to save the previously highlighted event. */
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case TOD:
|
||||
sav_hilt_tod = todo_hilt ();
|
||||
todo_hilt_set (0);
|
||||
break;
|
||||
case APP:
|
||||
sav_hilt_app = apoint_hilt ();
|
||||
apoint_hilt_set (0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
wins_slctd_next ();
|
||||
case KEY_GENERIC_CHANGE_VIEW:
|
||||
wins_reset_status_page ();
|
||||
/* Need to save the previously highlighted event. */
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case TOD:
|
||||
sav_hilt_tod = todo_hilt ();
|
||||
todo_hilt_set (0);
|
||||
break;
|
||||
case APP:
|
||||
sav_hilt_app = apoint_hilt ();
|
||||
apoint_hilt_set (0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
wins_slctd_next ();
|
||||
|
||||
/* Select the event to highlight. */
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case TOD:
|
||||
if ((sav_hilt_tod == 0) && (todo_nb () != 0))
|
||||
todo_hilt_set (1);
|
||||
else
|
||||
todo_hilt_set (sav_hilt_tod);
|
||||
break;
|
||||
case APP:
|
||||
if ((sav_hilt_app == 0)
|
||||
/* Select the event to highlight. */
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case TOD:
|
||||
if ((sav_hilt_tod == 0) && (todo_nb () != 0))
|
||||
todo_hilt_set (1);
|
||||
else
|
||||
todo_hilt_set (sav_hilt_tod);
|
||||
break;
|
||||
case APP:
|
||||
if ((sav_hilt_app == 0)
|
||||
&& ((inday.nb_events + inday.nb_apoints) != 0))
|
||||
apoint_hilt_set (1);
|
||||
else
|
||||
apoint_hilt_set (sav_hilt_app);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
apoint_hilt_set (1);
|
||||
else
|
||||
apoint_hilt_set (sav_hilt_app);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_OTHER_CMD:
|
||||
wins_other_status_page (wins_slctd ());
|
||||
break;
|
||||
wins_other_status_page (wins_slctd ());
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_GOTO:
|
||||
case KEY_GENERIC_GOTO_TODAY:
|
||||
wins_erase_status_bar ();
|
||||
calendar_set_current_date ();
|
||||
wins_erase_status_bar ();
|
||||
calendar_set_current_date ();
|
||||
if (key == KEY_GENERIC_GOTO_TODAY)
|
||||
calendar_goto_today ();
|
||||
else
|
||||
calendar_change_day (conf.input_datefmt);
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
break;
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
break;
|
||||
|
||||
case KEY_VIEW_ITEM:
|
||||
if ((wins_slctd () == APP) && (apoint_hilt () != 0))
|
||||
day_popup_item ();
|
||||
else if ((wins_slctd () == TOD) && (todo_hilt () != 0))
|
||||
item_in_popup (NULL, NULL, todo_saved_mesg (), _("To do :"));
|
||||
break;
|
||||
if ((wins_slctd () == APP) && (apoint_hilt () != 0))
|
||||
day_popup_item ();
|
||||
else if ((wins_slctd () == TOD) && (todo_hilt () != 0))
|
||||
item_in_popup (NULL, NULL, todo_saved_mesg (), _("To do :"));
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_CONFIG_MENU:
|
||||
wins_erase_status_bar ();
|
||||
custom_config_bar ();
|
||||
while ((key = wgetch (win[STA].p)) != 'q')
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 'C':
|
||||
case 'c':
|
||||
if (has_colors ())
|
||||
custom_color_config ();
|
||||
else
|
||||
{
|
||||
colorize = 0;
|
||||
wins_erase_status_bar ();
|
||||
mvwprintw (win[STA].p, 0, 0, _(no_color_support));
|
||||
wgetch (win[STA].p);
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
custom_layout_config ();
|
||||
break;
|
||||
case 'G':
|
||||
case 'g':
|
||||
custom_general_config (&conf);
|
||||
break;
|
||||
case 'N':
|
||||
case 'n':
|
||||
notify_config_bar ();
|
||||
break;
|
||||
wins_erase_status_bar ();
|
||||
custom_config_bar ();
|
||||
while ((key = wgetch (win[STA].p)) != 'q')
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 'C':
|
||||
case 'c':
|
||||
if (has_colors ())
|
||||
custom_color_config ();
|
||||
else
|
||||
{
|
||||
colorize = 0;
|
||||
wins_erase_status_bar ();
|
||||
mvwprintw (win[STA].p, 0, 0, _(no_color_support));
|
||||
wgetch (win[STA].p);
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
custom_layout_config ();
|
||||
break;
|
||||
case 'G':
|
||||
case 'g':
|
||||
custom_general_config (&conf);
|
||||
break;
|
||||
case 'N':
|
||||
case 'n':
|
||||
notify_config_bar ();
|
||||
break;
|
||||
case 'K':
|
||||
case 'k':
|
||||
custom_keys_config ();
|
||||
@ -281,59 +281,59 @@ main (int argc, char **argv)
|
||||
case 'S':
|
||||
custom_sidebar_config ();
|
||||
break;
|
||||
}
|
||||
wins_reset ();
|
||||
wins_update ();
|
||||
do_storage = 1;
|
||||
wins_erase_status_bar ();
|
||||
custom_config_bar ();
|
||||
}
|
||||
wins_update ();
|
||||
break;
|
||||
}
|
||||
wins_reset ();
|
||||
wins_update ();
|
||||
do_storage = 1;
|
||||
wins_erase_status_bar ();
|
||||
custom_config_bar ();
|
||||
}
|
||||
wins_update ();
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_ADD_APPT:
|
||||
apoint_add ();
|
||||
do_storage = 1;
|
||||
break;
|
||||
apoint_add ();
|
||||
do_storage = 1;
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_ADD_TODO:
|
||||
todo_new_item ();
|
||||
if (todo_hilt () == 0 && todo_nb () == 1)
|
||||
todo_hilt_increase ();
|
||||
break;
|
||||
todo_new_item ();
|
||||
if (todo_hilt () == 0 && todo_nb () == 1)
|
||||
todo_hilt_increase ();
|
||||
break;
|
||||
|
||||
case KEY_ADD_ITEM:
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case APP:
|
||||
apoint_add ();
|
||||
do_storage = 1;
|
||||
break;
|
||||
case TOD:
|
||||
todo_new_item ();
|
||||
if (todo_hilt () == 0 && todo_nb () == 1)
|
||||
todo_hilt_increase ();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
switch (wins_slctd ())
|
||||
{
|
||||
case APP:
|
||||
apoint_add ();
|
||||
do_storage = 1;
|
||||
break;
|
||||
case TOD:
|
||||
todo_new_item ();
|
||||
if (todo_hilt () == 0 && todo_nb () == 1)
|
||||
todo_hilt_increase ();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_EDIT_ITEM:
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_edit_item (&conf);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_edit_item ();
|
||||
do_storage = 1;
|
||||
break;
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_edit_item (&conf);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_edit_item ();
|
||||
do_storage = 1;
|
||||
break;
|
||||
|
||||
case KEY_DEL_ITEM:
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
apoint_delete (&conf, &inday.nb_events, &inday.nb_apoints);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_delete (&conf);
|
||||
do_storage = 1;
|
||||
break;
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
apoint_delete (&conf, &inday.nb_events, &inday.nb_apoints);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_delete (&conf);
|
||||
do_storage = 1;
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_CUT:
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
@ -353,54 +353,54 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case KEY_REPEAT_ITEM:
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
recur_repeat_item (&conf);
|
||||
do_storage = 1;
|
||||
break;
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
recur_repeat_item (&conf);
|
||||
do_storage = 1;
|
||||
break;
|
||||
|
||||
case KEY_FLAG_ITEM:
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
apoint_switch_notify ();
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
apoint_switch_notify ();
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_flag ();
|
||||
do_storage = 1;
|
||||
break;
|
||||
do_storage = 1;
|
||||
break;
|
||||
|
||||
case KEY_RAISE_PRIORITY:
|
||||
case KEY_LOWER_PRIORITY:
|
||||
if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
{
|
||||
todo_chg_priority (key);
|
||||
if (todo_hilt_pos () < 0)
|
||||
todo_set_first (todo_hilt ());
|
||||
else if (todo_hilt_pos () >= win[TOD].h - 4)
|
||||
todo_set_first (todo_hilt () - win[TOD].h + 5);
|
||||
}
|
||||
break;
|
||||
if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
{
|
||||
todo_chg_priority (key);
|
||||
if (todo_hilt_pos () < 0)
|
||||
todo_set_first (todo_hilt ());
|
||||
else if (todo_hilt_pos () >= win[TOD].h - 4)
|
||||
todo_set_first (todo_hilt () - win[TOD].h + 5);
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_EDIT_NOTE:
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_edit_note (conf.editor);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_edit_note (conf.editor);
|
||||
do_storage = 1;
|
||||
break;
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_edit_note (conf.editor);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_edit_note (conf.editor);
|
||||
do_storage = 1;
|
||||
break;
|
||||
|
||||
case KEY_VIEW_NOTE:
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_view_note (conf.pager);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_view_note (conf.pager);
|
||||
break;
|
||||
if (wins_slctd () == APP && apoint_hilt () != 0)
|
||||
day_view_note (conf.pager);
|
||||
else if (wins_slctd () == TOD && todo_hilt () != 0)
|
||||
todo_view_note (conf.pager);
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_HELP:
|
||||
wins_status_bar ();
|
||||
help_screen ();
|
||||
break;
|
||||
wins_status_bar ();
|
||||
help_screen ();
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_SAVE:
|
||||
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
|
||||
break;
|
||||
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_IMPORT:
|
||||
wins_erase_status_bar ();
|
||||
@ -412,55 +412,55 @@ main (int argc, char **argv)
|
||||
wins_erase_status_bar ();
|
||||
io_export_bar ();
|
||||
while ((key = wgetch (win[STA].p)) != 'q')
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 'I':
|
||||
case 'i':
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
case 'I':
|
||||
case 'i':
|
||||
io_export_data (IO_EXPORT_ICAL, &conf);
|
||||
break;
|
||||
case 'P':
|
||||
case 'p':
|
||||
break;
|
||||
case 'P':
|
||||
case 'p':
|
||||
io_export_data (IO_EXPORT_PCAL, &conf);
|
||||
break;
|
||||
}
|
||||
wins_reset ();
|
||||
wins_update ();
|
||||
do_storage = 1;
|
||||
wins_erase_status_bar ();
|
||||
io_export_bar ();
|
||||
}
|
||||
wins_update ();
|
||||
break;
|
||||
break;
|
||||
}
|
||||
wins_reset ();
|
||||
wins_update ();
|
||||
do_storage = 1;
|
||||
wins_erase_status_bar ();
|
||||
io_export_bar ();
|
||||
}
|
||||
wins_update ();
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_NEXT_DAY:
|
||||
case KEY_MOVE_RIGHT:
|
||||
if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_DAY)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (RIGHT);
|
||||
}
|
||||
break;
|
||||
if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_DAY)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (RIGHT);
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_PREV_DAY:
|
||||
case KEY_MOVE_LEFT:
|
||||
if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_DAY)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (LEFT);
|
||||
}
|
||||
break;
|
||||
if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_DAY)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (LEFT);
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_PREV_WEEK:
|
||||
case KEY_MOVE_UP:
|
||||
if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_WEEK)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (UP);
|
||||
}
|
||||
if (wins_slctd () == CAL || key == KEY_GENERIC_PREV_WEEK)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (UP);
|
||||
}
|
||||
else if ((wins_slctd () == APP) && (apoint_hilt () > 1))
|
||||
{
|
||||
apoint_hilt_decrease ();
|
||||
@ -476,12 +476,12 @@ main (int argc, char **argv)
|
||||
|
||||
case KEY_GENERIC_NEXT_WEEK:
|
||||
case KEY_MOVE_DOWN:
|
||||
if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_WEEK)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (DOWN);
|
||||
}
|
||||
if (wins_slctd () == CAL || key == KEY_GENERIC_NEXT_WEEK)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (DOWN);
|
||||
}
|
||||
else if ((wins_slctd () == APP) &&
|
||||
(apoint_hilt () < inday.nb_events + inday.nb_apoints))
|
||||
{
|
||||
@ -498,20 +498,20 @@ main (int argc, char **argv)
|
||||
|
||||
case KEY_START_OF_WEEK:
|
||||
if (wins_slctd () == CAL)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (WEEK_START);
|
||||
}
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (WEEK_START);
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_END_OF_WEEK:
|
||||
if (wins_slctd () == CAL)
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (WEEK_END);
|
||||
}
|
||||
{
|
||||
do_storage = 1;
|
||||
day_changed = 1;
|
||||
calendar_move (WEEK_END);
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_SCROLL_UP:
|
||||
@ -525,45 +525,45 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_QUIT:
|
||||
if (conf.auto_save)
|
||||
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
|
||||
if (conf.auto_save)
|
||||
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
|
||||
|
||||
if (conf.confirm_quit)
|
||||
{
|
||||
status_mesg (_(quit_message), choices);
|
||||
key = wgetch (win[STA].p);
|
||||
if (key == 'y')
|
||||
exit_calcurse (EXIT_SUCCESS);
|
||||
else
|
||||
{
|
||||
wins_erase_status_bar ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
exit_calcurse (EXIT_SUCCESS);
|
||||
break;
|
||||
if (conf.confirm_quit)
|
||||
{
|
||||
status_mesg (_(quit_message), choices);
|
||||
key = wgetch (win[STA].p);
|
||||
if (key == 'y')
|
||||
exit_calcurse (EXIT_SUCCESS);
|
||||
else
|
||||
{
|
||||
wins_erase_status_bar ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
exit_calcurse (EXIT_SUCCESS);
|
||||
break;
|
||||
|
||||
default:
|
||||
do_update = 0;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
do_update = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (do_storage)
|
||||
{
|
||||
inday = *day_process_storage (calendar_get_slctd_day (),
|
||||
day_changed, &inday);
|
||||
do_storage = !do_storage;
|
||||
if (day_changed)
|
||||
{
|
||||
sav_hilt_app = 0;
|
||||
day_changed = !day_changed;
|
||||
if ((wins_slctd () == APP) &&
|
||||
(inday.nb_events + inday.nb_apoints != 0))
|
||||
apoint_hilt_set (1);
|
||||
}
|
||||
}
|
||||
{
|
||||
inday = *day_process_storage (calendar_get_slctd_day (),
|
||||
day_changed, &inday);
|
||||
do_storage = !do_storage;
|
||||
if (day_changed)
|
||||
{
|
||||
sav_hilt_app = 0;
|
||||
day_changed = !day_changed;
|
||||
if ((wins_slctd () == APP) &&
|
||||
(inday.nb_events + inday.nb_apoints != 0))
|
||||
apoint_hilt_set (1);
|
||||
}
|
||||
}
|
||||
if (do_update)
|
||||
wins_update ();
|
||||
wins_update ();
|
||||
}
|
||||
}
|
||||
|
104
src/calendar.c
104
src/calendar.c
@ -328,7 +328,7 @@ draw_monthly_view (struct window *cwin, struct date *current_day,
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
mvwprintw (cwin->p, ofs_y,
|
||||
(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);
|
||||
++ofs_y;
|
||||
|
||||
@ -337,7 +337,7 @@ draw_monthly_view (struct window *cwin, struct date *current_day,
|
||||
for (j = 0; j < WEEKINDAYS; j++)
|
||||
{
|
||||
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);
|
||||
|
||||
@ -354,42 +354,42 @@ draw_monthly_view (struct window *cwin, struct date *current_day,
|
||||
|
||||
/* Go to next line, the week is over. */
|
||||
if (!c_day_1 && 1 != c_day)
|
||||
{
|
||||
ofs_y++;
|
||||
{
|
||||
ofs_y++;
|
||||
ofs_x = OFFX - day_1_sav - 4 * c_day;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is today, so print it in yellow. */
|
||||
if (c_day == current_day->dd
|
||||
&& current_day->mm == slctd_day.mm
|
||||
&& current_day->yyyy == slctd_day.yyyy
|
||||
&& current_day->dd != slctd_day.dd)
|
||||
{
|
||||
custom_apply_attr (cwin->p, ATTR_LOWEST);
|
||||
mvwprintw (cwin->p, ofs_y + 1,
|
||||
{
|
||||
custom_apply_attr (cwin->p, ATTR_LOWEST);
|
||||
mvwprintw (cwin->p, ofs_y + 1,
|
||||
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)
|
||||
{
|
||||
/* This is the selected day, print it according to user's theme. */
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
mvwprintw (cwin->p, ofs_y + 1,
|
||||
{
|
||||
/* This is the selected day, print it according to user's theme. */
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
mvwprintw (cwin->p, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
||||
}
|
||||
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
||||
}
|
||||
else if (item_this_day)
|
||||
{
|
||||
custom_apply_attr (cwin->p, ATTR_LOW);
|
||||
mvwprintw (cwin->p, ofs_y + 1,
|
||||
{
|
||||
custom_apply_attr (cwin->p, ATTR_LOW);
|
||||
mvwprintw (cwin->p, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
custom_remove_attr (cwin->p, ATTR_LOW);
|
||||
}
|
||||
custom_remove_attr (cwin->p, ATTR_LOW);
|
||||
}
|
||||
else
|
||||
/* otherwise, print normal days in black */
|
||||
mvwprintw (cwin->p, ofs_y + 1,
|
||||
/* otherwise, print normal days in black */
|
||||
mvwprintw (cwin->p, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
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 */
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
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);
|
||||
|
||||
/* 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));
|
||||
status_mesg (_(outstr), "");
|
||||
if (getstring (win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC)
|
||||
return;
|
||||
return;
|
||||
else
|
||||
{
|
||||
if (strlen (selected_day) == 0)
|
||||
{
|
||||
wrong_day = 0;
|
||||
{
|
||||
if (strlen (selected_day) == 0)
|
||||
{
|
||||
wrong_day = 0;
|
||||
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 ()))
|
||||
{
|
||||
wrong_day = 0;
|
||||
/* go to chosen day */
|
||||
slctd_day.dd = dday;
|
||||
slctd_day.mm = dmonth;
|
||||
slctd_day.yyyy = dyear;
|
||||
}
|
||||
if (wrong_day)
|
||||
{
|
||||
status_mesg (mesg_line1, mesg_line2);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
}
|
||||
{
|
||||
wrong_day = 0;
|
||||
/* go to chosen day */
|
||||
slctd_day.dd = dday;
|
||||
slctd_day.mm = dmonth;
|
||||
slctd_day.yyyy = dyear;
|
||||
}
|
||||
if (wrong_day)
|
||||
{
|
||||
status_mesg (mesg_line1, mesg_line2);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@ -681,25 +681,25 @@ calendar_move (enum move move)
|
||||
case UP:
|
||||
if ((slctd_day.dd <= 7) && (slctd_day.mm == 1)
|
||||
&& (slctd_day.yyyy == 1902))
|
||||
return;
|
||||
return;
|
||||
ret = date_change (&t, 0, -WEEKINDAYS);
|
||||
break;
|
||||
case DOWN:
|
||||
if ((slctd_day.dd > days[slctd_day.mm - 1] - 7)
|
||||
&& (slctd_day.mm == 12) && (slctd_day.yyyy == 2037))
|
||||
return;
|
||||
&& (slctd_day.mm == 12) && (slctd_day.yyyy == 2037))
|
||||
return;
|
||||
ret = date_change (&t, 0, WEEKINDAYS);
|
||||
break;
|
||||
case LEFT:
|
||||
if ((slctd_day.dd == 1) && (slctd_day.mm == 1)
|
||||
&& (slctd_day.yyyy == 1902))
|
||||
return;
|
||||
&& (slctd_day.yyyy == 1902))
|
||||
return;
|
||||
ret = date_change (&t, 0, -1);
|
||||
break;
|
||||
case RIGHT:
|
||||
if ((slctd_day.dd == 31) && (slctd_day.mm == 12)
|
||||
&& (slctd_day.yyyy == 2037))
|
||||
return;
|
||||
&& (slctd_day.yyyy == 2037))
|
||||
return;
|
||||
ret = date_change (&t, 0, 1);
|
||||
break;
|
||||
case WEEK_START:
|
||||
@ -891,7 +891,7 @@ pom (time_t tmpt)
|
||||
pom = NO_POM;
|
||||
GMT = gmtime (&tmpt);
|
||||
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)
|
||||
days += isleap (cnt + TM_YEAR_BASE) ? 366 : 365;
|
||||
/* Selected time could be before EPOCH */
|
||||
|
696
src/custom.c
696
src/custom.c
@ -106,37 +106,37 @@ custom_load_color (char *color, int background)
|
||||
{
|
||||
/* New version configuration */
|
||||
if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS)
|
||||
{
|
||||
{
|
||||
EXIT (_("missing colors in config file"));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
for (i = 0; i < AWAITED_COLORS; i++)
|
||||
{
|
||||
if (!strncmp (c[i], "black", 5))
|
||||
colr[i] = COLOR_BLACK;
|
||||
else if (!strncmp (c[i], "red", 3))
|
||||
colr[i] = COLOR_RED;
|
||||
else if (!strncmp (c[i], "green", 5))
|
||||
colr[i] = COLOR_GREEN;
|
||||
else if (!strncmp (c[i], "yellow", 6))
|
||||
colr[i] = COLOR_YELLOW;
|
||||
else if (!strncmp (c[i], "blue", 4))
|
||||
colr[i] = COLOR_BLUE;
|
||||
else if (!strncmp (c[i], "magenta", 7))
|
||||
colr[i] = COLOR_MAGENTA;
|
||||
else if (!strncmp (c[i], "cyan", 4))
|
||||
colr[i] = COLOR_CYAN;
|
||||
else if (!strncmp (c[i], "white", 5))
|
||||
colr[i] = COLOR_WHITE;
|
||||
else if (!strncmp (c[i], "default", 7))
|
||||
colr[i] = background;
|
||||
else
|
||||
{
|
||||
{
|
||||
if (!strncmp (c[i], "black", 5))
|
||||
colr[i] = COLOR_BLACK;
|
||||
else if (!strncmp (c[i], "red", 3))
|
||||
colr[i] = COLOR_RED;
|
||||
else if (!strncmp (c[i], "green", 5))
|
||||
colr[i] = COLOR_GREEN;
|
||||
else if (!strncmp (c[i], "yellow", 6))
|
||||
colr[i] = COLOR_YELLOW;
|
||||
else if (!strncmp (c[i], "blue", 4))
|
||||
colr[i] = COLOR_BLUE;
|
||||
else if (!strncmp (c[i], "magenta", 7))
|
||||
colr[i] = COLOR_MAGENTA;
|
||||
else if (!strncmp (c[i], "cyan", 4))
|
||||
colr[i] = COLOR_CYAN;
|
||||
else if (!strncmp (c[i], "white", 5))
|
||||
colr[i] = COLOR_WHITE;
|
||||
else if (!strncmp (c[i], "default", 7))
|
||||
colr[i] = background;
|
||||
else
|
||||
{
|
||||
EXIT (_("wrong color name"));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
init_pair (COLR_CUSTOM, colr[0], colr[1]);
|
||||
}
|
||||
else if (len > 0 && len < 2)
|
||||
@ -145,38 +145,38 @@ custom_load_color (char *color, int background)
|
||||
color_num = atoi (color);
|
||||
|
||||
switch (color_num)
|
||||
{
|
||||
case 0:
|
||||
colorize = 0;
|
||||
break;
|
||||
case 1:
|
||||
init_pair (COLR_CUSTOM, COLOR_RED, background);
|
||||
break;
|
||||
case 2:
|
||||
init_pair (COLR_CUSTOM, COLOR_GREEN, background);
|
||||
break;
|
||||
case 3:
|
||||
init_pair (COLR_CUSTOM, COLOR_BLUE, background);
|
||||
break;
|
||||
case 4:
|
||||
init_pair (COLR_CUSTOM, COLOR_CYAN, background);
|
||||
break;
|
||||
case 5:
|
||||
init_pair (COLR_CUSTOM, COLOR_YELLOW, background);
|
||||
break;
|
||||
case 6:
|
||||
init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_GREEN);
|
||||
break;
|
||||
case 7:
|
||||
init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_YELLOW);
|
||||
break;
|
||||
case 8:
|
||||
init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
case 0:
|
||||
colorize = 0;
|
||||
break;
|
||||
case 1:
|
||||
init_pair (COLR_CUSTOM, COLOR_RED, background);
|
||||
break;
|
||||
case 2:
|
||||
init_pair (COLR_CUSTOM, COLOR_GREEN, background);
|
||||
break;
|
||||
case 3:
|
||||
init_pair (COLR_CUSTOM, COLOR_BLUE, background);
|
||||
break;
|
||||
case 4:
|
||||
init_pair (COLR_CUSTOM, COLOR_CYAN, background);
|
||||
break;
|
||||
case 5:
|
||||
init_pair (COLR_CUSTOM, COLOR_YELLOW, background);
|
||||
break;
|
||||
case 6:
|
||||
init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_GREEN);
|
||||
break;
|
||||
case 7:
|
||||
init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_YELLOW);
|
||||
break;
|
||||
case 8:
|
||||
init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
|
||||
break;
|
||||
default:
|
||||
EXIT (_("wrong color number"));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -256,144 +256,144 @@ custom_load_conf (struct conf *conf, int background)
|
||||
for (;;)
|
||||
{
|
||||
if (fgets (buf, sizeof buf, data_file) == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
{
|
||||
break;
|
||||
}
|
||||
io_extract_data (e_conf, buf, sizeof buf);
|
||||
|
||||
switch (var)
|
||||
{
|
||||
case CUSTOM_CONF_NOVARIABLE:
|
||||
break;
|
||||
case CUSTOM_CONF_AUTOSAVE:
|
||||
conf->auto_save = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_PERIODICSAVE:
|
||||
conf->periodic_save = atoi (e_conf);
|
||||
if (conf->periodic_save < 0)
|
||||
conf->periodic_save = 0;
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_CONFIRMQUIT:
|
||||
conf->confirm_quit = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_CONFIRMDELETE:
|
||||
conf->confirm_delete = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_SKIPSYSTEMDIALOGS:
|
||||
conf->skip_system_dialogs = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_SKIPPROGRESSBAR:
|
||||
conf->skip_progress_bar = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
{
|
||||
case CUSTOM_CONF_NOVARIABLE:
|
||||
break;
|
||||
case CUSTOM_CONF_AUTOSAVE:
|
||||
conf->auto_save = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_PERIODICSAVE:
|
||||
conf->periodic_save = atoi (e_conf);
|
||||
if (conf->periodic_save < 0)
|
||||
conf->periodic_save = 0;
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_CONFIRMQUIT:
|
||||
conf->confirm_quit = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_CONFIRMDELETE:
|
||||
conf->confirm_delete = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_SKIPSYSTEMDIALOGS:
|
||||
conf->skip_system_dialogs = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_SKIPPROGRESSBAR:
|
||||
conf->skip_progress_bar = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_CALENDAR_DEFAULTVIEW:
|
||||
calendar_set_view (atoi (e_conf));
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_WEEKBEGINSONMONDAY:
|
||||
if (fill_config_var (e_conf))
|
||||
calendar_set_first_day_of_week (MONDAY);
|
||||
else
|
||||
calendar_set_first_day_of_week (SUNDAY);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_COLORTHEME:
|
||||
custom_load_color (e_conf, background);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_LAYOUT:
|
||||
wins_set_layout (atoi (e_conf));
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_WEEKBEGINSONMONDAY:
|
||||
if (fill_config_var (e_conf))
|
||||
calendar_set_first_day_of_week (MONDAY);
|
||||
else
|
||||
calendar_set_first_day_of_week (SUNDAY);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_COLORTHEME:
|
||||
custom_load_color (e_conf, background);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_LAYOUT:
|
||||
wins_set_layout (atoi (e_conf));
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_SBAR_WIDTH:
|
||||
wins_set_sbar_width (atoi (e_conf));
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARSHOW:
|
||||
nbar.show = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARDATE:
|
||||
(void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARCLOCK:
|
||||
(void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARWARNING:
|
||||
nbar.cntdwn = atoi (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARCOMMAND:
|
||||
(void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_OUTPUTDATEFMT:
|
||||
if (e_conf[0] != '\0')
|
||||
(void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_INPUTDATEFMT:
|
||||
conf->input_datefmt = atoi (e_conf);
|
||||
if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS)
|
||||
conf->input_datefmt = 1;
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_DMON_ENABLE:
|
||||
dmon.enable = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_DMON_LOG:
|
||||
dmon.log = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
default:
|
||||
case CUSTOM_CONF_NOTIFYBARSHOW:
|
||||
nbar.show = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARDATE:
|
||||
(void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARCLOCK:
|
||||
(void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARWARNING:
|
||||
nbar.cntdwn = atoi (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_NOTIFYBARCOMMAND:
|
||||
(void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_OUTPUTDATEFMT:
|
||||
if (e_conf[0] != '\0')
|
||||
(void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_INPUTDATEFMT:
|
||||
conf->input_datefmt = atoi (e_conf);
|
||||
if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS)
|
||||
conf->input_datefmt = 1;
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_DMON_ENABLE:
|
||||
dmon.enable = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
case CUSTOM_CONF_DMON_LOG:
|
||||
dmon.log = fill_config_var (e_conf);
|
||||
var = 0;
|
||||
break;
|
||||
default:
|
||||
EXIT (_("configuration variable unknown"));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
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)
|
||||
var = CUSTOM_CONF_PERIODICSAVE;
|
||||
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)
|
||||
var = CUSTOM_CONF_CONFIRMDELETE;
|
||||
var = CUSTOM_CONF_CONFIRMDELETE;
|
||||
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)
|
||||
var = CUSTOM_CONF_SKIPPROGRESSBAR;
|
||||
var = CUSTOM_CONF_SKIPPROGRESSBAR;
|
||||
else if (strncmp (e_conf, "calendar_default_view=", 22) == 0)
|
||||
var = CUSTOM_CONF_CALENDAR_DEFAULTVIEW;
|
||||
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)
|
||||
var = CUSTOM_CONF_COLORTHEME;
|
||||
var = CUSTOM_CONF_COLORTHEME;
|
||||
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)
|
||||
var = CUSTOM_CONF_SBAR_WIDTH;
|
||||
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)
|
||||
var = CUSTOM_CONF_NOTIFYBARDATE;
|
||||
var = CUSTOM_CONF_NOTIFYBARDATE;
|
||||
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)
|
||||
var = CUSTOM_CONF_NOTIFYBARWARNING;
|
||||
var = CUSTOM_CONF_NOTIFYBARWARNING;
|
||||
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)
|
||||
var = CUSTOM_CONF_OUTPUTDATEFMT;
|
||||
var = CUSTOM_CONF_OUTPUTDATEFMT;
|
||||
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)
|
||||
var = CUSTOM_CONF_DMON_ENABLE;
|
||||
else if (strncmp (e_conf, "notify-daemon_log=", 18) == 0)
|
||||
@ -547,13 +547,13 @@ custom_layout_config (void)
|
||||
{
|
||||
need_reset = 0;
|
||||
switch (ch)
|
||||
{
|
||||
case KEY_RESIZE:
|
||||
endwin ();
|
||||
wins_refresh ();
|
||||
curs_set (0);
|
||||
need_reset = 1;
|
||||
break;
|
||||
{
|
||||
case KEY_RESIZE:
|
||||
endwin ();
|
||||
wins_refresh ();
|
||||
curs_set (0);
|
||||
need_reset = 1;
|
||||
break;
|
||||
case KEY_GENERIC_HELP:
|
||||
help_wins_init (&hwin, 0, 0,
|
||||
(notify_bar ()) ? row - 3 : row - 2, col);
|
||||
@ -564,29 +564,29 @@ custom_layout_config (void)
|
||||
wins_scrollwin_delete (&hwin);
|
||||
need_reset = 1;
|
||||
break;
|
||||
case KEY_GENERIC_SELECT:
|
||||
case KEY_GENERIC_SELECT:
|
||||
mark = cursor;
|
||||
break;
|
||||
case KEY_MOVE_DOWN:
|
||||
if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1)
|
||||
cursor++;
|
||||
break;
|
||||
case KEY_MOVE_UP:
|
||||
if (cursor % LAYOUTSPERCOL > 0)
|
||||
cursor--;
|
||||
break;
|
||||
case KEY_MOVE_LEFT:
|
||||
if (cursor >= LAYOUTSPERCOL)
|
||||
cursor -= LAYOUTSPERCOL;
|
||||
break;
|
||||
case KEY_MOVE_RIGHT:
|
||||
if (cursor < NBLAYOUTS - LAYOUTSPERCOL)
|
||||
cursor += LAYOUTSPERCOL;
|
||||
break;
|
||||
case KEY_GENERIC_CANCEL:
|
||||
need_reset = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case KEY_MOVE_DOWN:
|
||||
if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1)
|
||||
cursor++;
|
||||
break;
|
||||
case KEY_MOVE_UP:
|
||||
if (cursor % LAYOUTSPERCOL > 0)
|
||||
cursor--;
|
||||
break;
|
||||
case KEY_MOVE_LEFT:
|
||||
if (cursor >= LAYOUTSPERCOL)
|
||||
cursor -= LAYOUTSPERCOL;
|
||||
break;
|
||||
case KEY_MOVE_RIGHT:
|
||||
if (cursor < NBLAYOUTS - LAYOUTSPERCOL)
|
||||
cursor += LAYOUTSPERCOL;
|
||||
break;
|
||||
case KEY_GENERIC_CANCEL:
|
||||
need_reset = 1;
|
||||
break;
|
||||
}
|
||||
display_layout_config (&conf_win, mark, cursor, need_reset);
|
||||
}
|
||||
wins_set_layout (mark + 1);
|
||||
@ -713,7 +713,7 @@ color_selection_bar (void)
|
||||
*/
|
||||
static void
|
||||
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 DEFAULTCOLOR 255
|
||||
@ -764,34 +764,34 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back,
|
||||
if (colorize)
|
||||
{
|
||||
if (theme_changed)
|
||||
{
|
||||
pair_content (colr[*mark_fore], &colr_fore, 0L);
|
||||
if (colr_fore == 255)
|
||||
colr_fore = -1;
|
||||
pair_content (colr[*mark_back], &colr_back, 0L);
|
||||
if (colr_back == 255)
|
||||
colr_back = -1;
|
||||
init_pair (COLR_CUSTOM, colr_fore, colr_back);
|
||||
}
|
||||
{
|
||||
pair_content (colr[*mark_fore], &colr_fore, 0L);
|
||||
if (colr_fore == 255)
|
||||
colr_fore = -1;
|
||||
pair_content (colr[*mark_back], &colr_back, 0L);
|
||||
if (colr_back == 255)
|
||||
colr_back = -1;
|
||||
init_pair (COLR_CUSTOM, colr_fore, colr_back);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Retrieve the actual color theme. */
|
||||
pair_content (COLR_CUSTOM, &colr_fore, &colr_back);
|
||||
{
|
||||
/* Retrieve the actual color theme. */
|
||||
pair_content (COLR_CUSTOM, &colr_fore, &colr_back);
|
||||
|
||||
if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT))
|
||||
*mark_fore = NBUSERCOLORS;
|
||||
else
|
||||
for (i = 0; i < NBUSERCOLORS + 1; i++)
|
||||
if (colr_fore == colr[i])
|
||||
*mark_fore = i;
|
||||
if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT))
|
||||
*mark_fore = NBUSERCOLORS;
|
||||
else
|
||||
for (i = 0; i < NBUSERCOLORS + 1; i++)
|
||||
if (colr_fore == colr[i])
|
||||
*mark_fore = i;
|
||||
|
||||
if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT))
|
||||
*mark_back = SIZE - 1;
|
||||
else
|
||||
for (i = 0; i < NBUSERCOLORS + 1; i++)
|
||||
if (colr_back == colr[NBUSERCOLORS + 1 + i])
|
||||
*mark_back = NBUSERCOLORS + 1 + i;
|
||||
}
|
||||
if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT))
|
||||
*mark_back = SIZE - 1;
|
||||
else
|
||||
for (i = 0; i < NBUSERCOLORS + 1; i++)
|
||||
if (colr_back == colr[NBUSERCOLORS + 1 + i])
|
||||
*mark_back = NBUSERCOLORS + 1 + i;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
wattroff (cwin->p, COLOR_PAIR (colr[i]));
|
||||
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,
|
||||
pos[SIZE - 1][XPOS] + XOFST, default_txt);
|
||||
pos[SIZE - 1][XPOS] + XOFST, default_txt);
|
||||
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
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)
|
||||
{
|
||||
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],
|
||||
pos[*mark_back][XPOS] + 1, MARK);
|
||||
pos[*mark_back][XPOS] + 1, MARK);
|
||||
}
|
||||
|
||||
mvwaddch (cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR);
|
||||
@ -853,7 +853,7 @@ custom_color_config (void)
|
||||
conf_win.p = 0;
|
||||
set_confwin_attr (&conf_win);
|
||||
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)
|
||||
{
|
||||
@ -861,51 +861,51 @@ custom_color_config (void)
|
||||
theme_changed = 0;
|
||||
|
||||
switch (ch)
|
||||
{
|
||||
case KEY_RESIZE:
|
||||
endwin ();
|
||||
wins_refresh ();
|
||||
curs_set (0);
|
||||
need_reset = 1;
|
||||
break;
|
||||
{
|
||||
case KEY_RESIZE:
|
||||
endwin ();
|
||||
wins_refresh ();
|
||||
curs_set (0);
|
||||
need_reset = 1;
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_SELECT:
|
||||
colorize = 1;
|
||||
need_reset = 1;
|
||||
theme_changed = 1;
|
||||
if (cursor > NBUSERCOLORS)
|
||||
mark_back = cursor;
|
||||
else
|
||||
mark_fore = cursor;
|
||||
break;
|
||||
case KEY_GENERIC_SELECT:
|
||||
colorize = 1;
|
||||
need_reset = 1;
|
||||
theme_changed = 1;
|
||||
if (cursor > NBUSERCOLORS)
|
||||
mark_back = cursor;
|
||||
else
|
||||
mark_fore = cursor;
|
||||
break;
|
||||
|
||||
case KEY_MOVE_DOWN:
|
||||
if (cursor < SIZE - 1)
|
||||
++cursor;
|
||||
break;
|
||||
case KEY_MOVE_DOWN:
|
||||
if (cursor < SIZE - 1)
|
||||
++cursor;
|
||||
break;
|
||||
|
||||
case KEY_MOVE_UP:
|
||||
if (cursor > 0)
|
||||
--cursor;
|
||||
break;
|
||||
case KEY_MOVE_UP:
|
||||
if (cursor > 0)
|
||||
--cursor;
|
||||
break;
|
||||
|
||||
case KEY_MOVE_LEFT:
|
||||
if (cursor > NBUSERCOLORS)
|
||||
cursor -= (NBUSERCOLORS + 1);
|
||||
break;
|
||||
case KEY_MOVE_LEFT:
|
||||
if (cursor > NBUSERCOLORS)
|
||||
cursor -= (NBUSERCOLORS + 1);
|
||||
break;
|
||||
|
||||
case KEY_MOVE_RIGHT:
|
||||
if (cursor <= NBUSERCOLORS)
|
||||
cursor += (NBUSERCOLORS + 1);
|
||||
break;
|
||||
case KEY_MOVE_RIGHT:
|
||||
if (cursor <= NBUSERCOLORS)
|
||||
cursor += (NBUSERCOLORS + 1);
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_CANCEL:
|
||||
colorize = 0;
|
||||
need_reset = 1;
|
||||
break;
|
||||
}
|
||||
case KEY_GENERIC_CANCEL:
|
||||
colorize = 0;
|
||||
need_reset = 1;
|
||||
break;
|
||||
}
|
||||
display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
|
||||
need_reset, theme_changed);
|
||||
need_reset, theme_changed);
|
||||
}
|
||||
delwin (conf_win.p);
|
||||
}
|
||||
@ -947,17 +947,17 @@ custom_color_theme_name (char *theme_name)
|
||||
{
|
||||
pair_content (COLR_CUSTOM, &color[0], &color[1]);
|
||||
for (i = 0; i < NBCOLORS; i++)
|
||||
{
|
||||
if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT))
|
||||
color_name[i] = default_color;
|
||||
else if (color[i] >= 0 && color[i] <= MAXCOLORS)
|
||||
color_name[i] = name[color[i]];
|
||||
else
|
||||
{
|
||||
{
|
||||
if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT))
|
||||
color_name[i] = default_color;
|
||||
else if (color[i] >= 0 && color[i] <= MAXCOLORS)
|
||||
color_name[i] = name[color[i]];
|
||||
else
|
||||
{
|
||||
EXIT (_("unknown color"));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
(void)snprintf (theme_name, BUFSIZ, "%s on %s", color_name[0],
|
||||
color_name[1]);
|
||||
}
|
||||
@ -999,7 +999,7 @@ print_general_options (WINDOW *win, struct conf *conf)
|
||||
print_bool_option_incolor (win, conf->auto_save, y,
|
||||
XPOS + 4 + strlen (opt[AUTO_SAVE]));
|
||||
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;
|
||||
mvwprintw (win, y, XPOS, "[2] %s ", opt[PERIODIC_SAVE]);
|
||||
custom_apply_attr (win, ATTR_HIGHEST);
|
||||
@ -1007,41 +1007,41 @@ print_general_options (WINDOW *win, struct conf *conf)
|
||||
conf->periodic_save);
|
||||
custom_remove_attr (win, ATTR_HIGHEST);
|
||||
mvwprintw (win, y + 1, XPOS,
|
||||
_("(if not null, automatically save data every 'periodic_save' "
|
||||
_("(if not null, automatically save data every 'periodic_save' "
|
||||
"minutes)"));
|
||||
y += YOFF;
|
||||
mvwprintw (win, y, XPOS, "[3] %s ", opt[CONFIRM_QUIT]);
|
||||
print_bool_option_incolor (win, conf->confirm_quit, y,
|
||||
XPOS + 4 + strlen (opt[CONFIRM_QUIT]));
|
||||
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;
|
||||
mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_DELETE]);
|
||||
print_bool_option_incolor (win, conf->confirm_delete, y,
|
||||
XPOS + 4 + strlen (opt[CONFIRM_DELETE]));
|
||||
mvwprintw (win, y + 1, XPOS,
|
||||
_("(if set to YES, confirmation is required "
|
||||
_("(if set to YES, confirmation is required "
|
||||
"before deleting an event)"));
|
||||
y += YOFF;
|
||||
mvwprintw (win, y, XPOS, "[5] %s ", opt[SKIP_SYSTEM_DIAGS]);
|
||||
print_bool_option_incolor (win, conf->skip_system_dialogs, y,
|
||||
XPOS + 4 + strlen (opt[SKIP_SYSTEM_DIAGS]));
|
||||
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)"));
|
||||
y += YOFF;
|
||||
mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_PROGRESS_BAR]);
|
||||
print_bool_option_incolor (win, conf->skip_progress_bar, y,
|
||||
XPOS + 4 + strlen (opt[SKIP_PROGRESS_BAR]));
|
||||
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)"));
|
||||
y += YOFF;
|
||||
mvwprintw (win, y, XPOS, "[7] %s ", opt[WEEK_BEGINS_MONDAY]);
|
||||
print_bool_option_incolor (win, calendar_week_begins_on_monday (), y,
|
||||
XPOS + 4 + strlen (opt[WEEK_BEGINS_MONDAY]));
|
||||
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)"));
|
||||
y += YOFF;
|
||||
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);
|
||||
custom_remove_attr (win, ATTR_HIGHEST);
|
||||
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;
|
||||
mvwprintw (win, y, XPOS, "[9] %s ", opt[INPUT_DATE_FMT]);
|
||||
custom_apply_attr (win, ATTR_HIGHEST);
|
||||
@ -1112,84 +1112,84 @@ custom_general_config (struct conf *conf)
|
||||
buf[0] = '\0';
|
||||
|
||||
switch (ch)
|
||||
{
|
||||
case KEY_RESIZE:
|
||||
{
|
||||
case KEY_RESIZE:
|
||||
wins_get_config ();
|
||||
wins_reset ();
|
||||
wins_scrollwin_delete (&cwin);
|
||||
wins_scrollwin_init (&cwin);
|
||||
wins_scrollwin_delete (&cwin);
|
||||
wins_scrollwin_init (&cwin);
|
||||
custom_set_swsiz (&cwin);
|
||||
wins_show (cwin.win.p, cwin.label);
|
||||
cwin.first_visible_line = 0;
|
||||
delwin (win[STA].p);
|
||||
win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y,
|
||||
win[STA].x);
|
||||
keypad (win[STA].p, TRUE);
|
||||
if (notify_bar ())
|
||||
{
|
||||
notify_reinit_bar ();
|
||||
notify_update_bar ();
|
||||
}
|
||||
break;
|
||||
cwin.first_visible_line = 0;
|
||||
delwin (win[STA].p);
|
||||
win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y,
|
||||
win[STA].x);
|
||||
keypad (win[STA].p, TRUE);
|
||||
if (notify_bar ())
|
||||
{
|
||||
notify_reinit_bar ();
|
||||
notify_update_bar ();
|
||||
}
|
||||
break;
|
||||
case CTRL ('N'):
|
||||
wins_scrollwin_down (&cwin, 1);
|
||||
break;
|
||||
break;
|
||||
case CTRL ('P'):
|
||||
wins_scrollwin_up (&cwin, 1);
|
||||
break;
|
||||
case '1':
|
||||
conf->auto_save = !conf->auto_save;
|
||||
break;
|
||||
case '2':
|
||||
status_mesg (periodic_save_str, "");
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
int val = atoi (buf);
|
||||
if (val >= 0)
|
||||
conf->periodic_save = val;
|
||||
break;
|
||||
case '1':
|
||||
conf->auto_save = !conf->auto_save;
|
||||
break;
|
||||
case '2':
|
||||
status_mesg (periodic_save_str, "");
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
int val = atoi (buf);
|
||||
if (val >= 0)
|
||||
conf->periodic_save = val;
|
||||
if (conf->periodic_save > 0)
|
||||
io_start_psave_thread (conf);
|
||||
else if (conf->periodic_save == 0)
|
||||
io_stop_psave_thread ();
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
break;
|
||||
case '3':
|
||||
conf->confirm_quit = !conf->confirm_quit;
|
||||
break;
|
||||
case '4':
|
||||
conf->confirm_delete = !conf->confirm_delete;
|
||||
break;
|
||||
case '5':
|
||||
conf->skip_system_dialogs = !conf->skip_system_dialogs;
|
||||
break;
|
||||
case '6':
|
||||
conf->skip_progress_bar = !conf->skip_progress_bar;
|
||||
break;
|
||||
case '7':
|
||||
calendar_change_first_day_of_week ();
|
||||
break;
|
||||
case '8':
|
||||
status_mesg (output_datefmt_str, "");
|
||||
(void)strncpy (buf, conf->output_datefmt,
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
break;
|
||||
case '3':
|
||||
conf->confirm_quit = !conf->confirm_quit;
|
||||
break;
|
||||
case '4':
|
||||
conf->confirm_delete = !conf->confirm_delete;
|
||||
break;
|
||||
case '5':
|
||||
conf->skip_system_dialogs = !conf->skip_system_dialogs;
|
||||
break;
|
||||
case '6':
|
||||
conf->skip_progress_bar = !conf->skip_progress_bar;
|
||||
break;
|
||||
case '7':
|
||||
calendar_change_first_day_of_week ();
|
||||
break;
|
||||
case '8':
|
||||
status_mesg (output_datefmt_str, "");
|
||||
(void)strncpy (buf, conf->output_datefmt,
|
||||
strlen (conf->output_datefmt) + 1);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
(void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1);
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
break;
|
||||
case '9':
|
||||
status_mesg (input_datefmt_str, "");
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
int val = atoi (buf);
|
||||
if (val > 0 && val <= DATE_FORMATS)
|
||||
conf->input_datefmt = val;
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
break;
|
||||
}
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
(void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1);
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
break;
|
||||
case '9':
|
||||
status_mesg (input_datefmt_str, "");
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
int val = atoi (buf);
|
||||
if (val > 0 && val <= DATE_FORMATS)
|
||||
conf->input_datefmt = val;
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
break;
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
cwin.total_lines = print_general_options (cwin.pad.p, conf);
|
||||
wins_scrollwin_display (&cwin);
|
||||
@ -1314,7 +1314,7 @@ custom_keys_config (void)
|
||||
|
||||
ch = keys_getch (win[STA].p);
|
||||
switch (ch)
|
||||
{
|
||||
{
|
||||
case KEY_MOVE_UP:
|
||||
if (selrow > 0)
|
||||
{
|
||||
@ -1327,8 +1327,8 @@ custom_keys_config (void)
|
||||
wins_scrollwin_up (&kwin, LINESPERKEY);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KEY_MOVE_DOWN:
|
||||
break;
|
||||
case KEY_MOVE_DOWN:
|
||||
if (selrow < NBKEYS - 1)
|
||||
{
|
||||
selrow++;
|
||||
@ -1340,7 +1340,7 @@ custom_keys_config (void)
|
||||
wins_scrollwin_down (&kwin, LINESPERKEY);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case KEY_MOVE_LEFT:
|
||||
if (selelm > 0)
|
||||
selelm--;
|
||||
@ -1418,7 +1418,7 @@ custom_keys_config (void)
|
||||
}
|
||||
wins_scrollwin_delete (&kwin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
custom_keys_config_bar ();
|
||||
werase (kwin.pad.p);
|
||||
nbrowelm = print_keys_bindings (kwin.pad.p, selrow, selelm, LINESPERKEY);
|
||||
|
484
src/day.c
484
src/day.c
@ -91,11 +91,11 @@ day_add_event (int type, char *mesg, char *note, long day, int id)
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
}
|
||||
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. */
|
||||
static struct day_item *
|
||||
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;
|
||||
int insert_item = 0;
|
||||
@ -122,19 +122,19 @@ day_add_apoint (int type, char *mesg, char *note, long start, long dur,
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0)
|
||||
{
|
||||
insert_item = 1;
|
||||
}
|
||||
{
|
||||
insert_item = 1;
|
||||
}
|
||||
else if (((*i)->start > start) && ((*i)->type > EVNT))
|
||||
{
|
||||
insert_item = 1;
|
||||
}
|
||||
{
|
||||
insert_item = 1;
|
||||
}
|
||||
if (insert_item)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
}
|
||||
return o;
|
||||
@ -157,10 +157,10 @@ day_store_events (long date)
|
||||
for (j = eventlist; j != 0; j = j->next)
|
||||
{
|
||||
if (event_inday (j, date))
|
||||
{
|
||||
e_nb++;
|
||||
ptr = day_add_event (EVNT, j->mesg, j->note, j->day, j->id);
|
||||
}
|
||||
{
|
||||
e_nb++;
|
||||
ptr = day_add_event (EVNT, j->mesg, j->note, j->day, j->id);
|
||||
}
|
||||
}
|
||||
|
||||
return e_nb;
|
||||
@ -183,11 +183,11 @@ day_store_recur_events (long date)
|
||||
for (j = recur_elist; j != 0; j = j->next)
|
||||
{
|
||||
if (recur_item_inday (j->day, j->exc, j->rpt->type, j->rpt->freq,
|
||||
j->rpt->until, date))
|
||||
{
|
||||
e_nb++;
|
||||
ptr = day_add_event (RECUR_EVNT, j->mesg, j->note, j->day, j->id);
|
||||
}
|
||||
j->rpt->until, date))
|
||||
{
|
||||
e_nb++;
|
||||
ptr = day_add_event (RECUR_EVNT, j->mesg, j->note, j->day, j->id);
|
||||
}
|
||||
}
|
||||
|
||||
return e_nb;
|
||||
@ -211,11 +211,11 @@ day_store_apoints (long date)
|
||||
for (j = alist_p->root; j != 0; j = j->next)
|
||||
{
|
||||
if (apoint_inday (j, date))
|
||||
{
|
||||
a_nb++;
|
||||
ptr = day_add_apoint (APPT, j->mesg, j->note, j->start,
|
||||
j->dur, j->state, 0);
|
||||
}
|
||||
{
|
||||
a_nb++;
|
||||
ptr = day_add_apoint (APPT, j->mesg, j->note, j->start,
|
||||
j->dur, j->state, 0);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
if ((real_start = recur_item_inday (j->start, j->exc,
|
||||
j->rpt->type, j->rpt->freq,
|
||||
j->rpt->until, date)))
|
||||
{
|
||||
a_nb++;
|
||||
ptr = day_add_apoint (RECUR_APPT, j->mesg, j->note,
|
||||
real_start, j->dur, j->state, n);
|
||||
n++;
|
||||
}
|
||||
j->rpt->type, j->rpt->freq,
|
||||
j->rpt->until, date)))
|
||||
{
|
||||
a_nb++;
|
||||
ptr = day_add_apoint (RECUR_APPT, j->mesg, j->note,
|
||||
real_start, j->dur, j->state, n);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
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 *
|
||||
day_process_storage (struct date *slctd_date, unsigned day_changed,
|
||||
struct day_items_nb *inday)
|
||||
struct day_items_nb *inday)
|
||||
{
|
||||
long date;
|
||||
struct date day;
|
||||
@ -341,7 +341,7 @@ day_item_s2apoint_s (struct apoint *a, struct day_item *p)
|
||||
*/
|
||||
static void
|
||||
display_item_date (int incolor, struct apoint *i, int type, long date,
|
||||
int y, int x)
|
||||
int y, int x)
|
||||
{
|
||||
WINDOW *win;
|
||||
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
|
||||
display_item (int incolor, char *msg, int recur, int note, int len, int y,
|
||||
int x)
|
||||
int x)
|
||||
{
|
||||
WINDOW *win;
|
||||
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)
|
||||
{
|
||||
if (p->type == RECUR_EVNT || p->type == RECUR_APPT)
|
||||
recur = 1;
|
||||
recur = 1;
|
||||
else
|
||||
recur = 0;
|
||||
recur = 0;
|
||||
/* First print the events for current day. */
|
||||
if (p->type < RECUR_APPT)
|
||||
{
|
||||
item_number++;
|
||||
if (item_number - incolor == 0)
|
||||
{
|
||||
day_saved_item.type = p->type;
|
||||
day_saved_item.mesg = p->mesg;
|
||||
}
|
||||
display_item (item_number - incolor, p->mesg, recur,
|
||||
(p->note != NULL) ? 1 : 0, width - 7, line, x_pos);
|
||||
line++;
|
||||
draw_line = 1;
|
||||
}
|
||||
{
|
||||
item_number++;
|
||||
if (item_number - incolor == 0)
|
||||
{
|
||||
day_saved_item.type = p->type;
|
||||
day_saved_item.mesg = p->mesg;
|
||||
}
|
||||
display_item (item_number - incolor, p->mesg, recur,
|
||||
(p->note != NULL) ? 1 : 0, width - 7, line, x_pos);
|
||||
line++;
|
||||
draw_line = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Draw a line between events and appointments. */
|
||||
if (line > 0 && draw_line)
|
||||
{
|
||||
wmove (apad.ptrwin, line, 0);
|
||||
whline (apad.ptrwin, 0, width);
|
||||
draw_line = 0;
|
||||
}
|
||||
/* Last print the appointments for current day. */
|
||||
item_number++;
|
||||
day_item_s2apoint_s (&a, p);
|
||||
if (item_number - incolor == 0)
|
||||
{
|
||||
day_saved_item.type = p->type;
|
||||
day_saved_item.mesg = p->mesg;
|
||||
apoint_sec2str (&a, p->type, date,
|
||||
day_saved_item.start, day_saved_item.end);
|
||||
}
|
||||
display_item_date (item_number - incolor, &a, p->type,
|
||||
date, line + 1, x_pos);
|
||||
display_item (item_number - incolor, p->mesg, 0,
|
||||
(p->note != NULL) ? 1 : 0, width - 7, line + 2,
|
||||
x_pos);
|
||||
line += 3;
|
||||
}
|
||||
{
|
||||
/* Draw a line between events and appointments. */
|
||||
if (line > 0 && draw_line)
|
||||
{
|
||||
wmove (apad.ptrwin, line, 0);
|
||||
whline (apad.ptrwin, 0, width);
|
||||
draw_line = 0;
|
||||
}
|
||||
/* Last print the appointments for current day. */
|
||||
item_number++;
|
||||
day_item_s2apoint_s (&a, p);
|
||||
if (item_number - incolor == 0)
|
||||
{
|
||||
day_saved_item.type = p->type;
|
||||
day_saved_item.mesg = p->mesg;
|
||||
apoint_sec2str (&a, p->type, date,
|
||||
day_saved_item.start, day_saved_item.end);
|
||||
}
|
||||
display_item_date (item_number - incolor, &a, p->type,
|
||||
date, line + 1, x_pos);
|
||||
display_item (item_number - incolor, p->mesg, 0,
|
||||
(p->note != NULL) ? 1 : 0, width - 7, line + 2,
|
||||
x_pos);
|
||||
line += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,7 +470,7 @@ day_popup_item (void)
|
||||
item_in_popup (NULL, NULL, day_saved_item.mesg, _("Event :"));
|
||||
else if (day_saved_item.type == APPT || day_saved_item.type == RECUR_APPT)
|
||||
item_in_popup (day_saved_item.start, day_saved_item.end,
|
||||
day_saved_item.mesg, _("Appointment :"));
|
||||
day_saved_item.mesg, _("Appointment :"));
|
||||
else
|
||||
EXIT (_("unknown item type"));
|
||||
/* NOTREACHED */
|
||||
@ -491,16 +491,16 @@ day_check_if_item (struct date day)
|
||||
|
||||
for (re = recur_elist; re != 0; re = re->next)
|
||||
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);
|
||||
|
||||
pthread_mutex_lock (&(recur_alist_p->mutex));
|
||||
for (ra = recur_alist_p->root; ra != 0; ra = ra->next)
|
||||
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type,
|
||||
ra->rpt->freq, ra->rpt->until, date))
|
||||
ra->rpt->freq, ra->rpt->until, date))
|
||||
{
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
return (1);
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
return (1);
|
||||
}
|
||||
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)
|
||||
if (apoint_inday (a, date))
|
||||
{
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
return (1);
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
return (1);
|
||||
}
|
||||
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));
|
||||
for (ra = recur_alist_p->root; ra != 0; ra = ra->next)
|
||||
if (recur_item_inday (ra->start, ra->exc, ra->rpt->type,
|
||||
ra->rpt->freq, ra->rpt->until, date))
|
||||
ra->rpt->freq, ra->rpt->until, date))
|
||||
{
|
||||
long start, end;
|
||||
|
||||
@ -606,12 +606,12 @@ day_edit_time (long time)
|
||||
timestr = date_sec2date_str (time, "%H:%M");
|
||||
updatestring (win[STA].p, ×tr, 0, 1);
|
||||
if (check_time (timestr) != 1 || strlen (timestr) == 0)
|
||||
{
|
||||
status_mesg (fmt_msg, enter_str);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
{
|
||||
status_mesg (fmt_msg, enter_str);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
else
|
||||
return (timestr);
|
||||
return (timestr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -632,17 +632,17 @@ update_start_time (long *start, long *dur)
|
||||
mem_free (timestr);
|
||||
newtime = update_time_in_date (*start, hr, mn);
|
||||
if (newtime < *start + *dur)
|
||||
{
|
||||
*dur -= (newtime - *start);
|
||||
*start = newtime;
|
||||
valid_date = 1;
|
||||
}
|
||||
{
|
||||
*dur -= (newtime - *start);
|
||||
*start = newtime;
|
||||
valid_date = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
status_mesg (msg_wrong_time, msg_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
valid_date = 0;
|
||||
}
|
||||
{
|
||||
status_mesg (msg_wrong_time, msg_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
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));
|
||||
cancel = updatestring (win[STA].p, &typstr, 0, 1);
|
||||
if (cancel)
|
||||
{
|
||||
mem_free (typstr);
|
||||
return;
|
||||
}
|
||||
{
|
||||
mem_free (typstr);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = toupper (*typstr);
|
||||
mem_free (typstr);
|
||||
}
|
||||
{
|
||||
ch = toupper (*typstr);
|
||||
mem_free (typstr);
|
||||
}
|
||||
}
|
||||
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);
|
||||
cancel = updatestring (win[STA].p, &freqstr, 0, 1);
|
||||
if (cancel)
|
||||
{
|
||||
mem_free (freqstr);
|
||||
return;
|
||||
}
|
||||
{
|
||||
mem_free (freqstr);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
newfreq = atoi (freqstr);
|
||||
mem_free (freqstr);
|
||||
if (newfreq == 0)
|
||||
{
|
||||
status_mesg (msg_wrong_freq, msg_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
}
|
||||
{
|
||||
newfreq = atoi (freqstr);
|
||||
mem_free (freqstr);
|
||||
if (newfreq == 0)
|
||||
{
|
||||
status_mesg (msg_wrong_freq, msg_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (newfreq == 0);
|
||||
|
||||
@ -735,52 +735,52 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
|
||||
DATEFMT_DESC (conf->input_datefmt));
|
||||
status_mesg (_(outstr), "");
|
||||
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);
|
||||
if (cancel)
|
||||
{
|
||||
mem_free (timstr);
|
||||
return;
|
||||
}
|
||||
{
|
||||
mem_free (timstr);
|
||||
return;
|
||||
}
|
||||
if (strcmp (timstr, "0") == 0)
|
||||
{
|
||||
newuntil = 0;
|
||||
date_entered = 1;
|
||||
}
|
||||
{
|
||||
newuntil = 0;
|
||||
date_entered = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct tm *lt;
|
||||
time_t t;
|
||||
struct date new_date;
|
||||
int newmonth, newday, newyear;
|
||||
{
|
||||
struct tm *lt;
|
||||
time_t t;
|
||||
struct date new_date;
|
||||
int newmonth, newday, newyear;
|
||||
|
||||
if (parse_date (timstr, conf->input_datefmt,
|
||||
&newyear, &newmonth, &newday, calendar_get_slctd_day ()))
|
||||
{
|
||||
t = start;
|
||||
lt = localtime (&t);
|
||||
new_date.dd = newday;
|
||||
new_date.mm = newmonth;
|
||||
new_date.yyyy = newyear;
|
||||
newuntil = date2sec (new_date, lt->tm_hour, lt->tm_min);
|
||||
if (newuntil < start)
|
||||
{
|
||||
status_mesg (msg_wrong_time, msg_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
date_entered = 0;
|
||||
}
|
||||
else
|
||||
date_entered = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)snprintf (outstr, BUFSIZ, msg_fmts,
|
||||
if (parse_date (timstr, conf->input_datefmt,
|
||||
&newyear, &newmonth, &newday, calendar_get_slctd_day ()))
|
||||
{
|
||||
t = start;
|
||||
lt = localtime (&t);
|
||||
new_date.dd = newday;
|
||||
new_date.mm = newmonth;
|
||||
new_date.yyyy = newyear;
|
||||
newuntil = date2sec (new_date, lt->tm_hour, lt->tm_min);
|
||||
if (newuntil < start)
|
||||
{
|
||||
status_mesg (msg_wrong_time, msg_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
date_entered = 0;
|
||||
}
|
||||
else
|
||||
date_entered = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)snprintf (outstr, BUFSIZ, msg_fmts,
|
||||
DATEFMT_DESC (conf->input_datefmt));
|
||||
status_mesg (msg_wrong_date, _(outstr));
|
||||
(void)wgetch (win[STA].p);
|
||||
date_entered = 0;
|
||||
}
|
||||
}
|
||||
status_mesg (msg_wrong_date, _(outstr));
|
||||
(void)wgetch (win[STA].p);
|
||||
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));
|
||||
status_mesg (_("Edit: (1)Description or (2)Repetition?"), "[1/2] ");
|
||||
while (ch != '1' && ch != '2' && ch != KEY_GENERIC_CANCEL)
|
||||
ch = wgetch (win[STA].p);
|
||||
ch = wgetch (win[STA].p);
|
||||
switch (ch)
|
||||
{
|
||||
case '1':
|
||||
update_desc (&re->mesg);
|
||||
break;
|
||||
case '2':
|
||||
update_rept (&re->rpt, re->day, conf);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
{
|
||||
case '1':
|
||||
update_desc (&re->mesg);
|
||||
break;
|
||||
case '2':
|
||||
update_rept (&re->rpt, re->day, conf);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case 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:
|
||||
ra = recur_get_apoint (date, day_item_nb (date, item_num, RECUR_APPT));
|
||||
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 &&
|
||||
ch != REPT && ch != KEY_GENERIC_CANCEL)
|
||||
ch = wgetch (win[STA].p);
|
||||
ch != REPT && ch != KEY_GENERIC_CANCEL)
|
||||
ch = wgetch (win[STA].p);
|
||||
switch (ch)
|
||||
{
|
||||
case STRT:
|
||||
update_start_time (&ra->start, &ra->dur);
|
||||
break;
|
||||
case END:
|
||||
update_duration (&ra->start, &ra->dur);
|
||||
break;
|
||||
case DESC:
|
||||
update_desc (&ra->mesg);
|
||||
break;
|
||||
case REPT:
|
||||
update_rept (&ra->rpt, ra->start, conf);
|
||||
break;
|
||||
case KEY_GENERIC_CANCEL:
|
||||
return;
|
||||
}
|
||||
{
|
||||
case STRT:
|
||||
update_start_time (&ra->start, &ra->dur);
|
||||
break;
|
||||
case END:
|
||||
update_duration (&ra->start, &ra->dur);
|
||||
break;
|
||||
case DESC:
|
||||
update_desc (&ra->mesg);
|
||||
break;
|
||||
case REPT:
|
||||
update_rept (&ra->rpt, ra->start, conf);
|
||||
break;
|
||||
case KEY_GENERIC_CANCEL:
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case APPT:
|
||||
a = apoint_get (date, day_item_nb (date, item_num, APPT));
|
||||
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)
|
||||
ch = wgetch (win[STA].p);
|
||||
ch = wgetch (win[STA].p);
|
||||
switch (ch)
|
||||
{
|
||||
case STRT:
|
||||
update_start_time (&a->start, &a->dur);
|
||||
break;
|
||||
case END:
|
||||
update_duration (&a->start, &a->dur);
|
||||
break;
|
||||
case DESC:
|
||||
update_desc (&a->mesg);
|
||||
break;
|
||||
case KEY_GENERIC_CANCEL:
|
||||
return;
|
||||
}
|
||||
{
|
||||
case STRT:
|
||||
update_start_time (&a->start, &a->dur);
|
||||
break;
|
||||
case END:
|
||||
update_duration (&a->start, &a->dur);
|
||||
break;
|
||||
case DESC:
|
||||
update_desc (&a->mesg);
|
||||
break;
|
||||
case KEY_GENERIC_CANCEL:
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -896,10 +896,10 @@ day_erase_item (long date, int item_number, enum eraseflg flag)
|
||||
struct day_item *p;
|
||||
char *erase_warning =
|
||||
_("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 =
|
||||
_("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 *erase_choice = _("[a/o] ");
|
||||
int ch, ans;
|
||||
@ -911,16 +911,16 @@ day_erase_item (long date, int item_number, enum eraseflg flag)
|
||||
{
|
||||
ans = 0;
|
||||
if (p->note == NULL)
|
||||
ans = 'i';
|
||||
ans = 'i';
|
||||
while (ans != 'i' && ans != 'n')
|
||||
{
|
||||
status_mesg (note_warning, note_choice);
|
||||
ans = wgetch (win[STA].p);
|
||||
}
|
||||
{
|
||||
status_mesg (note_warning, note_choice);
|
||||
ans = wgetch (win[STA].p);
|
||||
}
|
||||
if (ans == 'i')
|
||||
flag = ERASE_FORCE;
|
||||
flag = ERASE_FORCE;
|
||||
else
|
||||
flag = ERASE_FORCE_ONLY_NOTE;
|
||||
flag = ERASE_FORCE_ONLY_NOTE;
|
||||
}
|
||||
if (p->type == EVNT)
|
||||
{
|
||||
@ -933,33 +933,33 @@ day_erase_item (long date, int item_number, enum eraseflg flag)
|
||||
else
|
||||
{
|
||||
if (flag == ERASE_FORCE_ONLY_NOTE)
|
||||
ch = 'a';
|
||||
ch = 'a';
|
||||
while ((ch != 'a') && (ch != 'o') && (ch != KEY_GENERIC_CANCEL))
|
||||
{
|
||||
status_mesg (erase_warning, erase_choice);
|
||||
ch = wgetch (win[STA].p);
|
||||
}
|
||||
{
|
||||
status_mesg (erase_warning, erase_choice);
|
||||
ch = wgetch (win[STA].p);
|
||||
}
|
||||
if (ch == 'a')
|
||||
{
|
||||
delete_whole = 1;
|
||||
}
|
||||
{
|
||||
delete_whole = 1;
|
||||
}
|
||||
else if (ch == 'o')
|
||||
{
|
||||
delete_whole = 0;
|
||||
}
|
||||
{
|
||||
delete_whole = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
if (p->type == RECUR_EVNT)
|
||||
{
|
||||
recur_event_erase (date, day_item_nb (date, item_number, RECUR_EVNT),
|
||||
delete_whole, flag);
|
||||
}
|
||||
{
|
||||
recur_event_erase (date, day_item_nb (date, item_number, RECUR_EVNT),
|
||||
delete_whole, flag);
|
||||
}
|
||||
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)
|
||||
return 0;
|
||||
@ -1086,9 +1086,9 @@ day_edit_note (char *editor)
|
||||
if (p->note == NULL)
|
||||
{
|
||||
if ((filename = new_tempfile (path_notes, NOTESIZ)) == NULL)
|
||||
return;
|
||||
return;
|
||||
else
|
||||
p->note = filename;
|
||||
p->note = filename;
|
||||
}
|
||||
(void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, p->note);
|
||||
wins_launch_external (fullname, editor);
|
||||
|
40
src/event.c
40
src/event.c
@ -97,11 +97,11 @@ event_new (char *mesg, char *note, long day, int id)
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0 || (*i)->day > day)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
}
|
||||
return (o);
|
||||
@ -175,11 +175,11 @@ event_get (long day, int pos)
|
||||
for (o = eventlist; o; o = o->next)
|
||||
{
|
||||
if (event_inday (o, day))
|
||||
{
|
||||
if (n == pos)
|
||||
return o;
|
||||
n++;
|
||||
}
|
||||
{
|
||||
if (n == pos)
|
||||
return o;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
EXIT (_("event not found"));
|
||||
return 0;
|
||||
@ -198,9 +198,9 @@ event_delete_bynum (long start, unsigned num, enum eraseflg flag)
|
||||
for (i = eventlist; i != 0; i = i->next)
|
||||
{
|
||||
if (event_inday (i, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
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);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
|
||||
erase_note (&i->note, flag);
|
||||
mem_free (i);
|
||||
mem_free (i);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
iptr = &i->next;
|
||||
}
|
||||
EXIT (_("event not found"));
|
||||
|
360
src/io.c
360
src/io.c
@ -226,16 +226,16 @@ get_export_stream (enum export_type type)
|
||||
status_mesg (question, "");
|
||||
cancel = updatestring (win[STA].p, &stream_name, 0, 1);
|
||||
if (cancel)
|
||||
{
|
||||
mem_free (stream_name);
|
||||
return (NULL);
|
||||
}
|
||||
{
|
||||
mem_free (stream_name);
|
||||
return (NULL);
|
||||
}
|
||||
stream = fopen (stream_name, "w");
|
||||
if (stream == NULL)
|
||||
{
|
||||
status_mesg (wrong_name, press_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
{
|
||||
status_mesg (wrong_name, press_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
}
|
||||
mem_free (stream_name);
|
||||
|
||||
@ -354,24 +354,24 @@ ical_export_recur_events (FILE *stream)
|
||||
ical_recur_type[i->rpt->type], i->rpt->freq);
|
||||
|
||||
if (i->rpt->until != 0)
|
||||
{
|
||||
date_sec2date_fmt (i->rpt->until, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, ";UNTIL=%s\n", ical_date);
|
||||
}
|
||||
{
|
||||
date_sec2date_fmt (i->rpt->until, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, ";UNTIL=%s\n", ical_date);
|
||||
}
|
||||
else
|
||||
(void)fprintf (stream, "\n");
|
||||
(void)fprintf (stream, "\n");
|
||||
|
||||
if (i->exc != NULL)
|
||||
{
|
||||
date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, "EXDATE:%s", ical_date);
|
||||
for (day = i->exc->next; day; day = day->next)
|
||||
{
|
||||
date_sec2date_fmt (day->st, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, ",%s", ical_date);
|
||||
}
|
||||
(void)fprintf (stream, "\n");
|
||||
}
|
||||
{
|
||||
date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, "EXDATE:%s", ical_date);
|
||||
for (day = i->exc->next; day; day = day->next)
|
||||
{
|
||||
date_sec2date_fmt (day->st, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, ",%s", ical_date);
|
||||
}
|
||||
(void)fprintf (stream, "\n");
|
||||
}
|
||||
|
||||
(void)fprintf (stream, "SUMMARY:%s\n", i->mesg);
|
||||
(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);
|
||||
|
||||
if (i->rpt->until != 0)
|
||||
{
|
||||
date_sec2date_fmt (i->rpt->until + HOURINSEC, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, ";UNTIL=%s\n", ical_date);
|
||||
}
|
||||
{
|
||||
date_sec2date_fmt (i->rpt->until + HOURINSEC, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, ";UNTIL=%s\n", ical_date);
|
||||
}
|
||||
else
|
||||
(void)fprintf (stream, "\n");
|
||||
(void)fprintf (stream, "\n");
|
||||
|
||||
if (i->exc != NULL)
|
||||
{
|
||||
date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, "EXDATE:%s", ical_date);
|
||||
for (day = i->exc->next; day; day = day->next)
|
||||
{
|
||||
date_sec2date_fmt (day->st, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, ",%s", ical_date);
|
||||
}
|
||||
(void)fprintf (stream, "\n");
|
||||
}
|
||||
{
|
||||
date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, "EXDATE:%s", ical_date);
|
||||
for (day = i->exc->next; day; day = day->next)
|
||||
{
|
||||
date_sec2date_fmt (day->st, ICALDATEFMT, ical_date);
|
||||
(void)fprintf (stream, ",%s", ical_date);
|
||||
}
|
||||
(void)fprintf (stream, "\n");
|
||||
}
|
||||
|
||||
(void)fprintf (stream, "SUMMARY:%s\n", i->mesg);
|
||||
if (i->state & APOINT_NOTIFY)
|
||||
ical_export_valarm (stream);
|
||||
ical_export_valarm (stream);
|
||||
(void)fprintf (stream, "END:VEVENT\n");
|
||||
}
|
||||
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, "SUMMARY:%s\n", i->mesg);
|
||||
if (i->state & APOINT_NOTIFY)
|
||||
ical_export_valarm (stream);
|
||||
ical_export_valarm (stream);
|
||||
(void)fprintf (stream, "END:VEVENT\n");
|
||||
}
|
||||
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++)
|
||||
{
|
||||
if (*org == '\n' || *org == '\0')
|
||||
break;
|
||||
break;
|
||||
*dst_data++ = *org++;
|
||||
}
|
||||
*dst_data = '\0';
|
||||
@ -1096,17 +1096,17 @@ io_load_app (void)
|
||||
is_appointment = is_event = is_recursive = 0;
|
||||
c = getc (data_file);
|
||||
if (c == EOF)
|
||||
break;
|
||||
break;
|
||||
(void)ungetc (c, data_file);
|
||||
|
||||
/* Read the date first: it is common to both events
|
||||
* and appointments.
|
||||
*/
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
/* Read the next character : if it is an '@' then we have
|
||||
* an appointment, else if it is an '[' we have en event.
|
||||
@ -1114,144 +1114,144 @@ io_load_app (void)
|
||||
c = getc (data_file);
|
||||
|
||||
if (c == '@')
|
||||
is_appointment = 1;
|
||||
is_appointment = 1;
|
||||
else if (c == '[')
|
||||
is_event = 1;
|
||||
is_event = 1;
|
||||
else
|
||||
{
|
||||
{
|
||||
EXIT (_("no event nor appointment found"));
|
||||
}
|
||||
}
|
||||
(void)ungetc (c, data_file);
|
||||
|
||||
/* Read the remaining informations. */
|
||||
if (is_appointment)
|
||||
{
|
||||
fscanf (data_file, "@ %u : %u -> %u / %u / %u @ %u : %u ",
|
||||
&start.tm_hour, &start.tm_min,
|
||||
&end.tm_mon, &end.tm_mday, &end.tm_year,
|
||||
&end.tm_hour, &end.tm_min);
|
||||
}
|
||||
{
|
||||
fscanf (data_file, "@ %u : %u -> %u / %u / %u @ %u : %u ",
|
||||
&start.tm_hour, &start.tm_min,
|
||||
&end.tm_mon, &end.tm_mday, &end.tm_year,
|
||||
&end.tm_hour, &end.tm_min);
|
||||
}
|
||||
else if (is_event)
|
||||
{
|
||||
fscanf (data_file, "[%d] ", &id);
|
||||
}
|
||||
{
|
||||
fscanf (data_file, "[%d] ", &id);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
EXIT (_("wrong format in the appointment or event"));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we have a recursive item. */
|
||||
c = getc (data_file);
|
||||
|
||||
if (c == '{')
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
is_recursive = 1;
|
||||
fscanf (data_file, "{ %d%c ", &freq, &type);
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
is_recursive = 1;
|
||||
fscanf (data_file, "{ %d%c ", &freq, &type);
|
||||
|
||||
c = getc (data_file);
|
||||
if (c == '}')
|
||||
{ /* endless recurrent item */
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, "} ");
|
||||
until.tm_year = 0;
|
||||
}
|
||||
else if (c == '-')
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, " -> %u / %u / %u ",
|
||||
&until.tm_mon, &until.tm_mday, &until.tm_year);
|
||||
c = getc (data_file);
|
||||
if (c == '!')
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
exc = recur_exc_scan (data_file);
|
||||
c = getc (data_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, "} ");
|
||||
}
|
||||
}
|
||||
else if (c == '!')
|
||||
{ // endless item with exceptions
|
||||
(void)ungetc (c, data_file);
|
||||
exc = recur_exc_scan (data_file);
|
||||
c = getc (data_file);
|
||||
until.tm_year = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = getc (data_file);
|
||||
if (c == '}')
|
||||
{ /* endless recurrent item */
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, "} ");
|
||||
until.tm_year = 0;
|
||||
}
|
||||
else if (c == '-')
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, " -> %u / %u / %u ",
|
||||
&until.tm_mon, &until.tm_mday, &until.tm_year);
|
||||
c = getc (data_file);
|
||||
if (c == '!')
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
exc = recur_exc_scan (data_file);
|
||||
c = getc (data_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, "} ");
|
||||
}
|
||||
}
|
||||
else if (c == '!')
|
||||
{ // endless item with exceptions
|
||||
(void)ungetc (c, data_file);
|
||||
exc = recur_exc_scan (data_file);
|
||||
c = getc (data_file);
|
||||
until.tm_year = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
EXIT (_("wrong format in the appointment or event"));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
(void)ungetc (c, data_file);
|
||||
(void)ungetc (c, data_file);
|
||||
|
||||
/* Check if a note is attached to the item. */
|
||||
c = getc (data_file);
|
||||
if (c == '>')
|
||||
{
|
||||
(void)fgets (note, NOTESIZ + 1, data_file);
|
||||
note[NOTESIZ] = '\0';
|
||||
notep = note;
|
||||
getc (data_file);
|
||||
}
|
||||
{
|
||||
(void)fgets (note, NOTESIZ + 1, data_file);
|
||||
note[NOTESIZ] = '\0';
|
||||
notep = note;
|
||||
getc (data_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
notep = NULL;
|
||||
(void)ungetc (c, data_file);
|
||||
}
|
||||
{
|
||||
notep = NULL;
|
||||
(void)ungetc (c, data_file);
|
||||
}
|
||||
|
||||
/*
|
||||
* Last: read the item description and load it into its
|
||||
* corresponding linked list, depending on the item type.
|
||||
*/
|
||||
if (is_appointment)
|
||||
{
|
||||
c = getc (data_file);
|
||||
if (c == '!')
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, " ! ");
|
||||
state |= APOINT_NOTIFY;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, " | ");
|
||||
state = 0L;
|
||||
}
|
||||
if (is_recursive)
|
||||
{
|
||||
recur_apoint_scan (data_file, start, end,
|
||||
type, freq, until, notep, &exc, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
apoint_scan (data_file, start, end, state, notep);
|
||||
}
|
||||
}
|
||||
{
|
||||
c = getc (data_file);
|
||||
if (c == '!')
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, " ! ");
|
||||
state |= APOINT_NOTIFY;
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
fscanf (data_file, " | ");
|
||||
state = 0L;
|
||||
}
|
||||
if (is_recursive)
|
||||
{
|
||||
recur_apoint_scan (data_file, start, end,
|
||||
type, freq, until, notep, &exc, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
apoint_scan (data_file, start, end, state, notep);
|
||||
}
|
||||
}
|
||||
else if (is_event)
|
||||
{
|
||||
if (is_recursive)
|
||||
{
|
||||
recur_event_scan (data_file, start, id, type,
|
||||
freq, until, notep, &exc);
|
||||
}
|
||||
else
|
||||
{
|
||||
event_scan (data_file, start, id, notep);
|
||||
}
|
||||
}
|
||||
{
|
||||
if (is_recursive)
|
||||
{
|
||||
recur_event_scan (data_file, start, id, type,
|
||||
freq, until, notep, &exc);
|
||||
}
|
||||
else
|
||||
{
|
||||
event_scan (data_file, start, id, notep);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
EXIT (_("wrong format in the appointment or event"));
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
}
|
||||
file_close (data_file, __FILE_POS__);
|
||||
}
|
||||
@ -1278,28 +1278,28 @@ io_load_todo (void)
|
||||
{
|
||||
c = getc (data_file);
|
||||
if (c == EOF)
|
||||
{
|
||||
break;
|
||||
}
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (c == '[')
|
||||
{ /* new style with id */
|
||||
fscanf (data_file, "%d]", &id);
|
||||
}
|
||||
{ /* new style with id */
|
||||
fscanf (data_file, "%d]", &id);
|
||||
}
|
||||
else
|
||||
{
|
||||
id = 9;
|
||||
(void)ungetc (c, data_file);
|
||||
}
|
||||
{
|
||||
id = 9;
|
||||
(void)ungetc (c, data_file);
|
||||
}
|
||||
/* Now read the attached note, if any. */
|
||||
c = getc (data_file);
|
||||
if (c == '>')
|
||||
{
|
||||
(void)fgets (note, NOTESIZ + 1, data_file);
|
||||
note[NOTESIZ] = '\0';
|
||||
getc (data_file);
|
||||
}
|
||||
{
|
||||
(void)fgets (note, NOTESIZ + 1, data_file);
|
||||
note[NOTESIZ] = '\0';
|
||||
getc (data_file);
|
||||
}
|
||||
else
|
||||
note[0] = '\0';
|
||||
note[0] = '\0';
|
||||
/* Then read todo description. */
|
||||
(void)fgets (buf, sizeof buf, data_file);
|
||||
newline = strchr (buf, '\n');
|
||||
@ -1494,11 +1494,11 @@ io_check_dir (char *dir, int *missing)
|
||||
if (mkdir (dir, 0700) != 0)
|
||||
{
|
||||
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));
|
||||
exit_calcurse (EXIT_FAILURE);
|
||||
}
|
||||
exit_calcurse (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1534,11 +1534,11 @@ io_check_file (char *file, int *missing)
|
||||
if (missing)
|
||||
(*missing)++;
|
||||
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));
|
||||
exit_calcurse (EXIT_FAILURE);
|
||||
}
|
||||
exit_calcurse (EXIT_FAILURE);
|
||||
}
|
||||
file_close (fd, __FILE_POS__);
|
||||
}
|
||||
}
|
||||
@ -2706,16 +2706,16 @@ get_import_stream (enum export_type type)
|
||||
status_mesg (ask_fname, "");
|
||||
cancel = updatestring (win[STA].p, &stream_name, 0, 1);
|
||||
if (cancel)
|
||||
{
|
||||
mem_free (stream_name);
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
mem_free (stream_name);
|
||||
return NULL;
|
||||
}
|
||||
stream = fopen (stream_name, "r");
|
||||
if (stream == NULL)
|
||||
{
|
||||
status_mesg (wrong_file, press_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
{
|
||||
status_mesg (wrong_file, press_enter);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
}
|
||||
mem_free (stream_name);
|
||||
|
||||
|
@ -479,7 +479,7 @@ keys_display_bindings_bar (WINDOW *win, struct binding **binding, int first_key,
|
||||
custom_remove_attr (win, ATTR_HIGHEST);
|
||||
mvwprintw (win, 0, LABEL_POS, binding[i]->label);
|
||||
if (i + 1 != last_key)
|
||||
mvwprintw (win, 1, LABEL_POS, binding[i + 1]->label);
|
||||
mvwprintw (win, 1, LABEL_POS, binding[i + 1]->label);
|
||||
j++;
|
||||
}
|
||||
wnoutrefresh (win);
|
||||
|
276
src/notify.c
276
src/notify.c
@ -259,58 +259,58 @@ notify_update_bar (void)
|
||||
wattron (notify.win, A_UNDERLINE | A_REVERSE);
|
||||
mvwhline (notify.win, 0, 0, ACS_HLINE, col);
|
||||
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);
|
||||
|
||||
pthread_mutex_lock (¬ify_app.mutex);
|
||||
if (notify_app.got_app)
|
||||
{
|
||||
if (strlen (notify_app.txt) > txt_max_len)
|
||||
{
|
||||
{
|
||||
int shrink_len;
|
||||
|
||||
too_long = 1;
|
||||
too_long = 1;
|
||||
shrink_len = txt_max_len > 3 ? txt_max_len - 3 : 1;
|
||||
(void)strncpy (buf, notify_app.txt, shrink_len);
|
||||
buf[shrink_len] = '\0';
|
||||
}
|
||||
(void)strncpy (buf, notify_app.txt, shrink_len);
|
||||
buf[shrink_len] = '\0';
|
||||
}
|
||||
time_left = notify_time_left ();
|
||||
if (time_left > 0)
|
||||
{
|
||||
{
|
||||
int hours_left, minutes_left;
|
||||
|
||||
hours_left = (time_left / HOURINSEC);
|
||||
minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC;
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
hours_left = (time_left / HOURINSEC);
|
||||
minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC;
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
|
||||
if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY))
|
||||
blinking = 1;
|
||||
else
|
||||
blinking = 0;
|
||||
if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY))
|
||||
blinking = 1;
|
||||
else
|
||||
blinking = 0;
|
||||
|
||||
if (blinking)
|
||||
wattron (notify.win, A_BLINK);
|
||||
if (too_long)
|
||||
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s.. <",
|
||||
hours_left, minutes_left, buf);
|
||||
else
|
||||
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s <",
|
||||
hours_left, minutes_left, notify_app.txt);
|
||||
if (blinking)
|
||||
wattroff (notify.win, A_BLINK);
|
||||
if (blinking)
|
||||
wattron (notify.win, A_BLINK);
|
||||
if (too_long)
|
||||
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s.. <",
|
||||
hours_left, minutes_left, buf);
|
||||
else
|
||||
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s <",
|
||||
hours_left, minutes_left, notify_app.txt);
|
||||
if (blinking)
|
||||
wattroff (notify.win, A_BLINK);
|
||||
|
||||
if (blinking)
|
||||
if (blinking)
|
||||
(void)notify_launch_cmd ();
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
notify_app.got_app = 0;
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
pthread_mutex_unlock (¬ify.mutex);
|
||||
notify_check_next_app ();
|
||||
return;
|
||||
}
|
||||
{
|
||||
notify_app.got_app = 0;
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
pthread_mutex_unlock (¬ify.mutex);
|
||||
notify_check_next_app ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
|
||||
@ -349,14 +349,14 @@ notify_main_thread (void *arg)
|
||||
psleep (thread_sleep);
|
||||
elapse += thread_sleep;
|
||||
if (elapse >= check_app)
|
||||
{
|
||||
elapse = 0;
|
||||
pthread_mutex_lock (¬ify_app.mutex);
|
||||
got_app = notify_app.got_app;
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
if (!got_app)
|
||||
notify_check_next_app ();
|
||||
}
|
||||
{
|
||||
elapse = 0;
|
||||
pthread_mutex_lock (¬ify_app.mutex);
|
||||
got_app = notify_app.got_app;
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
if (!got_app)
|
||||
notify_check_next_app ();
|
||||
}
|
||||
}
|
||||
pthread_exit ((void *) 0);
|
||||
}
|
||||
@ -481,7 +481,7 @@ notify_check_added (char *mesg, long start, char state)
|
||||
{
|
||||
gap = start - current_time;
|
||||
if (gap >= 0 && gap <= DAYINSEC)
|
||||
update_notify = 1;
|
||||
update_notify = 1;
|
||||
}
|
||||
else if (start < notify_app.time && start >= current_time)
|
||||
{
|
||||
@ -509,22 +509,22 @@ notify_check_repeated (struct recur_apoint *i)
|
||||
current_time = time (NULL);
|
||||
pthread_mutex_lock (¬ify_app.mutex);
|
||||
if ((real_app_time = recur_item_inday (i->start, i->exc, i->rpt->type,
|
||||
i->rpt->freq, i->rpt->until,
|
||||
get_today ()) > current_time))
|
||||
i->rpt->freq, i->rpt->until,
|
||||
get_today ()) > current_time))
|
||||
{
|
||||
if (!notify_app.got_app)
|
||||
{
|
||||
if (real_app_time - current_time <= DAYINSEC)
|
||||
update_notify = 1;
|
||||
}
|
||||
{
|
||||
if (real_app_time - current_time <= DAYINSEC)
|
||||
update_notify = 1;
|
||||
}
|
||||
else if (real_app_time < notify_app.time &&
|
||||
real_app_time >= current_time)
|
||||
{
|
||||
update_notify = 1;
|
||||
}
|
||||
real_app_time >= current_time)
|
||||
{
|
||||
update_notify = 1;
|
||||
}
|
||||
else if (real_app_time == notify_app.time &&
|
||||
i->state != notify_app.state)
|
||||
update_notify = 1;
|
||||
i->state != notify_app.state)
|
||||
update_notify = 1;
|
||||
}
|
||||
if (update_notify)
|
||||
{
|
||||
@ -554,7 +554,7 @@ notify_same_recur_item (struct recur_apoint *i)
|
||||
long item_start = 0;
|
||||
|
||||
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 (¬ify_app.mutex);
|
||||
if (notify_app.got_app && item_start == notify_app.time)
|
||||
same = 1;
|
||||
@ -594,15 +594,15 @@ print_option (WINDOW *win, unsigned x, unsigned y, char *name,
|
||||
maxlen = MAXCOL - x_opt - 2;
|
||||
custom_apply_attr (win, ATTR_HIGHEST);
|
||||
if (len < maxlen)
|
||||
mvwprintw (win, y, x_opt, "%s", valstr);
|
||||
mvwprintw (win, y, x_opt, "%s", valstr);
|
||||
else
|
||||
{
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
|
||||
(void)strncpy (buf, valstr, maxlen - 1);
|
||||
buf[maxlen - 1] = '\0';
|
||||
mvwprintw (win, y, x_opt, "%s...", buf);
|
||||
}
|
||||
(void)strncpy (buf, valstr, maxlen - 1);
|
||||
buf[maxlen - 1] = '\0';
|
||||
mvwprintw (win, y, x_opt, "%s...", buf);
|
||||
}
|
||||
custom_remove_attr (win, ATTR_HIGHEST);
|
||||
}
|
||||
else
|
||||
@ -734,88 +734,88 @@ notify_config_bar (void)
|
||||
wins_get_config ();
|
||||
wins_reset ();
|
||||
reinit_conf_win (&cwin);
|
||||
delwin (win[STA].p);
|
||||
win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y,
|
||||
win[STA].x);
|
||||
keypad (win[STA].p, TRUE);
|
||||
if (notify_bar ())
|
||||
{
|
||||
notify_reinit_bar ();
|
||||
notify_update_bar ();
|
||||
}
|
||||
break;
|
||||
delwin (win[STA].p);
|
||||
win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y,
|
||||
win[STA].x);
|
||||
keypad (win[STA].p, TRUE);
|
||||
if (notify_bar ())
|
||||
{
|
||||
notify_reinit_bar ();
|
||||
notify_update_bar ();
|
||||
}
|
||||
break;
|
||||
case CTRL ('N'):
|
||||
wins_scrollwin_down (&cwin, 1);
|
||||
break;
|
||||
break;
|
||||
case CTRL ('P'):
|
||||
wins_scrollwin_up (&cwin, 1);
|
||||
break;
|
||||
case '1':
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
nbar.show = !nbar.show;
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (notify_bar ())
|
||||
notify_start_main_thread ();
|
||||
else
|
||||
notify_stop_main_thread ();
|
||||
break;
|
||||
case '1':
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
nbar.show = !nbar.show;
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (notify_bar ())
|
||||
notify_start_main_thread ();
|
||||
else
|
||||
notify_stop_main_thread ();
|
||||
wins_scrollwin_delete (&cwin);
|
||||
reinit_conf_win (&cwin);
|
||||
break;
|
||||
case '2':
|
||||
status_mesg (date_str, "");
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (buf, nbar.datefmt, strlen (nbar.datefmt) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (nbar.datefmt, buf, strlen (buf) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
status_mesg (time_str, "");
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (buf, nbar.timefmt, strlen (nbar.timefmt) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (nbar.timefmt, buf, strlen (buf) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
status_mesg (count_str, "");
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
printf (buf, "%d", nbar.cntdwn);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0 &&
|
||||
is_all_digit (buf) && atoi (buf) >= 0 && atoi (buf) <= DAYINSEC)
|
||||
{
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
nbar.cntdwn = atoi (buf);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '5':
|
||||
status_mesg (cmd_str, "");
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (buf, nbar.cmd, strlen (nbar.cmd) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (nbar.cmd, buf, strlen (buf) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '6':
|
||||
dmon.enable = !dmon.enable;
|
||||
break;
|
||||
case '7':
|
||||
dmon.log = !dmon.log;
|
||||
break;
|
||||
break;
|
||||
case '2':
|
||||
status_mesg (date_str, "");
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (buf, nbar.datefmt, strlen (nbar.datefmt) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (nbar.datefmt, buf, strlen (buf) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
status_mesg (time_str, "");
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (buf, nbar.timefmt, strlen (nbar.timefmt) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (nbar.timefmt, buf, strlen (buf) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '4':
|
||||
status_mesg (count_str, "");
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
printf (buf, "%d", nbar.cntdwn);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0 &&
|
||||
is_all_digit (buf) && atoi (buf) >= 0 && atoi (buf) <= DAYINSEC)
|
||||
{
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
nbar.cntdwn = atoi (buf);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '5':
|
||||
status_mesg (cmd_str, "");
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (buf, nbar.cmd, strlen (nbar.cmd) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
if (updatestring (win[STA].p, &buf, 0, 1) == 0)
|
||||
{
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
(void)strncpy (nbar.cmd, buf, strlen (buf) + 1);
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '6':
|
||||
dmon.enable = !dmon.enable;
|
||||
break;
|
||||
case '7':
|
||||
dmon.log = !dmon.log;
|
||||
break;
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
cwin.total_lines = print_config_options (cwin.pad.p);
|
||||
|
346
src/recur.c
346
src/recur.c
@ -236,7 +236,7 @@ recur_event_llist_free (void)
|
||||
/* Insert a new recursive appointment in the general linked list */
|
||||
struct recur_apoint *
|
||||
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;
|
||||
|
||||
@ -263,11 +263,11 @@ recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0 || (*i)->start > start)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
}
|
||||
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 */
|
||||
struct recur_event *
|
||||
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;
|
||||
|
||||
@ -303,11 +303,11 @@ recur_event_new (char *mesg, char *note, long day, int id, int type, int freq,
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0 || (*i)->day > day)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
}
|
||||
return (o);
|
||||
@ -397,8 +397,8 @@ recur_write_exc (struct days *exc, FILE *f)
|
||||
/* Load the recursive appointment description */
|
||||
struct recur_apoint *
|
||||
recur_apoint_scan (FILE *f, struct tm start, struct tm end, char type,
|
||||
int freq, struct tm until, char *note, struct days **exc,
|
||||
char state)
|
||||
int freq, struct tm until, char *note, struct days **exc,
|
||||
char state)
|
||||
{
|
||||
struct tm *lt;
|
||||
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"));
|
||||
|
||||
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 */
|
||||
struct recur_event *
|
||||
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;
|
||||
time_t tstart, tuntil;
|
||||
@ -657,7 +657,7 @@ diff_years (struct tm lt_start, struct tm lt_end)
|
||||
*/
|
||||
unsigned
|
||||
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;
|
||||
long day_end, diff;
|
||||
@ -687,20 +687,20 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
|
||||
case RECUR_DAILY:
|
||||
diff = diff_days (lt_item, lt_day);
|
||||
if (diff % rpt_freq != 0)
|
||||
return (0);
|
||||
return (0);
|
||||
lt_item.tm_mday = lt_day.tm_mday;
|
||||
lt_item.tm_mon = lt_day.tm_mon;
|
||||
lt_item.tm_year = lt_day.tm_year;
|
||||
break;
|
||||
case RECUR_WEEKLY:
|
||||
if (lt_item.tm_wday != lt_day.tm_wday)
|
||||
return (0);
|
||||
return (0);
|
||||
else
|
||||
{
|
||||
{
|
||||
diff = diff_weeks (lt_item, lt_day);
|
||||
if (diff % rpt_freq != 0)
|
||||
return (0);
|
||||
}
|
||||
if (diff % rpt_freq != 0)
|
||||
return (0);
|
||||
}
|
||||
lt_item.tm_mday = lt_day.tm_mday;
|
||||
lt_item.tm_mon = lt_day.tm_mon;
|
||||
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:
|
||||
diff = diff_months (lt_item, lt_day);
|
||||
if (diff % rpt_freq != 0)
|
||||
return (0);
|
||||
return (0);
|
||||
lt_item.tm_mon = lt_day.tm_mon;
|
||||
lt_item.tm_year = lt_day.tm_year;
|
||||
break;
|
||||
case RECUR_YEARLY:
|
||||
diff = diff_years (lt_item, lt_day);
|
||||
if (diff % rpt_freq != 0)
|
||||
return (0);
|
||||
return (0);
|
||||
lt_item.tm_year = lt_day.tm_year;
|
||||
break;
|
||||
default:
|
||||
@ -738,7 +738,7 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
|
||||
*/
|
||||
void
|
||||
recur_event_erase (long start, unsigned num, unsigned delete_whole,
|
||||
enum eraseflg flag)
|
||||
enum eraseflg flag)
|
||||
{
|
||||
unsigned n = 0;
|
||||
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)
|
||||
{
|
||||
if (recur_item_inday (i->day, i->exc, i->rpt->type,
|
||||
i->rpt->freq, i->rpt->until, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
if (delete_whole)
|
||||
{
|
||||
i->rpt->freq, i->rpt->until, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
if (delete_whole)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
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);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
if (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)
|
||||
erase_note (&i->note, flag);
|
||||
mem_free (i);
|
||||
mem_free (i);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
recur_add_exc (&i->exc, start);
|
||||
return;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
iptr = &i->next;
|
||||
}
|
||||
EXIT (_("event not found"));
|
||||
@ -803,7 +803,7 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
|
||||
*/
|
||||
void
|
||||
recur_apoint_erase (long start, unsigned num, unsigned delete_whole,
|
||||
enum eraseflg flag)
|
||||
enum eraseflg flag)
|
||||
{
|
||||
unsigned n = 0;
|
||||
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)
|
||||
{
|
||||
if (recur_item_inday (i->start, i->exc, i->rpt->type,
|
||||
i->rpt->freq, i->rpt->until, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
if (notify_bar () && flag != ERASE_FORCE_ONLY_NOTE)
|
||||
need_check_notify = notify_same_recur_item (i);
|
||||
if (delete_whole)
|
||||
{
|
||||
i->rpt->freq, i->rpt->until, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
if (notify_bar () && flag != ERASE_FORCE_ONLY_NOTE)
|
||||
need_check_notify = notify_same_recur_item (i);
|
||||
if (delete_whole)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
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);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
if (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)
|
||||
erase_note (&i->note, flag);
|
||||
mem_free (i);
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
if (need_check_notify)
|
||||
notify_check_next_app ();
|
||||
mem_free (i);
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
if (need_check_notify)
|
||||
notify_check_next_app ();
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
recur_add_exc (&i->exc, start);
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
if (need_check_notify)
|
||||
notify_check_next_app ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
if (need_check_notify)
|
||||
notify_check_next_app ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
n++;
|
||||
}
|
||||
iptr = &i->next;
|
||||
}
|
||||
EXIT (_("appointment not found"));
|
||||
@ -921,7 +921,7 @@ recur_repeat_item (struct conf *conf)
|
||||
}
|
||||
|
||||
while ((ch != 'D') && (ch != 'W') && (ch != 'M')
|
||||
&& (ch != 'Y') && (ch != ESCAPE))
|
||||
&& (ch != 'Y') && (ch != ESCAPE))
|
||||
{
|
||||
status_mesg (mesg_type_1, mesg_type_2);
|
||||
ch = wgetch (win[STA].p);
|
||||
@ -941,17 +941,17 @@ recur_repeat_item (struct conf *conf)
|
||||
{
|
||||
status_mesg (mesg_freq_1, "");
|
||||
if (getstring (win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID)
|
||||
{
|
||||
freq = atoi (user_input);
|
||||
if (freq == 0)
|
||||
{
|
||||
status_mesg (mesg_wrong_freq, wrong_type_2);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
user_input[0] = '\0';
|
||||
}
|
||||
{
|
||||
freq = atoi (user_input);
|
||||
if (freq == 0)
|
||||
{
|
||||
status_mesg (mesg_wrong_freq, wrong_type_2);
|
||||
(void)wgetch (win[STA].p);
|
||||
}
|
||||
user_input[0] = '\0';
|
||||
}
|
||||
else
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
while (!date_entered)
|
||||
@ -960,60 +960,60 @@ recur_repeat_item (struct conf *conf)
|
||||
DATEFMT_DESC (conf->input_datefmt));
|
||||
status_mesg (_(outstr), "");
|
||||
if (getstring (win[STA].p, user_input, BUFSIZ, 0, 1) == GETSTRING_VALID)
|
||||
{
|
||||
if (strlen (user_input) == 1 && strncmp (user_input, "0", 1) == 0)
|
||||
{
|
||||
until = 0;
|
||||
date_entered = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parse_date (user_input, conf->input_datefmt,
|
||||
&year, &month, &day, calendar_get_slctd_day ()))
|
||||
{
|
||||
t = p->start;
|
||||
lt = localtime (&t);
|
||||
until_date.dd = day;
|
||||
until_date.mm = month;
|
||||
until_date.yyyy = year;
|
||||
until = date2sec (until_date, lt->tm_hour, lt->tm_min);
|
||||
if (until < p->start)
|
||||
{
|
||||
status_mesg (mesg_older, wrong_type_2);
|
||||
(void)wgetch (win[STA].p);
|
||||
date_entered = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
date_entered = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)snprintf (outstr, BUFSIZ, mesg_wrong_2,
|
||||
{
|
||||
if (strlen (user_input) == 1 && strncmp (user_input, "0", 1) == 0)
|
||||
{
|
||||
until = 0;
|
||||
date_entered = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parse_date (user_input, conf->input_datefmt,
|
||||
&year, &month, &day, calendar_get_slctd_day ()))
|
||||
{
|
||||
t = p->start;
|
||||
lt = localtime (&t);
|
||||
until_date.dd = day;
|
||||
until_date.mm = month;
|
||||
until_date.yyyy = year;
|
||||
until = date2sec (until_date, lt->tm_hour, lt->tm_min);
|
||||
if (until < p->start)
|
||||
{
|
||||
status_mesg (mesg_older, wrong_type_2);
|
||||
(void)wgetch (win[STA].p);
|
||||
date_entered = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
date_entered = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(void)snprintf (outstr, BUFSIZ, mesg_wrong_2,
|
||||
DATEFMT_DESC (conf->input_datefmt));
|
||||
status_mesg (mesg_wrong_1, _(outstr));
|
||||
(void)wgetch (win[STA].p);
|
||||
date_entered = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
status_mesg (mesg_wrong_1, _(outstr));
|
||||
(void)wgetch (win[STA].p);
|
||||
date_entered = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
date = calendar_get_slctd_day_sec ();
|
||||
if (p->type == EVNT)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 ())
|
||||
notify_check_repeated (ra);
|
||||
notify_check_repeated (ra);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1039,10 +1039,10 @@ recur_exc_scan (FILE *data_file)
|
||||
{
|
||||
(void)ungetc (c, data_file);
|
||||
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"));
|
||||
}
|
||||
}
|
||||
day.tm_hour = 12;
|
||||
day.tm_min = day.tm_sec = 0;
|
||||
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)
|
||||
{
|
||||
if (i->start > app->time)
|
||||
{
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
return (app);
|
||||
}
|
||||
{
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
return (app);
|
||||
}
|
||||
else
|
||||
{
|
||||
real_recur_start_time =
|
||||
{
|
||||
real_recur_start_time =
|
||||
recur_item_inday (i->start, i->exc, i->rpt->type, i->rpt->freq,
|
||||
i->rpt->until, day);
|
||||
if (real_recur_start_time > start)
|
||||
{
|
||||
app->time = real_recur_start_time;
|
||||
app->txt = mem_strdup (i->mesg);
|
||||
app->state = i->state;
|
||||
app->got_app = 1;
|
||||
}
|
||||
}
|
||||
if (real_recur_start_time > start)
|
||||
{
|
||||
app->time = real_recur_start_time;
|
||||
app->txt = mem_strdup (i->mesg);
|
||||
app->state = i->state;
|
||||
app->got_app = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (recur_item_inday (o->start, o->exc, o->rpt->type,
|
||||
o->rpt->freq, o->rpt->until, date))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
return (o);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
o->rpt->freq, o->rpt->until, date))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
return (o);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
EXIT (_("item not found"));
|
||||
return 0;
|
||||
@ -1129,14 +1129,14 @@ recur_get_event (long date, int num)
|
||||
for (o = recur_elist; o != 0; o = o->next)
|
||||
{
|
||||
if (recur_item_inday (o->day, o->exc, o->rpt->type,
|
||||
o->rpt->freq, o->rpt->until, date))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
return (o);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
o->rpt->freq, o->rpt->until, date))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
return (o);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
EXIT (_("item not found"));
|
||||
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)
|
||||
{
|
||||
if (recur_item_inday (o->start, o->exc, o->rpt->type,
|
||||
o->rpt->freq, o->rpt->until, date))
|
||||
{
|
||||
if (n == recur_nb)
|
||||
{
|
||||
o->state ^= APOINT_NOTIFY;
|
||||
o->rpt->freq, o->rpt->until, date))
|
||||
{
|
||||
if (n == recur_nb)
|
||||
{
|
||||
o->state ^= APOINT_NOTIFY;
|
||||
|
||||
if (notify_bar ())
|
||||
notify_check_repeated (o);
|
||||
if (notify_bar ())
|
||||
notify_check_repeated (o);
|
||||
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
if (need_chk_notify)
|
||||
notify_check_next_app ();
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
pthread_mutex_unlock (&(recur_alist_p->mutex));
|
||||
if (need_chk_notify)
|
||||
notify_check_next_app ();
|
||||
return;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
EXIT (_("item not found"));
|
||||
/* NOTREACHED */
|
||||
|
@ -56,7 +56,7 @@ generic_hdlr (int sig)
|
||||
{
|
||||
case SIGCHLD:
|
||||
while (waitpid (WAIT_MYPGRP, NULL, WNOHANG) > 0)
|
||||
;
|
||||
;
|
||||
break;
|
||||
case SIGWINCH:
|
||||
clearok (curscr, TRUE);
|
||||
|
94
src/todo.c
94
src/todo.c
@ -150,10 +150,10 @@ todo_new_item (void)
|
||||
if (getstring (win[STA].p, todo_input, BUFSIZ, 0, 1) == GETSTRING_VALID)
|
||||
{
|
||||
while ((ch < '1') || (ch > '9'))
|
||||
{
|
||||
status_mesg (mesg_id, "");
|
||||
ch = wgetch (win[STA].p);
|
||||
}
|
||||
{
|
||||
status_mesg (mesg_id, "");
|
||||
ch = wgetch (win[STA].p);
|
||||
}
|
||||
todo_add (todo_input, ch - '0', NULL);
|
||||
todos++;
|
||||
}
|
||||
@ -183,11 +183,11 @@ todo_add (char *mesg, int id, char *note)
|
||||
for (;;)
|
||||
{
|
||||
if (*i == 0 || abs ((*i)->id) > absid)
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
{
|
||||
o->next = *i;
|
||||
*i = o;
|
||||
break;
|
||||
}
|
||||
i = &(*i)->next;
|
||||
}
|
||||
return (o);
|
||||
@ -205,12 +205,12 @@ todo_delete_note_bynum (unsigned num)
|
||||
for (i = todolist; i != 0; i = i->next)
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
if (i->note == NULL)
|
||||
{
|
||||
if (i->note == NULL)
|
||||
EXIT (_("no note attached"));
|
||||
erase_note (&i->note, ERASE_FORCE_ONLY_NOTE);
|
||||
return;
|
||||
}
|
||||
erase_note (&i->note, ERASE_FORCE_ONLY_NOTE);
|
||||
return;
|
||||
}
|
||||
iptr = &i->next;
|
||||
n++;
|
||||
}
|
||||
@ -230,13 +230,13 @@ todo_delete_bynum (unsigned num, enum eraseflg flag)
|
||||
for (i = todolist; i != 0; i = i->next)
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
{
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
erase_note (&i->note, flag);
|
||||
mem_free (i);
|
||||
return;
|
||||
}
|
||||
mem_free (i);
|
||||
return;
|
||||
}
|
||||
iptr = &i->next;
|
||||
n++;
|
||||
}
|
||||
@ -267,7 +267,7 @@ todo_delete (struct conf *conf)
|
||||
char *del_todo_str = _("Do you really want to delete this task ?");
|
||||
char *erase_warning =
|
||||
_("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] ");
|
||||
unsigned go_for_todo_del = 0;
|
||||
int answer, has_note;
|
||||
@ -277,14 +277,14 @@ todo_delete (struct conf *conf)
|
||||
status_mesg (del_todo_str, choices);
|
||||
answer = wgetch (win[STA].p);
|
||||
if ((answer == 'y') && (todos > 0))
|
||||
{
|
||||
go_for_todo_del = 1;
|
||||
}
|
||||
{
|
||||
go_for_todo_del = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
wins_erase_status_bar ();
|
||||
return;
|
||||
}
|
||||
{
|
||||
wins_erase_status_bar ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (todos > 0)
|
||||
go_for_todo_del = 1;
|
||||
@ -312,11 +312,11 @@ todo_delete (struct conf *conf)
|
||||
todo_delete_bynum (hilt - 1, ERASE_FORCE);
|
||||
todos--;
|
||||
if (hilt > 1)
|
||||
hilt--;
|
||||
hilt--;
|
||||
if (todos == 0)
|
||||
hilt = 0;
|
||||
hilt = 0;
|
||||
if (hilt - first < 0)
|
||||
first--;
|
||||
first--;
|
||||
break;
|
||||
case 'n':
|
||||
todo_delete_note_bynum (hilt - 1);
|
||||
@ -340,10 +340,10 @@ todo_get_position (struct todo *i)
|
||||
for (o = todolist; o; o = o->next)
|
||||
{
|
||||
if (o == i)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
if (found)
|
||||
@ -409,7 +409,7 @@ todo_edit_item (void)
|
||||
/* Display todo items in the corresponding panel. */
|
||||
static void
|
||||
display_todo_item (int incolor, char *msg, int prio, int note, int len, int y,
|
||||
int x)
|
||||
int x)
|
||||
{
|
||||
WINDOW *w;
|
||||
int ch_note;
|
||||
@ -459,14 +459,14 @@ todo_update_panel (int which_pan)
|
||||
t_realpos = num_todo - first;
|
||||
incolor = num_todo - hilt;
|
||||
if (incolor == 0)
|
||||
msgsav = i->mesg;
|
||||
msgsav = i->mesg;
|
||||
if (t_realpos >= 0 && t_realpos < max_items)
|
||||
{
|
||||
display_todo_item (incolor, i->mesg, i->id,
|
||||
(i->note != NULL) ? 1 : 0, len, y_offset,
|
||||
x_offset);
|
||||
y_offset = y_offset + todo_lines;
|
||||
}
|
||||
{
|
||||
display_todo_item (incolor, i->mesg, i->id,
|
||||
(i->note != NULL) ? 1 : 0, len, y_offset,
|
||||
x_offset);
|
||||
y_offset = y_offset + todo_lines;
|
||||
}
|
||||
}
|
||||
|
||||
/* Draw the scrollbar if necessary. */
|
||||
@ -479,9 +479,9 @@ todo_update_panel (int which_pan)
|
||||
int sbar_top = highend + title_lines;
|
||||
|
||||
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,
|
||||
sbar_length, title_lines, win[TOD].h - 1, hilt_bar);
|
||||
sbar_length, title_lines, win[TOD].h - 1, hilt_bar);
|
||||
}
|
||||
|
||||
wnoutrefresh (win[TOD].p);
|
||||
@ -499,9 +499,9 @@ todo_edit_note (char *editor)
|
||||
if (i->note == NULL)
|
||||
{
|
||||
if ((filename = new_tempfile (path_notes, NOTESIZ)) != NULL)
|
||||
i->note = filename;
|
||||
i->note = filename;
|
||||
else
|
||||
return;
|
||||
return;
|
||||
}
|
||||
(void)snprintf (fullname, BUFSIZ, "%s%s", path_notes, i->note);
|
||||
wins_launch_external (fullname, editor);
|
||||
|
16
src/utils.c
16
src/utils.c
@ -319,7 +319,7 @@ getstring (WINDOW *win, char *str, int l, int x, int y)
|
||||
del_char (curpos, str);
|
||||
len--;
|
||||
}
|
||||
else bell ();
|
||||
else bell ();
|
||||
break;
|
||||
case CTRL ('W'): /* delete a word */
|
||||
if (curpos > 0) {
|
||||
@ -579,7 +579,7 @@ check_time (char *string)
|
||||
*/
|
||||
void
|
||||
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);
|
||||
if (hilt)
|
||||
@ -598,7 +598,7 @@ draw_scrollbar (WINDOW *win, int y, int x, int length,
|
||||
*/
|
||||
void
|
||||
item_in_popup (char *saved_a_start, char *saved_a_end, char *msg,
|
||||
char *pop_title)
|
||||
char *pop_title)
|
||||
{
|
||||
WINDOW *popup_win, *pad;
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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 != -1)
|
||||
{
|
||||
unlink (fullname);
|
||||
close (fd);
|
||||
}
|
||||
{
|
||||
unlink (fullname);
|
||||
close (fd);
|
||||
}
|
||||
ERROR_MSG (_("temporary file \"%s\" could not be created"), fullname);
|
||||
return (char *)0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user