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
308
src/apoint.c
308
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));
|
||||
@ -154,7 +154,7 @@ apoint_new (char *mesg, char *note, long start, long dur, char state)
|
||||
return (o);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Add an item in either the appointment or the event list,
|
||||
* depending if the start time is entered or not.
|
||||
*/
|
||||
@ -186,61 +186,61 @@ 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,
|
||||
* depending on the starting time, and record the
|
||||
/*
|
||||
* Check if an event or appointment is entered,
|
||||
* depending on the starting time, and record the
|
||||
* corresponding item.
|
||||
*/
|
||||
if (is_appointment)
|
||||
{ /* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ int
|
||||
apoint_cut (unsigned *nb_events, unsigned *nb_apoints)
|
||||
{
|
||||
const int NBITEMS = *nb_apoints + *nb_events;
|
||||
int item_type, to_be_removed;
|
||||
int item_type, to_be_removed;
|
||||
long date;
|
||||
|
||||
if (NBITEMS == 0)
|
||||
@ -354,7 +354,7 @@ apoint_cut (unsigned *nb_events, unsigned *nb_apoints)
|
||||
else
|
||||
EXIT (_("no such type"));
|
||||
/* NOTREACHED */
|
||||
|
||||
|
||||
if (hilt > 1)
|
||||
hilt--;
|
||||
if (apad.first_onscreen >= to_be_removed)
|
||||
@ -380,7 +380,7 @@ apoint_paste (unsigned *nb_events, unsigned *nb_apoints, int cut_item_type)
|
||||
(*nb_apoints)++;
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
if (hilt == 0)
|
||||
hilt++;
|
||||
}
|
||||
@ -488,15 +488,15 @@ 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;
|
||||
/* NOTREACHED */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
@ -512,9 +512,9 @@ apoint_delete_bynum (long start, unsigned num, enum eraseflg flag)
|
||||
for (i = alist_p->root; i != 0; i = i->next)
|
||||
{
|
||||
if (apoint_inday (i, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case ERASE_FORCE_ONLY_NOTE:
|
||||
@ -527,25 +527,25 @@ apoint_delete_bynum (long start, unsigned num, enum eraseflg flag)
|
||||
erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
EXIT (_("no such appointment"));
|
||||
/* NOTREACHED */
|
||||
@ -553,7 +553,7 @@ apoint_delete_bynum (long start, unsigned num, enum eraseflg flag)
|
||||
|
||||
/*
|
||||
* Return the line number of an item (either an appointment or an event) in
|
||||
* the appointment panel. This is to help the appointment scroll function
|
||||
* the appointment panel. This is to help the appointment scroll function
|
||||
* to place beggining of the pad correctly.
|
||||
*/
|
||||
static int
|
||||
@ -570,9 +570,9 @@ get_item_line (int item_nb, int nb_events_inday)
|
||||
return line;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Update (if necessary) the first displayed pad line to make the
|
||||
* appointment panel scroll down next time pnoutrefresh is called.
|
||||
* appointment panel scroll down next time pnoutrefresh is called.
|
||||
*/
|
||||
void
|
||||
apoint_scroll_pad_down (int nb_events_inday, int win_length)
|
||||
@ -592,9 +592,9 @@ apoint_scroll_pad_down (int nb_events_inday, int win_length)
|
||||
apad.first_onscreen = item_last_line - awin_length;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Update (if necessary) the first displayed pad line to make the
|
||||
* appointment panel scroll up next time pnoutrefresh is called.
|
||||
* appointment panel scroll up next time pnoutrefresh is called.
|
||||
*/
|
||||
void
|
||||
apoint_scroll_pad_up (int nb_events_inday)
|
||||
@ -619,29 +619,29 @@ apoint_check_next (struct notify_app *app, long start)
|
||||
for (i = alist_p->root; i != 0; i = i->next)
|
||||
{
|
||||
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));
|
||||
|
||||
return (app);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a structure of type struct apoint_list given a structure of type
|
||||
* recur_apoint_s
|
||||
/*
|
||||
* Returns a structure of type struct apoint_list given a structure of type
|
||||
* recur_apoint_s
|
||||
*/
|
||||
struct apoint *
|
||||
apoint_recur_s2apoint_s (struct recur_apoint *p)
|
||||
@ -687,27 +687,27 @@ apoint_switch_notify (void)
|
||||
for (apoint = alist_p->root; apoint != 0; apoint = apoint->next)
|
||||
{
|
||||
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));
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
EXIT (_("no such appointment"));
|
||||
/* NOTREACHED */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* Updates the Appointment panel */
|
||||
@ -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
|
||||
|
520
src/args.c
520
src/args.c
@ -45,7 +45,7 @@
|
||||
|
||||
#include "calcurse.h"
|
||||
|
||||
/*
|
||||
/*
|
||||
* Print Calcurse usage and exit.
|
||||
*/
|
||||
static void
|
||||
@ -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);
|
||||
@ -82,7 +82,7 @@ version_arg ()
|
||||
fputs (vtext, stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Print the command line options and exit.
|
||||
*/
|
||||
static void
|
||||
@ -168,7 +168,7 @@ static void
|
||||
status_arg (void)
|
||||
{
|
||||
int cpid, dpid;
|
||||
|
||||
|
||||
cpid = io_get_pid (path_cpid);
|
||||
dpid = io_get_pid (path_dpid);
|
||||
|
||||
@ -191,7 +191,7 @@ status_arg (void)
|
||||
* (to be used together with the '-a' or '-t' flag in non-interactive mode).
|
||||
* Each line begins with nbtab tabs.
|
||||
* Print "No note file found", if the notefile does not exists.
|
||||
*
|
||||
*
|
||||
* (patch submitted by Erik Saule).
|
||||
*/
|
||||
static void
|
||||
@ -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__);
|
||||
}
|
||||
@ -266,12 +266,12 @@ todo_arg (int priority, int print_note, regex_t *regex)
|
||||
if (print_note && i->note) \
|
||||
print_notefile (stdout, i->note, 1); \
|
||||
} while (0)
|
||||
|
||||
|
||||
for (i = todolist; i != 0; i = i->next)
|
||||
{
|
||||
if (regex && regexec (regex, i->mesg, 0, 0, 0) != 0)
|
||||
continue;
|
||||
|
||||
|
||||
if (i->id < 0) /* completed task */
|
||||
{
|
||||
if (priority == 0)
|
||||
@ -291,7 +291,7 @@ todo_arg (int priority, int print_note, regex_t *regex)
|
||||
}
|
||||
|
||||
#undef DISPLAY_TITLE
|
||||
#undef DISPLAY_TODO
|
||||
#undef DISPLAY_TODO
|
||||
}
|
||||
|
||||
/* Print the next appointment within the upcoming 24 hours. */
|
||||
@ -323,7 +323,7 @@ next_arg (void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Print the date on stdout.
|
||||
*/
|
||||
static void
|
||||
@ -365,62 +365,62 @@ app_arg (int add_line, struct date *day, long date, int print_note,
|
||||
else
|
||||
today = date;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Calculate and print the selected date if there is an event for
|
||||
* that date and it is the first one, and then print all the events for
|
||||
* that date.
|
||||
* that date.
|
||||
*/
|
||||
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, 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));
|
||||
|
||||
@ -509,10 +509,10 @@ more_info (void)
|
||||
"<misc@calcurse.org>.\n"), stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* For a given date, print appointments for each day
|
||||
* in the chosen interval. app_found and add_line are used
|
||||
* to format the output correctly.
|
||||
* to format the output correctly.
|
||||
*/
|
||||
static void
|
||||
display_app (struct tm *t, int numdays, int add_line, int print_note,
|
||||
@ -549,25 +549,25 @@ date_arg (char *ddate, int add_line, int print_note, struct conf *conf,
|
||||
static struct tm t;
|
||||
time_t timer;
|
||||
|
||||
/*
|
||||
* Check (with the argument length) if a date or a number of days
|
||||
/*
|
||||
* Check (with the argument length) if a date or a number of days
|
||||
* was entered, and then call app_arg() to print appointments
|
||||
*/
|
||||
arg_len = strlen (ddate);
|
||||
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
|
||||
* in the chosen interval. app_found and add_line are used
|
||||
* to format the output correctly.
|
||||
* to format the output correctly.
|
||||
*/
|
||||
timer = time (NULL);
|
||||
t = *localtime (&timer);
|
||||
@ -577,25 +577,25 @@ 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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print appointment from the given date 'startday' for the 'range' upcoming
|
||||
* days.
|
||||
* days.
|
||||
* If no starday is given (NULL), today is considered
|
||||
* If no range is given (NULL), 1 day is considered
|
||||
*
|
||||
@ -609,35 +609,35 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
|
||||
static struct tm t;
|
||||
time_t timer;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Check arguments and extract information
|
||||
*/
|
||||
if (range != NULL)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -657,7 +657,7 @@ date_arg_extended (char *startday, char *range, int add_line, int print_note,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
* Parse the command-line arguments and call the appropriate
|
||||
* routines to handle those arguments. Also initialize the data paths.
|
||||
*/
|
||||
@ -681,7 +681,7 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
int tflag = 0; /* -t: print todo list */
|
||||
int vflag = 0; /* -v: print version number */
|
||||
int xflag = 0; /* -x: export data */
|
||||
|
||||
|
||||
int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag = 0, load_data = 0;
|
||||
char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL;
|
||||
char *datadir = NULL, *ifile = NULL;
|
||||
@ -691,9 +691,9 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
int statusflag = 0; /* --status: get the status of running instances */
|
||||
enum
|
||||
{
|
||||
STATUS_OPT = CHAR_MAX + 1
|
||||
STATUS_OPT = CHAR_MAX + 1
|
||||
};
|
||||
|
||||
|
||||
static char *optstr = "hvnNax::t::d:c:r::s::S:D:i:";
|
||||
|
||||
struct option longopts[] = {
|
||||
@ -718,48 +718,48 @@ parse_args (int argc, char **argv, struct conf *conf)
|
||||
while ((ch = getopt_long (argc, argv, optstr, longopts, NULL)) != -1)
|
||||
{
|
||||
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,37 +862,37 @@ 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);
|
||||
io_init (cfile, datadir);
|
||||
status_arg ();
|
||||
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);
|
||||
io_check_file (path_todo, (int *)0);
|
||||
io_check_file (path_todo, (int *)0);
|
||||
io_load_app ();
|
||||
io_load_todo ();
|
||||
io_import_data (IO_IMPORT_ICAL, conf, ifile);
|
||||
@ -900,34 +900,34 @@ 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)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_load_app ();
|
||||
next_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (dflag || rflag || sflag)
|
||||
{
|
||||
todo_arg (tnum, Nflag, preg);
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (nflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_conf, (int *)0);
|
||||
io_load_app ();
|
||||
next_arg ();
|
||||
non_interactive = 1;
|
||||
}
|
||||
if (dflag || rflag || sflag)
|
||||
{
|
||||
io_check_file (path_apts, (int *)0);
|
||||
io_check_file (path_conf, (int *)0);
|
||||
io_load_app ();
|
||||
custom_load_conf (conf, 0); /* To get output date format. */
|
||||
if (dflag)
|
||||
@ -935,31 +935,31 @@ 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);
|
||||
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)
|
||||
regfree (preg);
|
||||
|
||||
return non_interactive;
|
||||
|
||||
return non_interactive;
|
||||
}
|
||||
|
534
src/calcurse.c
534
src/calcurse.c
@ -42,7 +42,7 @@
|
||||
* Calcurse is a text-based personal organizer which helps keeping track
|
||||
* of events and everyday tasks. It contains a calendar, a 'todo' list,
|
||||
* and puts your appointments in order. The user interface is configurable,
|
||||
* and one can choose between different color schemes and layouts.
|
||||
* and one can choose between different color schemes and layouts.
|
||||
* All of the commands are documented within an online help system.
|
||||
*/
|
||||
int
|
||||
@ -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] ";
|
||||
|
||||
@ -75,7 +75,7 @@ main (int argc, char **argv)
|
||||
apoint_llist_init ();
|
||||
recur_apoint_llist_init ();
|
||||
|
||||
/*
|
||||
/*
|
||||
* Begin by parsing and handling command line arguments.
|
||||
* The data path is also initialized here.
|
||||
*/
|
||||
@ -88,7 +88,7 @@ main (int argc, char **argv)
|
||||
dmon_stop ();
|
||||
io_set_lock ();
|
||||
}
|
||||
|
||||
|
||||
/* Begin of interactive mode with ncurses interface. */
|
||||
sigs_init (); /* signal handling init */
|
||||
initscr (); /* start the curses mode */
|
||||
@ -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 */
|
||||
@ -139,7 +139,7 @@ main (int argc, char **argv)
|
||||
notify_init_bar ();
|
||||
wins_reset_status_page ();
|
||||
|
||||
/*
|
||||
/*
|
||||
* Read the data from files : first the user
|
||||
* configuration (the display is then updated), and then
|
||||
* the todo list, appointments and events.
|
||||
@ -160,119 +160,119 @@ main (int argc, char **argv)
|
||||
calendar_start_date_thread ();
|
||||
if (conf.periodic_save > 0)
|
||||
io_start_psave_thread (&conf);
|
||||
|
||||
|
||||
/* User input */
|
||||
for (;;)
|
||||
{
|
||||
int key;
|
||||
|
||||
|
||||
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)
|
||||
@ -351,116 +351,116 @@ main (int argc, char **argv)
|
||||
do_storage = 1;
|
||||
}
|
||||
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 ();
|
||||
io_import_data (IO_IMPORT_ICAL, &conf, NULL);
|
||||
do_storage = 1;
|
||||
break;
|
||||
|
||||
|
||||
case KEY_GENERIC_EXPORT:
|
||||
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:
|
||||
@ -523,47 +523,47 @@ main (int argc, char **argv)
|
||||
if (wins_slctd () == CAL)
|
||||
calendar_view_next ();
|
||||
break;
|
||||
|
||||
case KEY_GENERIC_QUIT:
|
||||
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;
|
||||
case KEY_GENERIC_QUIT:
|
||||
if (conf.auto_save)
|
||||
io_save_cal (&conf, IO_SAVE_DISPLAY_BAR);
|
||||
|
||||
default:
|
||||
do_update = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
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 ();
|
||||
}
|
||||
}
|
||||
|
136
src/calendar.c
136
src/calendar.c
@ -270,7 +270,7 @@ ymd_to_scalar (unsigned year, unsigned month, unsigned day)
|
||||
return (scalar);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Used to change date by adding a certain amount of days or weeks.
|
||||
* Returns 0 on success, 1 otherwise.
|
||||
*/
|
||||
@ -328,7 +328,7 @@ draw_monthly_view (struct window *cwin, struct date *current_day,
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
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);
|
||||
}
|
||||
@ -411,7 +411,7 @@ weeknum (const struct tm *t, int firstweekday)
|
||||
wnum = ((t->tm_yday + WEEKINDAYS - wday) / WEEKINDAYS);
|
||||
if (wnum < 0)
|
||||
wnum = 0;
|
||||
|
||||
|
||||
return wnum;
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ ISO8601weeknum (const struct tm *t)
|
||||
{
|
||||
/* Get week number of last week of last year. */
|
||||
struct tm dec31ly; /* 12/31 last year */
|
||||
|
||||
|
||||
dec31ly = *t;
|
||||
dec31ly.tm_year--;
|
||||
dec31ly.tm_mon = 11;
|
||||
@ -477,21 +477,21 @@ static void
|
||||
draw_weekly_view (struct window *cwin, struct date *current_day,
|
||||
unsigned sunday_first)
|
||||
{
|
||||
#define DAYSLICESNO 6
|
||||
#define DAYSLICESNO 6
|
||||
const int WCALWIDTH = 30;
|
||||
const int OFFY = 2 + (CALHEIGHT - 9) / 2;
|
||||
struct tm t;
|
||||
int OFFX, j, c_wday, days_to_remove, weeknum;
|
||||
|
||||
OFFX = (wins_sbar_width () - WCALWIDTH) / 2 + 1;
|
||||
|
||||
|
||||
/* Fill in a tm structure with the first day of the selected week. */
|
||||
c_wday = calendar_get_wday (&slctd_day);
|
||||
if (sunday_first)
|
||||
days_to_remove = c_wday;
|
||||
else
|
||||
days_to_remove = c_wday == 0 ? WEEKINDAYS - 1 : c_wday - 1;
|
||||
|
||||
|
||||
(void)memset (&t, 0, sizeof (struct tm));
|
||||
t.tm_mday = slctd_day.dd;
|
||||
t.tm_mon = slctd_day.mm - 1;
|
||||
@ -501,21 +501,21 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
|
||||
|
||||
/* Print the week number. */
|
||||
weeknum = ISO8601weeknum (&t);
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
mvwprintw (cwin->p, 2, cwin->w - 9, "(# %02d)", weeknum);
|
||||
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
||||
|
||||
|
||||
/* Now draw calendar view. */
|
||||
for (j = 0; j < WEEKINDAYS; j++)
|
||||
{
|
||||
struct date date;
|
||||
unsigned attr, item_this_day;
|
||||
int i, slices[DAYSLICESNO];
|
||||
|
||||
|
||||
/* print the day names, with regards to the first day of the week */
|
||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||
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. */
|
||||
@ -523,7 +523,7 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
|
||||
date.mm = t.tm_mon + 1;
|
||||
date.yyyy = t.tm_year + 1900;
|
||||
item_this_day = day_check_if_item (date);
|
||||
|
||||
|
||||
/* Print the day numbers with appropriate decoration. */
|
||||
if (t.tm_mday == current_day->dd
|
||||
&& current_day->mm == slctd_day.mm
|
||||
@ -563,11 +563,11 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
|
||||
mvwprintw (cwin->p, OFFY + 2 + i, OFFX + 2 + 4 * j, " ");
|
||||
wattroff (cwin->p, A_REVERSE);
|
||||
if (highlight)
|
||||
custom_remove_attr (cwin->p, attr);
|
||||
custom_remove_attr (cwin->p, attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* get next day */
|
||||
(void)date_change (&t, 0, 1);
|
||||
}
|
||||
@ -579,7 +579,7 @@ draw_weekly_view (struct window *cwin, struct date *current_day,
|
||||
OFFX + WCALWIDTH - 3, ACS_S9, 1);
|
||||
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
||||
|
||||
#undef DAYSLICESNO
|
||||
#undef DAYSLICESNO
|
||||
}
|
||||
|
||||
/* Function used to display the calendar panel. */
|
||||
@ -611,7 +611,7 @@ calendar_goto_today (void)
|
||||
slctd_day.yyyy = today.yyyy;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Ask for a date to jump to, then check the correctness of that date
|
||||
* and jump to it.
|
||||
* If the entered date is empty, automatically jump to the current date.
|
||||
@ -636,29 +636,29 @@ calendar_change_day (int datefmt)
|
||||
(void)snprintf (outstr, BUFSIZ, request_date, DATEFMT_DESC (datefmt));
|
||||
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:
|
||||
@ -771,7 +771,7 @@ calendar_end_of_year (void)
|
||||
}
|
||||
|
||||
/*
|
||||
* The pom, potm, dotr, adj360 are used to compute the current
|
||||
* The pom, potm, dotr, adj360 are used to compute the current
|
||||
* phase of the moon.
|
||||
* The code is based on the OpenBSD version of pom(6).
|
||||
* Below is reported the copyright notice.
|
||||
@ -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 */
|
||||
|
778
src/custom.c
778
src/custom.c
File diff suppressed because it is too large
Load Diff
542
src/day.c
542
src/day.c
@ -78,7 +78,7 @@ static struct day_item *
|
||||
day_add_event (int type, char *mesg, char *note, long day, int id)
|
||||
{
|
||||
struct day_item *o, **i;
|
||||
|
||||
|
||||
o = mem_malloc (sizeof (struct day_item));
|
||||
o->mesg = mesg;
|
||||
o->note = note;
|
||||
@ -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,29 +122,29 @@ 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;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Store the events for the selected day in structure pointed
|
||||
* by day_items_ptr. This is done by copying the events
|
||||
* by day_items_ptr. This is done by copying the events
|
||||
* from the general structure pointed by eventlist to the structure
|
||||
* dedicated to the selected day.
|
||||
* dedicated to the selected day.
|
||||
* Returns the number of events for the selected day.
|
||||
*/
|
||||
static int
|
||||
@ -157,20 +157,20 @@ 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;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Store the recurrent events for the selected day in structure pointed
|
||||
* by day_items_ptr. This is done by copying the recurrent events
|
||||
* by day_items_ptr. This is done by copying the recurrent events
|
||||
* from the general structure pointed by recur_elist to the structure
|
||||
* dedicated to the selected day.
|
||||
* dedicated to the selected day.
|
||||
* Returns the number of recurrent events for the selected day.
|
||||
*/
|
||||
static int
|
||||
@ -183,21 +183,21 @@ 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;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Store the apoints for the selected day in structure pointed
|
||||
* by day_items_ptr. This is done by copying the appointments
|
||||
* from the general structure pointed by alist_p->root to the
|
||||
* structure dedicated to the selected day.
|
||||
* from the general structure pointed by alist_p->root to the
|
||||
* structure dedicated to the selected day.
|
||||
* Returns the number of appointments for the selected day.
|
||||
*/
|
||||
static int
|
||||
@ -211,22 +211,22 @@ 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));
|
||||
|
||||
return a_nb;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Store the recurrent apoints for the selected day in structure pointed
|
||||
* by day_items_ptr. This is done by copying the appointments
|
||||
* from the general structure pointed by recur_alist_p->root to the
|
||||
* structure dedicated to the selected day.
|
||||
* from the general structure pointed by recur_alist_p->root to the
|
||||
* structure dedicated to the selected day.
|
||||
* Returns the number of recurrent appointments for the selected day.
|
||||
*/
|
||||
static int
|
||||
@ -241,23 +241,23 @@ 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));
|
||||
|
||||
return a_nb;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Store all of the items to be displayed for the selected day.
|
||||
* Items are of four types: recursive events, normal events,
|
||||
* Items are of four types: recursive events, normal events,
|
||||
* recursive appointments and normal appointments.
|
||||
* The items are stored in the linked list pointed by *day_items_ptr
|
||||
* and the length of the new pad to write is returned.
|
||||
@ -296,7 +296,7 @@ day_store_items (long date, unsigned *pnb_events, unsigned *pnb_apoints)
|
||||
*/
|
||||
struct day_items_nb *
|
||||
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;
|
||||
@ -324,8 +324,8 @@ day_process_storage (struct date *slctd_date, unsigned day_changed,
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a structure of type apoint_llist_node_t given a structure of type
|
||||
* day_item_s
|
||||
* Returns a structure of type apoint_llist_node_t given a structure of type
|
||||
* day_item_s
|
||||
*/
|
||||
static void
|
||||
day_item_s2apoint_s (struct apoint *a, struct day_item *p)
|
||||
@ -336,12 +336,12 @@ day_item_s2apoint_s (struct apoint *a, struct day_item *p)
|
||||
a->mesg = p->mesg;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Print an item date in the appointment panel.
|
||||
*/
|
||||
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];
|
||||
@ -366,12 +366,12 @@ display_item_date (int incolor, struct apoint *i, int type, long date,
|
||||
custom_remove_attr (win, ATTR_HIGHEST);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Print an item description in the corresponding panel window.
|
||||
*/
|
||||
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;
|
||||
@ -394,7 +394,7 @@ display_item (int incolor, char *msg, int recur, int note, int len, int y,
|
||||
custom_remove_attr (win, ATTR_HIGHEST);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Write the appointments and events for the selected day in a pad.
|
||||
* An horizontal line is drawn between events and appointments, and the
|
||||
* item selected by user is highlighted. This item is also saved inside
|
||||
@ -416,49 +416,49 @@ day_write_pad (long date, int width, int length, int incolor)
|
||||
for (p = day_items_ptr; p != 0; p = p->next)
|
||||
{
|
||||
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,13 +470,13 @@ 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 */
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Need to know if there is an item for the current selected day inside
|
||||
* calendar. This is used to put the correct colors inside calendar panel.
|
||||
*/
|
||||
@ -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));
|
||||
|
||||
@ -527,13 +527,13 @@ fill_slices (int *slices, int slicesno, int first, int last)
|
||||
|
||||
if (first < 0 || last < first)
|
||||
return 0;
|
||||
|
||||
|
||||
if (last >= slicesno)
|
||||
last = slicesno - 1; /* Appointment spanning more than one day. */
|
||||
|
||||
|
||||
for (i = first; i <= last; i++)
|
||||
slices[i] = 1;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -547,7 +547,7 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices)
|
||||
{
|
||||
struct recur_apoint *ra;
|
||||
struct apoint *a;
|
||||
int slicelen;
|
||||
int slicelen;
|
||||
const long date = date2sec (day, 0, 0);
|
||||
|
||||
slicelen = DAYINSEC / slicesno;
|
||||
@ -557,7 +557,7 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices)
|
||||
pthread_mutex_lock (&(recur_alist_p->mutex));
|
||||
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;
|
||||
|
||||
@ -587,7 +587,7 @@ day_chk_busy_slices (struct date day, int slicesno, int *slices)
|
||||
}
|
||||
pthread_mutex_unlock (&(alist_p->mutex));
|
||||
|
||||
#undef SLICENUM
|
||||
#undef SLICENUM
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -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,55 +838,55 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* In order to erase an item, we need to count first the number of
|
||||
* items for each type (in order: recurrent events, events,
|
||||
* items for each type (in order: recurrent events, events,
|
||||
* recurrent appointments and appointments) and then to test the
|
||||
* type of the item to be deleted.
|
||||
*/
|
||||
@ -896,10 +896,10 @@ day_erase_item (long date, int item_number, enum eraseflg flag)
|
||||
struct day_item *p;
|
||||
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;
|
||||
@ -973,13 +973,13 @@ day_cut_item (long date, int item_number)
|
||||
{
|
||||
const int DELETE_WHOLE = 1;
|
||||
struct day_item *p;
|
||||
|
||||
|
||||
p = day_get_item (item_number);
|
||||
switch (p->type)
|
||||
{
|
||||
case EVNT:
|
||||
event_delete_bynum (date, day_item_nb (date, item_number, EVNT),
|
||||
ERASE_CUT);
|
||||
ERASE_CUT);
|
||||
break;
|
||||
case RECUR_EVNT:
|
||||
recur_event_erase (date, day_item_nb (date, item_number, RECUR_EVNT),
|
||||
@ -1086,9 +1086,9 @@ day_edit_note (char *editor)
|
||||
if (p->note == NULL)
|
||||
{
|
||||
if ((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);
|
||||
|
16
src/dmon.c
16
src/dmon.c
@ -69,7 +69,7 @@ dmon_sigs_hdlr (int sig)
|
||||
{
|
||||
if (data_loaded)
|
||||
free_user_data ();
|
||||
|
||||
|
||||
DMON_LOG (_("terminated at %s with signal %d\n"), nowstr (), sig);
|
||||
|
||||
if (unlink (path_dpid) != 0)
|
||||
@ -78,7 +78,7 @@ dmon_sigs_hdlr (int sig)
|
||||
strerror (errno));
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ static unsigned
|
||||
daemonize (int status)
|
||||
{
|
||||
int fd;
|
||||
|
||||
|
||||
/*
|
||||
* Operate in the background: Daemonizing.
|
||||
*
|
||||
@ -127,7 +127,7 @@ daemonize (int status)
|
||||
strerror (errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Redirect standard file descriptors to /dev/null. */
|
||||
if ((fd = open (_PATH_DEVNULL, O_RDWR, 0)) != -1)
|
||||
{
|
||||
@ -155,7 +155,7 @@ void
|
||||
dmon_start (int parent_exit_status)
|
||||
{
|
||||
struct conf conf;
|
||||
|
||||
|
||||
if (!daemonize (parent_exit_status))
|
||||
DMON_ABRT (_("Cannot daemonize, aborting\n"));
|
||||
|
||||
@ -166,7 +166,7 @@ dmon_start (int parent_exit_status)
|
||||
DMON_ABRT (_("Could not access \"%s\": %s\n"),
|
||||
path_conf, strerror (errno));
|
||||
custom_load_conf (&conf, 0);
|
||||
|
||||
|
||||
if (!io_file_exist (path_apts))
|
||||
DMON_ABRT (_("Could not access \"%s\": %s\n"),
|
||||
path_apts, strerror (errno));
|
||||
@ -179,7 +179,7 @@ dmon_start (int parent_exit_status)
|
||||
for (;;)
|
||||
{
|
||||
int left;
|
||||
|
||||
|
||||
if (!notify_get_next_bkgd ())
|
||||
DMON_ABRT (_("error loading next appointment\n"));
|
||||
|
||||
@ -191,7 +191,7 @@ dmon_start (int parent_exit_status)
|
||||
if (!notify_launch_cmd ())
|
||||
DMON_LOG (_("error while sending notification\n"));
|
||||
}
|
||||
|
||||
|
||||
DMON_LOG (_("sleeping at %s for %d seconds\n"), nowstr (),
|
||||
DMON_SLEEP_TIME);
|
||||
psleep (DMON_SLEEP_TIME);
|
||||
|
44
src/event.c
44
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,15 +175,15 @@ 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;
|
||||
/* NOTREACHED */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* Delete an event from the list. */
|
||||
@ -198,9 +198,9 @@ event_delete_bynum (long start, unsigned num, enum eraseflg flag)
|
||||
for (i = eventlist; i != 0; i = i->next)
|
||||
{
|
||||
if (event_inday (i, start))
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
{
|
||||
if (n == num)
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
case ERASE_FORCE_ONLY_NOTE:
|
||||
@ -212,21 +212,21 @@ event_delete_bynum (long start, unsigned num, enum eraseflg flag)
|
||||
erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
|
||||
/* 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"));
|
||||
/* NOTREACHED */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void
|
||||
|
40
src/help.c
40
src/help.c
@ -91,9 +91,9 @@ get_help_lines (char *text)
|
||||
return newline + 1;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Write the desired help text inside the help pad, and return the number
|
||||
* of lines that were written.
|
||||
* of lines that were written.
|
||||
*/
|
||||
static int
|
||||
help_write_pad (struct window *win, char *title, char *text, enum key action)
|
||||
@ -136,16 +136,16 @@ help_write_pad (struct window *win, char *title, char *text, enum key action)
|
||||
}
|
||||
}
|
||||
colnum = 0;
|
||||
rownum += get_help_lines (title);
|
||||
rownum += get_help_lines (title);
|
||||
custom_remove_attr (win->p, ATTR_HIGHEST);
|
||||
mvwprintw (win->p, rownum, colnum, "%s", text);
|
||||
rownum += get_help_lines (text);
|
||||
return rownum;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Create and init help screen and its pad, which is used to make the scrolling
|
||||
* faster.
|
||||
* faster.
|
||||
*/
|
||||
void
|
||||
help_wins_init (struct scrollwin *hwin, int x, int y, int h, int w)
|
||||
@ -168,7 +168,7 @@ help_wins_init (struct scrollwin *hwin, int x, int y, int h, int w)
|
||||
wins_show (hwin->win.p, hwin->label);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Delete the existing windows and recreate them with their new
|
||||
* size and placement.
|
||||
*/
|
||||
@ -233,7 +233,7 @@ wanted_page (int ch)
|
||||
case KEY_GENERIC_IMPORT:
|
||||
page = HELP_IMPORT;
|
||||
break;
|
||||
|
||||
|
||||
case KEY_GENERIC_EXPORT:
|
||||
page = HELP_EXPORT;
|
||||
break;
|
||||
@ -263,7 +263,7 @@ wanted_page (int ch)
|
||||
case KEY_GENERIC_PASTE:
|
||||
page = HELP_CUT_PASTE;
|
||||
break;
|
||||
|
||||
|
||||
case KEY_EDIT_ITEM:
|
||||
page = HELP_EDIT;
|
||||
break;
|
||||
@ -330,7 +330,7 @@ help_screen (void)
|
||||
int page, oldpage;
|
||||
help_page_t hscr[HELPSCREENS];
|
||||
char keystr[DIRECTIONS][BUFSIZ];
|
||||
|
||||
|
||||
hscr[HELP_MAIN].title =
|
||||
_(" Welcome to Calcurse. This is the main help screen.\n");
|
||||
(void)snprintf (hscr[HELP_MAIN].text, HELPTEXTSIZ,
|
||||
@ -383,7 +383,7 @@ help_screen (void)
|
||||
"In this report is shown one item per line, with the line in the input\n"
|
||||
"stream at which this item begins, together with the description of why\n"
|
||||
"the item could not be imported.\n"));
|
||||
|
||||
|
||||
hscr[HELP_EXPORT].title = _("Export\n");
|
||||
(void)snprintf (hscr[HELP_EXPORT].text, HELPTEXTSIZ,
|
||||
_("Export calcurse data (appointments, events and todos).\n"
|
||||
@ -432,7 +432,7 @@ help_screen (void)
|
||||
keystr[MOVE_UP], keystr[MOVE_LEFT],
|
||||
keystr[MOVE_RIGHT], keystr[MOVE_DOWN],
|
||||
keys_action_firstkey (KEY_START_OF_WEEK),
|
||||
keys_action_firstkey (KEY_END_OF_WEEK));
|
||||
keys_action_firstkey (KEY_END_OF_WEEK));
|
||||
|
||||
hscr[HELP_VIEW].title = _("View\n");
|
||||
(void)snprintf (hscr[HELP_VIEW].text, HELPTEXTSIZ,
|
||||
@ -458,7 +458,7 @@ help_screen (void)
|
||||
"\nNotice that at the bottom of the screen the list of possible actions\n"
|
||||
"change while pressing '%s', so you always know what action can be\n"
|
||||
"performed on the selected panel."),
|
||||
keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW),
|
||||
keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW),
|
||||
keys_action_firstkey (KEY_ADD_ITEM),
|
||||
keys_action_firstkey (KEY_GENERIC_CHANGE_VIEW));
|
||||
|
||||
@ -520,7 +520,7 @@ help_screen (void)
|
||||
" event next time you launch Calcurse."),
|
||||
keys_action_firstkey (KEY_ADD_ITEM),
|
||||
keys_action_firstkey (KEY_RAISE_PRIORITY),
|
||||
keys_action_firstkey (KEY_LOWER_PRIORITY),
|
||||
keys_action_firstkey (KEY_LOWER_PRIORITY),
|
||||
keys_action_firstkey (KEY_ADD_ITEM),
|
||||
keys_action_firstkey (KEY_ADD_ITEM));
|
||||
|
||||
@ -539,7 +539,7 @@ help_screen (void)
|
||||
"with its associated note if it had one."),
|
||||
keys_action_firstkey (KEY_GENERIC_CUT),
|
||||
keys_action_firstkey (KEY_GENERIC_PASTE));
|
||||
|
||||
|
||||
hscr[HELP_EDIT].title = _("Edit Item\n");
|
||||
(void)snprintf (hscr[HELP_EDIT].text, HELPTEXTSIZ,
|
||||
_("Edit the item which is currently selected.\n"
|
||||
@ -596,7 +596,7 @@ help_screen (void)
|
||||
"Calcurse."),
|
||||
keys_action_firstkey (KEY_EDIT_NOTE),
|
||||
keys_action_firstkey (KEY_VIEW_NOTE));
|
||||
|
||||
|
||||
hscr[HELP_PRIORITY].title = _("Priority\n");
|
||||
(void)snprintf (hscr[HELP_PRIORITY].text, HELPTEXTSIZ,
|
||||
_("Change the priority of the currently selected item in the ToDo list.\n"
|
||||
@ -612,9 +612,9 @@ help_screen (void)
|
||||
"panel may change,\ndepending on the priority of the items above it.\n\n"
|
||||
"At the opposite, to lower a todo priority, press '%s'. The todo position"
|
||||
"\nmay also change depending on the priority of the items below."),
|
||||
keys_action_firstkey (KEY_RAISE_PRIORITY),
|
||||
keys_action_firstkey (KEY_RAISE_PRIORITY),
|
||||
keys_action_firstkey (KEY_LOWER_PRIORITY));
|
||||
|
||||
|
||||
hscr[HELP_REPEAT].title = _("Repeat\n");
|
||||
(void)snprintf (hscr[HELP_REPEAT].text, HELPTEXTSIZ,
|
||||
_("Repeat an event or an appointment.\n"
|
||||
@ -640,7 +640,7 @@ help_screen (void)
|
||||
" o the 'Repeat' and 'Delete' command can be mixed to create\n"
|
||||
" complicated configurations, as it is possible to delete only\n"
|
||||
" one occurence of a repeated item."),
|
||||
keys_action_firstkey (KEY_REPEAT_ITEM));
|
||||
keys_action_firstkey (KEY_REPEAT_ITEM));
|
||||
|
||||
hscr[HELP_FLAG].title = _("Flag Item\n");
|
||||
(void)snprintf (hscr[HELP_FLAG].text, HELPTEXTSIZ,
|
||||
@ -711,7 +711,7 @@ help_screen (void)
|
||||
"Once the last status bar page is reached, pressing '%s' another time\n"
|
||||
"leads you back to the first page."),
|
||||
keys_action_firstkey (KEY_GENERIC_OTHER_CMD),
|
||||
keys_action_firstkey (KEY_GENERIC_OTHER_CMD));
|
||||
keys_action_firstkey (KEY_GENERIC_OTHER_CMD));
|
||||
|
||||
hscr[HELP_CREDITS].title = _("Calcurse - text-based organizer");
|
||||
(void)snprintf (hscr[HELP_CREDITS].text, HELPTEXTSIZ,
|
||||
@ -737,7 +737,7 @@ help_screen (void)
|
||||
help_wins_init (&hwin, 0, 0, (notify_bar ()) ? row - 3 : row - 2, col);
|
||||
page = oldpage = HELP_MAIN;
|
||||
need_resize = 0;
|
||||
|
||||
|
||||
/* Display the help screen related to user input. */
|
||||
while (ch != KEY_GENERIC_QUIT)
|
||||
{
|
||||
|
42
src/keys.c
42
src/keys.c
@ -78,9 +78,9 @@ static struct keydef_s keydef[NBKEYS] = {
|
||||
{"generic-next-week", "C-j"},
|
||||
{"generic-prev-week", "C-k"},
|
||||
{"generic-scroll-down", "C-n"},
|
||||
{"generic-scroll-up", "C-p"},
|
||||
{"generic-scroll-up", "C-p"},
|
||||
{"generic-goto-today", "C-g"},
|
||||
|
||||
|
||||
{"move-right", "l L"},
|
||||
{"move-left", "h H"},
|
||||
{"move-down", "j J"},
|
||||
@ -164,7 +164,7 @@ keys_dump_defaults (char *file)
|
||||
{
|
||||
FILE *fd;
|
||||
int i;
|
||||
|
||||
|
||||
fd = fopen (file, "w");
|
||||
EXIT_IF (fd == NULL, _("FATAL ERROR: could not create default keys file."));
|
||||
|
||||
@ -196,7 +196,7 @@ enum key
|
||||
keys_getch (WINDOW *win)
|
||||
{
|
||||
int ch;
|
||||
|
||||
|
||||
ch = wgetch (win);
|
||||
switch (ch)
|
||||
{
|
||||
@ -211,7 +211,7 @@ static void
|
||||
add_key_str (enum key action, int key)
|
||||
{
|
||||
struct key_str_s *new, **i;
|
||||
|
||||
|
||||
if (action < 0 || action > NBKEYS)
|
||||
return;
|
||||
|
||||
@ -245,7 +245,7 @@ keys_assign_binding (int key, enum key action)
|
||||
actions[key] = action;
|
||||
add_key_str (action, key);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ del_key_str (enum key action, int key)
|
||||
{
|
||||
struct key_str_s *old, **i;
|
||||
char oldstr[BUFSIZ];
|
||||
|
||||
|
||||
if (action < 0 || action > NBKEYS)
|
||||
return;
|
||||
|
||||
@ -265,7 +265,7 @@ del_key_str (enum key action, int key)
|
||||
{
|
||||
old = *i;
|
||||
*i = old->next;
|
||||
mem_free (old->str);
|
||||
mem_free (old->str);
|
||||
mem_free (old);
|
||||
break;
|
||||
}
|
||||
@ -289,7 +289,7 @@ keys_str2int (char *key)
|
||||
{
|
||||
const struct string CONTROL_KEY = STRING_BUILD ("C-");
|
||||
const struct string TAB_KEY = STRING_BUILD ("TAB");
|
||||
const struct string SPACE_KEY = STRING_BUILD ("SPC");
|
||||
const struct string SPACE_KEY = STRING_BUILD ("SPC");
|
||||
const struct string ESCAPE_KEY = STRING_BUILD ("ESC");
|
||||
const struct string CURSES_KEY_UP = STRING_BUILD ("UP");
|
||||
const struct string CURSES_KEY_DOWN = STRING_BUILD ("DWN");
|
||||
@ -375,7 +375,7 @@ keys_action_count_keys (enum key action)
|
||||
char *
|
||||
keys_action_firstkey (enum key action)
|
||||
{
|
||||
return (keys[action] != NULL) ? keys[action]->str : "XXX";
|
||||
return (keys[action] != NULL) ? keys[action]->str : "XXX";
|
||||
}
|
||||
|
||||
char *
|
||||
@ -400,10 +400,10 @@ keys_action_allkeys (enum key action)
|
||||
static char keystr[BUFSIZ];
|
||||
struct key_str_s *i;
|
||||
const char *CHAR_SPACE = " ";
|
||||
|
||||
|
||||
if (keys[action] == NULL)
|
||||
return NULL;
|
||||
keystr[0] = '\0';
|
||||
keystr[0] = '\0';
|
||||
for (i = keys[action]; i; i = i->next)
|
||||
{
|
||||
const int MAXLEN = sizeof (keystr) - 1 - strlen (keystr);
|
||||
@ -454,7 +454,7 @@ keys_display_bindings_bar (WINDOW *win, struct binding **binding, int first_key,
|
||||
cmdlen = KEYS_KEYLEN + 1 + KEYS_LABELEN;
|
||||
space_between_cmds = floor (col / KEYS_CMDS_PER_LINE - cmdlen);
|
||||
cmdlen += space_between_cmds;
|
||||
|
||||
|
||||
j = 0;
|
||||
wins_erase_status_bar ();
|
||||
for (i = first_key; i < last_key; i += 2)
|
||||
@ -479,7 +479,7 @@ keys_display_bindings_bar (WINDOW *win, struct binding **binding, int first_key,
|
||||
custom_remove_attr (win, ATTR_HIGHEST);
|
||||
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);
|
||||
@ -494,7 +494,7 @@ keys_popup_info (enum key key)
|
||||
{
|
||||
char *info[NBKEYS];
|
||||
WINDOW *infowin;
|
||||
|
||||
|
||||
info[KEY_GENERIC_CANCEL] =
|
||||
_("Cancel the ongoing action.");
|
||||
info[KEY_GENERIC_SELECT] =
|
||||
@ -574,8 +574,8 @@ keys_popup_info (enum key key)
|
||||
info[KEY_RAISE_PRIORITY] =
|
||||
_("Raise a task priority inside the todo panel.");
|
||||
info[KEY_LOWER_PRIORITY] =
|
||||
_("Lower a task priority inside the todo panel.");
|
||||
|
||||
_("Lower a task priority inside the todo panel.");
|
||||
|
||||
if (key < 0 || key > NBKEYS)
|
||||
return;
|
||||
|
||||
@ -593,7 +593,7 @@ void
|
||||
keys_save_bindings (FILE *fd)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
EXIT_IF (fd == NULL, _("FATAL ERROR: null file pointer."));
|
||||
dump_intro (fd);
|
||||
for (i = 0; i < NBKEYS; i++)
|
||||
@ -604,7 +604,7 @@ int
|
||||
keys_check_missing_bindings (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < NBKEYS; i++)
|
||||
{
|
||||
if (keys[i] == 0)
|
||||
@ -624,7 +624,7 @@ keys_fill_missing (void)
|
||||
{
|
||||
char *p, tmpbuf[BUFSIZ];
|
||||
|
||||
(void)strncpy (tmpbuf, keydef[i].binding, BUFSIZ);
|
||||
(void)strncpy (tmpbuf, keydef[i].binding, BUFSIZ);
|
||||
p = tmpbuf;
|
||||
for (;;)
|
||||
{
|
||||
@ -635,7 +635,7 @@ keys_fill_missing (void)
|
||||
if (sscanf (p, "%s", key_ch) == 1)
|
||||
{
|
||||
int ch, used;
|
||||
|
||||
|
||||
ch = keys_str2int (key_ch);
|
||||
used = keys_assign_binding (ch, i);
|
||||
if (used)
|
||||
|
44
src/mem.c
44
src/mem.c
@ -77,11 +77,11 @@ stats_add_blk (size_t size, const char *pos)
|
||||
EXIT_IF (o == 0, _("could not allocate memory to store block info"));
|
||||
|
||||
mstats.ncall++;
|
||||
|
||||
|
||||
o->pos = pos;
|
||||
o->size = (unsigned)size;
|
||||
o->next = 0;
|
||||
|
||||
|
||||
i = &mstats.blk;
|
||||
for (i = &mstats.blk; *i; i = &(*i)->next)
|
||||
;
|
||||
@ -111,14 +111,14 @@ stats_del_blk (unsigned id)
|
||||
}
|
||||
|
||||
EXIT (_("Block not found"));
|
||||
/* NOTREACHED */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
void *
|
||||
xmalloc (size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
|
||||
EXIT_IF (size == 0, _("xmalloc: zero size"));
|
||||
p = malloc (size);
|
||||
EXIT_IF (p == 0, _("xmalloc: out of memory"));
|
||||
@ -177,13 +177,13 @@ void *
|
||||
dbg_malloc (size_t size, const char *pos)
|
||||
{
|
||||
unsigned *buf;
|
||||
|
||||
|
||||
if (size == 0)
|
||||
return (void *)0;
|
||||
|
||||
|
||||
size = EXTRA_SPACE + (size + sizeof (unsigned) - 1) / sizeof (unsigned);
|
||||
buf = xmalloc (size * sizeof (unsigned));
|
||||
|
||||
|
||||
buf[BLK_STATE] = MAGIC_ALLOC; /* state of the block */
|
||||
buf[BLK_SIZE] = size; /* size of the block */
|
||||
buf[BLK_ID] = stats_add_blk (size, pos); /* identify a block by its id */
|
||||
@ -198,10 +198,10 @@ void *
|
||||
dbg_calloc (size_t nmemb, size_t size, const char *pos)
|
||||
{
|
||||
void *buf;
|
||||
|
||||
|
||||
if (!nmemb || !size)
|
||||
return (void *)0;
|
||||
|
||||
|
||||
EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos);
|
||||
|
||||
size *= nmemb;
|
||||
@ -217,25 +217,25 @@ void *
|
||||
dbg_realloc (void *ptr, size_t nmemb, size_t size, const char *pos)
|
||||
{
|
||||
unsigned *buf, old_size, new_size, cpy_size;
|
||||
|
||||
|
||||
if (ptr == 0)
|
||||
return (void *)0;
|
||||
|
||||
new_size = nmemb *size;
|
||||
if (new_size == 0)
|
||||
return (void *)0;
|
||||
|
||||
|
||||
EXIT_IF (nmemb > SIZE_MAX / size, _("overflow at %s"), pos);
|
||||
|
||||
|
||||
if ((buf = dbg_malloc (new_size, pos)) == 0)
|
||||
return (void *)0;
|
||||
|
||||
old_size = *((unsigned *)ptr - EXTRA_SPACE_START + BLK_SIZE);
|
||||
cpy_size = (old_size > new_size) ? new_size : old_size;
|
||||
bcopy (ptr, buf, cpy_size);
|
||||
|
||||
|
||||
mem_free (ptr);
|
||||
|
||||
|
||||
return (void *)buf;
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ dbg_strdup (const char *s, const char *pos)
|
||||
{
|
||||
size_t size;
|
||||
char *buf;
|
||||
|
||||
|
||||
if (s == 0)
|
||||
return (char *)0;
|
||||
|
||||
@ -264,19 +264,19 @@ dbg_free (void *ptr, const char *pos)
|
||||
|
||||
buf = (unsigned *)ptr - EXTRA_SPACE_START;
|
||||
size = buf[BLK_SIZE];
|
||||
|
||||
|
||||
EXIT_IF (buf[BLK_STATE] == MAGIC_FREE,
|
||||
_("block seems already freed at %s"), pos);
|
||||
EXIT_IF (buf[BLK_STATE] != MAGIC_ALLOC,
|
||||
_("corrupt block header at %s"), pos);
|
||||
EXIT_IF (buf[size - 1] != buf[BLK_ID],
|
||||
_("corrupt block end at %s, (end = %u, should be %d)"), pos,
|
||||
buf[size - 1], buf[BLK_ID]);
|
||||
buf[size - 1], buf[BLK_ID]);
|
||||
|
||||
buf[0] = MAGIC_FREE;
|
||||
|
||||
stats_del_blk (buf[BLK_ID]);
|
||||
|
||||
|
||||
free (buf);
|
||||
mstats.nfree += size;
|
||||
}
|
||||
@ -289,10 +289,10 @@ dump_block_info (struct mem_blk *blk)
|
||||
{
|
||||
if (blk == 0)
|
||||
return;
|
||||
|
||||
|
||||
printf (_("---==== MEMORY BLOCK ====----------------\n"));
|
||||
printf (_(" id: %u\n"), blk->id);
|
||||
printf (_(" size: %u\n"), blk->size);
|
||||
printf (_(" id: %u\n"), blk->id);
|
||||
printf (_(" size: %u\n"), blk->size);
|
||||
printf (_(" allocated in: %s\n"), blk->pos);
|
||||
printf (_("-----------------------------------------\n"));
|
||||
}
|
||||
@ -301,7 +301,7 @@ void
|
||||
mem_stats (void)
|
||||
{
|
||||
printf ("\n");
|
||||
printf (_("+------------------------------+\n"));
|
||||
printf (_("+------------------------------+\n"));
|
||||
printf (_("| calcurse memory usage report |\n"));
|
||||
printf (_("+------------------------------+\n"));
|
||||
printf (_(" number of calls: %u\n"), mstats.ncall);
|
||||
|
352
src/notify.c
352
src/notify.c
@ -65,7 +65,7 @@ notify_time_left (void)
|
||||
{
|
||||
struct tm *ntime;
|
||||
time_t ntimer;
|
||||
int left;
|
||||
int left;
|
||||
|
||||
ntimer = time (NULL);
|
||||
ntime = localtime (&ntimer);
|
||||
@ -99,7 +99,7 @@ notify_update_app (long start, char state, char *msg)
|
||||
notify_free_app ();
|
||||
notify_app.got_app = 1;
|
||||
notify_app.time = start;
|
||||
notify_app.state = state;
|
||||
notify_app.state = state;
|
||||
notify_app.txt = mem_strdup (msg);
|
||||
}
|
||||
|
||||
@ -155,10 +155,10 @@ extract_aptsfile (void)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the notification bar, by initializing all the variables and
|
||||
/*
|
||||
* Create the notification bar, by initializing all the variables and
|
||||
* creating the notification window (l is the number of lines, c the
|
||||
* number of columns, y and x are its coordinates).
|
||||
* number of columns, y and x are its coordinates).
|
||||
*/
|
||||
void
|
||||
notify_init_bar (void)
|
||||
@ -193,9 +193,9 @@ notify_stop_main_thread (void)
|
||||
pthread_cancel (notify_t_main);
|
||||
}
|
||||
|
||||
/*
|
||||
* The calcurse window geometry has changed so we need to reset the
|
||||
* notification window.
|
||||
/*
|
||||
* The calcurse window geometry has changed so we need to reset the
|
||||
* notification window.
|
||||
*/
|
||||
void
|
||||
notify_reinit_bar (void)
|
||||
@ -212,9 +212,9 @@ notify_launch_cmd (void)
|
||||
|
||||
if (notify_app.state & APOINT_NOTIFIED)
|
||||
return 1;
|
||||
|
||||
|
||||
notify_app.state |= APOINT_NOTIFIED;
|
||||
|
||||
|
||||
pid = fork ();
|
||||
|
||||
if (pid < 0)
|
||||
@ -236,7 +236,7 @@ notify_launch_cmd (void)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Update the notification bar. This is useful when changing color theme
|
||||
* for example.
|
||||
*/
|
||||
@ -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);
|
||||
|
||||
if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY))
|
||||
blinking = 1;
|
||||
else
|
||||
blinking = 0;
|
||||
hours_left = (time_left / HOURINSEC);
|
||||
minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC;
|
||||
pthread_mutex_lock (&nbar.mutex);
|
||||
|
||||
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 (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY))
|
||||
blinking = 1;
|
||||
else
|
||||
blinking = 0;
|
||||
|
||||
if (blinking)
|
||||
if (blinking)
|
||||
wattron (notify.win, A_BLINK);
|
||||
if (too_long)
|
||||
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s.. <",
|
||||
hours_left, minutes_left, buf);
|
||||
else
|
||||
mvwprintw (notify.win, 0, app_pos, "> %02d:%02d :: %s <",
|
||||
hours_left, minutes_left, notify_app.txt);
|
||||
if (blinking)
|
||||
wattroff (notify.win, A_BLINK);
|
||||
|
||||
if (blinking)
|
||||
(void)notify_launch_cmd ();
|
||||
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);
|
||||
}
|
||||
@ -366,10 +366,10 @@ unsigned
|
||||
notify_get_next (struct notify_app *a)
|
||||
{
|
||||
time_t current_time;
|
||||
|
||||
|
||||
if (!a)
|
||||
return 0;
|
||||
|
||||
|
||||
current_time = time (NULL);
|
||||
|
||||
a->time = current_time + DAYINSEC;
|
||||
@ -409,7 +409,7 @@ notify_get_next_bkgd (void)
|
||||
|
||||
if (a.txt)
|
||||
mem_free (a.txt);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -432,23 +432,23 @@ notify_thread_app (void *arg)
|
||||
|
||||
if (!notify_get_next (&tmp_app))
|
||||
pthread_exit ((void *)0);
|
||||
|
||||
|
||||
if (!tmp_app.got_app)
|
||||
{
|
||||
pthread_mutex_lock (¬ify_app.mutex);
|
||||
notify_free_app ();
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!notify_same_item (tmp_app.time))
|
||||
{
|
||||
pthread_mutex_lock (¬ify_app.mutex);
|
||||
pthread_mutex_lock (¬ify_app.mutex);
|
||||
notify_update_app (tmp_app.time, tmp_app.state, tmp_app.txt);
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
pthread_mutex_unlock (¬ify_app.mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tmp_app.txt)
|
||||
mem_free (tmp_app.txt);
|
||||
notify_update_bar ();
|
||||
@ -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;
|
||||
@ -583,7 +583,7 @@ print_option (WINDOW *win, unsigned x, unsigned y, char *name,
|
||||
const int XOFF = 4;
|
||||
const int MAXCOL = col - 3;
|
||||
int x_opt, len;
|
||||
|
||||
|
||||
x_opt = x + XOFF + strlen (name);
|
||||
mvwprintw (win, y, x, "[%u] %s", num, name);
|
||||
erase_window_part (win, x_opt, y, MAXCOL, y);
|
||||
@ -594,15 +594,15 @@ print_option (WINDOW *win, unsigned x, unsigned y, char *name,
|
||||
maxlen = MAXCOL - x_opt - 2;
|
||||
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
|
||||
@ -617,7 +617,7 @@ print_config_options (WINDOW *optwin)
|
||||
const int XORIG = 3;
|
||||
const int YORIG = 0;
|
||||
const int YOFF = 3;
|
||||
|
||||
|
||||
enum
|
||||
{ SHOW, DATE, CLOCK, WARN, CMD, DMON, DMON_LOG, NB_OPT };
|
||||
|
||||
@ -633,23 +633,23 @@ print_config_options (WINDOW *optwin)
|
||||
|
||||
opt[SHOW].name = _("notify-bar_show = ");
|
||||
opt[SHOW].desc = _("(if set to YES, notify-bar will be displayed)");
|
||||
|
||||
|
||||
opt[DATE].name = _("notify-bar_date = ");
|
||||
opt[DATE].desc = _("(Format of the date to be displayed inside notify-bar)");
|
||||
|
||||
|
||||
opt[CLOCK].name = _("notify-bar_clock = ");
|
||||
opt[CLOCK].desc = _("(Format of the time to be displayed inside notify-bar)");
|
||||
|
||||
|
||||
opt[WARN].name = _("notify-bar_warning = ");
|
||||
opt[WARN].desc = _("(Warn user if an appointment is within next "
|
||||
"'notify-bar_warning' seconds)");
|
||||
|
||||
|
||||
opt[CMD].name = _("notify-bar_command = ");
|
||||
opt[CMD].desc = _("(Command used to notify user of an upcoming appointment)");
|
||||
|
||||
|
||||
opt[DMON].name = _("notify-daemon_enable = ");
|
||||
opt[DMON].desc = _("(Run in background to get notifications after exiting)");
|
||||
|
||||
|
||||
opt[DMON_LOG].name = _("notify-daemon_log = ");
|
||||
opt[DMON_LOG].desc = _("(Log activity when running in background)");
|
||||
|
||||
@ -664,16 +664,16 @@ print_config_options (WINDOW *optwin)
|
||||
/* Boolean options */
|
||||
opt[SHOW].valnum = nbar.show;
|
||||
pthread_mutex_unlock (&nbar.mutex);
|
||||
|
||||
|
||||
opt[DMON].valnum = dmon.enable;
|
||||
opt[DMON_LOG].valnum = dmon.log;
|
||||
|
||||
opt[SHOW].valstr[0] = opt[DMON].valstr[0] = opt[DMON_LOG].valstr[0] = '\0';
|
||||
|
||||
|
||||
for (i = 0; i < NB_OPT; i++)
|
||||
{
|
||||
int y;
|
||||
|
||||
|
||||
y = YORIG + i * YOFF;
|
||||
print_option (optwin, XORIG, y, opt[i].name, opt[i].valstr,
|
||||
opt[i].valnum, opt[i].desc, i + 1);
|
||||
@ -689,7 +689,7 @@ reinit_conf_win (struct scrollwin *win)
|
||||
|
||||
first_line = win->first_visible_line;
|
||||
wins_scrollwin_delete (win);
|
||||
custom_set_swsiz (win);
|
||||
custom_set_swsiz (win);
|
||||
wins_scrollwin_init (win);
|
||||
wins_show (win->win.p, win->label);
|
||||
win->first_visible_line = first_line;
|
||||
@ -714,7 +714,7 @@ notify_config_bar (void)
|
||||
char *cmd_str = _("Enter the notification command ");
|
||||
int ch;
|
||||
|
||||
clear ();
|
||||
clear ();
|
||||
custom_set_swsiz (&cwin);
|
||||
(void)snprintf (cwin.label, BUFSIZ, _("notification options"));
|
||||
wins_scrollwin_init (&cwin);
|
||||
@ -723,8 +723,8 @@ notify_config_bar (void)
|
||||
cwin.total_lines = print_config_options (cwin.pad.p);
|
||||
wins_scrollwin_display (&cwin);
|
||||
|
||||
buf = mem_malloc (BUFSIZ);
|
||||
while ((ch = wgetch (win[STA].p)) != 'q')
|
||||
buf = mem_malloc (BUFSIZ);
|
||||
while ((ch = wgetch (win[STA].p)) != 'q')
|
||||
{
|
||||
buf[0] = '\0';
|
||||
|
||||
@ -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;
|
||||
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;
|
||||
}
|
||||
status_mesg (number_str, keys);
|
||||
cwin.total_lines = print_config_options (cwin.pad.p);
|
||||
|
396
src/recur.c
396
src/recur.c
@ -66,7 +66,7 @@ static void
|
||||
recur_add_exc (struct days **exc, long day)
|
||||
{
|
||||
struct days **i, *o;
|
||||
|
||||
|
||||
o = mem_malloc (sizeof (struct days));
|
||||
o->st = day;
|
||||
i = exc;
|
||||
@ -86,7 +86,7 @@ static void
|
||||
exc_dup (struct days **in, struct days *exc)
|
||||
{
|
||||
struct days *p;
|
||||
|
||||
|
||||
for (p = exc; p; p = p->next)
|
||||
recur_add_exc (in, p->st);
|
||||
}
|
||||
@ -141,7 +141,7 @@ recur_event_dup (struct recur_event *in, struct recur_event *bkp)
|
||||
bkp->id = in->id;
|
||||
bkp->day = in->day;
|
||||
bkp->mesg = mem_strdup (in->mesg);
|
||||
|
||||
|
||||
bkp->rpt = mem_malloc (sizeof (struct rpt));
|
||||
bkp->rpt->type = in->rpt->type;
|
||||
bkp->rpt->freq = in->rpt->freq;
|
||||
@ -163,7 +163,7 @@ recur_apoint_dup (struct recur_apoint *in, struct recur_apoint *bkp)
|
||||
bkp->dur = in->dur;
|
||||
bkp->state = in->state;
|
||||
bkp->mesg = mem_strdup (in->mesg);
|
||||
|
||||
|
||||
bkp->rpt = mem_malloc (sizeof (struct rpt));
|
||||
bkp->rpt->type = in->rpt->type;
|
||||
bkp->rpt->freq = in->rpt->freq;
|
||||
@ -174,7 +174,7 @@ recur_apoint_dup (struct recur_apoint *in, struct recur_apoint *bkp)
|
||||
|
||||
if (in->note)
|
||||
bkp->note = mem_strdup (in->note);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
recur_apoint_llist_init (void)
|
||||
@ -236,10 +236,10 @@ recur_event_llist_free (void)
|
||||
/* Insert a new recursive appointment in the general linked list */
|
||||
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;
|
||||
|
||||
|
||||
o = mem_malloc (sizeof (struct recur_apoint));
|
||||
o->rpt = mem_malloc (sizeof (struct rpt));
|
||||
o->mesg = mem_strdup (mesg);
|
||||
@ -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,14 +278,14 @@ recur_apoint_new (char *mesg, char *note, long start, long dur, char state,
|
||||
/* Insert a new recursive event in the general linked list */
|
||||
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;
|
||||
|
||||
|
||||
o = mem_malloc (sizeof (struct recur_event));
|
||||
o->rpt = mem_malloc (sizeof (struct rpt));
|
||||
o->mesg = mem_strdup (mesg);
|
||||
o->note = (note != 0) ? mem_strdup (note) : 0;
|
||||
o->note = (note != 0) ? mem_strdup (note) : 0;
|
||||
o->day = day;
|
||||
o->id = id;
|
||||
o->rpt->type = type;
|
||||
@ -303,19 +303,19 @@ 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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Correspondance between the defines on recursive type,
|
||||
* and the letter to be written in file.
|
||||
/*
|
||||
* Correspondance between the defines on recursive type,
|
||||
* and the letter to be written in file.
|
||||
*/
|
||||
char
|
||||
recur_def2char (enum recur_type define)
|
||||
@ -344,7 +344,7 @@ recur_def2char (enum recur_type define)
|
||||
return (recur_char);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Correspondance between the letters written in file and the defines
|
||||
* concerning the recursive type.
|
||||
*/
|
||||
@ -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;
|
||||
@ -646,7 +646,7 @@ diff_years (struct tm lt_start, struct tm lt_end)
|
||||
return lt_end.tm_year - lt_start.tm_year;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Check if the recurrent item belongs to the selected day,
|
||||
* and if yes, return the real start time.
|
||||
*
|
||||
@ -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;
|
||||
@ -668,7 +668,7 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
|
||||
day_end = day_start + DAYINSEC;
|
||||
t = day_start;
|
||||
lt_day = *localtime (&t);
|
||||
|
||||
|
||||
for (exc = item_exc; exc != 0; exc = exc->next)
|
||||
if (exc->st < day_end && exc->st >= day_start)
|
||||
return (0);
|
||||
@ -681,26 +681,26 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
|
||||
|
||||
t = item_start;
|
||||
lt_item = *localtime (&t);
|
||||
|
||||
|
||||
switch (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:
|
||||
@ -732,13 +732,13 @@ recur_item_inday (long item_start, struct days *item_exc, int rpt_type,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Delete a recurrent event from the list (if delete_whole is not null),
|
||||
* or delete only one occurence of the recurrent event.
|
||||
* or delete only one occurence of the recurrent event.
|
||||
*/
|
||||
void
|
||||
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,16 +747,16 @@ 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:
|
||||
erase_note (&i->note, flag);
|
||||
erase_note (&i->note, flag);
|
||||
break;
|
||||
case ERASE_CUT:
|
||||
recur_event_free_bkp (ERASE_FORCE);
|
||||
@ -764,8 +764,8 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
|
||||
erase_note (&i->note, ERASE_FORCE_KEEP_NOTE);
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
*iptr = i->next;
|
||||
mem_free (i->mesg);
|
||||
if (i->rpt)
|
||||
{
|
||||
mem_free (i->rpt);
|
||||
@ -778,32 +778,32 @@ recur_event_erase (long start, unsigned num, unsigned delete_whole,
|
||||
}
|
||||
if (flag != ERASE_FORCE_KEEP_NOTE && flag != ERASE_CUT)
|
||||
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"));
|
||||
/* NOTREACHED */
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a recurrent appointment from the list (if delete_whole is not null),
|
||||
* or delete only one occurence of the recurrent appointment.
|
||||
* or delete only one occurence of the recurrent appointment.
|
||||
*/
|
||||
void
|
||||
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
|
||||
{
|
||||
@ -1023,7 +1023,7 @@ recur_repeat_item (struct conf *conf)
|
||||
day_erase_item (date, item_nb, ERASE_FORCE_KEEP_NOTE);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Read days for which recurrent items must not be repeated
|
||||
* (such days are called exceptions).
|
||||
*/
|
||||
@ -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 */
|
||||
@ -1192,11 +1192,11 @@ recur_event_paste_item (void)
|
||||
if (bkp_cut_recur_event.exc)
|
||||
{
|
||||
struct days *exc;
|
||||
|
||||
|
||||
for (exc = bkp_cut_recur_event.exc; exc != 0; exc = exc->next)
|
||||
exc->st += time_shift;
|
||||
}
|
||||
|
||||
|
||||
(void)recur_event_new (bkp_cut_recur_event.mesg, bkp_cut_recur_event.note,
|
||||
bkp_cut_recur_event.day, bkp_cut_recur_event.id,
|
||||
bkp_cut_recur_event.rpt->type,
|
||||
@ -1222,11 +1222,11 @@ recur_apoint_paste_item (void)
|
||||
if (bkp_cut_recur_apoint.exc)
|
||||
{
|
||||
struct days *exc;
|
||||
|
||||
|
||||
for (exc = bkp_cut_recur_apoint.exc; exc != 0; exc = exc->next)
|
||||
exc->st += time_shift;
|
||||
}
|
||||
|
||||
|
||||
(void)recur_apoint_new (bkp_cut_recur_apoint.mesg, bkp_cut_recur_apoint.note,
|
||||
bkp_cut_recur_apoint.start, bkp_cut_recur_apoint.dur,
|
||||
bkp_cut_recur_apoint.state,
|
||||
|
@ -43,7 +43,7 @@
|
||||
|
||||
#include "calcurse.h"
|
||||
|
||||
/*
|
||||
/*
|
||||
* General signal handling routine.
|
||||
* Catch return values from children (user-defined notification commands).
|
||||
* This is needed to avoid zombie processes running on system.
|
||||
@ -56,7 +56,7 @@ generic_hdlr (int sig)
|
||||
{
|
||||
case SIGCHLD:
|
||||
while (waitpid (WAIT_MYPGRP, NULL, WNOHANG) > 0)
|
||||
;
|
||||
;
|
||||
break;
|
||||
case SIGWINCH:
|
||||
clearok (curscr, TRUE);
|
||||
@ -98,7 +98,7 @@ sigs_init ()
|
||||
{
|
||||
if (!sigs_set_hdlr (SIGCHLD, generic_hdlr)
|
||||
|| !sigs_set_hdlr (SIGWINCH, generic_hdlr)
|
||||
|| !sigs_set_hdlr (SIGTERM, generic_hdlr)
|
||||
|| !sigs_set_hdlr (SIGTERM, generic_hdlr)
|
||||
|| !sigs_set_hdlr (SIGINT, SIG_IGN))
|
||||
exit_calcurse (1);
|
||||
}
|
||||
|
104
src/todo.c
104
src/todo.c
@ -120,9 +120,9 @@ todo_first_decrease (void)
|
||||
first--;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Return the position of the hilghlighted item, relative to the first one
|
||||
* displayed.
|
||||
* displayed.
|
||||
*/
|
||||
int
|
||||
todo_hilt_pos (void)
|
||||
@ -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++;
|
||||
}
|
||||
@ -167,7 +167,7 @@ todo_add (char *mesg, int id, char *note)
|
||||
{
|
||||
struct todo *o, **i;
|
||||
int absid;
|
||||
|
||||
|
||||
o = mem_malloc (sizeof (struct todo));
|
||||
o->mesg = mem_strdup (mesg);
|
||||
o->id = id;
|
||||
@ -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);
|
||||
@ -327,7 +327,7 @@ todo_delete (struct conf *conf)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Returns the position into the linked list corresponding to the
|
||||
* given todo item.
|
||||
*/
|
||||
@ -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;
|
||||
@ -421,7 +421,7 @@ display_todo_item (int incolor, char *msg, int prio, int note, int len, int y,
|
||||
snprintf (priostr, sizeof priostr, "%d", prio);
|
||||
else
|
||||
snprintf (priostr, sizeof priostr, "X");
|
||||
|
||||
|
||||
if (incolor == 0)
|
||||
custom_apply_attr (w, ATTR_HIGHEST);
|
||||
if (strlen (msg) < len)
|
||||
@ -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);
|
||||
|
60
src/utils.c
60
src/utils.c
@ -52,7 +52,7 @@ void
|
||||
exit_calcurse (int status)
|
||||
{
|
||||
int was_interactive;
|
||||
|
||||
|
||||
if (ui_mode == UI_CURSES)
|
||||
{
|
||||
notify_stop_main_thread ();
|
||||
@ -64,7 +64,7 @@ exit_calcurse (int status)
|
||||
}
|
||||
else
|
||||
was_interactive = 0;
|
||||
|
||||
|
||||
calendar_stop_date_thread ();
|
||||
io_stop_psave_thread ();
|
||||
free_user_data ();
|
||||
@ -78,7 +78,7 @@ exit_calcurse (int status)
|
||||
if (dmon.enable)
|
||||
dmon_start (status);
|
||||
}
|
||||
|
||||
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ fatalbox (const char *errmsg)
|
||||
|
||||
if (errmsg == 0)
|
||||
return;
|
||||
|
||||
|
||||
(void)strncpy (msg, errmsg, MSGLEN);
|
||||
errwin = newwin (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
|
||||
custom_apply_attr (errwin, ATTR_HIGHEST);
|
||||
@ -132,14 +132,14 @@ warnbox (const char *msg)
|
||||
{
|
||||
WINDOW *warnwin;
|
||||
char *label = "/!\\";
|
||||
const int WINROW = 10;
|
||||
const int WINROW = 10;
|
||||
const int WINCOL = col - 2;
|
||||
const int MSGLEN = WINCOL - 2;
|
||||
char displmsg[MSGLEN];
|
||||
|
||||
if (msg == 0)
|
||||
return;
|
||||
|
||||
|
||||
(void)strncpy (displmsg, msg, MSGLEN);
|
||||
warnwin = newwin (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
|
||||
custom_apply_attr (warnwin, ATTR_HIGHEST);
|
||||
@ -153,7 +153,7 @@ warnbox (const char *msg)
|
||||
wins_doupdate ();
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Print a message in the status bar.
|
||||
* Message texts for first line and second line are to be provided.
|
||||
*/
|
||||
@ -204,7 +204,7 @@ popup (int pop_row, int pop_col, int pop_y, int pop_x, char *title, char *msg,
|
||||
any_key);
|
||||
custom_remove_attr (popup_win, ATTR_HIGHEST);
|
||||
wins_wrefresh (popup_win);
|
||||
|
||||
|
||||
return popup_win;
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ bell (void)
|
||||
printf ("\a");
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Getstring allows to get user input and to print it on a window,
|
||||
* even if noecho() is on. This function is also used to modify an existing
|
||||
* text (the variable string can be non-NULL).
|
||||
@ -319,7 +319,7 @@ getstring (WINDOW *win, char *str, int l, int x, int y)
|
||||
del_char (curpos, str);
|
||||
len--;
|
||||
}
|
||||
else bell ();
|
||||
else bell ();
|
||||
break;
|
||||
case CTRL ('W'): /* delete a word */
|
||||
if (curpos > 0) {
|
||||
@ -377,7 +377,7 @@ updatestring (WINDOW *win, char **str, int x, int y)
|
||||
enum getstr ret;
|
||||
|
||||
EXIT_IF (len + 1 > BUFSIZ, _("Internal error: line too long"));
|
||||
|
||||
|
||||
buf = mem_malloc (BUFSIZ);
|
||||
(void)memcpy (buf, *str, len + 1);
|
||||
|
||||
@ -470,7 +470,7 @@ date_sec2date_fmt (long sec, const char *fmt, char *datef)
|
||||
strftime (datef, BUFSIZ, fmt, lt);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Used to change date by adding a certain amount of days or weeks.
|
||||
*/
|
||||
long
|
||||
@ -478,7 +478,7 @@ date_sec_change (long date, int delta_month, int delta_day)
|
||||
{
|
||||
struct tm *lt;
|
||||
time_t t;
|
||||
|
||||
|
||||
t = date;
|
||||
lt = localtime (&t);
|
||||
lt->tm_mon += delta_month;
|
||||
@ -490,7 +490,7 @@ date_sec_change (long date, int delta_month, int delta_day)
|
||||
return t;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Return a long containing the date which is updated taking into account
|
||||
* the new time and date entered by the user.
|
||||
*/
|
||||
@ -510,7 +510,7 @@ update_time_in_date (long date, unsigned hr, unsigned mn)
|
||||
return (new_date);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Returns the date in seconds from year 1900.
|
||||
* If no date is entered, current date is chosen.
|
||||
*/
|
||||
@ -545,11 +545,11 @@ min2sec (unsigned minutes)
|
||||
return (minutes * MININSEC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if a time has a good format.
|
||||
/*
|
||||
* Checks if a time has a good format.
|
||||
* The format could be either HH:MM or H:MM or MM, and we should have:
|
||||
* 0 <= HH <= 24 and 0 <= MM < 999.
|
||||
* This function returns 1 if the entered time is correct and in
|
||||
* This function returns 1 if the entered time is correct and in
|
||||
* [h:mm] or [hh:mm] format, and 2 if the entered time is correct and entered
|
||||
* in [mm] format.
|
||||
*/
|
||||
@ -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)
|
||||
@ -592,13 +592,13 @@ draw_scrollbar (WINDOW *win, int y, int x, int length,
|
||||
}
|
||||
|
||||
/*
|
||||
* Print an item (either an appointment, event, or todo) in a
|
||||
* popup window. This is useful if an item description is too
|
||||
* Print an item (either an appointment, event, or todo) in a
|
||||
* popup window. This is useful if an item description is too
|
||||
* long to fit in its corresponding panel window.
|
||||
*/
|
||||
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);
|
||||
@ -650,7 +650,7 @@ now (void)
|
||||
char *
|
||||
nowstr (void)
|
||||
{
|
||||
static char buf[BUFSIZ];
|
||||
static char buf[BUFSIZ];
|
||||
time_t t = now ();
|
||||
|
||||
(void)strftime (buf, sizeof buf, "%a %b %d %T %Y", localtime (&t));
|
||||
@ -701,9 +701,9 @@ print_bool_option_incolor (WINDOW *win, unsigned option, int pos_y, int pos_x)
|
||||
wins_doupdate ();
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Create a new unique file, and return a newly allocated string which contains
|
||||
* the random part of the file name.
|
||||
* the random part of the file name.
|
||||
*/
|
||||
char *
|
||||
new_tempfile (const char *prefix, int trailing_len)
|
||||
@ -724,10 +724,10 @@ new_tempfile (const char *prefix, int trailing_len)
|
||||
if ((fd = mkstemp (fullname)) == -1 || (file = fdopen (fd, "w+")) == NULL)
|
||||
{
|
||||
if (fd != -1)
|
||||
{
|
||||
unlink (fullname);
|
||||
close (fd);
|
||||
}
|
||||
{
|
||||
unlink (fullname);
|
||||
close (fd);
|
||||
}
|
||||
ERROR_MSG (_("temporary file \"%s\" could not be created"), fullname);
|
||||
return (char *)0;
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ char *daynames[8] = {
|
||||
N_("Sun")
|
||||
};
|
||||
|
||||
/*
|
||||
/*
|
||||
* variables to store data path names, which are initialized in
|
||||
* io_init()
|
||||
* io_init()
|
||||
*/
|
||||
char path_dir[] = "";
|
||||
char path_todo[] = "";
|
||||
@ -108,7 +108,7 @@ struct nbar nbar;
|
||||
struct dmon_conf dmon;
|
||||
|
||||
/*
|
||||
* Variables init
|
||||
* Variables init
|
||||
*/
|
||||
void
|
||||
vars_init (struct conf *conf)
|
||||
|
44
src/wins.c
44
src/wins.c
@ -82,7 +82,7 @@ int
|
||||
wins_refresh (void)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
if (!screen_acquire ())
|
||||
return ERR;
|
||||
rc = refresh ();
|
||||
@ -95,7 +95,7 @@ int
|
||||
wins_wrefresh (WINDOW *win)
|
||||
{
|
||||
int rc;
|
||||
|
||||
|
||||
if (!win || !screen_acquire ())
|
||||
return ERR;
|
||||
rc = wrefresh (win);
|
||||
@ -148,7 +148,7 @@ wins_sbar_wperc (void)
|
||||
unsigned perc;
|
||||
|
||||
perc = col ? (unsigned)(100 * sbarwidth / col + 1): 0;
|
||||
|
||||
|
||||
return perc > SBARMAXWIDTHPERC ? SBARMAXWIDTHPERC : perc;
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ static void
|
||||
wins_init_panels (void)
|
||||
{
|
||||
char label[BUFSIZ];
|
||||
|
||||
|
||||
win[CAL].p = newwin (CALHEIGHT, wins_sbar_width (), win[CAL].y, win[CAL].x);
|
||||
(void)snprintf (label, BUFSIZ, _("Calendar"));
|
||||
wins_show (win[CAL].p, label);
|
||||
@ -240,7 +240,7 @@ wins_init_panels (void)
|
||||
(void)snprintf (label, BUFSIZ, _("ToDo"));
|
||||
wins_show (win[TOD].p, label);
|
||||
|
||||
/* Enable function keys (i.e. arrow keys) in those windows */
|
||||
/* Enable function keys (i.e. arrow keys) in those windows */
|
||||
keypad (win[CAL].p, TRUE);
|
||||
keypad (win[APP].p, TRUE);
|
||||
keypad (win[TOD].p, TRUE);
|
||||
@ -259,7 +259,7 @@ wins_init (void)
|
||||
ui_mode = UI_CURSES;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Create a new window and its associated pad, which is used to make the
|
||||
* scrolling faster.
|
||||
*/
|
||||
@ -287,7 +287,7 @@ void
|
||||
wins_scrollwin_display (struct scrollwin *sw)
|
||||
{
|
||||
const int visible_lines = sw->win.h - sw->pad.y - 1;
|
||||
|
||||
|
||||
if (sw->total_lines > visible_lines)
|
||||
{
|
||||
float ratio = ((float) visible_lines) / ((float) sw->total_lines);
|
||||
@ -333,7 +333,7 @@ wins_reinit_panels (void)
|
||||
wins_init_panels ();
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Delete the existing windows and recreate them with their new
|
||||
* size and placement.
|
||||
*/
|
||||
@ -368,7 +368,7 @@ wins_show (WINDOW *win, char *label)
|
||||
print_in_middle (win, 1, 0, width, label);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Get the screen size and recalculate the windows configurations.
|
||||
*/
|
||||
void
|
||||
@ -400,7 +400,7 @@ wins_get_config (void)
|
||||
|
||||
win[CAL].w = wins_sbar_width ();
|
||||
win[CAL].h = CALHEIGHT;
|
||||
|
||||
|
||||
if (layout <= 4)
|
||||
{ /* APPOINTMENT is the biggest panel */
|
||||
win[APP].w = col - win[CAL].w;
|
||||
@ -575,7 +575,7 @@ wins_update_panels (void)
|
||||
calendar_update_panel (&win[CAL]);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Update all of the three windows and put a border around the
|
||||
* selected window.
|
||||
*/
|
||||
@ -613,7 +613,7 @@ wins_launch_external (const char *file, const char *cmd)
|
||||
int len;
|
||||
|
||||
/* Beware of space between cmd and file. */
|
||||
len = strlen (file) + strlen (cmd) + 2;
|
||||
len = strlen (file) + strlen (cmd) + 2;
|
||||
|
||||
p = (char *) mem_calloc (len, sizeof (char));
|
||||
if (snprintf (p, len, "%s %s", cmd, file) == -1)
|
||||
@ -643,12 +643,12 @@ wins_launch_external (const char *file, const char *cmd)
|
||||
#define NB_APP_CMDS 31 /* same thing while in appointment view */
|
||||
#define NB_TOD_CMDS 30 /* same thing while in todo view */
|
||||
#define TOTAL_CMDS NB_CAL_CMDS + NB_APP_CMDS + NB_TOD_CMDS
|
||||
#define CMDS_PER_LINE 6 /* max number of commands per line */
|
||||
#define CMDS_PER_LINE 6 /* max number of commands per line */
|
||||
|
||||
static unsigned status_page;
|
||||
|
||||
/*
|
||||
* Draws the status bar.
|
||||
/*
|
||||
* Draws the status bar.
|
||||
* To add a keybinding, insert a new binding_t item, add it in the *binding
|
||||
* table, and update the NB_CAL_CMDS, NB_APP_CMDS or NB_TOD_CMDS defines,
|
||||
* depending on which panel the added keybind is assigned to.
|
||||
@ -666,13 +666,13 @@ wins_status_bar (void)
|
||||
struct binding quit = {_("Quit"), KEY_GENERIC_QUIT};
|
||||
struct binding save = {_("Save"), KEY_GENERIC_SAVE};
|
||||
struct binding cut = {_("Cut"), KEY_GENERIC_CUT};
|
||||
struct binding paste = {_("Paste"), KEY_GENERIC_PASTE};
|
||||
struct binding paste = {_("Paste"), KEY_GENERIC_PASTE};
|
||||
struct binding chgvu = {_("Chg Win"), KEY_GENERIC_CHANGE_VIEW};
|
||||
struct binding import = {_("Import"), KEY_GENERIC_IMPORT};
|
||||
struct binding import = {_("Import"), KEY_GENERIC_IMPORT};
|
||||
struct binding export = {_("Export"), KEY_GENERIC_EXPORT};
|
||||
struct binding togo = {_("Go to"), KEY_GENERIC_GOTO};
|
||||
struct binding othr = {_("OtherCmd"), KEY_GENERIC_OTHER_CMD};
|
||||
struct binding conf = {_("Config"), KEY_GENERIC_CONFIG_MENU};
|
||||
struct binding conf = {_("Config"), KEY_GENERIC_CONFIG_MENU};
|
||||
struct binding draw = {_("Redraw"), KEY_GENERIC_REDRAW};
|
||||
struct binding appt = {_("Add Appt"), KEY_GENERIC_ADD_APPT};
|
||||
struct binding todo = {_("Add Todo"), KEY_GENERIC_ADD_TODO};
|
||||
@ -684,22 +684,22 @@ wins_status_bar (void)
|
||||
struct binding nview = {_("Nxt View"), KEY_GENERIC_SCROLL_DOWN};
|
||||
struct binding pview = {_("Prv View"), KEY_GENERIC_SCROLL_UP};
|
||||
struct binding up = {_("Up"), KEY_MOVE_UP};
|
||||
struct binding down = {_("Down"), KEY_MOVE_DOWN};
|
||||
struct binding down = {_("Down"), KEY_MOVE_DOWN};
|
||||
struct binding left = {_("Left"), KEY_MOVE_LEFT};
|
||||
struct binding right = {_("Right"), KEY_MOVE_RIGHT};
|
||||
struct binding right = {_("Right"), KEY_MOVE_RIGHT};
|
||||
struct binding weekb = {_("beg Week"), KEY_START_OF_WEEK};
|
||||
struct binding weeke = {_("end Week"), KEY_END_OF_WEEK};
|
||||
struct binding add = {_("Add Item"), KEY_ADD_ITEM};
|
||||
struct binding del = {_("Del Item"), KEY_DEL_ITEM};
|
||||
struct binding edit = {_("Edit Itm"), KEY_EDIT_ITEM};
|
||||
struct binding view = {_("View"), KEY_VIEW_ITEM};
|
||||
struct binding view = {_("View"), KEY_VIEW_ITEM};
|
||||
struct binding flag = {_("Flag Itm"), KEY_FLAG_ITEM};
|
||||
struct binding rept = {_("Repeat"), KEY_REPEAT_ITEM};
|
||||
struct binding enote = {_("EditNote"), KEY_EDIT_NOTE};
|
||||
struct binding vnote = {_("ViewNote"), KEY_VIEW_NOTE};
|
||||
struct binding rprio = {_("Prio.+"), KEY_RAISE_PRIORITY};
|
||||
struct binding lprio = {_("Prio.-"), KEY_LOWER_PRIORITY};
|
||||
|
||||
|
||||
struct binding *binding[TOTAL_CMDS] = {
|
||||
/* calendar keys */
|
||||
&help, &quit, &save, &chgvu, &nview, &pview, &up, &down, &left, &right,
|
||||
|
Loading…
x
Reference in New Issue
Block a user