diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-03-14 19:00:08 +0100 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-03-14 19:03:53 +0100 |
commit | 9c9fd5da15573a702efe5adc054c96a9eb8aa0ce (patch) | |
tree | 47b14650b9dc34e032a9e744651b1b921365d206 | |
parent | 55262a30743095ad4dbc14dc06f4487be11f9bd8 (diff) | |
download | calcurse-9c9fd5da15573a702efe5adc054c96a9eb8aa0ce.tar.gz calcurse-9c9fd5da15573a702efe5adc054c96a9eb8aa0ce.zip |
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>
-rw-r--r-- | src/apoint.c | 310 | ||||
-rw-r--r-- | src/args.c | 520 | ||||
-rw-r--r-- | src/calcurse.c | 544 | ||||
-rw-r--r-- | src/calendar.c | 136 | ||||
-rw-r--r-- | src/custom.c | 794 | ||||
-rw-r--r-- | src/day.c | 544 | ||||
-rw-r--r-- | src/dmon.c | 16 | ||||
-rw-r--r-- | src/event.c | 44 | ||||
-rw-r--r-- | src/help.c | 40 | ||||
-rw-r--r-- | src/io.c | 548 | ||||
-rw-r--r-- | src/keys.c | 42 | ||||
-rw-r--r-- | src/mem.c | 44 | ||||
-rw-r--r-- | src/notify.c | 358 | ||||
-rw-r--r-- | src/recur.c | 400 | ||||
-rw-r--r-- | src/sigs.c | 6 | ||||
-rw-r--r-- | src/todo.c | 104 | ||||
-rw-r--r-- | src/utils.c | 60 | ||||
-rw-r--r-- | src/vars.c | 6 | ||||
-rw-r--r-- | src/wins.c | 44 |
19 files changed, 2280 insertions, 2280 deletions
diff --git a/src/apoint.c b/src/apoint.c index 38b41ae..4b562f7 100644 --- a/src/apoint.c +++ b/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 */ - - 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; - } + /* 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; + } } } @@ -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 @@ -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); + todo_arg (tnum, Nflag, preg); + non_interactive = 1; + } + if (nflag) + { + io_check_file (path_apts, (int *)0); io_load_app (); - next_arg (); - non_interactive = 1; - } - if (dflag || rflag || sflag) - { + next_arg (); + non_interactive = 1; + } + if (dflag || rflag || sflag) + { io_check_file (path_apts, (int *)0); - io_check_file (path_conf, (int *)0); + io_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; - - io_check_file (path_apts, (int *)0); - io_check_file (path_conf, (int *)0); + non_interactive = 1; + } + else if (aflag) + { + struct date day; + + io_check_file (path_apts, (int *)0); + io_check_file (path_conf, (int *)0); vars_init (conf); custom_load_conf (conf, 0); /* To get output date format. */ io_load_app (); - day.dd = day.mm = day.yyyy = 0; - app_found = app_arg (add_line, &day, 0, Nflag, conf, preg); - non_interactive = 1; - } - } + day.dd = day.mm = day.yyyy = 0; + app_found = app_arg (add_line, &day, 0, Nflag, conf, preg); + non_interactive = 1; + } + } else - { - non_interactive = 0; + { + non_interactive = 0; io_init (cfile, datadir); - } + } } if (preg) regfree (preg); - - return non_interactive; + + return non_interactive; } diff --git a/src/calcurse.c b/src/calcurse.c index 3231869..6a90f57 100644 --- a/src/calcurse.c +++ b/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 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 (); - - /* 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) + { + case ERR: + do_update = 0; + 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 (); + + /* 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; - - default: - do_update = 0; - 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; + + 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 (); } } diff --git a/src/calendar.c b/src/calendar.c index aef503e..0e239a8 100644 --- a/src/calendar.c +++ b/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 */ diff --git a/src/custom.c b/src/custom.c index 667e05d..29a6261 100644 --- a/src/custom.c +++ b/src/custom.c @@ -87,8 +87,8 @@ fill_config_var (char *string) } } -/* - * Load user color theme from file. +/* + * Load user color theme from file. * Need to handle calcurse versions prior to 1.8, where colors where handled * differently (number between 1 and 8). */ @@ -106,37 +106,37 @@ custom_load_color (char *color, int background) { /* New version configuration */ if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS) - { + { EXIT (_("missing colors in config file")); - /* NOTREACHED */ - } + /* NOTREACHED */ + } for (i = 0; i < AWAITED_COLORS; i++) - { - if (!strncmp (c[i], "black", 5)) - colr[i] = COLOR_BLACK; - else if (!strncmp (c[i], "red", 3)) - colr[i] = COLOR_RED; - else if (!strncmp (c[i], "green", 5)) - colr[i] = COLOR_GREEN; - else if (!strncmp (c[i], "yellow", 6)) - colr[i] = COLOR_YELLOW; - else if (!strncmp (c[i], "blue", 4)) - colr[i] = COLOR_BLUE; - else if (!strncmp (c[i], "magenta", 7)) - colr[i] = COLOR_MAGENTA; - else if (!strncmp (c[i], "cyan", 4)) - colr[i] = COLOR_CYAN; - else if (!strncmp (c[i], "white", 5)) - colr[i] = COLOR_WHITE; - else if (!strncmp (c[i], "default", 7)) - colr[i] = background; - else - { + { + if (!strncmp (c[i], "black", 5)) + colr[i] = COLOR_BLACK; + else if (!strncmp (c[i], "red", 3)) + colr[i] = COLOR_RED; + else if (!strncmp (c[i], "green", 5)) + colr[i] = COLOR_GREEN; + else if (!strncmp (c[i], "yellow", 6)) + colr[i] = COLOR_YELLOW; + else if (!strncmp (c[i], "blue", 4)) + colr[i] = COLOR_BLUE; + else if (!strncmp (c[i], "magenta", 7)) + colr[i] = COLOR_MAGENTA; + else if (!strncmp (c[i], "cyan", 4)) + colr[i] = COLOR_CYAN; + else if (!strncmp (c[i], "white", 5)) + colr[i] = COLOR_WHITE; + else if (!strncmp (c[i], "default", 7)) + colr[i] = background; + else + { EXIT (_("wrong color name")); - /* NOTREACHED */ - } - } + /* NOTREACHED */ + } + } init_pair (COLR_CUSTOM, colr[0], colr[1]); } else if (len > 0 && len < 2) @@ -145,38 +145,38 @@ custom_load_color (char *color, int background) color_num = atoi (color); switch (color_num) - { - case 0: - colorize = 0; - break; - case 1: - init_pair (COLR_CUSTOM, COLOR_RED, background); - break; - case 2: - init_pair (COLR_CUSTOM, COLOR_GREEN, background); - break; - case 3: - init_pair (COLR_CUSTOM, COLOR_BLUE, background); - break; - case 4: - init_pair (COLR_CUSTOM, COLOR_CYAN, background); - break; - case 5: - init_pair (COLR_CUSTOM, COLOR_YELLOW, background); - break; - case 6: - init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_GREEN); - break; - case 7: - init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_YELLOW); - break; - case 8: - init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE); - break; - default: + { + case 0: + colorize = 0; + break; + case 1: + init_pair (COLR_CUSTOM, COLOR_RED, background); + break; + case 2: + init_pair (COLR_CUSTOM, COLOR_GREEN, background); + break; + case 3: + init_pair (COLR_CUSTOM, COLOR_BLUE, background); + break; + case 4: + init_pair (COLR_CUSTOM, COLOR_CYAN, background); + break; + case 5: + init_pair (COLR_CUSTOM, COLOR_YELLOW, background); + break; + case 6: + init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_GREEN); + break; + case 7: + init_pair (COLR_CUSTOM, COLOR_BLACK, COLR_YELLOW); + break; + case 8: + init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE); + break; + default: EXIT (_("wrong color number")); - /* NOTREACHED */ - } + /* NOTREACHED */ + } } else { @@ -185,7 +185,7 @@ custom_load_color (char *color, int background) } } -/* +/* * Define window attributes (for both color and non-color terminals): * ATTR_HIGHEST are for window titles * ATTR_HIGH are for month and days names @@ -256,144 +256,144 @@ custom_load_conf (struct conf *conf, int background) for (;;) { if (fgets (buf, sizeof buf, data_file) == NULL) - { - break; - } + { + break; + } io_extract_data (e_conf, buf, sizeof buf); switch (var) - { - case CUSTOM_CONF_NOVARIABLE: - break; - case CUSTOM_CONF_AUTOSAVE: - conf->auto_save = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_PERIODICSAVE: - conf->periodic_save = atoi (e_conf); - if (conf->periodic_save < 0) - conf->periodic_save = 0; - var = 0; - break; - case CUSTOM_CONF_CONFIRMQUIT: - conf->confirm_quit = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_CONFIRMDELETE: - conf->confirm_delete = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_SKIPSYSTEMDIALOGS: - conf->skip_system_dialogs = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_SKIPPROGRESSBAR: - conf->skip_progress_bar = fill_config_var (e_conf); - var = 0; - break; + { + case CUSTOM_CONF_NOVARIABLE: + break; + case CUSTOM_CONF_AUTOSAVE: + conf->auto_save = fill_config_var (e_conf); + var = 0; + break; + case CUSTOM_CONF_PERIODICSAVE: + conf->periodic_save = atoi (e_conf); + if (conf->periodic_save < 0) + conf->periodic_save = 0; + var = 0; + break; + case CUSTOM_CONF_CONFIRMQUIT: + conf->confirm_quit = fill_config_var (e_conf); + var = 0; + break; + case CUSTOM_CONF_CONFIRMDELETE: + conf->confirm_delete = fill_config_var (e_conf); + var = 0; + break; + case CUSTOM_CONF_SKIPSYSTEMDIALOGS: + conf->skip_system_dialogs = fill_config_var (e_conf); + var = 0; + break; + case CUSTOM_CONF_SKIPPROGRESSBAR: + conf->skip_progress_bar = fill_config_var (e_conf); + var = 0; + break; case CUSTOM_CONF_CALENDAR_DEFAULTVIEW: calendar_set_view (atoi (e_conf)); var = 0; break; - case CUSTOM_CONF_WEEKBEGINSONMONDAY: - if (fill_config_var (e_conf)) - calendar_set_first_day_of_week (MONDAY); - else - calendar_set_first_day_of_week (SUNDAY); - var = 0; - break; - case CUSTOM_CONF_COLORTHEME: - custom_load_color (e_conf, background); - var = 0; - break; - case CUSTOM_CONF_LAYOUT: - wins_set_layout (atoi (e_conf)); - var = 0; - break; + case CUSTOM_CONF_WEEKBEGINSONMONDAY: + if (fill_config_var (e_conf)) + calendar_set_first_day_of_week (MONDAY); + else + calendar_set_first_day_of_week (SUNDAY); + var = 0; + break; + case CUSTOM_CONF_COLORTHEME: + custom_load_color (e_conf, background); + var = 0; + break; + case CUSTOM_CONF_LAYOUT: + wins_set_layout (atoi (e_conf)); + var = 0; + break; case CUSTOM_CONF_SBAR_WIDTH: wins_set_sbar_width (atoi (e_conf)); var = 0; break; - case CUSTOM_CONF_NOTIFYBARSHOW: - nbar.show = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARDATE: - (void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARCLOCK: - (void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARWARNING: - nbar.cntdwn = atoi (e_conf); - var = 0; - break; - case CUSTOM_CONF_NOTIFYBARCOMMAND: - (void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1); - var = 0; - break; - case CUSTOM_CONF_OUTPUTDATEFMT: - if (e_conf[0] != '\0') - (void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1); - var = 0; - break; - case CUSTOM_CONF_INPUTDATEFMT: - conf->input_datefmt = atoi (e_conf); - if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS) - conf->input_datefmt = 1; - var = 0; - break; - case CUSTOM_CONF_DMON_ENABLE: - dmon.enable = fill_config_var (e_conf); - var = 0; - break; - case CUSTOM_CONF_DMON_LOG: - dmon.log = fill_config_var (e_conf); - var = 0; - break; - default: + case CUSTOM_CONF_NOTIFYBARSHOW: + nbar.show = fill_config_var (e_conf); + var = 0; + break; + case CUSTOM_CONF_NOTIFYBARDATE: + (void)strncpy (nbar.datefmt, e_conf, strlen (e_conf) + 1); + var = 0; + break; + case CUSTOM_CONF_NOTIFYBARCLOCK: + (void)strncpy (nbar.timefmt, e_conf, strlen (e_conf) + 1); + var = 0; + break; + case CUSTOM_CONF_NOTIFYBARWARNING: + nbar.cntdwn = atoi (e_conf); + var = 0; + break; + case CUSTOM_CONF_NOTIFYBARCOMMAND: + (void)strncpy (nbar.cmd, e_conf, strlen (e_conf) + 1); + var = 0; + break; + case CUSTOM_CONF_OUTPUTDATEFMT: + if (e_conf[0] != '\0') + (void)strncpy (conf->output_datefmt, e_conf, strlen (e_conf) + 1); + var = 0; + break; + case CUSTOM_CONF_INPUTDATEFMT: + conf->input_datefmt = atoi (e_conf); + if (conf->input_datefmt <= 0 || conf->input_datefmt >= DATE_FORMATS) + conf->input_datefmt = 1; + var = 0; + break; + case CUSTOM_CONF_DMON_ENABLE: + dmon.enable = fill_config_var (e_conf); + var = 0; + break; + case CUSTOM_CONF_DMON_LOG: + dmon.log = fill_config_var (e_conf); + var = 0; + break; + default: EXIT (_("configuration variable unknown")); - /* NOTREACHED */ - } + /* NOTREACHED */ + } if (strncmp (e_conf, "auto_save=", 10) == 0) - var = CUSTOM_CONF_AUTOSAVE; + var = CUSTOM_CONF_AUTOSAVE; else if (strncmp (e_conf, "periodic_save=", 14) == 0) var = CUSTOM_CONF_PERIODICSAVE; else if (strncmp (e_conf, "confirm_quit=", 13) == 0) - var = CUSTOM_CONF_CONFIRMQUIT; + var = CUSTOM_CONF_CONFIRMQUIT; else if (strncmp (e_conf, "confirm_delete=", 15) == 0) - var = CUSTOM_CONF_CONFIRMDELETE; + var = CUSTOM_CONF_CONFIRMDELETE; else if (strncmp (e_conf, "skip_system_dialogs=", 20) == 0) - var = CUSTOM_CONF_SKIPSYSTEMDIALOGS; + var = CUSTOM_CONF_SKIPSYSTEMDIALOGS; else if (strncmp (e_conf, "skip_progress_bar=", 18) == 0) - var = CUSTOM_CONF_SKIPPROGRESSBAR; + var = CUSTOM_CONF_SKIPPROGRESSBAR; else if (strncmp (e_conf, "calendar_default_view=", 22) == 0) var = CUSTOM_CONF_CALENDAR_DEFAULTVIEW; else if (strncmp (e_conf, "week_begins_on_monday=", 22) == 0) - var = CUSTOM_CONF_WEEKBEGINSONMONDAY; + var = CUSTOM_CONF_WEEKBEGINSONMONDAY; else if (strncmp (e_conf, "color-theme=", 12) == 0) - var = CUSTOM_CONF_COLORTHEME; + var = CUSTOM_CONF_COLORTHEME; else if (strncmp (e_conf, "layout=", 7) == 0) - var = CUSTOM_CONF_LAYOUT; + var = CUSTOM_CONF_LAYOUT; else if (strncmp (e_conf, "side-bar_width=", 15) == 0) var = CUSTOM_CONF_SBAR_WIDTH; else if (strncmp (e_conf, "notify-bar_show=", 16) == 0) - var = CUSTOM_CONF_NOTIFYBARSHOW; + var = CUSTOM_CONF_NOTIFYBARSHOW; else if (strncmp (e_conf, "notify-bar_date=", 16) == 0) - var = CUSTOM_CONF_NOTIFYBARDATE; + var = CUSTOM_CONF_NOTIFYBARDATE; else if (strncmp (e_conf, "notify-bar_clock=", 17) == 0) - var = CUSTOM_CONF_NOTIFYBARCLOCK; + var = CUSTOM_CONF_NOTIFYBARCLOCK; else if (strncmp (e_conf, "notify-bar_warning=", 19) == 0) - var = CUSTOM_CONF_NOTIFYBARWARNING; + var = CUSTOM_CONF_NOTIFYBARWARNING; else if (strncmp (e_conf, "notify-bar_command=", 19) == 0) - var = CUSTOM_CONF_NOTIFYBARCOMMAND; + var = CUSTOM_CONF_NOTIFYBARCOMMAND; else if (strncmp (e_conf, "output_datefmt=", 15) == 0) - var = CUSTOM_CONF_OUTPUTDATEFMT; + var = CUSTOM_CONF_OUTPUTDATEFMT; else if (strncmp (e_conf, "input_datefmt=", 14) == 0) - var = CUSTOM_CONF_INPUTDATEFMT; + var = CUSTOM_CONF_INPUTDATEFMT; else if (strncmp (e_conf, "notify-daemon_enable=", 21) == 0) var = CUSTOM_CONF_DMON_ENABLE; else if (strncmp (e_conf, "notify-daemon_log=", 18) == 0) @@ -417,17 +417,17 @@ custom_config_bar (void) mvwprintw (win[STA].p, 1, 2 + SPC, "S"); mvwprintw (win[STA].p, 0, 2 + 2 * SPC, "C"); mvwprintw (win[STA].p, 1, 2 + 2 * SPC, "N"); - mvwprintw (win[STA].p, 0, 2 + 3 * SPC, "K"); + mvwprintw (win[STA].p, 0, 2 + 3 * SPC, "K"); custom_remove_attr (win[STA].p, ATTR_HIGHEST); mvwprintw (win[STA].p, 0, 2 + SMLSPC, _("Exit")); mvwprintw (win[STA].p, 1, 2 + SMLSPC, _("General")); mvwprintw (win[STA].p, 0, 2 + SPC + SMLSPC, _("Layout")); mvwprintw (win[STA].p, 1, 2 + SPC + SMLSPC, _("Sidebar")); - mvwprintw (win[STA].p, 0, 2 + 2 * SPC + SMLSPC, _("Color")); + mvwprintw (win[STA].p, 0, 2 + 2 * SPC + SMLSPC, _("Color")); mvwprintw (win[STA].p, 1, 2 + 2 * SPC + SMLSPC, _("Notify")); mvwprintw (win[STA].p, 0, 2 + 3 * SPC + SMLSPC, _("Keys")); - + wnoutrefresh (win[STA].p); wmove (win[STA].p, 0, 0); wins_doupdate (); @@ -443,7 +443,7 @@ layout_selection_bar (void) struct binding left = {_("Left"), KEY_MOVE_LEFT}; struct binding right = {_("Right"), KEY_MOVE_RIGHT}; struct binding help = {_("Help"), KEY_GENERIC_HELP}; - + struct binding *binding[] = {&quit, &select, &up, &down, &left, &right, &help}; int binding_size = sizeof (binding) / sizeof (binding[0]); @@ -463,13 +463,13 @@ display_layout_config (struct window *lwin, int mark, int cursor, #define LAYOUTH 5 #define LAYOUTW 9 char *box = "[ ]"; - const int BOXSIZ = strlen (box); + const int BOXSIZ = strlen (box); const int NBCOLS = NBLAYOUTS / LAYOUTSPERCOL; const int COLSIZ = LAYOUTW + BOXSIZ + 1; const int XSPC = (col - NBCOLS * COLSIZ) / (NBCOLS + 1); const int XOFST = (col - NBCOLS * (XSPC + COLSIZ)) / 2; const int YSPC = (row - 8 - LAYOUTSPERCOL * LAYOUTH) / (LAYOUTSPERCOL + 1); - const int YOFST = (row - LAYOUTSPERCOL * (YSPC + LAYOUTH)) / 2; + const int YOFST = (row - LAYOUTSPERCOL * (YSPC + LAYOUTH)) / 2; enum {YPOS, XPOS, NBPOS}; int pos[NBLAYOUTS][NBPOS]; char *layouts[LAYOUTH][NBLAYOUTS] = { @@ -490,7 +490,7 @@ display_layout_config (struct window *lwin, int mark, int cursor, if (need_reset) { char label[BUFSIZ]; - + (void)snprintf (label, BUFSIZ, _("layout configuration")); custom_confwin_init (lwin, label); } @@ -498,7 +498,7 @@ display_layout_config (struct window *lwin, int mark, int cursor, for (i = 0; i < NBLAYOUTS; i++) { int j; - + mvwprintw (lwin->p, pos[i][YPOS] + 2, pos[i][XPOS], box); if (i == mark) custom_apply_attr (lwin->p, ATTR_HIGHEST); @@ -512,7 +512,7 @@ display_layout_config (struct window *lwin, int mark, int cursor, } mvwaddch (lwin->p, pos[mark][YPOS] + 2, pos[mark][XPOS] + 1, MARK); mvwaddch (lwin->p, pos[cursor][YPOS] + 2, pos[cursor][XPOS] + 1, CURSOR); - + layout_selection_bar (); wnoutrefresh (win[STA].p); wnoutrefresh (lwin->p); @@ -533,13 +533,13 @@ custom_layout_config (void) "displayed inside calcurse screen. \n" "It is possible to choose between eight different configurations.\n" "\nIn the configuration representations, letters correspond to:\n\n" - " 'c' -> calendar panel\n\n" + " 'c' -> calendar panel\n\n" " 'a' -> appointment panel\n\n" " 't' -> todo panel\n\n"); - - need_reset = 1; + + need_reset = 1; conf_win.p = (WINDOW *)0; - cursor = mark = wins_layout () - 1; + cursor = mark = wins_layout () - 1; clear (); display_layout_config (&conf_win, mark, cursor, need_reset); @@ -547,13 +547,13 @@ custom_layout_config (void) { need_reset = 0; switch (ch) - { - case KEY_RESIZE: - endwin (); - wins_refresh (); - curs_set (0); - need_reset = 1; - break; + { + case KEY_RESIZE: + endwin (); + wins_refresh (); + curs_set (0); + need_reset = 1; + break; case KEY_GENERIC_HELP: help_wins_init (&hwin, 0, 0, (notify_bar ()) ? row - 3 : row - 2, col); @@ -564,29 +564,29 @@ custom_layout_config (void) wins_scrollwin_delete (&hwin); need_reset = 1; break; - case KEY_GENERIC_SELECT: + case KEY_GENERIC_SELECT: mark = cursor; - break; - case KEY_MOVE_DOWN: - if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1) - cursor++; - break; - case KEY_MOVE_UP: - if (cursor % LAYOUTSPERCOL > 0) - cursor--; - break; - case KEY_MOVE_LEFT: - if (cursor >= LAYOUTSPERCOL) - cursor -= LAYOUTSPERCOL; - break; - case KEY_MOVE_RIGHT: - if (cursor < NBLAYOUTS - LAYOUTSPERCOL) - cursor += LAYOUTSPERCOL; - break; - case KEY_GENERIC_CANCEL: - need_reset = 1; - break; - } + break; + case KEY_MOVE_DOWN: + if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1) + cursor++; + break; + case KEY_MOVE_UP: + if (cursor % LAYOUTSPERCOL > 0) + cursor--; + break; + case KEY_MOVE_LEFT: + if (cursor >= LAYOUTSPERCOL) + cursor -= LAYOUTSPERCOL; + break; + case KEY_MOVE_RIGHT: + if (cursor < NBLAYOUTS - LAYOUTSPERCOL) + cursor += LAYOUTSPERCOL; + break; + case KEY_GENERIC_CANCEL: + need_reset = 1; + break; + } display_layout_config (&conf_win, mark, cursor, need_reset); } wins_set_layout (mark + 1); @@ -602,7 +602,7 @@ custom_sidebar_config (void) { struct scrollwin hwin; struct binding quit = {_("Exit"), KEY_GENERIC_QUIT}; - struct binding inc = {_("Width +"), KEY_MOVE_UP}; + struct binding inc = {_("Width +"), KEY_MOVE_UP}; struct binding dec = {_("Width -"), KEY_MOVE_DOWN}; struct binding help = {_("Help"), KEY_GENERIC_HELP}; struct binding *binding[] = {&inc, &dec, &help, &quit}; @@ -620,7 +620,7 @@ custom_sidebar_config (void) keys_display_bindings_bar (win[STA].p, binding, 0, binding_size); wins_doupdate (); - while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT) + while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT) { switch (ch) { @@ -658,8 +658,8 @@ set_confwin_attr (struct window *cwin) cwin->x = cwin->y = 0; } -/* - * Create a configuration window and initialize status and notification bar +/* + * Create a configuration window and initialize status and notification bar * (useful in case of window resize). */ void @@ -671,10 +671,10 @@ custom_confwin_init (struct window *confwin, char *label) confwin->x + confwin->w, confwin->y + confwin->h); (void)delwin (confwin->p); } - + wins_get_config (); set_confwin_attr (confwin); - confwin->p = newwin (confwin->h, col, 0, 0); + confwin->p = newwin (confwin->h, col, 0, 0); box (confwin->p, 0, 0); wins_show (confwin->p, label); delwin (win[STA].p); @@ -698,7 +698,7 @@ color_selection_bar (void) struct binding left = {_("Left"), KEY_MOVE_LEFT}; struct binding right = {_("Right"), KEY_MOVE_RIGHT}; - + struct binding *binding[] = { &quit, &nocolor, &up, &down, &left, &right, &select }; @@ -707,13 +707,13 @@ color_selection_bar (void) keys_display_bindings_bar (win[STA].p, binding, 0, binding_size); } -/* +/* * Used to display available colors in color configuration menu. * This is useful for window resizing. */ static void display_color_config (struct window *cwin, int *mark_fore, int *mark_back, - int cursor, int need_reset, int theme_changed) + int cursor, int need_reset, int theme_changed) { #define SIZE (2 * (NBUSERCOLORS + 1)) #define DEFAULTCOLOR 255 @@ -764,34 +764,34 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back, if (colorize) { if (theme_changed) - { - pair_content (colr[*mark_fore], &colr_fore, 0L); - if (colr_fore == 255) - colr_fore = -1; - pair_content (colr[*mark_back], &colr_back, 0L); - if (colr_back == 255) - colr_back = -1; - init_pair (COLR_CUSTOM, colr_fore, colr_back); - } + { + pair_content (colr[*mark_fore], &colr_fore, 0L); + if (colr_fore == 255) + colr_fore = -1; + pair_content (colr[*mark_back], &colr_back, 0L); + if (colr_back == 255) + colr_back = -1; + init_pair (COLR_CUSTOM, colr_fore, colr_back); + } else - { - /* Retrieve the actual color theme. */ - pair_content (COLR_CUSTOM, &colr_fore, &colr_back); - - if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT)) - *mark_fore = NBUSERCOLORS; - else - for (i = 0; i < NBUSERCOLORS + 1; i++) - if (colr_fore == colr[i]) - *mark_fore = i; - - if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT)) - *mark_back = SIZE - 1; - else - for (i = 0; i < NBUSERCOLORS + 1; i++) - if (colr_back == colr[NBUSERCOLORS + 1 + i]) - *mark_back = NBUSERCOLORS + 1 + i; - } + { + /* Retrieve the actual color theme. */ + pair_content (COLR_CUSTOM, &colr_fore, &colr_back); + + if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT)) + *mark_fore = NBUSERCOLORS; + else + for (i = 0; i < NBUSERCOLORS + 1; i++) + if (colr_fore == colr[i]) + *mark_fore = i; + + if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT)) + *mark_back = SIZE - 1; + else + for (i = 0; i < NBUSERCOLORS + 1; i++) + if (colr_back == colr[NBUSERCOLORS + 1 + i]) + *mark_back = NBUSERCOLORS + 1 + i; + } } /* color boxes */ @@ -810,9 +810,9 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back, mvwprintw (cwin->p, pos[i][YPOS], pos[i][XPOS] + XOFST, bar); wattroff (cwin->p, COLOR_PAIR (colr[i])); mvwprintw (cwin->p, pos[NBUSERCOLORS][YPOS] + 1, - pos[NBUSERCOLORS][XPOS] + XOFST, default_txt); + pos[NBUSERCOLORS][XPOS] + XOFST, default_txt); mvwprintw (cwin->p, pos[SIZE - 1][YPOS] + 1, - pos[SIZE - 1][XPOS] + XOFST, default_txt); + pos[SIZE - 1][XPOS] + XOFST, default_txt); custom_apply_attr (cwin->p, ATTR_HIGHEST); mvwprintw (cwin->p, Y, XFORE + XOFST, fore_txt); @@ -822,9 +822,9 @@ display_color_config (struct window *cwin, int *mark_fore, int *mark_back, if (colorize) { mvwaddch (cwin->p, pos[*mark_fore][YPOS], - pos[*mark_fore][XPOS] + 1, MARK); + pos[*mark_fore][XPOS] + 1, MARK); mvwaddch (cwin->p, pos[*mark_back][YPOS], - pos[*mark_back][XPOS] + 1, MARK); + pos[*mark_back][XPOS] + 1, MARK); } mvwaddch (cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR); @@ -853,7 +853,7 @@ custom_color_config (void) conf_win.p = 0; set_confwin_attr (&conf_win); display_color_config (&conf_win, &mark_fore, &mark_back, cursor, - need_reset, theme_changed); + need_reset, theme_changed); while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT) { @@ -861,60 +861,60 @@ custom_color_config (void) theme_changed = 0; switch (ch) - { - case KEY_RESIZE: - endwin (); - wins_refresh (); - curs_set (0); - need_reset = 1; - break; - - case KEY_GENERIC_SELECT: - colorize = 1; - need_reset = 1; - theme_changed = 1; - if (cursor > NBUSERCOLORS) - mark_back = cursor; - else - mark_fore = cursor; - break; - - case KEY_MOVE_DOWN: - if (cursor < SIZE - 1) - ++cursor; - break; - - case KEY_MOVE_UP: - if (cursor > 0) - --cursor; - break; - - case KEY_MOVE_LEFT: - if (cursor > NBUSERCOLORS) - cursor -= (NBUSERCOLORS + 1); - break; - - case KEY_MOVE_RIGHT: - if (cursor <= NBUSERCOLORS) - cursor += (NBUSERCOLORS + 1); - break; - - case KEY_GENERIC_CANCEL: - colorize = 0; - need_reset = 1; - break; - } + { + case KEY_RESIZE: + endwin (); + wins_refresh (); + curs_set (0); + need_reset = 1; + break; + + case KEY_GENERIC_SELECT: + colorize = 1; + need_reset = 1; + theme_changed = 1; + if (cursor > NBUSERCOLORS) + mark_back = cursor; + else + mark_fore = cursor; + break; + + case KEY_MOVE_DOWN: + if (cursor < SIZE - 1) + ++cursor; + break; + + case KEY_MOVE_UP: + if (cursor > 0) + --cursor; + break; + + case KEY_MOVE_LEFT: + if (cursor > NBUSERCOLORS) + cursor -= (NBUSERCOLORS + 1); + break; + + case KEY_MOVE_RIGHT: + if (cursor <= NBUSERCOLORS) + cursor += (NBUSERCOLORS + 1); + break; + + case KEY_GENERIC_CANCEL: + colorize = 0; + need_reset = 1; + break; + } display_color_config (&conf_win, &mark_fore, &mark_back, cursor, - need_reset, theme_changed); + need_reset, theme_changed); } delwin (conf_win.p); } -/* +/* * Return a string defining the color theme in the form: * foreground color 'on' background color * in order to dump this data in the configuration file. - * Color numbers follow the ncurses library definitions. + * Color numbers follow the ncurses library definitions. * If ncurses library was compiled with --enable-ext-funcs, * then default color is -1. */ @@ -947,17 +947,17 @@ custom_color_theme_name (char *theme_name) { pair_content (COLR_CUSTOM, &color[0], &color[1]); for (i = 0; i < NBCOLORS; i++) - { - if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT)) - color_name[i] = default_color; - else if (color[i] >= 0 && color[i] <= MAXCOLORS) - color_name[i] = name[color[i]]; - else - { + { + if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT)) + color_name[i] = default_color; + else if (color[i] >= 0 && color[i] <= MAXCOLORS) + color_name[i] = name[color[i]]; + else + { EXIT (_("unknown color")); - /* NOTREACHED */ - } - } + /* NOTREACHED */ + } + } (void)snprintf (theme_name, BUFSIZ, "%s on %s", color_name[0], color_name[1]); } @@ -984,7 +984,7 @@ print_general_options (WINDOW *win, struct conf *conf) int y; char *opt[NB_OPTIONS] = { _("auto_save = "), - _("periodic_save = "), + _("periodic_save = "), _("confirm_quit = "), _("confirm_delete = "), _("skip_system_dialogs = "), @@ -993,13 +993,13 @@ print_general_options (WINDOW *win, struct conf *conf) _("output_datefmt = "), _("input_datefmt = ") }; - + y = 0; mvwprintw (win, y, XPOS, "[1] %s ", opt[AUTO_SAVE]); print_bool_option_incolor (win, conf->auto_save, y, XPOS + 4 + strlen (opt[AUTO_SAVE])); mvwprintw (win, y + 1, XPOS, - _("(if set to YES, automatic save is done when quitting)")); + _("(if set to YES, automatic save is done when quitting)")); y += YOFF; mvwprintw (win, y, XPOS, "[2] %s ", opt[PERIODIC_SAVE]); custom_apply_attr (win, ATTR_HIGHEST); @@ -1007,41 +1007,41 @@ print_general_options (WINDOW *win, struct conf *conf) conf->periodic_save); custom_remove_attr (win, ATTR_HIGHEST); mvwprintw (win, y + 1, XPOS, - _("(if not null, automatically save data every 'periodic_save' " + _("(if not null, automatically save data every 'periodic_save' " "minutes)")); y += YOFF; mvwprintw (win, y, XPOS, "[3] %s ", opt[CONFIRM_QUIT]); print_bool_option_incolor (win, conf->confirm_quit, y, XPOS + 4 + strlen (opt[CONFIRM_QUIT])); mvwprintw (win, y + 1, XPOS, - _("(if set to YES, confirmation is required before quitting)")); + _("(if set to YES, confirmation is required before quitting)")); y += YOFF; mvwprintw (win, y, XPOS, "[4] %s ", opt[CONFIRM_DELETE]); print_bool_option_incolor (win, conf->confirm_delete, y, XPOS + 4 + strlen (opt[CONFIRM_DELETE])); mvwprintw (win, y + 1, XPOS, - _("(if set to YES, confirmation is required " + _("(if set to YES, confirmation is required " "before deleting an event)")); y += YOFF; mvwprintw (win, y, XPOS, "[5] %s ", opt[SKIP_SYSTEM_DIAGS]); print_bool_option_incolor (win, conf->skip_system_dialogs, y, XPOS + 4 + strlen (opt[SKIP_SYSTEM_DIAGS])); mvwprintw (win, y + 1, XPOS, - _("(if set to YES, messages about loaded " + _("(if set to YES, messages about loaded " "and saved data will not be displayed)")); y += YOFF; mvwprintw (win, y, XPOS, "[6] %s ", opt[SKIP_PROGRESS_BAR]); print_bool_option_incolor (win, conf->skip_progress_bar, y, XPOS + 4 + strlen (opt[SKIP_PROGRESS_BAR])); mvwprintw (win, y + 1, XPOS, - _("(if set to YES, progress bar will not be displayed " + _("(if set to YES, progress bar will not be displayed " "when saving data)")); y += YOFF; mvwprintw (win, y, XPOS, "[7] %s ", opt[WEEK_BEGINS_MONDAY]); print_bool_option_incolor (win, calendar_week_begins_on_monday (), y, XPOS + 4 + strlen (opt[WEEK_BEGINS_MONDAY])); mvwprintw (win, y + 1, XPOS, - _("(if set to YES, monday is the first day of the week, " + _("(if set to YES, monday is the first day of the week, " "else it is sunday)")); y += YOFF; mvwprintw (win, y, XPOS, "[8] %s ", opt[OUTPUT_DATE_FMT]); @@ -1050,7 +1050,7 @@ print_general_options (WINDOW *win, struct conf *conf) conf->output_datefmt); custom_remove_attr (win, ATTR_HIGHEST); mvwprintw (win, y + 1, XPOS, - _("(Format of the date to be displayed in non-interactive mode)")); + _("(Format of the date to be displayed in non-interactive mode)")); y += YOFF; mvwprintw (win, y, XPOS, "[9] %s ", opt[INPUT_DATE_FMT]); custom_apply_attr (win, ATTR_HIGHEST); @@ -1077,7 +1077,7 @@ custom_set_swsiz (struct scrollwin *sw) sw->pad.h = BUFSIZ; sw->pad.w = col - 2 * sw->pad.x - 1; } - + /* General configuration. */ void custom_general_config (struct conf *conf) @@ -1110,86 +1110,86 @@ custom_general_config (struct conf *conf) while ((ch = wgetch (win[STA].p)) != 'q') { buf[0] = '\0'; - + switch (ch) - { - case KEY_RESIZE: + { + case KEY_RESIZE: wins_get_config (); wins_reset (); - wins_scrollwin_delete (&cwin); - wins_scrollwin_init (&cwin); + wins_scrollwin_delete (&cwin); + wins_scrollwin_init (&cwin); custom_set_swsiz (&cwin); wins_show (cwin.win.p, cwin.label); - cwin.first_visible_line = 0; - delwin (win[STA].p); - win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y, - win[STA].x); - keypad (win[STA].p, TRUE); - if (notify_bar ()) - { - notify_reinit_bar (); - notify_update_bar (); - } - break; + cwin.first_visible_line = 0; + delwin (win[STA].p); + win[STA].p = newwin (win[STA].h, win[STA].w, win[STA].y, + win[STA].x); + keypad (win[STA].p, TRUE); + if (notify_bar ()) + { + notify_reinit_bar (); + notify_update_bar (); + } + break; case CTRL ('N'): wins_scrollwin_down (&cwin, 1); - break; + break; case CTRL ('P'): wins_scrollwin_up (&cwin, 1); - break; - case '1': - conf->auto_save = !conf->auto_save; - break; - case '2': - status_mesg (periodic_save_str, ""); - if (updatestring (win[STA].p, &buf, 0, 1) == 0) - { - int val = atoi (buf); - if (val >= 0) - conf->periodic_save = val; + break; + case '1': + conf->auto_save = !conf->auto_save; + break; + case '2': + status_mesg (periodic_save_str, ""); + if (updatestring (win[STA].p, &buf, 0, 1) == 0) + { + int val = atoi (buf); + if (val >= 0) + conf->periodic_save = val; if (conf->periodic_save > 0) io_start_psave_thread (conf); else if (conf->periodic_save == 0) io_stop_psave_thread (); - } - status_mesg (number_str, keys); - break; - case '3': - conf->confirm_quit = !conf->confirm_quit; - break; - case '4': - conf->confirm_delete = !conf->confirm_delete; - break; - case '5': - conf->skip_system_dialogs = !conf->skip_system_dialogs; - break; - case '6': - conf->skip_progress_bar = !conf->skip_progress_bar; - break; - case '7': - calendar_change_first_day_of_week (); - break; - case '8': - status_mesg (output_datefmt_str, ""); - (void)strncpy (buf, conf->output_datefmt, + } + status_mesg (number_str, keys); + break; + case '3': + conf->confirm_quit = !conf->confirm_quit; + break; + case '4': + conf->confirm_delete = !conf->confirm_delete; + break; + case '5': + conf->skip_system_dialogs = !conf->skip_system_dialogs; + break; + case '6': + conf->skip_progress_bar = !conf->skip_progress_bar; + break; + case '7': + calendar_change_first_day_of_week (); + break; + case '8': + status_mesg (output_datefmt_str, ""); + (void)strncpy (buf, conf->output_datefmt, strlen (conf->output_datefmt) + 1); - if (updatestring (win[STA].p, &buf, 0, 1) == 0) - { - (void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1); - } - status_mesg (number_str, keys); - break; - case '9': - status_mesg (input_datefmt_str, ""); - if (updatestring (win[STA].p, &buf, 0, 1) == 0) - { - int val = atoi (buf); - if (val > 0 && val <= DATE_FORMATS) - conf->input_datefmt = val; - } - status_mesg (number_str, keys); - break; - } + if (updatestring (win[STA].p, &buf, 0, 1) == 0) + { + (void)strncpy (conf->output_datefmt, buf, strlen (buf) + 1); + } + status_mesg (number_str, keys); + break; + case '9': + status_mesg (input_datefmt_str, ""); + if (updatestring (win[STA].p, &buf, 0, 1) == 0) + { + int val = atoi (buf); + if (val > 0 && val <= DATE_FORMATS) + conf->input_datefmt = val; + } + status_mesg (number_str, keys); + break; + } status_mesg (number_str, keys); cwin.total_lines = print_general_options (cwin.pad.p, conf); wins_scrollwin_display (&cwin); @@ -1225,14 +1225,14 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff) char actionstr[BUFSIZ]; int nbkeys; - nbkeys = keys_action_count_keys (action); + nbkeys = keys_action_count_keys (action); (void)snprintf (actionstr, BUFSIZ, "%s", keys_get_label (action)); if (action == selected_row) custom_apply_attr (win, ATTR_HIGHEST); mvwprintw (win, y, XPOS, "%s ", actionstr); mvwprintw (win, y, EQUALPOS, "="); if (nbkeys == 0) - mvwprintw (win, y, KEYPOS, _("undefined")); + mvwprintw (win, y, KEYPOS, _("undefined")); if (action == selected_row) custom_remove_attr (win, ATTR_HIGHEST); if (nbkeys > 0) @@ -1241,14 +1241,14 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff) { char *key; int pos; - + pos = KEYPOS; while ((key = keys_action_nkey (action, noelm)) != 0) { if (noelm == selected_elm) print_key_incolor (win, key, y, pos); else - mvwprintw (win, y, pos, "%s ", key); + mvwprintw (win, y, pos, "%s ", key); noelm++; pos += strlen (key) + 1; } @@ -1260,7 +1260,7 @@ print_keys_bindings (WINDOW *win, int selected_row, int selected_elm, int yoff) } y += yoff; } - + return noelm; } @@ -1275,7 +1275,7 @@ custom_keys_config_bar (void) struct binding down = {_("Down"), KEY_MOVE_DOWN}; struct binding left = {_("Prev Key"), KEY_MOVE_LEFT}; struct binding right = {_("Next Key"), KEY_MOVE_RIGHT}; - + struct binding *binding[] = { &quit, &info, &add, &del, &up, &down, &left, &right }; @@ -1294,7 +1294,7 @@ custom_keys_config (void) WINDOW *grabwin; const int LINESPERKEY = 2; const int LABELLINES = 3; - + clear (); custom_set_swsiz (&kwin); nbdisplayed = (kwin.win.h - LABELLINES) / LINESPERKEY; @@ -1314,7 +1314,7 @@ custom_keys_config (void) ch = keys_getch (win[STA].p); switch (ch) - { + { case KEY_MOVE_UP: if (selrow > 0) { @@ -1327,8 +1327,8 @@ custom_keys_config (void) wins_scrollwin_up (&kwin, LINESPERKEY); } } - break; - case KEY_MOVE_DOWN: + break; + case KEY_MOVE_DOWN: if (selrow < NBKEYS - 1) { selrow++; @@ -1340,7 +1340,7 @@ custom_keys_config (void) wins_scrollwin_down (&kwin, LINESPERKEY); } } - break; + break; case KEY_MOVE_LEFT: if (selelm > 0) selelm--; @@ -1383,7 +1383,7 @@ custom_keys_config (void) if (used) { enum key action; - + action = keys_get_action (keyval); WARN_MSG (_("This key is already in use for %s, " "please choose another one."), @@ -1393,10 +1393,10 @@ custom_keys_config (void) LINESPERKEY); wins_scrollwin_display (&kwin); } - delwin (grabwin); + delwin (grabwin); } while (used || not_recognized); - nbrowelm++; + nbrowelm++; if (selelm < nbrowelm - 1) selelm++; #undef WINROW @@ -1414,11 +1414,11 @@ custom_keys_config (void) if (keys_check_missing_bindings () != 0) { WARN_MSG (_("Some actions do not have any associated " - "key bindings!")); + "key bindings!")); } wins_scrollwin_delete (&kwin); return; - } + } custom_keys_config_bar (); werase (kwin.pad.p); nbrowelm = print_keys_bindings (kwin.pad.p, selrow, selelm, LINESPERKEY); @@ -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; - - 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, + { + 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, 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); @@ -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); diff --git a/src/event.c b/src/event.c index 263cd2d..fc527c6 100644 --- a/src/event.c +++ b/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 @@ -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) { @@ -226,16 +226,16 @@ get_export_stream (enum export_type type) status_mesg (question, ""); cancel = updatestring (win[STA].p, &stream_name, 0, 1); if (cancel) - { - mem_free (stream_name); - return (NULL); - } + { + mem_free (stream_name); + return (NULL); + } stream = fopen (stream_name, "w"); if (stream == NULL) - { - status_mesg (wrong_name, press_enter); - (void)wgetch (win[STA].p); - } + { + status_mesg (wrong_name, press_enter); + (void)wgetch (win[STA].p); + } } mem_free (stream_name); @@ -324,7 +324,7 @@ pcal_export_header (FILE *stream) (void)fprintf (stream, "all monday in all %s %%w\n", _("Week")); (void)fprintf (stream, "\n"); } - + /* Export footer. */ static void ical_export_footer (FILE *stream) @@ -354,24 +354,24 @@ ical_export_recur_events (FILE *stream) ical_recur_type[i->rpt->type], i->rpt->freq); if (i->rpt->until != 0) - { - date_sec2date_fmt (i->rpt->until, ICALDATEFMT, ical_date); - (void)fprintf (stream, ";UNTIL=%s\n", ical_date); - } + { + date_sec2date_fmt (i->rpt->until, ICALDATEFMT, ical_date); + (void)fprintf (stream, ";UNTIL=%s\n", ical_date); + } else - (void)fprintf (stream, "\n"); + (void)fprintf (stream, "\n"); if (i->exc != NULL) - { - date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date); - (void)fprintf (stream, "EXDATE:%s", ical_date); - for (day = i->exc->next; day; day = day->next) - { - date_sec2date_fmt (day->st, ICALDATEFMT, ical_date); - (void)fprintf (stream, ",%s", ical_date); - } - (void)fprintf (stream, "\n"); - } + { + date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date); + (void)fprintf (stream, "EXDATE:%s", ical_date); + for (day = i->exc->next; day; day = day->next) + { + date_sec2date_fmt (day->st, ICALDATEFMT, ical_date); + (void)fprintf (stream, ",%s", ical_date); + } + (void)fprintf (stream, "\n"); + } (void)fprintf (stream, "SUMMARY:%s\n", i->mesg); (void)fprintf (stream, "END:VEVENT\n"); @@ -477,13 +477,13 @@ static void pcal_export_events (FILE *stream) { struct event *i; - + (void)fprintf (stream, "\n# ======\n# Events\n# ======\n"); for (i = eventlist; i != 0; i = i->next) pcal_dump_event (stream, i->day, 0, i->mesg); (void)fprintf (stream, "\n"); } - + /* Export recurrent appointments. */ static void ical_export_recur_apoints (FILE *stream) @@ -504,28 +504,28 @@ ical_export_recur_apoints (FILE *stream) ical_recur_type[i->rpt->type], i->rpt->freq); if (i->rpt->until != 0) - { - date_sec2date_fmt (i->rpt->until + HOURINSEC, ICALDATEFMT, ical_date); - (void)fprintf (stream, ";UNTIL=%s\n", ical_date); - } + { + date_sec2date_fmt (i->rpt->until + HOURINSEC, ICALDATEFMT, ical_date); + (void)fprintf (stream, ";UNTIL=%s\n", ical_date); + } else - (void)fprintf (stream, "\n"); + (void)fprintf (stream, "\n"); if (i->exc != NULL) - { - date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date); - (void)fprintf (stream, "EXDATE:%s", ical_date); - for (day = i->exc->next; day; day = day->next) - { - date_sec2date_fmt (day->st, ICALDATEFMT, ical_date); - (void)fprintf (stream, ",%s", ical_date); - } - (void)fprintf (stream, "\n"); - } + { + date_sec2date_fmt (i->exc->st, ICALDATEFMT, ical_date); + (void)fprintf (stream, "EXDATE:%s", ical_date); + for (day = i->exc->next; day; day = day->next) + { + date_sec2date_fmt (day->st, ICALDATEFMT, ical_date); + (void)fprintf (stream, ",%s", ical_date); + } + (void)fprintf (stream, "\n"); + } (void)fprintf (stream, "SUMMARY:%s\n", i->mesg); if (i->state & APOINT_NOTIFY) - ical_export_valarm (stream); + ical_export_valarm (stream); (void)fprintf (stream, "END:VEVENT\n"); } pthread_mutex_unlock (&(recur_alist_p->mutex)); @@ -536,11 +536,11 @@ pcal_export_recur_apoints (FILE *stream) { struct recur_apoint *i; char pcal_date[BUFSIZ], pcal_beg[BUFSIZ], pcal_end[BUFSIZ]; - + (void)fprintf (stream, "\n# =============="); (void)fprintf (stream, "\n# Recur. Apoints"); (void)fprintf (stream, "\n# ==============\n"); - (void)fprintf (stream, + (void)fprintf (stream, "# (pcal does not support from..until dates specification\n"); for (i = recur_alist_p->root; i != 0; i = i->next) @@ -605,7 +605,7 @@ ical_export_apoints (FILE *stream) (void)fprintf (stream, "DURATION:PT0H0M%ldS\n", i->dur); (void)fprintf (stream, "SUMMARY:%s\n", i->mesg); if (i->state & APOINT_NOTIFY) - ical_export_valarm (stream); + ical_export_valarm (stream); (void)fprintf (stream, "END:VEVENT\n"); } pthread_mutex_unlock (&(alist_p->mutex)); @@ -634,7 +634,7 @@ ical_export_todo (FILE *stream) { if (i->id < 0) /* completed items */ continue; - + (void)fprintf (stream, "BEGIN:VTODO\n"); (void)fprintf (stream, "PRIORITY:%d\n", i->id); (void)fprintf (stream, "SUMMARY:%s\n", i->mesg); @@ -652,7 +652,7 @@ pcal_export_todo (FILE *stream) { if (i->id < 0) /* completed items */ continue; - + (void)fprintf (stream, "note all "); (void)fprintf (stream, "%d. %s\n", i->id, i->mesg); } @@ -676,10 +676,10 @@ io_fprintln (const char *fname, const char *fmt, ...) ret = vsnprintf (buf, sizeof buf, fmt, ap); RETVAL_IF (ret < 0, 0, _("Failed to build message\n")); va_end (ap); - + ret = fprintf (fp, "%s", buf); RETVAL_IF (ret < 0, 0, _("Failed to print message \"%s\"\n"), buf); - + ret = fclose (fp); RETVAL_IF (ret != 0, 0, _("Failed to close \"%s\" - %s\n"), fname, strerror (errno)); @@ -687,7 +687,7 @@ io_fprintln (const char *fname, const char *fmt, ...) return 1; } -/* +/* * Initialization of data paths. The cfile argument is the variable * which contains the calendar file. If none is given, then the default * one (~/.calcurse/apts) is taken. If the one given does not exist, it @@ -712,7 +712,7 @@ io_init (char *cfile, char *datadir) (void)snprintf (path_apts, BUFSIZ, "%s/" APTS_PATH_NAME, home); (void)snprintf (path_keys, BUFSIZ, "%s/" KEYS_PATH_NAME, home); (void)snprintf (path_cpid, BUFSIZ, "%s/" CPID_PATH_NAME, home); - (void)snprintf (path_dpid, BUFSIZ, "%s/" DPID_PATH_NAME, home); + (void)snprintf (path_dpid, BUFSIZ, "%s/" DPID_PATH_NAME, home); (void)snprintf (path_dmon_log, BUFSIZ, "%s/" DLOG_PATH_NAME, home); } else @@ -727,8 +727,8 @@ io_init (char *cfile, char *datadir) (void)snprintf (path_conf, BUFSIZ, "%s/" CONF_PATH, home); (void)snprintf (path_keys, BUFSIZ, "%s/" KEYS_PATH, home); (void)snprintf (path_cpid, BUFSIZ, "%s/" CPID_PATH, home); - (void)snprintf (path_dpid, BUFSIZ, "%s/" DPID_PATH, home); - (void)snprintf (path_dmon_log, BUFSIZ, "%s/" DLOG_PATH, home); + (void)snprintf (path_dpid, BUFSIZ, "%s/" DPID_PATH, home); + (void)snprintf (path_dmon_log, BUFSIZ, "%s/" DLOG_PATH, home); (void)snprintf (path_notes, BUFSIZ, "%s/" NOTES_DIR, home); if (cfile == NULL) { @@ -783,11 +783,11 @@ void io_extract_data (char *dst_data, const char *org, int len) { int i; - + for (i = 0; i < len - 1; i++) { if (*org == '\n' || *org == '\0') - break; + break; *dst_data++ = *org++; } *dst_data = '\0'; @@ -800,13 +800,13 @@ display_mark (void) WINDOW *mwin; mwin = newwin (1, 2, 1, col - 3); - + custom_apply_attr (mwin, ATTR_HIGHEST); mvwprintw (mwin, 0, 0, "**"); wins_wrefresh (mwin); sleep (DISPLAY_TIME); mvwprintw (mwin, 0, 0, " "); - wins_wrefresh (mwin); + wins_wrefresh (mwin); delwin (mwin); wins_doupdate (); } @@ -827,41 +827,41 @@ io_save_conf (struct conf *conf) "# For a variable to be unset its value must be blank.\n" "# To set a variable to the empty string its value should be \"\".\n" "# Lines beginning with \"#\" are comments, and ignored by Calcurse.\n"; - char theme_name[BUFSIZ]; + char theme_name[BUFSIZ]; FILE *fp; - + if ((fp = fopen (path_conf, "w")) == 0) return 0; custom_color_theme_name (theme_name); (void)fprintf (fp, "%s\n", config_txt); - + (void)fprintf (fp, "# If this option is set to yes, " "automatic save is done when quitting\n"); (void)fprintf (fp, "auto_save=\n"); (void)fprintf (fp, "%s\n", (conf->auto_save) ? "yes" : "no"); - + (void)fprintf (fp, "\n# If not null, perform automatic saves every " "'periodic_save' minutes\n"); (void)fprintf (fp, "periodic_save=\n"); (void)fprintf (fp, "%d\n", conf->periodic_save); - + (void)fprintf (fp, "\n# If this option is set to yes, " "confirmation is required before quitting\n"); (void)fprintf (fp, "confirm_quit=\n"); (void)fprintf (fp, "%s\n", (conf->confirm_quit) ? "yes" : "no"); - + (void)fprintf (fp, "\n# If this option is set to yes, " "confirmation is required before deleting an event\n"); (void)fprintf (fp, "confirm_delete=\n"); (void)fprintf (fp, "%s\n", (conf->confirm_delete) ? "yes" : "no"); - + (void)fprintf (fp, "\n# If this option is set to yes, " "messages about loaded and saved data will not be displayed\n"); (void)fprintf (fp, "skip_system_dialogs=\n"); (void)fprintf (fp, "%s\n", (conf->skip_system_dialogs) ? "yes" : "no"); - + (void)fprintf (fp, "\n# If this option is set to yes, progress bar appearing " "when saving data will not be displayed\n"); @@ -871,17 +871,17 @@ io_save_conf (struct conf *conf) (void)fprintf (fp, "\n# Default calendar view (0)monthly (1)weekly:\n"); (void)fprintf (fp, "calendar_default_view=\n"); (void)fprintf (fp, "%d\n", calendar_get_view ()); - + (void)fprintf (fp, "\n# If this option is set to yes, " "monday is the first day of the week, else it is sunday\n"); (void)fprintf (fp, "week_begins_on_monday=\n"); (void)fprintf (fp, "%s\n", (calendar_week_begins_on_monday ())? "yes" : "no"); - + (void)fprintf (fp, "\n# This is the color theme used for menus :\n"); (void)fprintf (fp, "color-theme=\n"); (void)fprintf (fp, "%s\n", theme_name); - + (void)fprintf (fp, "\n# This is the layout of the calendar :\n"); (void)fprintf (fp, "layout=\n"); (void)fprintf (fp, "%d\n", wins_layout ()); @@ -890,7 +890,7 @@ io_save_conf (struct conf *conf) "of the side bar :\n"); (void)fprintf (fp, "side-bar_width=\n"); (void)fprintf (fp, "%d\n", wins_sbar_wperc ()); - + if (ui_mode == UI_CURSES) pthread_mutex_lock (&nbar.mutex); (void)fprintf (fp, @@ -898,39 +898,39 @@ io_save_conf (struct conf *conf) "notify-bar will be displayed :\n"); (void)fprintf (fp, "notify-bar_show=\n"); (void)fprintf (fp, "%s\n", (nbar.show) ? "yes" : "no"); - + (void)fprintf (fp, "\n# Format of the date to be displayed inside notify-bar :\n"); (void)fprintf (fp, "notify-bar_date=\n"); (void)fprintf (fp, "%s\n", nbar.datefmt); - + (void)fprintf (fp, "\n# Format of the time to be displayed inside notify-bar :\n"); (void)fprintf (fp, "notify-bar_clock=\n"); (void)fprintf (fp, "%s\n", nbar.timefmt); - + (void)fprintf (fp, "\n# Warn user if he has an appointment within next " "'notify-bar_warning' seconds :\n"); (void)fprintf (fp, "notify-bar_warning=\n"); (void)fprintf (fp, "%d\n", nbar.cntdwn); - + (void)fprintf (fp, "\n# Command used to notify user of " "an upcoming appointment :\n"); (void)fprintf (fp, "notify-bar_command=\n"); (void)fprintf (fp, "%s\n", nbar.cmd); - + (void)fprintf (fp, "\n# Format of the date to be displayed " "in non-interactive mode :\n"); (void)fprintf (fp, "output_datefmt=\n"); (void)fprintf (fp, "%s\n", conf->output_datefmt); - + (void)fprintf (fp, "\n# Format to be used when entering a date " "(1)mm/dd/yyyy (2)dd/mm/yyyy (3)yyyy/mm/dd) " "(4)yyyy-mm-dd:\n"); (void)fprintf (fp, "input_datefmt=\n"); (void)fprintf (fp, "%d\n", conf->input_datefmt); - + if (ui_mode == UI_CURSES) pthread_mutex_unlock (&nbar.mutex); @@ -944,22 +944,22 @@ io_save_conf (struct conf *conf) "activity will be logged when running in background\n"); (void)fprintf (fp, "notify-daemon_log=\n"); (void)fprintf (fp, "%s\n", dmon.log ? "yes" : "no"); - + file_close (fp, __FILE_POS__); return 1; } -/* - * Save the apts data file, which contains the - * appointments first, and then the events. +/* + * Save the apts data file, which contains the + * appointments first, and then the events. * Recursive items are written first. */ unsigned io_save_apts (void) { struct apoint *a; - struct event *e; + struct event *e; FILE *fp; if ((fp = fopen (path_apts, "w")) == 0) @@ -985,9 +985,9 @@ io_save_apts (void) unsigned io_save_todo (void) { - struct todo *t; + struct todo *t; FILE *fp; - + if ((fp = fopen (path_todo, "w")) == 0) return 0; @@ -1008,10 +1008,10 @@ unsigned io_save_keys (void) { FILE *fp; - + if ((fp = fopen (path_keys, "w")) == 0) return 0; - + keys_save_bindings (fp); file_close (fp, __FILE_POS__); @@ -1029,7 +1029,7 @@ io_save_cal (struct conf *conf, enum save_display display) pthread_mutex_lock (&io_save_mutex); - show_bar = 0; + show_bar = 0; if (ui_mode == UI_CURSES && display == IO_SAVE_DISPLAY_BAR && !conf->skip_progress_bar) show_bar = 1; @@ -1040,22 +1040,22 @@ io_save_cal (struct conf *conf, enum save_display display) progress_bar (PROGRESS_BAR_SAVE, PROGRESS_BAR_CONF); if (!io_save_conf (conf)) ERROR_MSG ("%s", access_pb); - + if (show_bar) progress_bar (PROGRESS_BAR_SAVE, PROGRESS_BAR_TODO); if (!io_save_todo ()) ERROR_MSG ("%s", access_pb); - + if (show_bar) progress_bar (PROGRESS_BAR_SAVE, PROGRESS_BAR_APTS); if (!io_save_apts ()) ERROR_MSG ("%s", access_pb); - + if (show_bar) progress_bar (PROGRESS_BAR_SAVE, PROGRESS_BAR_KEYS); if (!io_save_keys ()) ERROR_MSG ("%s", access_pb); - + /* Print a message telling data were saved */ if (ui_mode == UI_CURSES && !conf->skip_system_dialogs && display != IO_SAVE_DISPLAY_MARK) @@ -1067,8 +1067,8 @@ io_save_cal (struct conf *conf, enum save_display display) pthread_mutex_unlock (&io_save_mutex); } -/* - * Check what type of data is written in the appointment file, +/* + * Check what type of data is written in the appointment file, * and then load either: a new appointment, a new event, or a new * recursive item (which can also be either an event or an appointment). */ @@ -1096,17 +1096,17 @@ io_load_app (void) is_appointment = is_event = is_recursive = 0; c = getc (data_file); if (c == EOF) - break; + break; (void)ungetc (c, data_file); /* Read the date first: it is common to both events - * and appointments. + * and appointments. */ if (fscanf (data_file, "%u / %u / %u ", - &start.tm_mon, &start.tm_mday, &start.tm_year) != 3) - { + &start.tm_mon, &start.tm_mday, &start.tm_year) != 3) + { EXIT (_("syntax error in the item date")); - } + } /* Read the next character : if it is an '@' then we have * an appointment, else if it is an '[' we have en event. @@ -1114,144 +1114,144 @@ io_load_app (void) c = getc (data_file); if (c == '@') - is_appointment = 1; + is_appointment = 1; else if (c == '[') - is_event = 1; + is_event = 1; else - { + { EXIT (_("no event nor appointment found")); - } + } (void)ungetc (c, data_file); /* Read the remaining informations. */ if (is_appointment) - { - fscanf (data_file, "@ %u : %u -> %u / %u / %u @ %u : %u ", - &start.tm_hour, &start.tm_min, - &end.tm_mon, &end.tm_mday, &end.tm_year, - &end.tm_hour, &end.tm_min); - } + { + fscanf (data_file, "@ %u : %u -> %u / %u / %u @ %u : %u ", + &start.tm_hour, &start.tm_min, + &end.tm_mon, &end.tm_mday, &end.tm_year, + &end.tm_hour, &end.tm_min); + } else if (is_event) - { - fscanf (data_file, "[%d] ", &id); - } + { + fscanf (data_file, "[%d] ", &id); + } else - { + { EXIT (_("wrong format in the appointment or event")); /* NOTREACHED */ - } + } /* Check if we have a recursive item. */ c = getc (data_file); if (c == '{') - { - (void)ungetc (c, data_file); - is_recursive = 1; - fscanf (data_file, "{ %d%c ", &freq, &type); - - c = getc (data_file); - if (c == '}') - { /* endless recurrent item */ - (void)ungetc (c, data_file); - fscanf (data_file, "} "); - until.tm_year = 0; - } - else if (c == '-') - { - (void)ungetc (c, data_file); - fscanf (data_file, " -> %u / %u / %u ", - &until.tm_mon, &until.tm_mday, &until.tm_year); - c = getc (data_file); - if (c == '!') - { - (void)ungetc (c, data_file); - exc = recur_exc_scan (data_file); - c = getc (data_file); - } - else - { - (void)ungetc (c, data_file); - fscanf (data_file, "} "); - } - } - else if (c == '!') - { // endless item with exceptions - (void)ungetc (c, data_file); - exc = recur_exc_scan (data_file); - c = getc (data_file); - until.tm_year = 0; - } - else - { + { + (void)ungetc (c, data_file); + is_recursive = 1; + fscanf (data_file, "{ %d%c ", &freq, &type); + + c = getc (data_file); + if (c == '}') + { /* endless recurrent item */ + (void)ungetc (c, data_file); + fscanf (data_file, "} "); + until.tm_year = 0; + } + else if (c == '-') + { + (void)ungetc (c, data_file); + fscanf (data_file, " -> %u / %u / %u ", + &until.tm_mon, &until.tm_mday, &until.tm_year); + c = getc (data_file); + if (c == '!') + { + (void)ungetc (c, data_file); + exc = recur_exc_scan (data_file); + c = getc (data_file); + } + else + { + (void)ungetc (c, data_file); + fscanf (data_file, "} "); + } + } + else if (c == '!') + { // endless item with exceptions + (void)ungetc (c, data_file); + exc = recur_exc_scan (data_file); + c = getc (data_file); + until.tm_year = 0; + } + else + { EXIT (_("wrong format in the appointment or event")); /* NOTREACHED */ - } - } + } + } else - (void)ungetc (c, data_file); + (void)ungetc (c, data_file); /* Check if a note is attached to the item. */ c = getc (data_file); if (c == '>') - { - (void)fgets (note, NOTESIZ + 1, data_file); - note[NOTESIZ] = '\0'; - notep = note; - getc (data_file); - } + { + (void)fgets (note, NOTESIZ + 1, data_file); + note[NOTESIZ] = '\0'; + notep = note; + getc (data_file); + } else - { - notep = NULL; - (void)ungetc (c, data_file); - } + { + notep = NULL; + (void)ungetc (c, data_file); + } /* * Last: read the item description and load it into its * corresponding linked list, depending on the item type. */ if (is_appointment) - { - c = getc (data_file); - if (c == '!') - { - (void)ungetc (c, data_file); - fscanf (data_file, " ! "); - state |= APOINT_NOTIFY; - } - else - { - (void)ungetc (c, data_file); - fscanf (data_file, " | "); - state = 0L; - } - if (is_recursive) - { - recur_apoint_scan (data_file, start, end, - type, freq, until, notep, &exc, state); - } - else - { - apoint_scan (data_file, start, end, state, notep); - } - } + { + c = getc (data_file); + if (c == '!') + { + (void)ungetc (c, data_file); + fscanf (data_file, " ! "); + state |= APOINT_NOTIFY; + } + else + { + (void)ungetc (c, data_file); + fscanf (data_file, " | "); + state = 0L; + } + if (is_recursive) + { + recur_apoint_scan (data_file, start, end, + type, freq, until, notep, &exc, state); + } + else + { + apoint_scan (data_file, start, end, state, notep); + } + } else if (is_event) - { - if (is_recursive) - { - recur_event_scan (data_file, start, id, type, - freq, until, notep, &exc); - } - else - { - event_scan (data_file, start, id, notep); - } - } + { + if (is_recursive) + { + recur_event_scan (data_file, start, id, type, + freq, until, notep, &exc); + } + else + { + event_scan (data_file, start, id, notep); + } + } else - { + { EXIT (_("wrong format in the appointment or event")); /* NOTREACHED */ - } + } } file_close (data_file, __FILE_POS__); } @@ -1278,28 +1278,28 @@ io_load_todo (void) { c = getc (data_file); if (c == EOF) - { - break; - } + { + break; + } else if (c == '[') - { /* new style with id */ - fscanf (data_file, "%d]", &id); - } + { /* new style with id */ + fscanf (data_file, "%d]", &id); + } else - { - id = 9; - (void)ungetc (c, data_file); - } + { + id = 9; + (void)ungetc (c, data_file); + } /* Now read the attached note, if any. */ c = getc (data_file); if (c == '>') - { - (void)fgets (note, NOTESIZ + 1, data_file); - note[NOTESIZ] = '\0'; - getc (data_file); - } + { + (void)fgets (note, NOTESIZ + 1, data_file); + note[NOTESIZ] = '\0'; + getc (data_file); + } else - note[0] = '\0'; + note[0] = '\0'; /* Then read todo description. */ (void)fgets (buf, sizeof buf, data_file); newline = strchr (buf, '\n'); @@ -1361,11 +1361,11 @@ io_load_keys (char *pager) const int MAX_ERRORS = 5; keys_init (); - + #define HSIZE 256 HTABLE_HEAD (ht_keybindings, HSIZE, ht_keybindings_s) ht_keys = HTABLE_INITIALIZER (&ht_keys); - + HTABLE_GENERATE (ht_keybindings, ht_keybindings_s, load_keys_ht_getkey, load_keys_ht_compare); @@ -1404,7 +1404,7 @@ io_load_keys (char *pager) memmove (buf, p, strlen (p)); if (buf[0] == '#' || buf[0] == '\n') continue; - + if (sscanf (buf, "%s", key_label) != AWAITED) { skipped++; @@ -1412,7 +1412,7 @@ io_load_keys (char *pager) continue; } ht_entry.label = key_label; - p = buf + strlen (key_label) + 1; + p = buf + strlen (key_label) + 1; ht_elm = HTABLE_LOOKUP (ht_keybindings, &ht_keys, &ht_entry); if (!ht_elm) { @@ -1431,7 +1431,7 @@ io_load_keys (char *pager) if (sscanf (tmpbuf, "%s", key_ch) == AWAITED) { int ch; - + if ((ch = keys_str2int (key_ch)) < 0) { char unknown_key[BUFSIZ]; @@ -1444,7 +1444,7 @@ io_load_keys (char *pager) else { int used; - + used = keys_assign_binding (ch, ht_elm->key); if (used) { @@ -1474,7 +1474,7 @@ io_load_keys (char *pager) { char *view_log = _("There were some errors when loading keys file, see log file ?"); - + io_log_display (log, view_log, pager); } io_log_free (log); @@ -1494,11 +1494,11 @@ io_check_dir (char *dir, int *missing) if (mkdir (dir, 0700) != 0) { if (errno != EEXIST) - { - (void)fprintf (stderr, _("FATAL ERROR: could not create %s: %s\n"), + { + (void)fprintf (stderr, _("FATAL ERROR: could not create %s: %s\n"), dir, strerror (errno)); - exit_calcurse (EXIT_FAILURE); - } + exit_calcurse (EXIT_FAILURE); + } } else { @@ -1511,7 +1511,7 @@ unsigned io_file_exist (char *file) { FILE *fd; - + if (!file) return 0; @@ -1530,21 +1530,21 @@ io_check_file (char *file, int *missing) if (!io_file_exist (file)) { FILE *fd; - + if (missing) (*missing)++; if ((fd = fopen (file, "w")) == NULL) - { - (void)fprintf (stderr, _("FATAL ERROR: could not create %s: %s\n"), + { + (void)fprintf (stderr, _("FATAL ERROR: could not create %s: %s\n"), file, strerror (errno)); - exit_calcurse (EXIT_FAILURE); - } + exit_calcurse (EXIT_FAILURE); + } file_close (fd, __FILE_POS__); } } -/* - * Checks if data files exist. If not, create them. +/* + * Checks if data files exist. If not, create them. * The following structure has to be created: * * $HOME/.calcurse/ @@ -1731,7 +1731,7 @@ ical_store_event (char *mesg, char *note, long day, long end, ical_rpt_t *rpt, struct days *exc) { const int EVENTID = 1; - + if (rpt) { recur_event_new (mesg, note, day, EVENTID, rpt->type, rpt->freq, @@ -1844,7 +1844,7 @@ ical_unformat_line (char *line) #undef CARRIAGE_RETURN return NULL; } - + /* * Extract from RFC2445: * @@ -1861,19 +1861,19 @@ ical_unfold_content (FILE *fd, char *line, unsigned *lineno) content = ical_unformat_line (line); if (!content) return NULL; - + for (;;) { c = getc (fd); if (c == SPACE || c == TAB) { char buf[BUFSIZ]; - + if (fgets (buf, BUFSIZ, fd) != NULL) { char *tmpline, *rline; int newsize; - + (*lineno)++; tmpline = ical_unformat_line (buf); if (!tmpline) @@ -2056,7 +2056,7 @@ ical_dur2long (char *durstr) return NOTFOUND; else if (*p == '+') p++; - + if (*p == 'T') /* dur-time */ durlong = ical_durtime2long (p); else if (strchr (p, 'W')) /* dur-week */ @@ -2128,7 +2128,7 @@ ical_compute_rpt_until (long start, ical_rpt_t *rpt) * * Purpose: This value type is used to identify properties that contain * a recurrence rule specification. - * + * * Formal Definition: The value type is defined by the following * notation: * @@ -2176,7 +2176,7 @@ ical_read_rrule (FILE *log, char *rrulestr, unsigned *noskipped, if ((p = strchr (rrulestr, ':')) != NULL) { char freqstr[BUFSIZ]; - + p++; rpt = mem_malloc (sizeof (ical_rpt_t)); bzero (rpt, sizeof (ical_rpt_t)); @@ -2280,7 +2280,7 @@ ical_add_exc (struct days **exc_head, long date) else { struct days *exc; - + exc = mem_malloc (sizeof (struct days)); exc->st = date; exc->next = *exc_head; @@ -2350,7 +2350,7 @@ ical_read_note (char *first_line, FILE *fdi, unsigned *noskipped, notestr = ical_unfold_content (fdi, p, lineno); if (notestr == NULL) { - ical_log (log, item_type, itemline, + ical_log (log, item_type, itemline, _("could not get entire item description.")); file_close (fdo, __FILE_POS__); erase_note (¬ename, ERASE_FORCE); @@ -2409,7 +2409,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints, const struct string rrule = STRING_BUILD ("RRULE"); const struct string exdate = STRING_BUILD ("EXDATE"); const struct string alarm = STRING_BUILD ("BEGIN:VALARM"); - const struct string endalarm = STRING_BUILD ("END:VALARM"); + const struct string endalarm = STRING_BUILD ("END:VALARM"); const struct string desc = STRING_BUILD ("DESCRIPTION"); ical_vevent_e vevent_type; char *p, buf[BUFSIZ], buf_upper[BUFSIZ]; @@ -2421,7 +2421,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints, int has_alarm; } vevent; int skip_alarm; - + vevent_type = UNDEFINED; bzero (&vevent, sizeof vevent); skip_alarm = 0; @@ -2430,7 +2430,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints, (*lineno)++; memcpy (buf_upper, buf, strlen (buf)); str_toupper (buf_upper); - if (skip_alarm) + if (skip_alarm) { /* Need to skip VALARM properties because some keywords could interfere, such as DURATION, SUMMARY,.. */ @@ -2445,13 +2445,13 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints, if (vevent.rpt && vevent.rpt->count) vevent.rpt->until = ical_compute_rpt_until (vevent.start, vevent.rpt); - + switch (vevent_type) { case APPOINTMENT: if (vevent.start == 0) { - ical_log (log, ICAL_VEVENT, ITEMLINE, + ical_log (log, ICAL_VEVENT, ITEMLINE, _("appointment has no start time.")); goto cleanup; } @@ -2459,7 +2459,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints, { if (vevent.end == 0) { - ical_log (log, ICAL_VEVENT, ITEMLINE, + ical_log (log, ICAL_VEVENT, ITEMLINE, _("could not compute duration " "(no end time).")); goto cleanup; @@ -2493,7 +2493,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints, case EVENT: if (vevent.start == 0) { - ical_log (log, ICAL_VEVENT, ITEMLINE, + ical_log (log, ICAL_VEVENT, ITEMLINE, _("event date is not defined.")); goto cleanup; } @@ -2502,11 +2502,11 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints, (*noevents)++; break; case UNDEFINED: - ical_log (log, ICAL_VEVENT, ITEMLINE, + ical_log (log, ICAL_VEVENT, ITEMLINE, _("item could not be identified.")); goto cleanup; break; - } + } } else { @@ -2556,7 +2556,7 @@ ical_read_event (FILE *fdi, FILE *log, unsigned *noevents, unsigned *noapoints, else if (strncmp (buf_upper, exdate.str, exdate.len) == 0) { vevent.exc = ical_read_exdate (log, buf, noskipped, ITEMLINE); - } + } else if (strncmp (buf_upper, summary.str, summary.len) == 0) { vevent.mesg = ical_read_summary (buf, fdi, lineno); @@ -2607,7 +2607,7 @@ ical_read_todo (FILE *fdi, FILE *log, unsigned *notodos, unsigned *noskipped, int has_priority, priority; } vtodo; int skip_alarm; - + bzero (&vtodo, sizeof vtodo); skip_alarm = 0; while (fgets (buf, BUFSIZ, fdi) != NULL) @@ -2615,7 +2615,7 @@ ical_read_todo (FILE *fdi, FILE *log, unsigned *notodos, unsigned *noskipped, (*lineno)++; memcpy (buf_upper, buf, strlen (buf)); str_toupper (buf_upper); - if (skip_alarm) + if (skip_alarm) { /* Need to skip VALARM properties because some keywords could interfere, such as DURATION, SUMMARY,.. */ @@ -2643,7 +2643,7 @@ ical_read_todo (FILE *fdi, FILE *log, unsigned *notodos, unsigned *noskipped, else { int tmpint; - + if (sscanf (buf_upper, "PRIORITY:%d", &tmpint) == 1) { if (tmpint <= 9 && tmpint >= 1) @@ -2706,16 +2706,16 @@ get_import_stream (enum export_type type) status_mesg (ask_fname, ""); cancel = updatestring (win[STA].p, &stream_name, 0, 1); if (cancel) - { - mem_free (stream_name); - return NULL; - } + { + mem_free (stream_name); + return NULL; + } stream = fopen (stream_name, "r"); if (stream == NULL) - { - status_mesg (wrong_file, press_enter); - (void)wgetch (win[STA].p); - } + { + status_mesg (wrong_file, press_enter); + (void)wgetch (win[STA].p); + } } mem_free (stream_name); @@ -2817,7 +2817,7 @@ io_import_data (enum import_type type, struct conf *conf, char *stream_name) stats.skipped); printf ("\n"); } - + /* User has the choice to look at the log file if some items could not be imported. */ @@ -2878,7 +2878,7 @@ io_log_display (struct io_file *log, char *msg, char *pager) if (ans == 'y') { char cmd[BUFSIZ]; - + (void)snprintf (cmd, BUFSIZ, "%s %s", pager, log->name); (void)system (cmd); } @@ -2922,7 +2922,7 @@ io_psave_thread (void *arg) config = (struct conf *)arg; delay = config->periodic_save; EXIT_IF (delay < 0, _("Invalid delay")); - + for (;;) { (void)sleep (delay * MININSEC); @@ -2942,7 +2942,7 @@ void io_stop_psave_thread (void) { if (io_t_psave) - pthread_cancel (io_t_psave); + pthread_cancel (io_t_psave); } /* @@ -2976,7 +2976,7 @@ io_set_lock (void) EXIT (_("FATAL ERROR: could not create %s: %s\n"), path_cpid, strerror (errno)); } -} +} /* * Create a new file and write the process pid inside @@ -2987,7 +2987,7 @@ io_dump_pid (char *file) { pid_t pid; FILE *fp; - + if (!file) return 0; @@ -2996,7 +2996,7 @@ io_dump_pid (char *file) || fprintf (fp, "%ld\n", (long)pid) < 0 || fclose (fp) != 0) return 0; - + return 1; } @@ -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) @@ -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); diff --git a/src/notify.c b/src/notify.c index b39d021..eaa8224 100644 --- a/src/notify.c +++ b/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; - - 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) + + hours_left = (time_left / HOURINSEC); + minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC; + pthread_mutex_lock (&nbar.mutex); + + if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY)) + blinking = 1; + else + blinking = 0; + + if (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); diff --git a/src/recur.c b/src/recur.c index fbd894d..4bdb217 100644 --- a/src/recur.c +++ b/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; - - if (notify_bar ()) - notify_check_repeated (o); - - pthread_mutex_unlock (&(recur_alist_p->mutex)); - if (need_chk_notify) - notify_check_next_app (); - return; - } - n++; - } + o->rpt->freq, o->rpt->until, date)) + { + if (n == recur_nb) + { + o->state ^= APOINT_NOTIFY; + + if (notify_bar ()) + notify_check_repeated (o); + + 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); } @@ -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); diff --git a/src/utils.c b/src/utils.c index 3ce9898..450988a 100644 --- a/src/utils.c +++ b/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) @@ -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, |