Use tabs instead of spaces for indentation
This completes our switch to the Linux kernel coding style. Note that we still use deeply nested constructs at some places which need to be fixed up later. Converted using the `Lindent` script from the Linux kernel code base, along with some manual fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
9907069f44
commit
694d28eb78
17
src/apoint.c
17
src/apoint.c
@ -109,7 +109,8 @@ struct apoint *apoint_new(char *mesg, char *note, long start, long dur,
|
||||
|
||||
unsigned apoint_inday(struct apoint *i, long *start)
|
||||
{
|
||||
return (i->start <= *start + DAYINSEC && i->start + i->dur > *start);
|
||||
return (i->start <= *start + DAYINSEC
|
||||
&& i->start + i->dur > *start);
|
||||
}
|
||||
|
||||
void apoint_sec2str(struct apoint *o, long day, char *start, char *end)
|
||||
@ -122,14 +123,16 @@ void apoint_sec2str(struct apoint *o, long day, char *start, char *end)
|
||||
} else {
|
||||
t = o->start;
|
||||
localtime_r(&t, <);
|
||||
snprintf(start, HRMIN_SIZE, "%02u:%02u", lt.tm_hour, lt.tm_min);
|
||||
snprintf(start, HRMIN_SIZE, "%02u:%02u", lt.tm_hour,
|
||||
lt.tm_min);
|
||||
}
|
||||
if (o->start + o->dur > day + DAYINSEC) {
|
||||
strncpy(end, "..:..", 6);
|
||||
} else {
|
||||
t = o->start + o->dur;
|
||||
localtime_r(&t, <);
|
||||
snprintf(end, HRMIN_SIZE, "%02u:%02u", lt.tm_hour, lt.tm_min);
|
||||
snprintf(end, HRMIN_SIZE, "%02u:%02u", lt.tm_hour,
|
||||
lt.tm_min);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,8 +148,8 @@ void apoint_write(struct apoint *o, FILE * f)
|
||||
|
||||
t = o->start + o->dur;
|
||||
localtime_r(&t, <);
|
||||
fprintf(f, " -> %02u/%02u/%04u @ %02u:%02u ", lt.tm_mon + 1, lt.tm_mday,
|
||||
1900 + lt.tm_year, lt.tm_hour, lt.tm_min);
|
||||
fprintf(f, " -> %02u/%02u/%04u @ %02u:%02u ", lt.tm_mon + 1,
|
||||
lt.tm_mday, 1900 + lt.tm_year, lt.tm_hour, lt.tm_min);
|
||||
|
||||
if (o->note != NULL)
|
||||
fprintf(f, ">%s ", o->note);
|
||||
@ -159,8 +162,8 @@ void apoint_write(struct apoint *o, FILE * f)
|
||||
fprintf(f, "%s\n", o->mesg);
|
||||
}
|
||||
|
||||
struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, char state,
|
||||
char *note)
|
||||
struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end,
|
||||
char state, char *note)
|
||||
{
|
||||
char buf[BUFSIZ], *newline;
|
||||
time_t tstart, tend;
|
||||
|
85
src/args.c
85
src/args.c
@ -69,7 +69,8 @@ static void usage(void)
|
||||
|
||||
static void usage_try(void)
|
||||
{
|
||||
const char *arg_usage_try = _("Try 'calcurse -h' for more information.\n");
|
||||
const char *arg_usage_try =
|
||||
_("Try 'calcurse -h' for more information.\n");
|
||||
fputs(arg_usage_try, stdout);
|
||||
}
|
||||
|
||||
@ -82,7 +83,8 @@ static void version_arg(void)
|
||||
_("\nCopyright (c) 2004-2013 calcurse Development Team.\n"
|
||||
"This is free software; see the source for copying conditions.\n");
|
||||
|
||||
fprintf(stdout, _("Calcurse %s - text-based organizer\n"), VERSION);
|
||||
fprintf(stdout, _("Calcurse %s - text-based organizer\n"),
|
||||
VERSION);
|
||||
fputs(vtext, stdout);
|
||||
}
|
||||
|
||||
@ -155,7 +157,8 @@ static void help_arg(void)
|
||||
"\tnote: redirect standard output to export data to a file,\n"
|
||||
"\tby issuing a command such as: calcurse --export > calcurse.dat\n");
|
||||
|
||||
fprintf(stdout, _("Calcurse %s - text-based organizer\n"), VERSION);
|
||||
fprintf(stdout, _("Calcurse %s - text-based organizer\n"),
|
||||
VERSION);
|
||||
usage();
|
||||
fputs(htext, stdout);
|
||||
more_info();
|
||||
@ -182,12 +185,15 @@ static void status_arg(void)
|
||||
EXIT_IF(cpid && dpid,
|
||||
_("Error: both calcurse (pid: %d) and its daemon (pid: %d)\n"
|
||||
"seem to be running at the same time!\n"
|
||||
"Please check manually and restart calcurse.\n"), cpid, dpid);
|
||||
"Please check manually and restart calcurse.\n"), cpid,
|
||||
dpid);
|
||||
|
||||
if (cpid)
|
||||
fprintf(stdout, _("calcurse is running (pid %d)\n"), cpid);
|
||||
else if (dpid)
|
||||
fprintf(stdout, _("calcurse is running in background (pid %d)\n"), dpid);
|
||||
fprintf(stdout,
|
||||
_("calcurse is running in background (pid %d)\n"),
|
||||
dpid);
|
||||
else
|
||||
puts(_("calcurse is not running\n"));
|
||||
}
|
||||
@ -249,7 +255,8 @@ static void next_arg(void)
|
||||
next_app.got_app = 0;
|
||||
next_app.txt = NULL;
|
||||
|
||||
next_app = *recur_apoint_check_next(&next_app, current_time, get_today());
|
||||
next_app =
|
||||
*recur_apoint_check_next(&next_app, current_time, get_today());
|
||||
next_app = *apoint_check_next(&next_app, current_time);
|
||||
|
||||
if (next_app.got_app) {
|
||||
@ -257,8 +264,8 @@ static void next_arg(void)
|
||||
hours_left = (time_left / HOURINSEC);
|
||||
min_left = (time_left - hours_left * HOURINSEC) / MININSEC;
|
||||
fputs(_("next appointment:\n"), stdout);
|
||||
fprintf(stdout, " [%02d:%02d] %s\n", hours_left, min_left,
|
||||
next_app.txt);
|
||||
fprintf(stdout, " [%02d:%02d] %s\n", hours_left,
|
||||
min_left, next_app.txt);
|
||||
mem_free(next_app.txt);
|
||||
}
|
||||
}
|
||||
@ -271,7 +278,7 @@ static void arg_print_date(long date)
|
||||
char date_str[BUFSIZ];
|
||||
struct tm lt;
|
||||
|
||||
localtime_r((time_t *)&date, <);
|
||||
localtime_r((time_t *) & date, <);
|
||||
strftime(date_str, BUFSIZ, conf.output_datefmt, <);
|
||||
fputs(date_str, stdout);
|
||||
fputs(":\n", stdout);
|
||||
@ -286,7 +293,7 @@ static void arg_print_date(long date)
|
||||
static int
|
||||
app_arg(int add_line, struct date *day, long date, const char *fmt_apt,
|
||||
const char *fmt_rapt, const char *fmt_ev, const char *fmt_rev,
|
||||
regex_t *regex)
|
||||
regex_t * regex)
|
||||
{
|
||||
if (date == 0)
|
||||
date = get_sec_date(*day);
|
||||
@ -320,7 +327,8 @@ display_app(struct tm *t, int numdays, int add_line, const char *fmt_apt,
|
||||
day.dd = t->tm_mday;
|
||||
day.mm = t->tm_mon + 1;
|
||||
day.yyyy = t->tm_year + 1900;
|
||||
app_found = app_arg(add_line, &day, 0, fmt_apt, fmt_rapt, fmt_ev,
|
||||
app_found =
|
||||
app_arg(add_line, &day, 0, fmt_apt, fmt_rapt, fmt_ev,
|
||||
fmt_rev, regex);
|
||||
if (app_found)
|
||||
add_line = 1;
|
||||
@ -354,16 +362,19 @@ date_arg(const char *ddate, int add_line, const char *fmt_apt,
|
||||
*/
|
||||
timer = time(NULL);
|
||||
localtime_r(&timer, &t);
|
||||
display_app(&t, atoi(ddate), add_line, fmt_apt, fmt_rapt, fmt_ev, fmt_rev,
|
||||
regex);
|
||||
display_app(&t, atoi(ddate), add_line, fmt_apt, fmt_rapt,
|
||||
fmt_ev, fmt_rev, regex);
|
||||
} else {
|
||||
/* A date was entered. */
|
||||
if (parse_date(ddate, conf.input_datefmt, (int *)&day.yyyy,
|
||||
(int *)&day.mm, (int *)&day.dd, NULL)) {
|
||||
app_arg(add_line, &day, 0, fmt_apt, fmt_rapt, fmt_ev, fmt_rev, regex);
|
||||
app_arg(add_line, &day, 0, fmt_apt, fmt_rapt,
|
||||
fmt_ev, fmt_rev, regex);
|
||||
} else {
|
||||
fputs(_("Argument to the '-d' flag is not valid\n"), stderr);
|
||||
fprintf(stdout, _("Possible argument format are: '%s' or 'n'\n"),
|
||||
fputs(_("Argument to the '-d' flag is not valid\n"),
|
||||
stderr);
|
||||
fprintf(stdout,
|
||||
_("Possible argument format are: '%s' or 'n'\n"),
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
more_info();
|
||||
}
|
||||
@ -400,7 +411,8 @@ date_arg_extended(const char *startday, const char *range, int add_line,
|
||||
timer = time(NULL);
|
||||
localtime_r(&timer, &t);
|
||||
if (startday != NULL) {
|
||||
if (parse_date(startday, conf.input_datefmt, (int *)&t.tm_year,
|
||||
if (parse_date
|
||||
(startday, conf.input_datefmt, (int *)&t.tm_year,
|
||||
(int *)&t.tm_mon, (int *)&t.tm_mday, NULL)) {
|
||||
t.tm_year -= 1900;
|
||||
t.tm_mon--;
|
||||
@ -410,13 +422,15 @@ date_arg_extended(const char *startday, const char *range, int add_line,
|
||||
}
|
||||
}
|
||||
if (!error) {
|
||||
display_app(&t, numdays, add_line, fmt_apt, fmt_rapt, fmt_ev, fmt_rev,
|
||||
regex);
|
||||
display_app(&t, numdays, add_line, fmt_apt, fmt_rapt,
|
||||
fmt_ev, fmt_rev, regex);
|
||||
} else {
|
||||
fputs(_("Argument is not valid\n"), stderr);
|
||||
fprintf(stdout, _("Argument format for -s and --startday is: '%s'\n"),
|
||||
fprintf(stdout,
|
||||
_("Argument format for -s and --startday is: '%s'\n"),
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
fputs(_("Argument format for -r and --range is: 'n'\n"), stdout);
|
||||
fputs(_("Argument format for -r and --range is: 'n'\n"),
|
||||
stdout);
|
||||
more_info();
|
||||
}
|
||||
}
|
||||
@ -449,8 +463,10 @@ int parse_args(int argc, char **argv)
|
||||
const char *fmt_rev = " * %m\n";
|
||||
const char *fmt_todo = "%p. %m\n";
|
||||
|
||||
int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag = 0, load_data = 0;
|
||||
const char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL;
|
||||
int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag =
|
||||
0, load_data = 0;
|
||||
const char *ddate = "", *cfile = NULL, *range = NULL, *startday =
|
||||
NULL;
|
||||
const char *datadir = NULL, *ifile = NULL;
|
||||
regex_t reg, *preg = NULL;
|
||||
|
||||
@ -489,7 +505,8 @@ int parse_args(int argc, char **argv)
|
||||
{NULL, no_argument, NULL, 0}
|
||||
};
|
||||
|
||||
while ((ch = getopt_long(argc, argv, optstr, longopts, NULL)) != -1) {
|
||||
while ((ch =
|
||||
getopt_long(argc, argv, optstr, longopts, NULL)) != -1) {
|
||||
switch (ch) {
|
||||
case STATUS_OPT:
|
||||
statusflag = 1;
|
||||
@ -543,7 +560,8 @@ int parse_args(int argc, char **argv)
|
||||
startday = optarg;
|
||||
break;
|
||||
case 'S':
|
||||
EXIT_IF(Sflag > 0, _("Can not handle more than one regular expression."));
|
||||
EXIT_IF(Sflag > 0,
|
||||
_("Can not handle more than one regular expression."));
|
||||
Sflag = 1;
|
||||
if (regcomp(®, optarg, REG_EXTENDED))
|
||||
EXIT(_("Could not compile regular expression."));
|
||||
@ -579,7 +597,8 @@ int parse_args(int argc, char **argv)
|
||||
xfmt = IO_EXPORT_PCAL;
|
||||
} else {
|
||||
fputs(_("Argument for '-x' should be either "
|
||||
"'ical' or 'pcal'\n"), stderr);
|
||||
"'ical' or 'pcal'\n"),
|
||||
stderr);
|
||||
usage();
|
||||
usage_try();
|
||||
return EXIT_FAILURE;
|
||||
@ -695,10 +714,15 @@ int parse_args(int argc, char **argv)
|
||||
io_load_app();
|
||||
config_load(); /* To get output date format. */
|
||||
if (dflag)
|
||||
date_arg(ddate, add_line, fmt_apt, fmt_rapt, fmt_ev, fmt_rev, preg);
|
||||
date_arg(ddate, add_line, fmt_apt,
|
||||
fmt_rapt, fmt_ev, fmt_rev,
|
||||
preg);
|
||||
if (rflag || sflag)
|
||||
date_arg_extended(startday, range, add_line, fmt_apt,
|
||||
fmt_rapt, fmt_ev, fmt_rev, preg);
|
||||
date_arg_extended(startday, range,
|
||||
add_line,
|
||||
fmt_apt,
|
||||
fmt_rapt, fmt_ev,
|
||||
fmt_rev, preg);
|
||||
non_interactive = 1;
|
||||
} else if (aflag) {
|
||||
struct date day;
|
||||
@ -709,7 +733,8 @@ int parse_args(int argc, char **argv)
|
||||
config_load(); /* To get output date format. */
|
||||
io_load_app();
|
||||
day.dd = day.mm = day.yyyy = 0;
|
||||
app_arg(add_line, &day, 0, fmt_apt, fmt_rapt, fmt_ev, fmt_rev, preg);
|
||||
app_arg(add_line, &day, 0, fmt_apt,
|
||||
fmt_rapt, fmt_ev, fmt_rev, preg);
|
||||
non_interactive = 1;
|
||||
}
|
||||
} else {
|
||||
|
@ -49,7 +49,8 @@ int count, reg;
|
||||
*/
|
||||
static struct day_items_nb do_storage(int day_changed)
|
||||
{
|
||||
struct day_items_nb inday = day_process_storage(ui_calendar_get_slctd_day(),
|
||||
struct day_items_nb inday =
|
||||
day_process_storage(ui_calendar_get_slctd_day(),
|
||||
day_changed);
|
||||
|
||||
if (day_changed) {
|
||||
@ -74,7 +75,8 @@ static inline void key_generic_change_view(void)
|
||||
ui_todo_hilt_set(1);
|
||||
break;
|
||||
case APP:
|
||||
if ((ui_day_hilt() == 0) && ((inday.nb_events + inday.nb_apoints) > 0))
|
||||
if ((ui_day_hilt() == 0)
|
||||
&& ((inday.nb_events + inday.nb_apoints) > 0))
|
||||
ui_day_hilt_set(1);
|
||||
break;
|
||||
default:
|
||||
@ -112,7 +114,8 @@ static inline void key_view_item(void)
|
||||
if ((wins_slctd() == APP) && (ui_day_hilt() != 0))
|
||||
day_popup_item(day_get_item(ui_day_hilt()));
|
||||
else if ((wins_slctd() == TOD) && (ui_todo_hilt() != 0))
|
||||
item_in_popup(NULL, NULL, ui_todo_saved_mesg(), _("To do :"));
|
||||
item_in_popup(NULL, NULL, ui_todo_saved_mesg(),
|
||||
_("To do :"));
|
||||
wins_update(FLAG_ALL);
|
||||
}
|
||||
|
||||
@ -173,7 +176,8 @@ static inline void key_edit_item(void)
|
||||
static inline void key_del_item(void)
|
||||
{
|
||||
if (wins_slctd() == APP && ui_day_hilt() != 0) {
|
||||
ui_day_item_delete(&inday.nb_events, &inday.nb_apoints, reg);
|
||||
ui_day_item_delete(&inday.nb_events, &inday.nb_apoints,
|
||||
reg);
|
||||
inday = do_storage(0);
|
||||
wins_update(FLAG_CAL | FLAG_APP | FLAG_STA);
|
||||
} else if (wins_slctd() == TOD && ui_todo_hilt() != 0) {
|
||||
@ -194,7 +198,8 @@ static inline void key_generic_copy(void)
|
||||
static inline void key_generic_paste(void)
|
||||
{
|
||||
if (wins_slctd() == APP) {
|
||||
ui_day_item_paste(&inday.nb_events, &inday.nb_apoints, reg);
|
||||
ui_day_item_paste(&inday.nb_events, &inday.nb_apoints,
|
||||
reg);
|
||||
inday = do_storage(0);
|
||||
wins_update(FLAG_CAL | FLAG_APP);
|
||||
}
|
||||
@ -301,7 +306,8 @@ static inline void key_generic_export()
|
||||
|
||||
wins_erase_status_bar();
|
||||
|
||||
switch (status_ask_choice(export_msg, export_choices, nb_export_choices)) {
|
||||
switch (status_ask_choice
|
||||
(export_msg, export_choices, nb_export_choices)) {
|
||||
case 1:
|
||||
io_export_data(IO_EXPORT_ICAL);
|
||||
break;
|
||||
@ -381,8 +387,11 @@ static inline void key_move_down(void)
|
||||
if (wins_slctd() == CAL) {
|
||||
key_generic_next_week();
|
||||
} else if (wins_slctd() == APP) {
|
||||
if (count > inday.nb_events + inday.nb_apoints - ui_day_hilt())
|
||||
count = inday.nb_events + inday.nb_apoints - ui_day_hilt();
|
||||
if (count >
|
||||
inday.nb_events + inday.nb_apoints - ui_day_hilt())
|
||||
count =
|
||||
inday.nb_events + inday.nb_apoints -
|
||||
ui_day_hilt();
|
||||
ui_day_hilt_increase(count);
|
||||
ui_day_scroll_pad_down(inday.nb_events, win[APP].h);
|
||||
wins_update(FLAG_APP);
|
||||
@ -391,7 +400,8 @@ static inline void key_move_down(void)
|
||||
count = ui_todo_nb() - ui_todo_hilt();
|
||||
ui_todo_hilt_increase(count);
|
||||
if (ui_todo_hilt_pos() >= win[TOD].h - 4)
|
||||
ui_todo_first_increase(ui_todo_hilt_pos() - win[TOD].h + 5);
|
||||
ui_todo_first_increase(ui_todo_hilt_pos() -
|
||||
win[TOD].h + 5);
|
||||
wins_update(FLAG_TOD);
|
||||
}
|
||||
}
|
||||
@ -466,7 +476,8 @@ static inline void key_generic_quit(void)
|
||||
note_gc();
|
||||
|
||||
if (conf.confirm_quit) {
|
||||
if (status_ask_bool(_("Do you really want to quit ?")) == 1) {
|
||||
if (status_ask_bool(_("Do you really want to quit ?")) ==
|
||||
1) {
|
||||
exit_calcurse(EXIT_SUCCESS);
|
||||
} else {
|
||||
wins_erase_status_bar();
|
||||
|
@ -890,8 +890,10 @@ void recur_event_write(struct recur_event *, FILE *);
|
||||
void recur_save_data(FILE *);
|
||||
unsigned recur_item_find_occurrence(long, long, llist_t *, int,
|
||||
int, long, long, unsigned *);
|
||||
unsigned recur_apoint_find_occurrence(struct recur_apoint *, long, unsigned *);
|
||||
unsigned recur_event_find_occurrence(struct recur_event *, long, unsigned *);
|
||||
unsigned recur_apoint_find_occurrence(struct recur_apoint *, long,
|
||||
unsigned *);
|
||||
unsigned recur_event_find_occurrence(struct recur_event *, long,
|
||||
unsigned *);
|
||||
unsigned recur_item_inday(long, long, llist_t *, int, int, long, long);
|
||||
unsigned recur_apoint_inday(struct recur_apoint *, long *);
|
||||
unsigned recur_event_inday(struct recur_event *, long *);
|
||||
@ -900,7 +902,8 @@ void recur_apoint_add_exc(struct recur_apoint *, long);
|
||||
void recur_event_erase(struct recur_event *);
|
||||
void recur_apoint_erase(struct recur_apoint *);
|
||||
void recur_exc_scan(llist_t *, FILE *);
|
||||
struct notify_app *recur_apoint_check_next(struct notify_app *, long, long);
|
||||
struct notify_app *recur_apoint_check_next(struct notify_app *, long,
|
||||
long);
|
||||
void recur_apoint_switch_notify(struct recur_apoint *);
|
||||
void recur_event_paste_item(struct recur_event *, long);
|
||||
void recur_apoint_paste_item(struct recur_apoint *, long);
|
||||
@ -975,7 +978,8 @@ void print_bool_option_incolor(WINDOW *, unsigned, int, int);
|
||||
const char *get_tempdir(void);
|
||||
char *new_tempfile(const char *, int);
|
||||
int check_date(unsigned, unsigned, unsigned);
|
||||
int parse_date(const char *, enum datefmt, int *, int *, int *, struct date *);
|
||||
int parse_date(const char *, enum datefmt, int *, int *, int *,
|
||||
struct date *);
|
||||
int check_time(unsigned, unsigned);
|
||||
int parse_time(const char *, unsigned *, unsigned *);
|
||||
int parse_duration(const char *, unsigned *);
|
||||
@ -987,7 +991,8 @@ int child_wait(int *, int *, int);
|
||||
void press_any_key(void);
|
||||
void print_apoint(const char *, long, struct apoint *);
|
||||
void print_event(const char *, long, struct event *);
|
||||
void print_recur_apoint(const char *, long, unsigned, struct recur_apoint *);
|
||||
void print_recur_apoint(const char *, long, unsigned,
|
||||
struct recur_apoint *);
|
||||
void print_recur_event(const char *, long, struct recur_event *);
|
||||
void print_todo(const char *, struct todo *);
|
||||
|
||||
|
60
src/config.c
60
src/config.c
@ -84,31 +84,24 @@ static int config_serialize_input_datefmt(char *, void *);
|
||||
(config_fn_serialize_t) config_serialize_str, &(var)
|
||||
|
||||
static const struct confvar confmap[] = {
|
||||
{"appearance.calendarview", config_parse_calendar_view,
|
||||
config_serialize_calendar_view, NULL},
|
||||
{"appearance.calendarview", config_parse_calendar_view, config_serialize_calendar_view, NULL},
|
||||
{"appearance.compactpanels", CONFIG_HANDLER_BOOL(conf.compact_panels)},
|
||||
{"appearance.defaultpanel", config_parse_default_panel,
|
||||
config_serialize_default_panel, NULL},
|
||||
{"appearance.defaultpanel", config_parse_default_panel, config_serialize_default_panel, NULL},
|
||||
{"appearance.layout", config_parse_layout, config_serialize_layout, NULL},
|
||||
{"appearance.notifybar", CONFIG_HANDLER_BOOL(nbar.show)},
|
||||
{"appearance.sidebarwidth", config_parse_sidebar_width,
|
||||
config_serialize_sidebar_width, NULL},
|
||||
{"appearance.theme", config_parse_color_theme, config_serialize_color_theme,
|
||||
NULL},
|
||||
{"appearance.sidebarwidth", config_parse_sidebar_width, config_serialize_sidebar_width, NULL},
|
||||
{"appearance.theme", config_parse_color_theme, config_serialize_color_theme, NULL},
|
||||
{"daemon.enable", CONFIG_HANDLER_BOOL(dmon.enable)},
|
||||
{"daemon.log", CONFIG_HANDLER_BOOL(dmon.log)},
|
||||
{"format.inputdate", config_parse_input_datefmt,
|
||||
config_serialize_input_datefmt, NULL},
|
||||
{"format.inputdate", config_parse_input_datefmt, config_serialize_input_datefmt, NULL},
|
||||
{"format.notifydate", CONFIG_HANDLER_STR(nbar.datefmt)},
|
||||
{"format.notifytime", CONFIG_HANDLER_STR(nbar.timefmt)},
|
||||
{"format.outputdate", config_parse_output_datefmt,
|
||||
config_serialize_output_datefmt, NULL},
|
||||
{"format.outputdate", config_parse_output_datefmt, config_serialize_output_datefmt, NULL},
|
||||
{"general.autogc", CONFIG_HANDLER_BOOL(conf.auto_gc)},
|
||||
{"general.autosave", CONFIG_HANDLER_BOOL(conf.auto_save)},
|
||||
{"general.confirmdelete", CONFIG_HANDLER_BOOL(conf.confirm_delete)},
|
||||
{"general.confirmquit", CONFIG_HANDLER_BOOL(conf.confirm_quit)},
|
||||
{"general.firstdayofweek", config_parse_first_day_of_week,
|
||||
config_serialize_first_day_of_week, NULL},
|
||||
{"general.firstdayofweek", config_parse_first_day_of_week, config_serialize_first_day_of_week, NULL},
|
||||
{"general.periodicsave", CONFIG_HANDLER_UNSIGNED(conf.periodic_save)},
|
||||
{"general.progressbar", CONFIG_HANDLER_BOOL(conf.progress_bar)},
|
||||
{"general.systemdialogs", CONFIG_HANDLER_BOOL(conf.system_dialogs)},
|
||||
@ -149,7 +142,8 @@ static int config_parse_unsigned(unsigned *dest, const char *val)
|
||||
|
||||
static int config_parse_int(int *dest, const char *val)
|
||||
{
|
||||
if ((*val == '+' || *val == '-' || isdigit(*val)) && is_all_digit(val + 1))
|
||||
if ((*val == '+' || *val == '-' || isdigit(*val))
|
||||
&& is_all_digit(val + 1))
|
||||
*dest = atoi(val);
|
||||
else
|
||||
return 0;
|
||||
@ -196,7 +190,8 @@ static int config_parse_color_pair(int *dest1, int *dest2, const char *val)
|
||||
if (sscanf(val, "%s on %s", s1, s2) != 2)
|
||||
return 0;
|
||||
|
||||
return (config_parse_color(dest1, s1) && config_parse_color(dest2, s2));
|
||||
return (config_parse_color(dest1, s1)
|
||||
&& config_parse_color(dest2, s2));
|
||||
}
|
||||
|
||||
static int config_parse_calendar_view(void *dummy, const char *val)
|
||||
@ -272,7 +267,8 @@ static int config_parse_output_datefmt(void *dummy, const char *val)
|
||||
static int config_parse_input_datefmt(void *dummy, const char *val)
|
||||
{
|
||||
if (config_parse_int(&conf.input_datefmt, val)) {
|
||||
if (conf.input_datefmt <= 0 || conf.input_datefmt > DATE_FORMATS)
|
||||
if (conf.input_datefmt <= 0
|
||||
|| conf.input_datefmt > DATE_FORMATS)
|
||||
conf.input_datefmt = 1;
|
||||
return 1;
|
||||
} else {
|
||||
@ -290,7 +286,8 @@ static int config_set_conf(const char *key, const char *value)
|
||||
|
||||
for (i = 0; i < sizeof(confmap) / sizeof(confmap[0]); i++) {
|
||||
if (!strcmp(confmap[i].key, key))
|
||||
return confmap[i].fn_parse(confmap[i].target, value);
|
||||
return confmap[i].fn_parse(confmap[i].target,
|
||||
value);
|
||||
}
|
||||
|
||||
return -1;
|
||||
@ -365,7 +362,8 @@ static void config_color_theme_name(char *theme_name)
|
||||
} else {
|
||||
pair_content(COLR_CUSTOM, &color[0], &color[1]);
|
||||
for (i = 0; i < NBCOLORS; i++) {
|
||||
if ((color[i] == DEFAULTCOLOR) || (color[i] == DEFAULTCOLOR_EXT)) {
|
||||
if ((color[i] == DEFAULTCOLOR)
|
||||
|| (color[i] == DEFAULTCOLOR_EXT)) {
|
||||
color_name[i] = default_color;
|
||||
} else if (color[i] >= 0 && color[i] <= MAXCOLORS) {
|
||||
color_name[i] = name[color[i]];
|
||||
@ -374,7 +372,8 @@ static void config_color_theme_name(char *theme_name)
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
snprintf(theme_name, BUFSIZ, "%s on %s", color_name[0], color_name[1]);
|
||||
snprintf(theme_name, BUFSIZ, "%s on %s", color_name[0],
|
||||
color_name[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,7 +449,8 @@ config_serialize_conf(char *buf, const char *key,
|
||||
|
||||
for (i = 0; i < sizeof(confmap) / sizeof(confmap[0]); i++) {
|
||||
if (!strcmp(confmap[i].key, key)) {
|
||||
if (confmap[i].fn_serialize(buf, confmap[i].target)) {
|
||||
if (confmap[i].
|
||||
fn_serialize(buf, confmap[i].target)) {
|
||||
if (status)
|
||||
status->done[i] = 1;
|
||||
return 1;
|
||||
@ -492,7 +492,8 @@ config_file_walk(config_fn_walk_cb_t fn_cb,
|
||||
*value = '\0';
|
||||
value++;
|
||||
} else {
|
||||
EXIT(_("invalid configuration directive: \"%s\""), e_conf);
|
||||
EXIT(_("invalid configuration directive: \"%s\""),
|
||||
e_conf);
|
||||
}
|
||||
|
||||
if (strcmp(key, "auto_save") == 0 ||
|
||||
@ -543,7 +544,8 @@ static int config_load_cb(const char *key, const char *value, void *dummy)
|
||||
EXIT(_("configuration variable unknown: \"%s\""), key);
|
||||
/* NOTREACHED */
|
||||
} else if (result == 0) {
|
||||
EXIT(_("wrong configuration variable format for \"%s\""), key);
|
||||
EXIT(_("wrong configuration variable format for \"%s\""),
|
||||
key);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
@ -560,13 +562,15 @@ static int config_save_cb(const char *key, const char *value, void *status)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int result =
|
||||
config_serialize_conf(buf, key, (struct config_save_status *)status);
|
||||
config_serialize_conf(buf, key,
|
||||
(struct config_save_status *)status);
|
||||
|
||||
if (result < 0) {
|
||||
EXIT(_("configuration variable unknown: \"%s\""), key);
|
||||
/* NOTREACHED */
|
||||
} else if (result == 0) {
|
||||
EXIT(_("wrong configuration variable format for \"%s\""), key);
|
||||
EXIT(_("wrong configuration variable format for \"%s\""),
|
||||
key);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
@ -596,7 +600,8 @@ unsigned config_save(void)
|
||||
return 1;
|
||||
|
||||
strncpy(tmppath, get_tempdir(), BUFSIZ);
|
||||
strncat(tmppath, "/" CONF_PATH_NAME ".", BUFSIZ - strlen(tmppath) - 1);
|
||||
strncat(tmppath, "/" CONF_PATH_NAME ".",
|
||||
BUFSIZ - strlen(tmppath) - 1);
|
||||
if ((tmpext = new_tempfile(tmppath, TMPEXTSIZ)) == NULL)
|
||||
return 0;
|
||||
strncat(tmppath, tmpext, BUFSIZ - strlen(tmppath) - 1);
|
||||
@ -608,7 +613,8 @@ unsigned config_save(void)
|
||||
|
||||
memset(status.done, 0, sizeof(status.done));
|
||||
|
||||
config_file_walk(config_save_cb, config_save_junk_cb, (void *)&status);
|
||||
config_file_walk(config_save_cb, config_save_junk_cb,
|
||||
(void *)&status);
|
||||
|
||||
/* Set variables that were missing from the configuration file. */
|
||||
for (i = 0; i < sizeof(confmap) / sizeof(confmap[0]); i++) {
|
||||
|
179
src/custom.c
179
src/custom.c
@ -145,7 +145,8 @@ static void layout_selection_bar(void)
|
||||
#define LAYOUTSPERCOL 2
|
||||
|
||||
/* Used to display available layouts in layout configuration menu. */
|
||||
static void display_layout_config(struct window *lwin, int mark, int cursor)
|
||||
static void display_layout_config(struct window *lwin, int mark,
|
||||
int cursor)
|
||||
{
|
||||
#define CURSOR (32 | A_REVERSE)
|
||||
#define MARK 88
|
||||
@ -163,22 +164,19 @@ static void display_layout_config(struct window *lwin, int mark, int cursor)
|
||||
enum { YPOS, XPOS, NBPOS };
|
||||
int pos[NBLAYOUTS][NBPOS];
|
||||
const char *layouts[LAYOUTH][NBLAYOUTS] = {
|
||||
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+",
|
||||
"+---+---+", "+---+---+", "+---+---+"},
|
||||
{"| | c |", "| | t |", "| c | |", "| t | |", "| | c |",
|
||||
"| | a |", "| c | |", "| a | |"},
|
||||
{"| a +---+", "| a +---+", "+---+ a |", "|---+ a |", "| t +---+",
|
||||
"| t +---+", "+---+ t |", "+---+ t |"},
|
||||
{"| | t |", "| | c |", "| t | |", "| c | |", "| | a |",
|
||||
"| | c |", "| a | |", "| c | |"},
|
||||
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+",
|
||||
"+---+---+", "+---+---+", "+---+---+"}
|
||||
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+"},
|
||||
{"| | c |", "| | t |", "| c | |", "| t | |", "| | c |", "| | a |", "| c | |", "| a | |"},
|
||||
{"| a +---+", "| a +---+", "+---+ a |", "|---+ a |", "| t +---+", "| t +---+", "+---+ t |", "+---+ t |"},
|
||||
{"| | t |", "| | c |", "| t | |", "| c | |", "| | a |", "| | c |", "| a | |", "| c | |"},
|
||||
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+"}
|
||||
};
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NBLAYOUTS; i++) {
|
||||
pos[i][YPOS] = YOFST + (i % LAYOUTSPERCOL) * (YSPC + LAYOUTH);
|
||||
pos[i][XPOS] = XOFST + (i / LAYOUTSPERCOL) * (XSPC + COLSIZ);
|
||||
pos[i][YPOS] =
|
||||
YOFST + (i % LAYOUTSPERCOL) * (YSPC + LAYOUTH);
|
||||
pos[i][XPOS] =
|
||||
XOFST + (i / LAYOUTSPERCOL) * (XSPC + COLSIZ);
|
||||
}
|
||||
|
||||
for (i = 0; i < NBLAYOUTS; i++) {
|
||||
@ -188,14 +186,16 @@ static void display_layout_config(struct window *lwin, int mark, int cursor)
|
||||
if (i == mark)
|
||||
custom_apply_attr(lwin->p, ATTR_HIGHEST);
|
||||
for (j = 0; j < LAYOUTH; j++) {
|
||||
mvwaddstr(lwin->p, pos[i][YPOS] + j, pos[i][XPOS] + BOXSIZ + 1,
|
||||
mvwaddstr(lwin->p, pos[i][YPOS] + j,
|
||||
pos[i][XPOS] + BOXSIZ + 1,
|
||||
layouts[j][i]);
|
||||
}
|
||||
if (i == mark)
|
||||
custom_remove_attr(lwin->p, ATTR_HIGHEST);
|
||||
}
|
||||
mvwaddch(lwin->p, pos[mark][YPOS] + 2, pos[mark][XPOS] + 1, MARK);
|
||||
mvwaddch(lwin->p, pos[cursor][YPOS] + 2, pos[cursor][XPOS] + 1, CURSOR);
|
||||
mvwaddch(lwin->p, pos[cursor][YPOS] + 2, pos[cursor][XPOS] + 1,
|
||||
CURSOR);
|
||||
|
||||
layout_selection_bar();
|
||||
wnoutrefresh(win[STA].p);
|
||||
@ -218,7 +218,8 @@ void custom_layout_config(void)
|
||||
"It is possible to choose between eight different configurations.\n"
|
||||
"\nIn the configuration representations, letters correspond to:\n\n"
|
||||
" 'c' -> calendar panel\n\n"
|
||||
" 'a' -> appointment panel\n\n" " 't' -> todo panel\n\n");
|
||||
" 'a' -> appointment panel\n\n"
|
||||
" 't' -> todo panel\n\n");
|
||||
|
||||
conf_win.p = NULL;
|
||||
custom_confwin_init(&conf_win, label);
|
||||
@ -226,12 +227,16 @@ void custom_layout_config(void)
|
||||
display_layout_config(&conf_win, mark, cursor);
|
||||
clear();
|
||||
|
||||
while ((ch = keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
|
||||
while ((ch =
|
||||
keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
|
||||
need_reset = 0;
|
||||
switch (ch) {
|
||||
case KEY_GENERIC_HELP:
|
||||
help_wins_init(&hwin, 0, 0, (notify_bar())? row - 3 : row - 2, col);
|
||||
mvwprintw(hwin.pad.p, 1, 0, help_text, SBARMINWIDTH);
|
||||
help_wins_init(&hwin, 0, 0,
|
||||
(notify_bar())? row - 3 : row - 2,
|
||||
col);
|
||||
mvwprintw(hwin.pad.p, 1, 0, help_text,
|
||||
SBARMINWIDTH);
|
||||
hwin.total_lines = 7;
|
||||
wins_scrollwin_display(&hwin);
|
||||
wgetch(hwin.win.p);
|
||||
@ -294,8 +299,7 @@ void custom_sidebar_config(void)
|
||||
&inc, &dec, &help, &quit
|
||||
};
|
||||
const char *help_text =
|
||||
_
|
||||
("This configuration screen is used to change the width of the side bar.\n"
|
||||
_("This configuration screen is used to change the width of the side bar.\n"
|
||||
"The side bar is the part of the screen which contains two panels:\n"
|
||||
"the calendar and, depending on the chosen layout, either the todo list\n"
|
||||
"or the appointment list.\n\n"
|
||||
@ -309,7 +313,8 @@ void custom_sidebar_config(void)
|
||||
bindings_size, NULL);
|
||||
wins_doupdate();
|
||||
|
||||
while ((ch = keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
|
||||
while ((ch =
|
||||
keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
|
||||
switch (ch) {
|
||||
case KEY_MOVE_UP:
|
||||
wins_sbar_winc();
|
||||
@ -318,7 +323,9 @@ void custom_sidebar_config(void)
|
||||
wins_sbar_wdec();
|
||||
break;
|
||||
case KEY_GENERIC_HELP:
|
||||
help_wins_init(&hwin, 0, 0, (notify_bar())? row - 3 : row - 2, col);
|
||||
help_wins_init(&hwin, 0, 0,
|
||||
(notify_bar())? row - 3 : row - 2,
|
||||
col);
|
||||
mvwaddstr(hwin.pad.p, 1, 0, help_text);
|
||||
hwin.total_lines = 6;
|
||||
wins_scrollwin_display(&hwin);
|
||||
@ -338,7 +345,8 @@ void custom_sidebar_config(void)
|
||||
wins_reinit_panels();
|
||||
wins_update_border(FLAG_ALL);
|
||||
wins_update_panels(FLAG_ALL);
|
||||
keys_display_bindings_bar(win[STA].p, bindings, bindings_size, 0,
|
||||
keys_display_bindings_bar(win[STA].p, bindings,
|
||||
bindings_size, 0,
|
||||
bindings_size, NULL);
|
||||
wins_doupdate();
|
||||
}
|
||||
@ -360,7 +368,8 @@ void custom_confwin_init(struct window *confwin, const char *label)
|
||||
{
|
||||
if (confwin->p) {
|
||||
erase_window_part(confwin->p, confwin->x, confwin->y,
|
||||
confwin->x + confwin->w, confwin->y + confwin->h);
|
||||
confwin->x + confwin->w,
|
||||
confwin->y + confwin->h);
|
||||
delwin(confwin->p);
|
||||
}
|
||||
|
||||
@ -370,7 +379,8 @@ void custom_confwin_init(struct window *confwin, const char *label)
|
||||
box(confwin->p, 0, 0);
|
||||
wins_show(confwin->p, label);
|
||||
delwin(win[STA].p);
|
||||
win[STA].p = newwin(win[STA].h, win[STA].w, win[STA].y, win[STA].x);
|
||||
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();
|
||||
@ -455,7 +465,8 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
|
||||
/* Retrieve the actual color theme. */
|
||||
pair_content(COLR_CUSTOM, &colr_fore, &colr_back);
|
||||
|
||||
if ((colr_fore == DEFAULTCOLOR) || (colr_fore == DEFAULTCOLOR_EXT)) {
|
||||
if ((colr_fore == DEFAULTCOLOR)
|
||||
|| (colr_fore == DEFAULTCOLOR_EXT)) {
|
||||
*mark_fore = NBUSERCOLORS;
|
||||
} else {
|
||||
for (i = 0; i < NBUSERCOLORS + 1; i++)
|
||||
@ -463,12 +474,15 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
|
||||
*mark_fore = i;
|
||||
}
|
||||
|
||||
if ((colr_back == DEFAULTCOLOR) || (colr_back == DEFAULTCOLOR_EXT)) {
|
||||
if ((colr_back == DEFAULTCOLOR)
|
||||
|| (colr_back == DEFAULTCOLOR_EXT)) {
|
||||
*mark_back = SIZE - 1;
|
||||
} else {
|
||||
for (i = 0; i < NBUSERCOLORS + 1; i++)
|
||||
if (colr_back == colr[NBUSERCOLORS + 1 + i])
|
||||
*mark_back = NBUSERCOLORS + 1 + i;
|
||||
if (colr_back ==
|
||||
colr[NBUSERCOLORS + 1 + i])
|
||||
*mark_back =
|
||||
NBUSERCOLORS + 1 + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -477,7 +491,8 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
|
||||
for (i = 0; i < SIZE - 1; i++) {
|
||||
mvwaddstr(cwin->p, pos[i][YPOS], pos[i][XPOS], box);
|
||||
wattron(cwin->p, COLOR_PAIR(colr[i]) | A_REVERSE);
|
||||
mvwaddstr(cwin->p, pos[i][YPOS], pos[i][XPOS] + XOFST, bar);
|
||||
mvwaddstr(cwin->p, pos[i][YPOS], pos[i][XPOS] + XOFST,
|
||||
bar);
|
||||
wattroff(cwin->p, COLOR_PAIR(colr[i]) | A_REVERSE);
|
||||
}
|
||||
|
||||
@ -498,11 +513,14 @@ display_color_config(struct window *cwin, int *mark_fore, int *mark_back,
|
||||
custom_remove_attr(cwin->p, ATTR_HIGHEST);
|
||||
|
||||
if (colorize) {
|
||||
mvwaddch(cwin->p, pos[*mark_fore][YPOS], pos[*mark_fore][XPOS] + 1, MARK);
|
||||
mvwaddch(cwin->p, pos[*mark_back][YPOS], pos[*mark_back][XPOS] + 1, MARK);
|
||||
mvwaddch(cwin->p, pos[*mark_fore][YPOS],
|
||||
pos[*mark_fore][XPOS] + 1, MARK);
|
||||
mvwaddch(cwin->p, pos[*mark_back][YPOS],
|
||||
pos[*mark_back][XPOS] + 1, MARK);
|
||||
}
|
||||
|
||||
mvwaddch(cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR);
|
||||
mvwaddch(cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1,
|
||||
CURSOR);
|
||||
color_selection_bar();
|
||||
wnoutrefresh(win[STA].p);
|
||||
wnoutrefresh(cwin->p);
|
||||
@ -529,7 +547,8 @@ void custom_color_config(void)
|
||||
theme_changed);
|
||||
clear();
|
||||
|
||||
while ((ch = keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
|
||||
while ((ch =
|
||||
keys_getch(win[KEY].p, NULL, NULL)) != KEY_GENERIC_QUIT) {
|
||||
need_reset = 0;
|
||||
theme_changed = 0;
|
||||
|
||||
@ -581,8 +600,8 @@ void custom_color_config(void)
|
||||
if (need_reset)
|
||||
custom_confwin_init(&conf_win, label);
|
||||
|
||||
display_color_config(&conf_win, &mark_fore, &mark_back, cursor,
|
||||
theme_changed);
|
||||
display_color_config(&conf_win, &mark_fore, &mark_back,
|
||||
cursor, theme_changed);
|
||||
}
|
||||
delwin(conf_win.p);
|
||||
}
|
||||
@ -629,7 +648,8 @@ static int print_general_options(WINDOW * win)
|
||||
mvwprintw(win, y, XPOS, "[2] %s ", opt[AUTO_GC]);
|
||||
print_bool_option_incolor(win, conf.auto_gc, y,
|
||||
XPOS + 4 + strlen(opt[AUTO_GC]));
|
||||
mvwaddstr(win, y + 1, XPOS, _("(run the garbage collector when quitting)"));
|
||||
mvwaddstr(win, y + 1, XPOS,
|
||||
_("(run the garbage collector when quitting)"));
|
||||
y += YOFF;
|
||||
mvwprintw(win, y, XPOS, "[3] %s ", opt[PERIODIC_SAVE]);
|
||||
custom_apply_attr(win, ATTR_HIGHEST);
|
||||
@ -670,7 +690,8 @@ static int print_general_options(WINDOW * win)
|
||||
mvwprintw(win, y, XPOS, "[8] %s ", opt[FIRST_DAY_OF_WEEK]);
|
||||
custom_apply_attr(win, ATTR_HIGHEST);
|
||||
mvwaddstr(win, y, XPOS + 4 + strlen(opt[FIRST_DAY_OF_WEEK]),
|
||||
ui_calendar_week_begins_on_monday()? _("Monday") : _("Sunday"));
|
||||
ui_calendar_week_begins_on_monday()? _("Monday") :
|
||||
_("Sunday"));
|
||||
custom_remove_attr(win, ATTR_HIGHEST);
|
||||
mvwaddstr(win, y + 1, XPOS,
|
||||
_("(specifies the first day of week in the calendar view)"));
|
||||
@ -688,9 +709,11 @@ static int print_general_options(WINDOW * win)
|
||||
mvwprintw(win, y, XPOS + 4 + strlen(opt[INPUT_DATE_FMT]), "%d",
|
||||
conf.input_datefmt);
|
||||
custom_remove_attr(win, ATTR_HIGHEST);
|
||||
mvwaddstr(win, y + 1, XPOS, _("(Format to be used when entering a date: "));
|
||||
mvwaddstr(win, y + 1, XPOS,
|
||||
_("(Format to be used when entering a date: "));
|
||||
mvwprintw(win, y + 2, XPOS, " (1) %s, (2) %s, (3) %s, (4) %s)",
|
||||
datefmt_str[0], datefmt_str[1], datefmt_str[2], datefmt_str[3]);
|
||||
datefmt_str[0], datefmt_str[1], datefmt_str[2],
|
||||
datefmt_str[3]);
|
||||
|
||||
return y + YOFF;
|
||||
}
|
||||
@ -712,8 +735,10 @@ void custom_set_swsiz(struct scrollwin *sw)
|
||||
void custom_general_config(void)
|
||||
{
|
||||
struct scrollwin cwin;
|
||||
const char *number_str = _("Enter an option number to change its value");
|
||||
const char *keys = _("(Press '^P' or '^N' to move up or down, 'Q' to quit)");
|
||||
const char *number_str =
|
||||
_("Enter an option number to change its value");
|
||||
const char *keys =
|
||||
_("(Press '^P' or '^N' to move up or down, 'Q' to quit)");
|
||||
const char *output_datefmt_str =
|
||||
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
|
||||
const char *input_datefmt_prefix = _("Enter the date format: ");
|
||||
@ -779,15 +804,18 @@ void custom_general_config(void)
|
||||
break;
|
||||
case '9':
|
||||
status_mesg(output_datefmt_str, "");
|
||||
strncpy(buf, conf.output_datefmt, strlen(conf.output_datefmt) + 1);
|
||||
strncpy(buf, conf.output_datefmt,
|
||||
strlen(conf.output_datefmt) + 1);
|
||||
if (updatestring(win[STA].p, &buf, 0, 1) == 0) {
|
||||
strncpy(conf.output_datefmt, buf, strlen(buf) + 1);
|
||||
strncpy(conf.output_datefmt, buf,
|
||||
strlen(buf) + 1);
|
||||
}
|
||||
status_mesg(number_str, keys);
|
||||
break;
|
||||
case '0':
|
||||
val = status_ask_simplechoice(input_datefmt_prefix,
|
||||
datefmt_str, DATE_FORMATS);
|
||||
datefmt_str,
|
||||
DATE_FORMATS);
|
||||
if (val != -1)
|
||||
conf.input_datefmt = val;
|
||||
break;
|
||||
@ -802,7 +830,9 @@ void custom_general_config(void)
|
||||
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);
|
||||
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();
|
||||
@ -830,7 +860,8 @@ print_key_incolor(WINDOW * win, const char *option, int pos_y, int pos_x)
|
||||
}
|
||||
|
||||
static int
|
||||
print_keys_bindings(WINDOW * win, int selected_row, int selected_elm, int yoff)
|
||||
print_keys_bindings(WINDOW * win, int selected_row, int selected_elm,
|
||||
int yoff)
|
||||
{
|
||||
const int XPOS = 1;
|
||||
const int EQUALPOS = 23;
|
||||
@ -858,16 +889,21 @@ print_keys_bindings(WINDOW * win, int selected_row, int selected_elm, int yoff)
|
||||
int pos;
|
||||
|
||||
pos = KEYPOS;
|
||||
while ((key = keys_action_nkey(action, noelm)) != NULL) {
|
||||
while ((key =
|
||||
keys_action_nkey(action,
|
||||
noelm)) != NULL) {
|
||||
if (noelm == selected_elm)
|
||||
print_key_incolor(win, key, y, pos);
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
mvwaddstr(win, y, KEYPOS, keys_action_allkeys(action));
|
||||
mvwaddstr(win, y, KEYPOS,
|
||||
keys_action_allkeys(action));
|
||||
}
|
||||
}
|
||||
y += yoff;
|
||||
@ -914,7 +950,8 @@ void custom_keys_config(void)
|
||||
wins_show(kwin.win.p, kwin.label);
|
||||
custom_keys_config_bar();
|
||||
selrow = selelm = 0;
|
||||
nbrowelm = print_keys_bindings(kwin.pad.p, selrow, selelm, LINESPERKEY);
|
||||
nbrowelm =
|
||||
print_keys_bindings(kwin.pad.p, selrow, selelm, LINESPERKEY);
|
||||
kwin.total_lines = NBKEYS * LINESPERKEY;
|
||||
wins_scrollwin_display(&kwin);
|
||||
firstrow = 0;
|
||||
@ -931,7 +968,8 @@ void custom_keys_config(void)
|
||||
if (selrow == firstrow) {
|
||||
firstrow--;
|
||||
lastrow--;
|
||||
wins_scrollwin_up(&kwin, LINESPERKEY);
|
||||
wins_scrollwin_up(&kwin,
|
||||
LINESPERKEY);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -942,7 +980,8 @@ void custom_keys_config(void)
|
||||
if (selrow == lastrow) {
|
||||
firstrow++;
|
||||
lastrow++;
|
||||
wins_scrollwin_down(&kwin, LINESPERKEY);
|
||||
wins_scrollwin_down(&kwin,
|
||||
LINESPERKEY);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -962,19 +1001,25 @@ void custom_keys_config(void)
|
||||
#define WINCOL 50
|
||||
do {
|
||||
used = 0;
|
||||
grabwin = popup(WINROW, WINCOL, (row - WINROW) / 2,
|
||||
grabwin =
|
||||
popup(WINROW, WINCOL,
|
||||
(row - WINROW) / 2,
|
||||
(col - WINCOL) / 2,
|
||||
_("Press the key you want to assign to:"),
|
||||
keys_get_label(selrow), 0);
|
||||
keyval = wgetch(grabwin);
|
||||
|
||||
/* First check if this key would be recognized by calcurse. */
|
||||
if (keys_str2int(keys_int2str(keyval)) == -1) {
|
||||
if (keys_str2int(keys_int2str(keyval)) ==
|
||||
-1) {
|
||||
not_recognized = 1;
|
||||
WARN_MSG(_("This key is not yet recognized by calcurse, "
|
||||
"please choose another one."));
|
||||
werase(kwin.pad.p);
|
||||
nbrowelm = print_keys_bindings(kwin.pad.p, selrow, selelm,
|
||||
nbrowelm =
|
||||
print_keys_bindings(kwin.pad.p,
|
||||
selrow,
|
||||
selelm,
|
||||
LINESPERKEY);
|
||||
wins_scrollwin_display(&kwin);
|
||||
continue;
|
||||
@ -994,9 +1039,13 @@ void custom_keys_config(void)
|
||||
|
||||
action = keys_get_action(keyval);
|
||||
WARN_MSG(_("This key is already in use for %s, "
|
||||
"please choose another one."), keys_get_label(action));
|
||||
"please choose another one."),
|
||||
keys_get_label(action));
|
||||
werase(kwin.pad.p);
|
||||
nbrowelm = print_keys_bindings(kwin.pad.p, selrow, selelm,
|
||||
nbrowelm =
|
||||
print_keys_bindings(kwin.pad.p,
|
||||
selrow,
|
||||
selelm,
|
||||
LINESPERKEY);
|
||||
wins_scrollwin_display(&kwin);
|
||||
}
|
||||
@ -1019,14 +1068,17 @@ void custom_keys_config(void)
|
||||
break;
|
||||
case KEY_GENERIC_QUIT:
|
||||
if (keys_check_missing_bindings() != 0) {
|
||||
WARN_MSG(_("Some actions do not have any associated " "key bindings!"));
|
||||
WARN_MSG(_("Some actions do not have any associated "
|
||||
"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);
|
||||
nbrowelm =
|
||||
print_keys_bindings(kwin.pad.p, selrow, selelm,
|
||||
LINESPERKEY);
|
||||
wins_scrollwin_display(&kwin);
|
||||
}
|
||||
}
|
||||
@ -1049,7 +1101,8 @@ void custom_config_main(void)
|
||||
} else {
|
||||
colorize = 0;
|
||||
wins_erase_status_bar();
|
||||
mvwaddstr(win[STA].p, 0, 0, no_color_support);
|
||||
mvwaddstr(win[STA].p, 0, 0,
|
||||
no_color_support);
|
||||
wgetch(win[KEY].p);
|
||||
}
|
||||
break;
|
||||
|
55
src/day.c
55
src/day.c
@ -75,7 +75,8 @@ static int day_cmp_start(struct day_item *a, struct day_item *b)
|
||||
} else if (b->type <= EVNT) {
|
||||
return 1;
|
||||
} else {
|
||||
return a->start < b->start ? -1 : (a->start == b->start ? 0 : 1);
|
||||
return a->start < b->start ? -1 : (a->start ==
|
||||
b->start ? 0 : 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +213,7 @@ void day_item_fork(struct day_item *day_in, struct day_item *day_out)
|
||||
* dedicated to the selected day.
|
||||
* Returns the number of events for the selected day.
|
||||
*/
|
||||
static int day_store_events(long date, regex_t *regex)
|
||||
static int day_store_events(long date, regex_t * regex)
|
||||
{
|
||||
llist_item_t *i;
|
||||
union aptev_ptr p;
|
||||
@ -239,7 +240,7 @@ static int day_store_events(long date, regex_t *regex)
|
||||
* dedicated to the selected day.
|
||||
* Returns the number of recurrent events for the selected day.
|
||||
*/
|
||||
static int day_store_recur_events(long date, regex_t *regex)
|
||||
static int day_store_recur_events(long date, regex_t * regex)
|
||||
{
|
||||
llist_item_t *i;
|
||||
union aptev_ptr p;
|
||||
@ -266,7 +267,7 @@ static int day_store_recur_events(long date, regex_t *regex)
|
||||
* structure dedicated to the selected day.
|
||||
* Returns the number of appointments for the selected day.
|
||||
*/
|
||||
static int day_store_apoints(long date, regex_t *regex)
|
||||
static int day_store_apoints(long date, regex_t * regex)
|
||||
{
|
||||
llist_item_t *i;
|
||||
union aptev_ptr p;
|
||||
@ -299,7 +300,7 @@ static int day_store_apoints(long date, regex_t *regex)
|
||||
* structure dedicated to the selected day.
|
||||
* Returns the number of recurrent appointments for the selected day.
|
||||
*/
|
||||
static int day_store_recur_apoints(long date, regex_t *regex)
|
||||
static int day_store_recur_apoints(long date, regex_t * regex)
|
||||
{
|
||||
llist_item_t *i;
|
||||
union aptev_ptr p;
|
||||
@ -335,7 +336,7 @@ static int day_store_recur_apoints(long date, regex_t *regex)
|
||||
*/
|
||||
int
|
||||
day_store_items(long date, unsigned *pnb_events, unsigned *pnb_apoints,
|
||||
regex_t *regex)
|
||||
regex_t * regex)
|
||||
{
|
||||
int nb_events, nb_recur_events;
|
||||
int nb_apoints, nb_recur_apoints;
|
||||
@ -395,7 +396,8 @@ struct day_items_nb day_process_storage(struct date *slctd_date,
|
||||
* Print an item date in the appointment panel.
|
||||
*/
|
||||
static void
|
||||
display_item_date(struct day_item *day, int incolor, long date, int y, int x)
|
||||
display_item_date(struct day_item *day, int incolor, long date, int y,
|
||||
int x)
|
||||
{
|
||||
WINDOW *win;
|
||||
char a_st[100], a_end[100];
|
||||
@ -443,7 +445,8 @@ display_item(struct day_item *day, int incolor, int width, int y, int x)
|
||||
char *mesg = day_item_get_mesg(day);
|
||||
|
||||
win = apad.ptrwin;
|
||||
ch_recur = (day->type == RECUR_EVNT || day->type == RECUR_APPT) ? '*' : ' ';
|
||||
ch_recur = (day->type == RECUR_EVNT
|
||||
|| day->type == RECUR_APPT) ? '*' : ' ';
|
||||
ch_note = day_item_get_note(day) ? '>' : ' ';
|
||||
if (incolor == 0)
|
||||
custom_apply_attr(win, ATTR_HIGHEST);
|
||||
@ -485,7 +488,8 @@ void day_write_pad(long date, int width, int length, int incolor)
|
||||
/* First print the events for current day. */
|
||||
if (day->type < RECUR_APPT) {
|
||||
item_number++;
|
||||
display_item(day, item_number - incolor, width - 7, line, x_pos);
|
||||
display_item(day, item_number - incolor, width - 7,
|
||||
line, x_pos);
|
||||
line++;
|
||||
draw_line = 1;
|
||||
} else {
|
||||
@ -497,8 +501,10 @@ void day_write_pad(long date, int width, int length, int incolor)
|
||||
}
|
||||
/* Last print the appointments for current day. */
|
||||
item_number++;
|
||||
display_item_date(day, item_number - incolor, date, line + 1, x_pos);
|
||||
display_item(day, item_number - incolor, width - 7, line + 2, x_pos);
|
||||
display_item_date(day, item_number - incolor, date,
|
||||
line + 1, x_pos);
|
||||
display_item(day, item_number - incolor, width - 7,
|
||||
line + 2, x_pos);
|
||||
line += 3;
|
||||
}
|
||||
}
|
||||
@ -521,7 +527,8 @@ void day_write_stdout(long date, const char *fmt_apt, const char *fmt_rapt,
|
||||
print_event(fmt_ev, date, day->item.ev);
|
||||
break;
|
||||
case RECUR_APPT:
|
||||
print_recur_apoint(fmt_rapt, date, day->start, day->item.rapt);
|
||||
print_recur_apoint(fmt_rapt, date, day->start,
|
||||
day->item.rapt);
|
||||
break;
|
||||
case RECUR_EVNT:
|
||||
print_recur_event(fmt_rev, date, day->item.rev);
|
||||
@ -537,7 +544,8 @@ void day_write_stdout(long date, const char *fmt_apt, const char *fmt_rapt,
|
||||
void day_popup_item(struct day_item *day)
|
||||
{
|
||||
if (day->type == EVNT || day->type == RECUR_EVNT) {
|
||||
item_in_popup(NULL, NULL, day_item_get_mesg(day), _("Event :"));
|
||||
item_in_popup(NULL, NULL, day_item_get_mesg(day),
|
||||
_("Event :"));
|
||||
} else if (day->type == APPT || day->type == RECUR_APPT) {
|
||||
char a_st[100], a_end[100];
|
||||
|
||||
@ -546,9 +554,11 @@ void day_popup_item(struct day_item *day)
|
||||
struct apoint apt_tmp;
|
||||
apt_tmp.start = day->start;
|
||||
apt_tmp.dur = day_item_get_duration(day);
|
||||
apoint_sec2str(&apt_tmp, ui_calendar_get_slctd_day_sec(), a_st, a_end);
|
||||
apoint_sec2str(&apt_tmp, ui_calendar_get_slctd_day_sec(),
|
||||
a_st, a_end);
|
||||
|
||||
item_in_popup(a_st, a_end, day_item_get_mesg(day), _("Appointment :"));
|
||||
item_in_popup(a_st, a_end, day_item_get_mesg(day),
|
||||
_("Appointment :"));
|
||||
} else {
|
||||
EXIT(_("unknown item type"));
|
||||
/* NOTREACHED */
|
||||
@ -563,11 +573,13 @@ int day_check_if_item(struct date day)
|
||||
{
|
||||
const long date = date2sec(day, 0, 0);
|
||||
|
||||
if (LLIST_FIND_FIRST(&recur_elist, (long *)&date, recur_event_inday))
|
||||
if (LLIST_FIND_FIRST
|
||||
(&recur_elist, (long *)&date, recur_event_inday))
|
||||
return 1;
|
||||
|
||||
LLIST_TS_LOCK(&recur_alist_p);
|
||||
if (LLIST_TS_FIND_FIRST(&recur_alist_p, (long *)&date, recur_apoint_inday)) {
|
||||
if (LLIST_TS_FIND_FIRST
|
||||
(&recur_alist_p, (long *)&date, recur_apoint_inday)) {
|
||||
LLIST_TS_UNLOCK(&recur_alist_p);
|
||||
return 1;
|
||||
}
|
||||
@ -618,7 +630,8 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
|
||||
#define SLICENUM(tsec) ((tsec) / slicelen % slicesno)
|
||||
|
||||
LLIST_TS_LOCK(&recur_alist_p);
|
||||
LLIST_TS_FIND_FOREACH(&recur_alist_p, (long *)&date, recur_apoint_inday, i) {
|
||||
LLIST_TS_FIND_FOREACH(&recur_alist_p, (long *)&date,
|
||||
recur_apoint_inday, i) {
|
||||
struct apoint *rapt = LLIST_TS_GET_DATA(i);
|
||||
long start = get_item_time(rapt->start);
|
||||
long end = get_item_time(rapt->start + rapt->dur);
|
||||
@ -628,7 +641,8 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
|
||||
if (rapt->start + rapt->dur >= date + DAYINSEC)
|
||||
end = DAYINSEC - 1;
|
||||
|
||||
if (!fill_slices(slices, slicesno, SLICENUM(start), SLICENUM(end))) {
|
||||
if (!fill_slices
|
||||
(slices, slicesno, SLICENUM(start), SLICENUM(end))) {
|
||||
LLIST_TS_UNLOCK(&recur_alist_p);
|
||||
return 0;
|
||||
}
|
||||
@ -648,7 +662,8 @@ unsigned day_chk_busy_slices(struct date day, int slicesno, int *slices)
|
||||
if (apt->start + apt->dur >= date + DAYINSEC)
|
||||
end = DAYINSEC - 1;
|
||||
|
||||
if (!fill_slices(slices, slicesno, SLICENUM(start), SLICENUM(end))) {
|
||||
if (!fill_slices
|
||||
(slices, slicesno, SLICENUM(start), SLICENUM(end))) {
|
||||
LLIST_TS_UNLOCK(&alist_p);
|
||||
return 0;
|
||||
}
|
||||
|
21
src/dmon.c
21
src/dmon.c
@ -72,7 +72,8 @@ static void dmon_sigs_hdlr(int sig)
|
||||
DMON_LOG(_("terminated at %s with signal %d\n"), nowstr(), sig);
|
||||
|
||||
if (unlink(path_dpid) != 0) {
|
||||
DMON_LOG(_("Could not remove daemon lock file: %s\n"), strerror(errno));
|
||||
DMON_LOG(_("Could not remove daemon lock file: %s\n"),
|
||||
strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@ -116,7 +117,8 @@ static unsigned daemonize(int status)
|
||||
* to prevent filesystem unmounts.
|
||||
*/
|
||||
if (chdir("/") == -1) {
|
||||
DMON_LOG(_("Could not change working directory: %s\n"), strerror(errno));
|
||||
DMON_LOG(_("Could not change working directory: %s\n"),
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -151,11 +153,13 @@ void dmon_start(int parent_exit_status)
|
||||
DMON_ABRT(_("Could not set lock file\n"));
|
||||
|
||||
if (!io_file_exist(path_conf))
|
||||
DMON_ABRT(_("Could not access \"%s\": %s\n"), path_conf, strerror(errno));
|
||||
DMON_ABRT(_("Could not access \"%s\": %s\n"), path_conf,
|
||||
strerror(errno));
|
||||
config_load();
|
||||
|
||||
if (!io_file_exist(path_apts))
|
||||
DMON_ABRT(_("Could not access \"%s\": %s\n"), path_apts, strerror(errno));
|
||||
DMON_ABRT(_("Could not access \"%s\": %s\n"), path_apts,
|
||||
strerror(errno));
|
||||
apoint_llist_init();
|
||||
recur_apoint_llist_init();
|
||||
event_llist_init();
|
||||
@ -171,7 +175,8 @@ void dmon_start(int parent_exit_status)
|
||||
DMON_ABRT(_("error loading next appointment\n"));
|
||||
|
||||
left = notify_time_left();
|
||||
if (left > 0 && left < nbar.cntdwn && notify_needs_reminder()) {
|
||||
if (left > 0 && left < nbar.cntdwn
|
||||
&& notify_needs_reminder()) {
|
||||
DMON_LOG(_("launching notification at %s for: \"%s\"\n"),
|
||||
nowstr(), notify_app_txt());
|
||||
if (!notify_launch_cmd())
|
||||
@ -180,7 +185,8 @@ void dmon_start(int parent_exit_status)
|
||||
|
||||
DMON_LOG(ngettext("sleeping at %s for %d second\n",
|
||||
"sleeping at %s for %d seconds\n",
|
||||
DMON_SLEEP_TIME), nowstr(), DMON_SLEEP_TIME);
|
||||
DMON_SLEEP_TIME), nowstr(),
|
||||
DMON_SLEEP_TIME);
|
||||
psleep(DMON_SLEEP_TIME);
|
||||
DMON_LOG(_("awakened at %s\n"), nowstr());
|
||||
}
|
||||
@ -199,5 +205,6 @@ void dmon_stop(void)
|
||||
return;
|
||||
|
||||
if (kill((pid_t) dpid, SIGINT) < 0 && errno != ESRCH)
|
||||
EXIT(_("Could not stop calcurse daemon: %s\n"), strerror(errno));
|
||||
EXIT(_("Could not stop calcurse daemon: %s\n"),
|
||||
strerror(errno));
|
||||
}
|
||||
|
@ -48,7 +48,8 @@ struct getstr_status {
|
||||
};
|
||||
|
||||
/* Print the string at the desired position. */
|
||||
static void getstr_print(WINDOW * win, int x, int y, struct getstr_status *st)
|
||||
static void getstr_print(WINDOW * win, int x, int y,
|
||||
struct getstr_status *st)
|
||||
{
|
||||
char c = 0;
|
||||
|
||||
@ -62,7 +63,8 @@ static void getstr_print(WINDOW * win, int x, int y, struct getstr_status *st)
|
||||
c = '*';
|
||||
else if (st->scrpos > 0)
|
||||
c = '<';
|
||||
else if (st->ci[st->len].dpyoff - st->ci[st->scrpos].dpyoff > col - 2)
|
||||
else if (st->ci[st->len].dpyoff - st->ci[st->scrpos].dpyoff >
|
||||
col - 2)
|
||||
c = '>';
|
||||
mvwprintw(win, y, col - 2, " %c", c);
|
||||
|
||||
@ -114,7 +116,8 @@ static void bell(void)
|
||||
|
||||
/* Initialize getstring data structure. */
|
||||
static void
|
||||
getstr_init(struct getstr_status *st, char *str, struct getstr_charinfo *ci)
|
||||
getstr_init(struct getstr_status *st, char *str,
|
||||
struct getstr_charinfo *ci)
|
||||
{
|
||||
int width;
|
||||
|
||||
@ -147,13 +150,18 @@ static void getstr_fixscr(struct getstr_status *st)
|
||||
pgskip = 0;
|
||||
while (pgskip < pgsize && st->scrpos > 0) {
|
||||
st->scrpos--;
|
||||
pgskip += st->ci[st->scrpos + 1].dpyoff - st->ci[st->scrpos].dpyoff;
|
||||
pgskip +=
|
||||
st->ci[st->scrpos + 1].dpyoff -
|
||||
st->ci[st->scrpos].dpyoff;
|
||||
}
|
||||
}
|
||||
while (st->ci[st->pos].dpyoff - st->ci[st->scrpos].dpyoff > col - 2) {
|
||||
while (st->ci[st->pos].dpyoff - st->ci[st->scrpos].dpyoff >
|
||||
col - 2) {
|
||||
pgskip = 0;
|
||||
while (pgskip < pgsize && st->scrpos < st->len) {
|
||||
pgskip += st->ci[st->scrpos + 1].dpyoff - st->ci[st->scrpos].dpyoff;
|
||||
pgskip +=
|
||||
st->ci[st->scrpos + 1].dpyoff -
|
||||
st->ci[st->scrpos].dpyoff;
|
||||
st->scrpos++;
|
||||
}
|
||||
}
|
||||
@ -205,11 +213,15 @@ enum getstr getstring(WINDOW * win, char *str, int l, int x, int y)
|
||||
break;
|
||||
case CTRL('W'): /* delete a word */
|
||||
if (st.pos > 0) {
|
||||
while (st.pos && st.s[st.ci[st.pos - 1].offset] == ' ') {
|
||||
while (st.pos
|
||||
&& st.s[st.ci[st.pos - 1].offset] ==
|
||||
' ') {
|
||||
st.pos--;
|
||||
getstr_del_char(&st);
|
||||
}
|
||||
while (st.pos && st.s[st.ci[st.pos - 1].offset] != ' ') {
|
||||
while (st.pos
|
||||
&& st.s[st.ci[st.pos - 1].offset] !=
|
||||
' ') {
|
||||
st.pos--;
|
||||
getstr_del_char(&st);
|
||||
}
|
||||
@ -242,7 +254,8 @@ enum getstr getstring(WINDOW * win, char *str, int l, int x, int y)
|
||||
break;
|
||||
default: /* insert one character */
|
||||
c[0] = ch;
|
||||
for (k = 1; k < MIN(UTF8_LENGTH(c[0]), UTF8_MAXLEN); k++)
|
||||
for (k = 1;
|
||||
k < MIN(UTF8_LENGTH(c[0]), UTF8_MAXLEN); k++)
|
||||
c[k] = (unsigned char)wgetch(win);
|
||||
if (st.ci[st.len].offset + k < l) {
|
||||
getstr_ins_char(&st, c);
|
||||
|
75
src/help.c
75
src/help.c
@ -93,7 +93,8 @@ static int get_help_lines(char *text)
|
||||
* of lines that were written.
|
||||
*/
|
||||
static int
|
||||
help_write_pad(struct window *win, char *title, char *text, enum key action)
|
||||
help_write_pad(struct window *win, char *title, char *text,
|
||||
enum key action)
|
||||
{
|
||||
int colnum, rownum;
|
||||
const char *bindings_title = _("key bindings: %s");
|
||||
@ -133,8 +134,11 @@ help_write_pad(struct window *win, char *title, char *text, enum key action)
|
||||
bindings = keys_action_allkeys(action);
|
||||
|
||||
if (bindings) {
|
||||
colnum = win->w - strlen(bindings_title) - strlen(bindings);
|
||||
mvwprintw(win->p, rownum, colnum, bindings_title, bindings);
|
||||
colnum =
|
||||
win->w - strlen(bindings_title) -
|
||||
strlen(bindings);
|
||||
mvwprintw(win->p, rownum, colnum,
|
||||
bindings_title, bindings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -189,7 +193,8 @@ static void help_wins_reset(struct scrollwin *hwin)
|
||||
curs_set(0);
|
||||
delwin(win[STA].p);
|
||||
help_wins_reinit(hwin);
|
||||
win[STA].p = newwin(win[STA].h, win[STA].w, win[STA].y, win[STA].x);
|
||||
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();
|
||||
@ -339,8 +344,7 @@ void help_screen(void)
|
||||
hscr[HELP_MAIN].title =
|
||||
_(" Welcome to Calcurse. This is the main help screen.\n");
|
||||
snprintf(hscr[HELP_MAIN].text, HELPTEXTSIZ,
|
||||
_
|
||||
("Moving around: Press '%s' or '%s' to scroll text upward or downward\n"
|
||||
_("Moving around: Press '%s' or '%s' to scroll text upward or downward\n"
|
||||
" inside help screens, if necessary.\n\n"
|
||||
" Exit help: When finished, press '%s' to exit help and go back to\n"
|
||||
" the main Calcurse screen.\n\n"
|
||||
@ -398,18 +402,19 @@ void help_screen(void)
|
||||
"those formats lets you export calcurse data to icalendar or pcal\n"
|
||||
"format.\n\n"
|
||||
"You first need to specify the file to which the data will be exported.\n"
|
||||
"By default, this file is:\n\n"
|
||||
" ~/calcurse.ics\n\n"
|
||||
"for an ical export, and:\n\n"
|
||||
" ~/calcurse.txt\n\n"
|
||||
"By default, this file is:\n\n" " ~/calcurse.ics\n\n"
|
||||
"for an ical export, and:\n\n" " ~/calcurse.txt\n\n"
|
||||
"for a pcal export.\n\n"
|
||||
"Calcurse data are exported in the following order:\n"
|
||||
" events, appointments, todos.\n"));
|
||||
|
||||
strncpy(keystr[MOVE_UP], keys_action_allkeys(KEY_MOVE_UP), BUFSIZ);
|
||||
strncpy(keystr[MOVE_DOWN], keys_action_allkeys(KEY_MOVE_DOWN), BUFSIZ);
|
||||
strncpy(keystr[MOVE_LEFT], keys_action_allkeys(KEY_MOVE_LEFT), BUFSIZ);
|
||||
strncpy(keystr[MOVE_RIGHT], keys_action_allkeys(KEY_MOVE_RIGHT), BUFSIZ);
|
||||
strncpy(keystr[MOVE_DOWN], keys_action_allkeys(KEY_MOVE_DOWN),
|
||||
BUFSIZ);
|
||||
strncpy(keystr[MOVE_LEFT], keys_action_allkeys(KEY_MOVE_LEFT),
|
||||
BUFSIZ);
|
||||
strncpy(keystr[MOVE_RIGHT], keys_action_allkeys(KEY_MOVE_RIGHT),
|
||||
BUFSIZ);
|
||||
hscr[HELP_DISPLACEMENT].title = _("Displacement keys\n");
|
||||
snprintf(hscr[HELP_DISPLACEMENT].text, HELPTEXTSIZ,
|
||||
_("Move around inside calcurse screens.\n"
|
||||
@ -439,8 +444,7 @@ void help_screen(void)
|
||||
|
||||
hscr[HELP_VIEW].title = _("View\n");
|
||||
snprintf(hscr[HELP_VIEW].text, HELPTEXTSIZ,
|
||||
_
|
||||
("View the item you select in either the Todo or Appointment panel.\n"
|
||||
_("View the item you select in either the Todo or Appointment panel.\n"
|
||||
"\nThis is usefull when an event description is longer than the "
|
||||
"available\nspace to display it. "
|
||||
"If that is the case, the description will be\n"
|
||||
@ -448,7 +452,8 @@ void help_screen(void)
|
||||
"description, just press '%s' and a popup window will appear, containing\n"
|
||||
"the whole event.\n"
|
||||
"\nPress any key to close the popup window and go back to the main\n"
|
||||
"Calcurse screen."), keys_action_firstkey(KEY_VIEW_ITEM));
|
||||
"Calcurse screen."),
|
||||
keys_action_firstkey(KEY_VIEW_ITEM));
|
||||
|
||||
hscr[HELP_PIPE].title = _("Pipe\n");
|
||||
snprintf(hscr[HELP_PIPE].text, HELPTEXTSIZ,
|
||||
@ -500,8 +505,7 @@ void help_screen(void)
|
||||
|
||||
hscr[HELP_ADD].title = _("Add\n");
|
||||
snprintf(hscr[HELP_ADD].text, HELPTEXTSIZ,
|
||||
_
|
||||
("Add an item in either the ToDo or Appointment list, depending on which\n"
|
||||
_("Add an item in either the ToDo or Appointment list, depending on which\n"
|
||||
"panel is selected when you press '%s'.\n"
|
||||
"\nTo enter a new item in the TODO list, you will need first to enter the"
|
||||
"\ndescription of this new item. Then you will be asked to specify the "
|
||||
@ -538,9 +542,7 @@ void help_screen(void)
|
||||
|
||||
hscr[HELP_COPY_PASTE].title = _("Copy and Paste\n");
|
||||
snprintf(hscr[HELP_COPY_PASTE].text, HELPTEXTSIZ,
|
||||
_
|
||||
(
|
||||
"Copy and paste the currently selected item. This is useful to quickly\n"
|
||||
_("Copy and paste the currently selected item. This is useful to quickly\n"
|
||||
"copy an item from one date to another. To do so, one must first\n"
|
||||
"highlight the item that needs to be copied, then press '%s' to copy.\n"
|
||||
"Once the new date is chosen in the calendar, the appointment panel must\n"
|
||||
@ -569,8 +571,7 @@ void help_screen(void)
|
||||
|
||||
hscr[HELP_ENOTE].title = _("EditNote\n");
|
||||
snprintf(hscr[HELP_ENOTE].text, HELPTEXTSIZ,
|
||||
_
|
||||
("Attach a note to any type of item, or edit an already existing note.\n"
|
||||
_("Attach a note to any type of item, or edit an already existing note.\n"
|
||||
"This feature is useful if you do not have enough space to store all\n"
|
||||
"of your item description, or if you would like to add sub-tasks to an\n"
|
||||
"already existing todo item for example.\n"
|
||||
@ -591,14 +592,14 @@ void help_screen(void)
|
||||
|
||||
hscr[HELP_VNOTE].title = _("ViewNote\n");
|
||||
snprintf(hscr[HELP_VNOTE].text, HELPTEXTSIZ,
|
||||
_
|
||||
("View a note which was previously attached to an item (an item which\n"
|
||||
_("View a note which was previously attached to an item (an item which\n"
|
||||
"owns a note has a '>' sign in front of it).\n"
|
||||
"This command only permits to view the note, not to edit it (to do so,\n"
|
||||
"use the 'EditNote' command, by pressing the '%s' key).\n"
|
||||
"Once you highlighted an item with a note attached to it, and the '%s' key"
|
||||
"\nwas pressed, you will be driven to an external pager to view that "
|
||||
"note.\n" "The default pager is chosen the following way:\n"
|
||||
"note.\n"
|
||||
"The default pager is chosen the following way:\n"
|
||||
" o if the 'PAGER' environment variable is set, then this will be\n"
|
||||
" the default viewer to be called.\n"
|
||||
" o if the above environment variable is not set, then\n"
|
||||
@ -609,8 +610,7 @@ void help_screen(void)
|
||||
|
||||
hscr[HELP_PRIORITY].title = _("Priority\n");
|
||||
snprintf(hscr[HELP_PRIORITY].text, HELPTEXTSIZ,
|
||||
_
|
||||
("Change the priority of the currently selected item in the ToDo list.\n"
|
||||
_("Change the priority of the currently selected item in the ToDo list.\n"
|
||||
"Priorities are represented by the number appearing in front of the\n"
|
||||
"todo description. This number goes from 9 for the lowest priority to\n"
|
||||
"1 for the highest priority.\n"
|
||||
@ -655,8 +655,7 @@ void help_screen(void)
|
||||
|
||||
hscr[HELP_FLAG].title = _("Flag Item\n");
|
||||
snprintf(hscr[HELP_FLAG].text, HELPTEXTSIZ,
|
||||
_
|
||||
("Toggle an appointment's 'important' flag or a todo's 'completed' flag.\n"
|
||||
_("Toggle an appointment's 'important' flag or a todo's 'completed' flag.\n"
|
||||
"If a todo is flagged as completed, its priority number will be replaced\n"
|
||||
"by an 'X' sign. Completed tasks will no longer appear in exported data\n"
|
||||
"or when using the '-t' command line flag (unless specifying '0' as the\n"
|
||||
@ -685,8 +684,7 @@ void help_screen(void)
|
||||
|
||||
hscr[HELP_GENERAL].title = _("Generic keybindings\n");
|
||||
snprintf(hscr[HELP_GENERAL].text, HELPTEXTSIZ,
|
||||
_
|
||||
("Some of the keybindings apply whatever panel is selected. They are\n"
|
||||
_("Some of the keybindings apply whatever panel is selected. They are\n"
|
||||
"called generic keybinding.\n"
|
||||
"Here is the list of all the generic key bindings, together with their\n"
|
||||
"corresponding action:\n\n"
|
||||
@ -755,13 +753,15 @@ void help_screen(void)
|
||||
"Send your feedback or comments to : misc@calcurse.org\n"
|
||||
"Calcurse home page : http://calcurse.org"));
|
||||
|
||||
help_wins_init(&hwin, 0, 0, (notify_bar())? row - 3 : row - 2, col);
|
||||
help_wins_init(&hwin, 0, 0, (notify_bar())? row - 3 : row - 2,
|
||||
col);
|
||||
oldpage = HELP_MAIN;
|
||||
need_resize = 0;
|
||||
|
||||
/* Display the help screen related to user input. */
|
||||
while (ch != KEY_GENERIC_QUIT) {
|
||||
erase_window_part(hwin.win.p, 1, hwin.pad.y, col - 2, hwin.win.h - 2);
|
||||
erase_window_part(hwin.win.p, 1, hwin.pad.y, col - 2,
|
||||
hwin.win.h - 2);
|
||||
|
||||
switch (ch) {
|
||||
case KEY_GENERIC_SCROLL_DOWN:
|
||||
@ -776,7 +776,9 @@ void help_screen(void)
|
||||
page = wanted_page(ch);
|
||||
if (page != NOPAGE) {
|
||||
hwin.first_visible_line = 0;
|
||||
hwin.total_lines = help_write_pad(&hwin.pad, hscr[page].title,
|
||||
hwin.total_lines =
|
||||
help_write_pad(&hwin.pad,
|
||||
hscr[page].title,
|
||||
hscr[page].text, ch);
|
||||
oldpage = page;
|
||||
}
|
||||
@ -787,7 +789,8 @@ void help_screen(void)
|
||||
wins_get_config();
|
||||
help_wins_reset(&hwin);
|
||||
hwin.first_visible_line = 0;
|
||||
hwin.total_lines = help_write_pad(&hwin.pad, hscr[oldpage].title,
|
||||
hwin.total_lines =
|
||||
help_write_pad(&hwin.pad, hscr[oldpage].title,
|
||||
hscr[oldpage].text, ch);
|
||||
need_resize = 1;
|
||||
}
|
||||
|
276
src/ical.c
276
src/ical.c
@ -112,7 +112,8 @@ static void ical_export_recur_events(FILE * stream)
|
||||
ical_recur_type[rev->rpt->type], rev->rpt->freq);
|
||||
|
||||
if (rev->rpt->until != 0) {
|
||||
date_sec2date_fmt(rev->rpt->until, ICALDATEFMT, ical_date);
|
||||
date_sec2date_fmt(rev->rpt->until, ICALDATEFMT,
|
||||
ical_date);
|
||||
fprintf(stream, ";UNTIL=%s\n", ical_date);
|
||||
} else {
|
||||
fputc('\n', stream);
|
||||
@ -122,7 +123,8 @@ static void ical_export_recur_events(FILE * stream)
|
||||
fputs("EXDATE:", stream);
|
||||
LLIST_FOREACH(&rev->exc, j) {
|
||||
struct excp *exc = LLIST_GET_DATA(j);
|
||||
date_sec2date_fmt(exc->st, ICALDATEFMT, ical_date);
|
||||
date_sec2date_fmt(exc->st, ICALDATEFMT,
|
||||
ical_date);
|
||||
fprintf(stream, "%s", ical_date);
|
||||
if (LLIST_NEXT(j))
|
||||
fputc(',', stream);
|
||||
@ -163,7 +165,8 @@ static void ical_export_recur_apoints(FILE * stream)
|
||||
LLIST_TS_FOREACH(&recur_alist_p, i) {
|
||||
struct recur_apoint *rapt = LLIST_TS_GET_DATA(i);
|
||||
|
||||
date_sec2date_fmt(rapt->start, ICALDATETIMEFMT, ical_datetime);
|
||||
date_sec2date_fmt(rapt->start, ICALDATETIMEFMT,
|
||||
ical_datetime);
|
||||
fputs("BEGIN:VEVENT\n", stream);
|
||||
fprintf(stream, "DTSTART:%s\n", ical_datetime);
|
||||
fprintf(stream, "DURATION:PT0H0M%ldS\n", rapt->dur);
|
||||
@ -171,7 +174,8 @@ static void ical_export_recur_apoints(FILE * stream)
|
||||
ical_recur_type[rapt->rpt->type], rapt->rpt->freq);
|
||||
|
||||
if (rapt->rpt->until != 0) {
|
||||
date_sec2date_fmt(rapt->rpt->until + HOURINSEC, ICALDATEFMT, ical_date);
|
||||
date_sec2date_fmt(rapt->rpt->until + HOURINSEC,
|
||||
ICALDATEFMT, ical_date);
|
||||
fprintf(stream, ";UNTIL=%s\n", ical_date);
|
||||
} else {
|
||||
fputc('\n', stream);
|
||||
@ -181,7 +185,8 @@ static void ical_export_recur_apoints(FILE * stream)
|
||||
fputs("EXDATE:", stream);
|
||||
LLIST_FOREACH(&rapt->exc, j) {
|
||||
struct excp *exc = LLIST_GET_DATA(j);
|
||||
date_sec2date_fmt(exc->st, ICALDATEFMT, ical_date);
|
||||
date_sec2date_fmt(exc->st, ICALDATEFMT,
|
||||
ical_date);
|
||||
fprintf(stream, "%s", ical_date);
|
||||
if (LLIST_NEXT(j))
|
||||
fputc(',', stream);
|
||||
@ -207,13 +212,15 @@ static void ical_export_apoints(FILE * stream)
|
||||
LLIST_TS_LOCK(&alist_p);
|
||||
LLIST_TS_FOREACH(&alist_p, i) {
|
||||
struct apoint *apt = LLIST_TS_GET_DATA(i);
|
||||
date_sec2date_fmt(apt->start, ICALDATETIMEFMT, ical_datetime);
|
||||
date_sec2date_fmt(apt->start, ICALDATETIMEFMT,
|
||||
ical_datetime);
|
||||
fputs("BEGIN:VEVENT\n", stream);
|
||||
fprintf(stream, "DTSTART:%s\n", ical_datetime);
|
||||
fprintf(stream, "DURATION:P%ldDT%ldH%ldM%ldS\n",
|
||||
apt->dur / DAYINSEC,
|
||||
(apt->dur / HOURINSEC) % DAYINHOURS,
|
||||
(apt->dur / MININSEC) % HOURINMIN, apt->dur % MININSEC);
|
||||
(apt->dur / MININSEC) % HOURINMIN,
|
||||
apt->dur % MININSEC);
|
||||
fprintf(stream, "SUMMARY:%s\n", apt->mesg);
|
||||
if (apt->state & APOINT_NOTIFY)
|
||||
ical_export_valarm(stream);
|
||||
@ -268,7 +275,8 @@ static void ical_log_init(FILE * log, int major, int minor)
|
||||
* first line inside the icalendar file), together with a message describing the
|
||||
* problem.
|
||||
*/
|
||||
static void ical_log(FILE * log, ical_types_e type, unsigned lineno, char *msg)
|
||||
static void ical_log(FILE * log, ical_types_e type, unsigned lineno,
|
||||
char *msg)
|
||||
{
|
||||
const char *typestr[ICAL_TYPES] = { "VEVENT", "VTODO" };
|
||||
|
||||
@ -285,14 +293,14 @@ static void ical_store_todo(int priority, char *mesg, char *note)
|
||||
}
|
||||
|
||||
static void
|
||||
ical_store_event(char *mesg, char *note, long day, long end, ical_rpt_t * rpt,
|
||||
llist_t * exc)
|
||||
ical_store_event(char *mesg, char *note, long day, long end,
|
||||
ical_rpt_t * rpt, llist_t * exc)
|
||||
{
|
||||
const int EVENTID = 1;
|
||||
|
||||
if (rpt) {
|
||||
recur_event_new(mesg, note, day, EVENTID, rpt->type, rpt->freq,
|
||||
rpt->until, exc);
|
||||
recur_event_new(mesg, note, day, EVENTID, rpt->type,
|
||||
rpt->freq, rpt->until, exc);
|
||||
mem_free(rpt);
|
||||
} else if (end && end != day) {
|
||||
/* Here we have an event that spans over several days. */
|
||||
@ -301,8 +309,8 @@ ical_store_event(char *mesg, char *note, long day, long end, ical_rpt_t * rpt,
|
||||
rpt->freq = 1;
|
||||
rpt->count = 0;
|
||||
rpt->until = end;
|
||||
recur_event_new(mesg, note, day, EVENTID, rpt->type, rpt->freq,
|
||||
rpt->until, exc);
|
||||
recur_event_new(mesg, note, day, EVENTID, rpt->type,
|
||||
rpt->freq, rpt->until, exc);
|
||||
mem_free(rpt);
|
||||
} else {
|
||||
event_new(mesg, note, day, EVENTID);
|
||||
@ -320,8 +328,8 @@ ical_store_apoint(char *mesg, char *note, long start, long dur,
|
||||
if (has_alarm)
|
||||
state |= APOINT_NOTIFY;
|
||||
if (rpt) {
|
||||
recur_apoint_new(mesg, note, start, dur, state, rpt->type, rpt->freq,
|
||||
rpt->until, exc);
|
||||
recur_apoint_new(mesg, note, start, dur, state, rpt->type,
|
||||
rpt->freq, rpt->until, exc);
|
||||
mem_free(rpt);
|
||||
} else {
|
||||
apoint_new(mesg, note, start, dur, state);
|
||||
@ -493,11 +501,15 @@ static long ical_durtime2long(char *timestr)
|
||||
|
||||
p++;
|
||||
memset(&time, 0, sizeof time);
|
||||
nbmatch = sscanf(p, "%uH%uM%uS", &time.hour, &time.min, &time.sec);
|
||||
nbmatch =
|
||||
sscanf(p, "%uH%uM%uS", &time.hour, &time.min,
|
||||
&time.sec);
|
||||
if (nbmatch < 1 || nbmatch > 3)
|
||||
timelong = 0;
|
||||
else
|
||||
timelong = time.hour * HOURINSEC + time.min * MININSEC + time.sec;
|
||||
timelong =
|
||||
time.hour * HOURINSEC + time.min * MININSEC +
|
||||
time.sec;
|
||||
}
|
||||
return timelong;
|
||||
}
|
||||
@ -550,7 +562,8 @@ static long ical_dur2long(char *durstr)
|
||||
durlong = ical_durtime2long(p);
|
||||
} else if (strchr(p, 'W')) { /* dur-week */
|
||||
if (sscanf(p, "%u", &date.week) == 1)
|
||||
durlong = date.week * WEEKINDAYS * DAYINSEC;
|
||||
durlong =
|
||||
date.week * WEEKINDAYS * DAYINSEC;
|
||||
else
|
||||
durlong = NOTFOUND;
|
||||
} else {
|
||||
@ -583,17 +596,24 @@ static long ical_compute_rpt_until(long start, ical_rpt_t * rpt)
|
||||
|
||||
switch (rpt->type) {
|
||||
case RECUR_DAILY:
|
||||
until = date_sec_change(start, 0, rpt->freq * (rpt->count - 1));
|
||||
until =
|
||||
date_sec_change(start, 0,
|
||||
rpt->freq * (rpt->count - 1));
|
||||
break;
|
||||
case RECUR_WEEKLY:
|
||||
until = date_sec_change(start, 0,
|
||||
rpt->freq * WEEKINDAYS * (rpt->count - 1));
|
||||
rpt->freq * WEEKINDAYS *
|
||||
(rpt->count - 1));
|
||||
break;
|
||||
case RECUR_MONTHLY:
|
||||
until = date_sec_change(start, rpt->freq * (rpt->count - 1), 0);
|
||||
until =
|
||||
date_sec_change(start, rpt->freq * (rpt->count - 1),
|
||||
0);
|
||||
break;
|
||||
case RECUR_YEARLY:
|
||||
until = date_sec_change(start, rpt->freq * 12 * (rpt->count - 1), 0);
|
||||
until =
|
||||
date_sec_change(start,
|
||||
rpt->freq * 12 * (rpt->count - 1), 0);
|
||||
break;
|
||||
default:
|
||||
until = 0;
|
||||
@ -667,13 +687,23 @@ static ical_rpt_t *ical_read_rrule(FILE * log, char *rrulestr,
|
||||
mem_free(rpt);
|
||||
return NULL;
|
||||
} else {
|
||||
if (strncmp(freqstr, daily, sizeof(daily) - 1) == 0) {
|
||||
if (strncmp(freqstr, daily, sizeof(daily) - 1) ==
|
||||
0) {
|
||||
rpt->type = RECUR_DAILY;
|
||||
} else if (strncmp(freqstr, weekly, sizeof(weekly) - 1) == 0) {
|
||||
} else
|
||||
if (strncmp
|
||||
(freqstr, weekly,
|
||||
sizeof(weekly) - 1) == 0) {
|
||||
rpt->type = RECUR_WEEKLY;
|
||||
} else if (strncmp(freqstr, monthly, sizeof(monthly) - 1) == 0) {
|
||||
} else
|
||||
if (strncmp
|
||||
(freqstr, monthly,
|
||||
sizeof(monthly) - 1) == 0) {
|
||||
rpt->type = RECUR_MONTHLY;
|
||||
} else if (strncmp(freqstr, yearly, sizeof(yearly) - 1) == 0) {
|
||||
} else
|
||||
if (strncmp
|
||||
(freqstr, yearly,
|
||||
sizeof(yearly) - 1) == 0) {
|
||||
rpt->type = RECUR_YEARLY;
|
||||
} else {
|
||||
ical_log(log, ICAL_VEVENT, itemline,
|
||||
@ -727,7 +757,8 @@ static ical_rpt_t *ical_read_rrule(FILE * log, char *rrulestr,
|
||||
rpt->freq = 1;
|
||||
}
|
||||
} else {
|
||||
ical_log(log, ICAL_VEVENT, itemline, _("recurrence rule malformed."));
|
||||
ical_log(log, ICAL_VEVENT, itemline,
|
||||
_("recurrence rule malformed."));
|
||||
(*noskipped)++;
|
||||
}
|
||||
return rpt;
|
||||
@ -748,8 +779,8 @@ static void ical_add_exc(llist_t * exc_head, long date)
|
||||
* recurring calendar component.
|
||||
*/
|
||||
static void
|
||||
ical_read_exdate(llist_t * exc, FILE * log, char *exstr, unsigned *noskipped,
|
||||
const int itemline)
|
||||
ical_read_exdate(llist_t * exc, FILE * log, char *exstr,
|
||||
unsigned *noskipped, const int itemline)
|
||||
{
|
||||
char *p, *q;
|
||||
long date;
|
||||
@ -800,7 +831,8 @@ static char *ical_read_note(char *line, unsigned *noskipped,
|
||||
return note;
|
||||
}
|
||||
} else {
|
||||
ical_log(log, item_type, itemline, _("description malformed."));
|
||||
ical_log(log, item_type, itemline,
|
||||
_("description malformed."));
|
||||
(*noskipped)++;
|
||||
return NULL;
|
||||
}
|
||||
@ -821,8 +853,9 @@ static char *ical_read_summary(char *line)
|
||||
}
|
||||
|
||||
static void
|
||||
ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, unsigned *noapoints,
|
||||
unsigned *noskipped, char *buf, char *lstore, unsigned *lineno)
|
||||
ical_read_event(FILE * fdi, FILE * log, unsigned *noevents,
|
||||
unsigned *noapoints, unsigned *noskipped, char *buf,
|
||||
char *lstore, unsigned *lineno)
|
||||
{
|
||||
const int ITEMLINE = *lineno;
|
||||
const char endevent[] = "END:VEVENT";
|
||||
@ -853,61 +886,92 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, unsigned *noapoints,
|
||||
if (skip_alarm) {
|
||||
/* Need to skip VALARM properties because some keywords could
|
||||
interfere, such as DURATION, SUMMARY,.. */
|
||||
if (strncasecmp(buf, endalarm, sizeof(endalarm) - 1) == 0)
|
||||
if (strncasecmp
|
||||
(buf, endalarm, sizeof(endalarm) - 1) == 0)
|
||||
skip_alarm = 0;
|
||||
continue;
|
||||
}
|
||||
if (strncasecmp(buf, endevent, sizeof(endevent) - 1) == 0) {
|
||||
if (vevent.mesg) {
|
||||
if (vevent.rpt && vevent.rpt->count)
|
||||
vevent.rpt->until = ical_compute_rpt_until(vevent.start, vevent.rpt);
|
||||
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;
|
||||
}
|
||||
if (vevent.dur == 0) {
|
||||
if (vevent.end == 0) {
|
||||
ical_log(log, ICAL_VEVENT, ITEMLINE,
|
||||
_("could not compute duration " "(no end time)."));
|
||||
ical_log(log,
|
||||
ICAL_VEVENT,
|
||||
ITEMLINE,
|
||||
_("could not compute duration "
|
||||
"(no end time)."));
|
||||
goto cleanup;
|
||||
} else if (vevent.start == vevent.end) {
|
||||
vevent_type = EVENT;
|
||||
} else if (vevent.start ==
|
||||
vevent.end) {
|
||||
vevent_type =
|
||||
EVENT;
|
||||
vevent.end = 0L;
|
||||
ical_store_event(vevent.mesg, vevent.note,
|
||||
vevent.start, vevent.end,
|
||||
vevent.rpt, &vevent.exc);
|
||||
ical_store_event
|
||||
(vevent.mesg,
|
||||
vevent.note,
|
||||
vevent.start,
|
||||
vevent.end,
|
||||
vevent.rpt,
|
||||
&vevent.exc);
|
||||
(*noevents)++;
|
||||
return;
|
||||
} else {
|
||||
vevent.dur = vevent.end - vevent.start;
|
||||
vevent.dur =
|
||||
vevent.end -
|
||||
vevent.start;
|
||||
if (vevent.dur < 0) {
|
||||
ical_log(log, ICAL_VEVENT, ITEMLINE,
|
||||
ical_log
|
||||
(log,
|
||||
ICAL_VEVENT,
|
||||
ITEMLINE,
|
||||
_("item has a negative duration."));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
ical_store_apoint(vevent.mesg, vevent.note, vevent.start,
|
||||
vevent.dur, vevent.rpt, &vevent.exc,
|
||||
vevent.has_alarm);
|
||||
ical_store_apoint(vevent.mesg,
|
||||
vevent.note,
|
||||
vevent.start,
|
||||
vevent.dur,
|
||||
vevent.rpt,
|
||||
&vevent.exc,
|
||||
vevent.
|
||||
has_alarm);
|
||||
(*noapoints)++;
|
||||
break;
|
||||
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;
|
||||
}
|
||||
ical_store_event(vevent.mesg, vevent.note, vevent.start,
|
||||
vevent.end, vevent.rpt, &vevent.exc);
|
||||
ical_store_event(vevent.mesg,
|
||||
vevent.note,
|
||||
vevent.start,
|
||||
vevent.end,
|
||||
vevent.rpt,
|
||||
&vevent.exc);
|
||||
(*noevents)++;
|
||||
break;
|
||||
case UNDEFINED:
|
||||
ical_log(log, ICAL_VEVENT, ITEMLINE,
|
||||
ical_log(log, ICAL_VEVENT,
|
||||
ITEMLINE,
|
||||
_("item could not be identified."));
|
||||
goto cleanup;
|
||||
break;
|
||||
@ -919,39 +983,67 @@ ical_read_event(FILE * fdi, FILE * log, unsigned *noevents, unsigned *noapoints,
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (strncasecmp(buf, dtstart, sizeof(dtstart) - 1) == 0) {
|
||||
if (strncasecmp(buf, dtstart, sizeof(dtstart) - 1)
|
||||
== 0) {
|
||||
if ((p = strchr(buf, ':')) != NULL)
|
||||
vevent.start = ical_datetime2long(++p, &vevent_type);
|
||||
vevent.start =
|
||||
ical_datetime2long(++p,
|
||||
&vevent_type);
|
||||
if (!vevent.start) {
|
||||
ical_log(log, ICAL_VEVENT, ITEMLINE,
|
||||
ical_log(log, ICAL_VEVENT,
|
||||
ITEMLINE,
|
||||
_("could not retrieve event start time."));
|
||||
goto cleanup;
|
||||
}
|
||||
} else if (strncasecmp(buf, dtend, sizeof(dtend) - 1) == 0) {
|
||||
} else
|
||||
if (strncasecmp(buf, dtend, sizeof(dtend) - 1)
|
||||
== 0) {
|
||||
if ((p = strchr(buf, ':')) != NULL)
|
||||
vevent.end = ical_datetime2long(++p, &vevent_type);
|
||||
vevent.end =
|
||||
ical_datetime2long(++p,
|
||||
&vevent_type);
|
||||
if (!vevent.end) {
|
||||
ical_log(log, ICAL_VEVENT, ITEMLINE,
|
||||
ical_log(log, ICAL_VEVENT,
|
||||
ITEMLINE,
|
||||
_("could not retrieve event end time."));
|
||||
goto cleanup;
|
||||
}
|
||||
} else if (strncasecmp(buf, duration, sizeof(duration) - 1) == 0) {
|
||||
} else
|
||||
if (strncasecmp
|
||||
(buf, duration,
|
||||
sizeof(duration) - 1) == 0) {
|
||||
if ((vevent.dur = ical_dur2long(buf)) <= 0) {
|
||||
ical_log(log, ICAL_VEVENT, ITEMLINE, _("item duration malformed."));
|
||||
ical_log(log, ICAL_VEVENT,
|
||||
ITEMLINE,
|
||||
_("item duration malformed."));
|
||||
goto cleanup;
|
||||
}
|
||||
} else if (strncasecmp(buf, rrule, sizeof(rrule) - 1) == 0) {
|
||||
vevent.rpt = ical_read_rrule(log, buf, noskipped, ITEMLINE);
|
||||
} else if (strncasecmp(buf, exdate, sizeof(exdate) - 1) == 0) {
|
||||
ical_read_exdate(&vevent.exc, log, buf, noskipped, ITEMLINE);
|
||||
} else if (strncasecmp(buf, summary, sizeof(summary) - 1) == 0) {
|
||||
} else
|
||||
if (strncasecmp(buf, rrule, sizeof(rrule) - 1)
|
||||
== 0) {
|
||||
vevent.rpt =
|
||||
ical_read_rrule(log, buf, noskipped,
|
||||
ITEMLINE);
|
||||
} else
|
||||
if (strncasecmp
|
||||
(buf, exdate, sizeof(exdate) - 1) == 0) {
|
||||
ical_read_exdate(&vevent.exc, log, buf,
|
||||
noskipped, ITEMLINE);
|
||||
} else
|
||||
if (strncasecmp
|
||||
(buf, summary, sizeof(summary) - 1) == 0) {
|
||||
vevent.mesg = ical_read_summary(buf);
|
||||
} else if (strncasecmp(buf, alarm, sizeof(alarm) - 1) == 0) {
|
||||
} else
|
||||
if (strncasecmp(buf, alarm, sizeof(alarm) - 1)
|
||||
== 0) {
|
||||
skip_alarm = 1;
|
||||
vevent.has_alarm = 1;
|
||||
} else if (strncasecmp(buf, desc, sizeof(desc) - 1) == 0) {
|
||||
vevent.note = ical_read_note(buf, noskipped, ICAL_VEVENT,
|
||||
ITEMLINE, log);
|
||||
} else if (strncasecmp(buf, desc, sizeof(desc) - 1)
|
||||
== 0) {
|
||||
vevent.note =
|
||||
ical_read_note(buf, noskipped,
|
||||
ICAL_VEVENT, ITEMLINE,
|
||||
log);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -972,8 +1064,9 @@ cleanup:
|
||||
}
|
||||
|
||||
static void
|
||||
ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
||||
char *buf, char *lstore, unsigned *lineno)
|
||||
ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos,
|
||||
unsigned *noskipped, char *buf, char *lstore,
|
||||
unsigned *lineno)
|
||||
{
|
||||
const char endtodo[] = "END:VTODO";
|
||||
const char summary[] = "SUMMARY";
|
||||
@ -994,7 +1087,8 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
||||
if (skip_alarm) {
|
||||
/* Need to skip VALARM properties because some keywords could
|
||||
interfere, such as DURATION, SUMMARY,.. */
|
||||
if (strncasecmp(buf, endalarm, sizeof(endalarm) - 1) == 0)
|
||||
if (strncasecmp
|
||||
(buf, endalarm, sizeof(endalarm) - 1) == 0)
|
||||
skip_alarm = 0;
|
||||
continue;
|
||||
}
|
||||
@ -1002,7 +1096,8 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
||||
if (!vtodo.has_priority)
|
||||
vtodo.priority = LOWEST;
|
||||
if (vtodo.mesg) {
|
||||
ical_store_todo(vtodo.priority, vtodo.mesg, vtodo.note);
|
||||
ical_store_todo(vtodo.priority, vtodo.mesg,
|
||||
vtodo.note);
|
||||
(*notodos)++;
|
||||
} else {
|
||||
ical_log(log, ICAL_VTODO, ITEMLINE,
|
||||
@ -1013,7 +1108,9 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
||||
} else {
|
||||
int tmpint;
|
||||
|
||||
if (strncasecmp(buf, "PRIORITY:", sizeof("PRIORITY:") - 1) == 0) {
|
||||
if (strncasecmp
|
||||
(buf, "PRIORITY:",
|
||||
sizeof("PRIORITY:") - 1) == 0) {
|
||||
sscanf(buf, "%d", &tmpint);
|
||||
if (tmpint <= 9 && tmpint >= 1) {
|
||||
vtodo.priority = tmpint;
|
||||
@ -1024,12 +1121,20 @@ ical_read_todo(FILE * fdi, FILE * log, unsigned *notodos, unsigned *noskipped,
|
||||
"(must be between 1 and 9)."));
|
||||
vtodo.priority = LOWEST;
|
||||
}
|
||||
} else if (strncasecmp(buf, summary, sizeof(summary) - 1) == 0) {
|
||||
} else
|
||||
if (strncasecmp
|
||||
(buf, summary, sizeof(summary) - 1) == 0) {
|
||||
vtodo.mesg = ical_read_summary(buf);
|
||||
} else if (strncasecmp(buf, alarm, sizeof(alarm) - 1) == 0) {
|
||||
} else
|
||||
if (strncasecmp(buf, alarm, sizeof(alarm) - 1)
|
||||
== 0) {
|
||||
skip_alarm = 1;
|
||||
} else if (strncasecmp(buf, desc, sizeof(desc) - 1) == 0) {
|
||||
vtodo.note = ical_read_note(buf, noskipped, ICAL_VTODO, ITEMLINE, log);
|
||||
} else if (strncasecmp(buf, desc, sizeof(desc) - 1)
|
||||
== 0) {
|
||||
vtodo.note =
|
||||
ical_read_note(buf, noskipped,
|
||||
ICAL_VTODO, ITEMLINE,
|
||||
log);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1048,8 +1153,9 @@ cleanup:
|
||||
|
||||
/* Import calcurse data. */
|
||||
void
|
||||
ical_import_data(FILE * stream, FILE * log, unsigned *events, unsigned *apoints,
|
||||
unsigned *todos, unsigned *lines, unsigned *skipped)
|
||||
ical_import_data(FILE * stream, FILE * log, unsigned *events,
|
||||
unsigned *apoints, unsigned *todos, unsigned *lines,
|
||||
unsigned *skipped)
|
||||
{
|
||||
const char vevent[] = "BEGIN:VEVENT";
|
||||
const char vtodo[] = "BEGIN:VTODO";
|
||||
@ -1057,7 +1163,8 @@ ical_import_data(FILE * stream, FILE * log, unsigned *events, unsigned *apoints,
|
||||
int major, minor;
|
||||
|
||||
ical_readline_init(stream, buf, lstore, lines);
|
||||
RETURN_IF(!ical_chk_header(stream, buf, lstore, lines, &major, &minor),
|
||||
RETURN_IF(!ical_chk_header
|
||||
(stream, buf, lstore, lines, &major, &minor),
|
||||
_("Warning: ical header malformed or wrong version number. "
|
||||
"Aborting..."));
|
||||
|
||||
@ -1066,10 +1173,11 @@ ical_import_data(FILE * stream, FILE * log, unsigned *events, unsigned *apoints,
|
||||
while (ical_readline(stream, buf, lstore, lines)) {
|
||||
(*lines)++;
|
||||
if (strncasecmp(buf, vevent, sizeof(vevent) - 1) == 0) {
|
||||
ical_read_event(stream, log, events, apoints, skipped, buf, lstore,
|
||||
lines);
|
||||
ical_read_event(stream, log, events, apoints,
|
||||
skipped, buf, lstore, lines);
|
||||
} else if (strncasecmp(buf, vtodo, sizeof(vtodo) - 1) == 0) {
|
||||
ical_read_todo(stream, log, todos, skipped, buf, lstore, lines);
|
||||
ical_read_todo(stream, log, todos, skipped, buf,
|
||||
lstore, lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
193
src/io.c
193
src/io.c
@ -93,7 +93,8 @@ static void progress_bar(progress_bar_t type, int progress)
|
||||
const char *mesg_sav = _("Saving...");
|
||||
const char *mesg_load = _("Loading...");
|
||||
const char *mesg_export = _("Exporting...");
|
||||
const char *error_msg = _("Internal error while displaying progress bar");
|
||||
const char *error_msg =
|
||||
_("Internal error while displaying progress bar");
|
||||
const char *barchar = "|";
|
||||
const char *file[NBFILES] = {
|
||||
"[ conf ]",
|
||||
@ -119,16 +120,19 @@ static void progress_bar(progress_bar_t type, int progress)
|
||||
|
||||
switch (type) {
|
||||
case PROGRESS_BAR_SAVE:
|
||||
EXIT_IF(progress < 0 || progress > PROGRESS_BAR_KEYS, "%s", error_msg);
|
||||
EXIT_IF(progress < 0
|
||||
|| progress > PROGRESS_BAR_KEYS, "%s", error_msg);
|
||||
status_mesg(mesg_sav, file[progress]);
|
||||
break;
|
||||
case PROGRESS_BAR_LOAD:
|
||||
EXIT_IF(progress < 0 || progress > PROGRESS_BAR_KEYS, "%s", error_msg);
|
||||
EXIT_IF(progress < 0
|
||||
|| progress > PROGRESS_BAR_KEYS, "%s", error_msg);
|
||||
status_mesg(mesg_load, file[progress]);
|
||||
break;
|
||||
case PROGRESS_BAR_EXPORT:
|
||||
EXIT_IF(progress < 0
|
||||
|| progress > PROGRESS_BAR_EXPORT_TODO, "%s", error_msg);
|
||||
|| progress > PROGRESS_BAR_EXPORT_TODO, "%s",
|
||||
error_msg);
|
||||
status_mesg(mesg_export, data[progress]);
|
||||
break;
|
||||
}
|
||||
@ -152,7 +156,8 @@ static FILE *get_export_stream(enum export_type type)
|
||||
{
|
||||
FILE *stream;
|
||||
char *home, *stream_name;
|
||||
const char *question = _("Choose the file used to export calcurse data:");
|
||||
const char *question =
|
||||
_("Choose the file used to export calcurse data:");
|
||||
const char *wrong_name =
|
||||
_("The file cannot be accessed, please enter another file name.");
|
||||
const char *press_enter = _("Press [ENTER] to continue.");
|
||||
@ -161,10 +166,11 @@ static FILE *get_export_stream(enum export_type type)
|
||||
stream = NULL;
|
||||
stream_name = (char *)mem_malloc(BUFSIZ);
|
||||
if ((home = getenv("HOME")) != NULL)
|
||||
snprintf(stream_name, BUFSIZ, "%s/calcurse.%s", home, file_ext[type]);
|
||||
else
|
||||
snprintf(stream_name, BUFSIZ, "%s/calcurse.%s", get_tempdir(),
|
||||
snprintf(stream_name, BUFSIZ, "%s/calcurse.%s", home,
|
||||
file_ext[type]);
|
||||
else
|
||||
snprintf(stream_name, BUFSIZ, "%s/calcurse.%s",
|
||||
get_tempdir(), file_ext[type]);
|
||||
|
||||
while (stream == NULL) {
|
||||
status_mesg(question, "");
|
||||
@ -192,7 +198,8 @@ unsigned io_fprintln(const char *fname, const char *fmt, ...)
|
||||
int ret;
|
||||
|
||||
fp = fopen(fname, "a");
|
||||
RETVAL_IF(!fp, 0, _("Failed to open \"%s\", - %s\n"), fname, strerror(errno));
|
||||
RETVAL_IF(!fp, 0, _("Failed to open \"%s\", - %s\n"), fname,
|
||||
strerror(errno));
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = vsnprintf(buf, sizeof buf, fmt, ap);
|
||||
@ -232,7 +239,8 @@ void io_init(const char *cfile, const char *datadir)
|
||||
snprintf(path_keys, BUFSIZ, "%s/" KEYS_PATH_NAME, home);
|
||||
snprintf(path_cpid, BUFSIZ, "%s/" CPID_PATH_NAME, home);
|
||||
snprintf(path_dpid, BUFSIZ, "%s/" DPID_PATH_NAME, home);
|
||||
snprintf(path_dmon_log, BUFSIZ, "%s/" DLOG_PATH_NAME, home);
|
||||
snprintf(path_dmon_log, BUFSIZ, "%s/" DLOG_PATH_NAME,
|
||||
home);
|
||||
} else {
|
||||
home = getenv("HOME");
|
||||
if (home == NULL) {
|
||||
@ -250,7 +258,8 @@ void io_init(const char *cfile, const char *datadir)
|
||||
|
||||
if (cfile == NULL) {
|
||||
if (datadir != NULL) {
|
||||
snprintf(path_apts, BUFSIZ, "%s/" APTS_PATH_NAME, home);
|
||||
snprintf(path_apts, BUFSIZ, "%s/" APTS_PATH_NAME,
|
||||
home);
|
||||
} else {
|
||||
snprintf(path_apts, BUFSIZ, "%s/" APTS_PATH, home);
|
||||
}
|
||||
@ -260,7 +269,8 @@ void io_init(const char *cfile, const char *datadir)
|
||||
/* check if the file exists, otherwise create it */
|
||||
data_file = fopen(path_apts, "r");
|
||||
if (data_file == NULL) {
|
||||
printf(_("%s does not exist, create it now [y or n] ? "), path_apts);
|
||||
printf(_("%s does not exist, create it now [y or n] ? "),
|
||||
path_apts);
|
||||
ch = getchar();
|
||||
switch (ch) {
|
||||
case 'N':
|
||||
@ -276,7 +286,8 @@ void io_init(const char *cfile, const char *datadir)
|
||||
perror(path_apts);
|
||||
exit_calcurse(EXIT_FAILURE);
|
||||
} else {
|
||||
printf(_("%s successfully created\n"), path_apts);
|
||||
printf(_("%s successfully created\n"),
|
||||
path_apts);
|
||||
puts(_("starting interactive mode...\n"));
|
||||
}
|
||||
break;
|
||||
@ -384,7 +395,8 @@ unsigned io_save_keys(void)
|
||||
void io_save_cal(enum save_display display)
|
||||
{
|
||||
const char *access_pb = _("Problems accessing data file ...");
|
||||
const char *save_success = _("The data files were successfully saved");
|
||||
const char *save_success =
|
||||
_("The data files were successfully saved");
|
||||
const char *enter = _("Press [ENTER] to continue");
|
||||
int show_bar;
|
||||
|
||||
@ -471,8 +483,10 @@ void io_load_app(void)
|
||||
* and appointments.
|
||||
*/
|
||||
if (fscanf(data_file, "%d / %d / %d ",
|
||||
&start.tm_mon, &start.tm_mday, &start.tm_year) != 3)
|
||||
io_load_error(path_apts, line, _("syntax error in the item date"));
|
||||
&start.tm_mon, &start.tm_mday,
|
||||
&start.tm_year) != 3)
|
||||
io_load_error(path_apts, line,
|
||||
_("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.
|
||||
@ -484,19 +498,24 @@ void io_load_app(void)
|
||||
else if (c == '[')
|
||||
is_event = 1;
|
||||
else
|
||||
io_load_error(path_apts, line, _("no event nor appointment found"));
|
||||
io_load_error(path_apts, line,
|
||||
_("no event nor appointment found"));
|
||||
|
||||
/* Read the remaining informations. */
|
||||
if (is_appointment) {
|
||||
if (fscanf(data_file, " %d : %d -> %d / %d / %d @ %d : %d ",
|
||||
&start.tm_hour, &start.tm_min,
|
||||
&end.tm_mon, &end.tm_mday, &end.tm_year,
|
||||
&end.tm_hour, &end.tm_min) != 7)
|
||||
if (fscanf
|
||||
(data_file,
|
||||
" %d : %d -> %d / %d / %d @ %d : %d ",
|
||||
&start.tm_hour, &start.tm_min, &end.tm_mon,
|
||||
&end.tm_mday, &end.tm_year, &end.tm_hour,
|
||||
&end.tm_min) != 7)
|
||||
io_load_error(path_apts, line,
|
||||
_("syntax error in item time or duration"));
|
||||
} else if (is_event) {
|
||||
if (fscanf(data_file, " %d ", &id) != 1 || getc(data_file) != ']')
|
||||
io_load_error(path_apts, line, _("syntax error in item identifier"));
|
||||
if (fscanf(data_file, " %d ", &id) != 1
|
||||
|| getc(data_file) != ']')
|
||||
io_load_error(path_apts, line,
|
||||
_("syntax error in item identifier"));
|
||||
while ((c = getc(data_file)) == ' ') ;
|
||||
ungetc(c, data_file);
|
||||
} else {
|
||||
@ -511,7 +530,8 @@ void io_load_app(void)
|
||||
if (c == '{') {
|
||||
is_recursive = 1;
|
||||
if (fscanf(data_file, " %d%c ", &freq, &type) != 2)
|
||||
io_load_error(path_apts, line, _("syntax error in item repetition"));
|
||||
io_load_error(path_apts, line,
|
||||
_("syntax error in item repetition"));
|
||||
|
||||
c = getc(data_file);
|
||||
if (c == '}') { /* endless recurrent item */
|
||||
@ -519,20 +539,26 @@ void io_load_app(void)
|
||||
while ((c = getc(data_file)) == ' ') ;
|
||||
ungetc(c, data_file);
|
||||
} else if (c == '-' && getc(data_file) == '>') {
|
||||
if (fscanf(data_file, " %d / %d / %d ", &until.tm_mon,
|
||||
&until.tm_mday, &until.tm_year) != 3)
|
||||
io_load_error(path_apts, line, _("syntax error in item repetition"));
|
||||
if (fscanf
|
||||
(data_file, " %d / %d / %d ",
|
||||
&until.tm_mon, &until.tm_mday,
|
||||
&until.tm_year) != 3)
|
||||
io_load_error(path_apts, line,
|
||||
_("syntax error in item repetition"));
|
||||
c = getc(data_file);
|
||||
if (c == '!') {
|
||||
ungetc(c, data_file);
|
||||
recur_exc_scan(&exc, data_file);
|
||||
while ((c = getc(data_file)) == ' ') ;
|
||||
while ((c =
|
||||
getc(data_file)) == ' ') ;
|
||||
ungetc(c, data_file);
|
||||
} else if (c == '}') {
|
||||
while ((c = getc(data_file)) == ' ') ;
|
||||
while ((c =
|
||||
getc(data_file)) == ' ') ;
|
||||
ungetc(c, data_file);
|
||||
} else {
|
||||
io_load_error(path_apts, line, _("syntax error in item repetition"));
|
||||
io_load_error(path_apts, line,
|
||||
_("syntax error in item repetition"));
|
||||
}
|
||||
} else if (c == '!') { /* endless item with exceptions */
|
||||
ungetc(c, data_file);
|
||||
@ -574,17 +600,22 @@ void io_load_app(void)
|
||||
while ((c = getc(data_file)) == ' ') ;
|
||||
ungetc(c, data_file);
|
||||
} else {
|
||||
io_load_error(path_apts, line, _("syntax error in item repetition"));
|
||||
io_load_error(path_apts, line,
|
||||
_("syntax error in item repetition"));
|
||||
}
|
||||
if (is_recursive) {
|
||||
recur_apoint_scan(data_file, start, end,
|
||||
type, freq, until, notep, &exc, state);
|
||||
type, freq, until, notep,
|
||||
&exc, state);
|
||||
} else {
|
||||
apoint_scan(data_file, start, end, state, notep);
|
||||
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);
|
||||
recur_event_scan(data_file, start, id,
|
||||
type, freq, until, notep,
|
||||
&exc);
|
||||
} else {
|
||||
event_scan(data_file, start, id, notep);
|
||||
}
|
||||
@ -616,8 +647,10 @@ void io_load_todo(void)
|
||||
if (c == EOF) {
|
||||
break;
|
||||
} else if (c == '[') { /* new style with id */
|
||||
if (fscanf(data_file, " %d ", &id) != 1 || getc(data_file) != ']')
|
||||
io_load_error(path_todo, line, _("syntax error in item identifier"));
|
||||
if (fscanf(data_file, " %d ", &id) != 1
|
||||
|| getc(data_file) != ']')
|
||||
io_load_error(path_todo, line,
|
||||
_("syntax error in item identifier"));
|
||||
while ((c = getc(data_file)) == ' ') ;
|
||||
ungetc(c, data_file);
|
||||
} else {
|
||||
@ -647,7 +680,8 @@ void io_load_todo(void)
|
||||
}
|
||||
|
||||
static void
|
||||
load_keys_ht_getkey(struct ht_keybindings_s *data, const char **key, int *len)
|
||||
load_keys_ht_getkey(struct ht_keybindings_s *data, const char **key,
|
||||
int *len)
|
||||
{
|
||||
*key = data->label;
|
||||
*len = strlen(data->label);
|
||||
@ -731,7 +765,8 @@ void io_load_keys(const char *pager)
|
||||
|
||||
if (sscanf(buf, "%s", key_label) != AWAITED) {
|
||||
skipped++;
|
||||
io_log_print(log, line, _("Could not read key label"));
|
||||
io_log_print(log, line,
|
||||
_("Could not read key label"));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -741,10 +776,12 @@ void io_load_keys(const char *pager)
|
||||
|
||||
ht_entry.label = key_label;
|
||||
p = buf + strlen(key_label) + 1;
|
||||
ht_elm = HTABLE_LOOKUP(ht_keybindings, &ht_keys, &ht_entry);
|
||||
ht_elm =
|
||||
HTABLE_LOOKUP(ht_keybindings, &ht_keys, &ht_entry);
|
||||
if (!ht_elm) {
|
||||
skipped++;
|
||||
io_log_print(log, line, _("Key label not recognized"));
|
||||
io_log_print(log, line,
|
||||
_("Key label not recognized"));
|
||||
continue;
|
||||
}
|
||||
assigned = 0;
|
||||
@ -762,19 +799,30 @@ void io_load_keys(const char *pager)
|
||||
|
||||
skipped++;
|
||||
(void)snprintf(unknown_key, BUFSIZ,
|
||||
_("Error reading key: \"%s\""), key_ch);
|
||||
io_log_print(log, line, unknown_key);
|
||||
_("Error reading key: \"%s\""),
|
||||
key_ch);
|
||||
io_log_print(log, line,
|
||||
unknown_key);
|
||||
} else {
|
||||
int used;
|
||||
|
||||
used = keys_assign_binding(ch, ht_elm->key);
|
||||
used =
|
||||
keys_assign_binding(ch,
|
||||
ht_elm->
|
||||
key);
|
||||
if (used) {
|
||||
char already_assigned[BUFSIZ];
|
||||
char already_assigned
|
||||
[BUFSIZ];
|
||||
|
||||
skipped++;
|
||||
(void)snprintf(already_assigned, BUFSIZ,
|
||||
_("\"%s\" assigned multiple times!"), key_ch);
|
||||
io_log_print(log, line, already_assigned);
|
||||
(void)
|
||||
snprintf
|
||||
(already_assigned,
|
||||
BUFSIZ,
|
||||
_("\"%s\" assigned multiple times!"),
|
||||
key_ch);
|
||||
io_log_print(log, line,
|
||||
already_assigned);
|
||||
} else {
|
||||
assigned++;
|
||||
}
|
||||
@ -812,8 +860,9 @@ int io_check_dir(const char *dir)
|
||||
errno = 0;
|
||||
if (mkdir(dir, 0700) != 0) {
|
||||
if (errno != EEXIST) {
|
||||
fprintf(stderr, _("FATAL ERROR: could not create %s: %s\n"), dir,
|
||||
strerror(errno));
|
||||
fprintf(stderr,
|
||||
_("FATAL ERROR: could not create %s: %s\n"),
|
||||
dir, strerror(errno));
|
||||
exit_calcurse(EXIT_FAILURE);
|
||||
} else {
|
||||
return 1;
|
||||
@ -847,8 +896,9 @@ int io_check_file(const char *file)
|
||||
FILE *fd;
|
||||
|
||||
if ((fd = fopen(file, "w")) == NULL) {
|
||||
fprintf(stderr, _("FATAL ERROR: could not create %s: %s\n"), file,
|
||||
strerror(errno));
|
||||
fprintf(stderr,
|
||||
_("FATAL ERROR: could not create %s: %s\n"),
|
||||
file, strerror(errno));
|
||||
exit_calcurse(EXIT_FAILURE);
|
||||
}
|
||||
file_close(fd, __FILE_POS__);
|
||||
@ -896,7 +946,8 @@ void io_startup_screen(int no_data_file)
|
||||
status_mesg(_("Welcome to Calcurse. Missing data files were created."),
|
||||
enter);
|
||||
else
|
||||
status_mesg(_("Data files found. Data will be loaded now."), enter);
|
||||
status_mesg(_("Data files found. Data will be loaded now."),
|
||||
enter);
|
||||
|
||||
wgetch(win[KEY].p);
|
||||
}
|
||||
@ -941,7 +992,8 @@ static FILE *get_import_stream(enum import_type type)
|
||||
{
|
||||
FILE *stream = NULL;
|
||||
char *stream_name;
|
||||
const char *ask_fname = _("Enter the file name to import data from:");
|
||||
const char *ask_fname =
|
||||
_("Enter the file name to import data from:");
|
||||
const char *wrong_file =
|
||||
_("The file cannot be accessed, please enter another file name.");
|
||||
const char *press_enter = _("Press [ENTER] to continue.");
|
||||
@ -973,7 +1025,8 @@ static FILE *get_import_stream(enum import_type type)
|
||||
*/
|
||||
void io_import_data(enum import_type type, const char *stream_name)
|
||||
{
|
||||
const char *proc_report = _("Import process report: %04d lines read ");
|
||||
const char *proc_report =
|
||||
_("Import process report: %04d lines read ");
|
||||
char stats_str[4][BUFSIZ];
|
||||
FILE *stream = NULL;
|
||||
struct io_file *log;
|
||||
@ -981,7 +1034,8 @@ void io_import_data(enum import_type type, const char *stream_name)
|
||||
unsigned events, apoints, todos, lines, skipped;
|
||||
} stats;
|
||||
|
||||
EXIT_IF(type < 0 || type >= IO_IMPORT_NBTYPES, _("unknown import type"));
|
||||
EXIT_IF(type < 0
|
||||
|| type >= IO_IMPORT_NBTYPES, _("unknown import type"));
|
||||
switch (ui_mode) {
|
||||
case UI_CMDLINE:
|
||||
stream = fopen(stream_name, "r");
|
||||
@ -1010,18 +1064,22 @@ void io_import_data(enum import_type type, const char *stream_name)
|
||||
}
|
||||
|
||||
if (type == IO_IMPORT_ICAL)
|
||||
ical_import_data(stream, log->fd, &stats.events, &stats.apoints,
|
||||
&stats.todos, &stats.lines, &stats.skipped);
|
||||
ical_import_data(stream, log->fd, &stats.events,
|
||||
&stats.apoints, &stats.todos,
|
||||
&stats.lines, &stats.skipped);
|
||||
|
||||
if (stream != stdin)
|
||||
file_close(stream, __FILE_POS__);
|
||||
|
||||
snprintf(stats_str[0], BUFSIZ,
|
||||
ngettext("%d app", "%d apps", stats.apoints), stats.apoints);
|
||||
ngettext("%d app", "%d apps", stats.apoints),
|
||||
stats.apoints);
|
||||
snprintf(stats_str[1], BUFSIZ,
|
||||
ngettext("%d event", "%d events", stats.events), stats.events);
|
||||
ngettext("%d event", "%d events", stats.events),
|
||||
stats.events);
|
||||
snprintf(stats_str[2], BUFSIZ,
|
||||
ngettext("%d todo", "%d todos", stats.todos), stats.todos);
|
||||
ngettext("%d todo", "%d todos", stats.todos),
|
||||
stats.todos);
|
||||
snprintf(stats_str[3], BUFSIZ, _("%d skipped"), stats.skipped);
|
||||
|
||||
/* Update the number of todo items. */
|
||||
@ -1031,9 +1089,9 @@ void io_import_data(enum import_type type, const char *stream_name)
|
||||
char read[BUFSIZ], stat[BUFSIZ];
|
||||
|
||||
snprintf(read, BUFSIZ, proc_report, stats.lines);
|
||||
snprintf(stat, BUFSIZ, "%s / %s / %s / %s (%s)", stats_str[0],
|
||||
stats_str[1], stats_str[2], stats_str[3],
|
||||
_("Press [ENTER] to continue"));
|
||||
snprintf(stat, BUFSIZ, "%s / %s / %s / %s (%s)",
|
||||
stats_str[0], stats_str[1], stats_str[2],
|
||||
stats_str[3], _("Press [ENTER] to continue"));
|
||||
status_mesg(read, stat);
|
||||
wgetch(win[KEY].p);
|
||||
} else if (ui_mode == UI_CMDLINE) {
|
||||
@ -1086,7 +1144,8 @@ void io_log_print(struct io_file *log, int line, const char *msg)
|
||||
fprintf(log->fd, "line %d: %s\n", line, msg);
|
||||
}
|
||||
|
||||
void io_log_display(struct io_file *log, const char *msg, const char *pager)
|
||||
void io_log_display(struct io_file *log, const char *msg,
|
||||
const char *pager)
|
||||
{
|
||||
RETURN_IF(log == NULL, _("No log file to display!"));
|
||||
if (ui_mode == UI_CMDLINE) {
|
||||
@ -1176,7 +1235,8 @@ void io_set_lock(void)
|
||||
_("\nWARNING: it seems that another calcurse instance is "
|
||||
"already running.\n"
|
||||
"If this is not the case, please remove the following "
|
||||
"lock file: \n\"%s\"\n" "and restart calcurse.\n"), path_cpid);
|
||||
"lock file: \n\"%s\"\n"
|
||||
"and restart calcurse.\n"), path_cpid);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
if (!io_dump_pid(path_cpid))
|
||||
@ -1266,7 +1326,8 @@ int io_file_cp(const char *src, const char *dst)
|
||||
while (!feof(fp_src)) {
|
||||
bytes_read = fread(buffer, 1, BUFSIZ, fp_src);
|
||||
if (bytes_read > 0) {
|
||||
if (fwrite(buffer, 1, bytes_read, fp_dst) != bytes_read)
|
||||
if (fwrite(buffer, 1, bytes_read, fp_dst) !=
|
||||
bytes_read)
|
||||
return 0;
|
||||
} else {
|
||||
return 0;
|
||||
|
72
src/keys.c
72
src/keys.c
@ -156,17 +156,21 @@ void keys_dump_defaults(char *file)
|
||||
int i;
|
||||
|
||||
fd = fopen(file, "w");
|
||||
EXIT_IF(fd == NULL, _("FATAL ERROR: could not create default keys file."));
|
||||
EXIT_IF(fd == NULL,
|
||||
_("FATAL ERROR: could not create default keys file."));
|
||||
|
||||
dump_intro(fd);
|
||||
for (i = 0; i < NBKEYS; i++)
|
||||
fprintf(fd, "%s %s\n", keydef[i].label, keydef[i].binding);
|
||||
fprintf(fd, "%s %s\n", keydef[i].label,
|
||||
keydef[i].binding);
|
||||
file_close(fd, __FILE_POS__);
|
||||
}
|
||||
|
||||
const char *keys_get_label(enum key key)
|
||||
{
|
||||
EXIT_IF(key < 0 || key > NBKEYS, _("FATAL ERROR: key value out of bounds"));
|
||||
EXIT_IF(key < 0
|
||||
|| key > NBKEYS,
|
||||
_("FATAL ERROR: key value out of bounds"));
|
||||
|
||||
return keydef[key].label;
|
||||
}
|
||||
@ -190,7 +194,8 @@ enum key keys_getch(WINDOW * win, int *count, int *reg)
|
||||
*count = *count * 10 + ch - '0';
|
||||
ch = wgetch(win);
|
||||
}
|
||||
while ((ch == '0' && *count > 0) || (ch >= '1' && ch <= '9'));
|
||||
while ((ch == '0' && *count > 0)
|
||||
|| (ch >= '1' && ch <= '9'));
|
||||
|
||||
if (*count == 0)
|
||||
*count = 1;
|
||||
@ -284,7 +289,8 @@ int keys_str2int(const char *key)
|
||||
} else {
|
||||
if (key[0] == '^')
|
||||
return CTRL((int)key[1]);
|
||||
else if (!strncmp(key, CONTROL_KEY, sizeof(CONTROL_KEY) - 1))
|
||||
else if (!strncmp
|
||||
(key, CONTROL_KEY, sizeof(CONTROL_KEY) - 1))
|
||||
return CTRL((int)key[sizeof(CONTROL_KEY) - 1]);
|
||||
else if (!strcmp(key, TAB_KEY))
|
||||
return TAB;
|
||||
@ -403,11 +409,13 @@ static char *keys_format_label(char *key, int keylen)
|
||||
}
|
||||
|
||||
void
|
||||
keys_display_bindings_bar(WINDOW * win, struct binding *bindings[], int count,
|
||||
int page_base, int page_size, struct binding *more)
|
||||
keys_display_bindings_bar(WINDOW * win, struct binding *bindings[],
|
||||
int count, int page_base, int page_size,
|
||||
struct binding *more)
|
||||
{
|
||||
/* Padding between two key bindings. */
|
||||
const int padding = (col * 2) / page_size - (KEYS_KEYLEN + KEYS_LABELEN + 1);
|
||||
const int padding =
|
||||
(col * 2) / page_size - (KEYS_KEYLEN + KEYS_LABELEN + 1);
|
||||
/* Total length of a key binding (including padding). */
|
||||
const int cmd_len = KEYS_KEYLEN + KEYS_LABELEN + 1 + padding;
|
||||
|
||||
@ -424,12 +432,14 @@ keys_display_bindings_bar(WINDOW * win, struct binding *bindings[], int count,
|
||||
struct binding *binding;
|
||||
char key[KEYS_KEYLEN + 1], *fmtkey;
|
||||
|
||||
if (!more || i < page_size - 1 || page_base + i == count - 1)
|
||||
if (!more || i < page_size - 1
|
||||
|| page_base + i == count - 1)
|
||||
binding = bindings[page_base + i];
|
||||
else
|
||||
binding = more;
|
||||
|
||||
strncpy(key, keys_action_firstkey(binding->action), KEYS_KEYLEN);
|
||||
strncpy(key, keys_action_firstkey(binding->action),
|
||||
KEYS_KEYLEN);
|
||||
key[KEYS_KEYLEN] = '\0';
|
||||
fmtkey = keys_format_label(key, KEYS_KEYLEN);
|
||||
|
||||
@ -456,10 +466,13 @@ void keys_popup_info(enum key key)
|
||||
_("Print general information about calcurse's authors, license, etc.");
|
||||
info[KEY_GENERIC_HELP] =
|
||||
_("Display hints whenever some help screens are available.");
|
||||
info[KEY_GENERIC_QUIT] = _("Exit from the current menu, or quit calcurse.");
|
||||
info[KEY_GENERIC_QUIT] =
|
||||
_("Exit from the current menu, or quit calcurse.");
|
||||
info[KEY_GENERIC_SAVE] = _("Save calcurse data.");
|
||||
info[KEY_GENERIC_COPY] = _("Copy the item that is currently selected.");
|
||||
info[KEY_GENERIC_PASTE] = _("Paste an item at the current position.");
|
||||
info[KEY_GENERIC_COPY] =
|
||||
_("Copy the item that is currently selected.");
|
||||
info[KEY_GENERIC_PASTE] =
|
||||
_("Paste an item at the current position.");
|
||||
info[KEY_GENERIC_CHANGE_VIEW] =
|
||||
_("Select next panel in calcurse main screen.");
|
||||
info[KEY_GENERIC_IMPORT] = _("Import data from an external file.");
|
||||
@ -482,27 +495,24 @@ void keys_popup_info(enum key key)
|
||||
_("Move to previous week in calendar, whichever panel is currently "
|
||||
"selected");
|
||||
info[KEY_GENERIC_NEXT_WEEK] =
|
||||
_
|
||||
("Move to next week in calendar, whichever panel is currently selected.");
|
||||
_("Move to next week in calendar, whichever panel is currently selected.");
|
||||
info[KEY_GENERIC_PREV_MONTH] =
|
||||
_("Move to previous month in calendar, whichever panel is currently "
|
||||
"selected");
|
||||
info[KEY_GENERIC_NEXT_MONTH] =
|
||||
_
|
||||
("Move to next month in calendar, whichever panel is currently "
|
||||
_("Move to next month in calendar, whichever panel is currently "
|
||||
"selected.");
|
||||
info[KEY_GENERIC_PREV_YEAR] =
|
||||
_("Move to previous year in calendar, whichever panel is currently "
|
||||
"selected");
|
||||
info[KEY_GENERIC_NEXT_YEAR] =
|
||||
_
|
||||
("Move to next year in calendar, whichever panel is currently selected.");
|
||||
_("Move to next year in calendar, whichever panel is currently selected.");
|
||||
info[KEY_GENERIC_SCROLL_DOWN] =
|
||||
_
|
||||
("Scroll window down (e.g. when displaying text inside a popup window).");
|
||||
_("Scroll window down (e.g. when displaying text inside a popup window).");
|
||||
info[KEY_GENERIC_SCROLL_UP] =
|
||||
_("Scroll window up (e.g. when displaying text inside a popup window).");
|
||||
info[KEY_GENERIC_GOTO_TODAY] = _("Go to today, whichever panel is selected.");
|
||||
info[KEY_GENERIC_GOTO_TODAY] =
|
||||
_("Go to today, whichever panel is selected.");
|
||||
info[KEY_MOVE_RIGHT] = _("Move to the right.");
|
||||
info[KEY_MOVE_LEFT] = _("Move to the left.");
|
||||
info[KEY_MOVE_DOWN] = _("Move down.");
|
||||
@ -513,12 +523,14 @@ void keys_popup_info(enum key key)
|
||||
info[KEY_END_OF_WEEK] =
|
||||
_("Select the last day of the current week when inside the calendar "
|
||||
"panel.");
|
||||
info[KEY_ADD_ITEM] = _("Add an item to the currently selected panel.");
|
||||
info[KEY_ADD_ITEM] =
|
||||
_("Add an item to the currently selected panel.");
|
||||
info[KEY_DEL_ITEM] = _("Delete the currently selected item.");
|
||||
info[KEY_EDIT_ITEM] = _("Edit the currently seleted item.");
|
||||
info[KEY_VIEW_ITEM] =
|
||||
_("Display the currently selected item inside a popup window.");
|
||||
info[KEY_FLAG_ITEM] = _("Flag the currently selected item as important.");
|
||||
info[KEY_FLAG_ITEM] =
|
||||
_("Flag the currently selected item as important.");
|
||||
info[KEY_REPEAT_ITEM] = _("Repeat an item");
|
||||
info[KEY_PIPE_ITEM] =
|
||||
_("Pipe the currently selected item to an external program.");
|
||||
@ -526,15 +538,18 @@ void keys_popup_info(enum key key)
|
||||
_("Attach (or edit if one exists) a note to the currently selected item");
|
||||
info[KEY_VIEW_NOTE] =
|
||||
_("View the note attached to the currently selected item.");
|
||||
info[KEY_RAISE_PRIORITY] = _("Raise a task priority inside the todo panel.");
|
||||
info[KEY_LOWER_PRIORITY] = _("Lower a task priority inside the todo panel.");
|
||||
info[KEY_RAISE_PRIORITY] =
|
||||
_("Raise a task priority inside the todo panel.");
|
||||
info[KEY_LOWER_PRIORITY] =
|
||||
_("Lower a task priority inside the todo panel.");
|
||||
|
||||
if (key > NBKEYS)
|
||||
return;
|
||||
|
||||
#define WINROW 10
|
||||
#define WINCOL (col - 4)
|
||||
infowin = popup(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2,
|
||||
infowin =
|
||||
popup(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2,
|
||||
keydef[key].label, info[key], 1);
|
||||
keys_getch(infowin, NULL, NULL);
|
||||
delwin(infowin);
|
||||
@ -590,7 +605,8 @@ void keys_fill_missing(void)
|
||||
if (used)
|
||||
WARN_MSG(_("When adding default key for \"%s\", "
|
||||
"\"%s\" was already assigned!"),
|
||||
keydef[i].label, key_ch);
|
||||
keydef[i].label,
|
||||
key_ch);
|
||||
p += strlen(key_ch) + 1;
|
||||
} else {
|
||||
break;
|
||||
|
@ -171,7 +171,8 @@ void llist_add_sorted(llist_t * l, void *data, llist_fn_cmp_t fn_cmp)
|
||||
l->head = o;
|
||||
} else {
|
||||
i = l->head;
|
||||
while (i->next && fn_cmp(o->data, i->next->data) >= 0)
|
||||
while (i->next
|
||||
&& fn_cmp(o->data, i->next->data) >= 0)
|
||||
i = i->next;
|
||||
o->next = i->next;
|
||||
i->next = o;
|
||||
|
13
src/mem.c
13
src/mem.c
@ -132,7 +132,8 @@ static unsigned stats_add_blk(size_t size, const char *pos)
|
||||
struct mem_blk *o, **i;
|
||||
|
||||
o = malloc(sizeof(*o));
|
||||
EXIT_IF(o == NULL, _("could not allocate memory to store block info"));
|
||||
EXIT_IF(o == NULL,
|
||||
_("could not allocate memory to store block info"));
|
||||
|
||||
mstats.ncall++;
|
||||
|
||||
@ -172,7 +173,8 @@ void *dbg_malloc(size_t size, const char *pos)
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
|
||||
size = EXTRA_SPACE + (size + sizeof(unsigned) - 1) / sizeof(unsigned);
|
||||
size =
|
||||
EXTRA_SPACE + (size + sizeof(unsigned) - 1) / sizeof(unsigned);
|
||||
buf = xmalloc(size * sizeof(unsigned));
|
||||
|
||||
buf[BLK_STATE] = MAGIC_ALLOC; /* state of the block */
|
||||
@ -254,10 +256,11 @@ void dbg_free(void *ptr, const char *pos)
|
||||
|
||||
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[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]);
|
||||
_("corrupt block end at %s, (end = %u, should be %d)"),
|
||||
pos, buf[size - 1], buf[BLK_ID]);
|
||||
|
||||
buf[0] = MAGIC_FREE;
|
||||
|
||||
|
@ -46,7 +46,8 @@ struct note_gc_hash {
|
||||
HTABLE_ENTRY(note_gc_hash);
|
||||
};
|
||||
|
||||
static void note_gc_extract_key(struct note_gc_hash *, const char **, int *);
|
||||
static void note_gc_extract_key(struct note_gc_hash *, const char **,
|
||||
int *);
|
||||
static int note_gc_cmp(struct note_gc_hash *, struct note_gc_hash *);
|
||||
|
||||
HTABLE_HEAD(htp, NOTE_GC_HSIZE, note_gc_hash);
|
||||
@ -64,7 +65,8 @@ char *generate_note(const char *str)
|
||||
sha1_digest(str, sha1);
|
||||
snprintf(notepath, BUFSIZ, "%s%s", path_notes, sha1);
|
||||
fp = fopen(notepath, "w");
|
||||
EXIT_IF(fp == NULL, _("Warning: could not open %s, Aborting..."), notepath);
|
||||
EXIT_IF(fp == NULL, _("Warning: could not open %s, Aborting..."),
|
||||
notepath);
|
||||
fputs(str, fp);
|
||||
file_close(fp, __FILE_POS__);
|
||||
|
||||
|
118
src/notify.c
118
src/notify.c
@ -131,7 +131,8 @@ void notify_init_vars(void)
|
||||
nbar.notify_all = 0;
|
||||
|
||||
pthread_attr_init(&detached_thread_attr);
|
||||
pthread_attr_setdetachstate(&detached_thread_attr, PTHREAD_CREATE_DETACHED);
|
||||
pthread_attr_setdetachstate(&detached_thread_attr,
|
||||
PTHREAD_CREATE_DETACHED);
|
||||
}
|
||||
|
||||
/* Extract the appointment file name from the complete file path. */
|
||||
@ -159,7 +160,8 @@ void notify_init_bar(void)
|
||||
pthread_mutex_init(¬ify_app.mutex, NULL);
|
||||
notify_app.got_app = 0;
|
||||
notify_app.txt = 0;
|
||||
notify.win = newwin(win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
|
||||
notify.win =
|
||||
newwin(win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
|
||||
extract_aptsfile();
|
||||
}
|
||||
|
||||
@ -192,7 +194,8 @@ void notify_stop_main_thread(void)
|
||||
void notify_reinit_bar(void)
|
||||
{
|
||||
delwin(notify.win);
|
||||
notify.win = newwin(win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
|
||||
notify.win =
|
||||
newwin(win[NOT].h, win[NOT].w, win[NOT].y, win[NOT].x);
|
||||
}
|
||||
|
||||
/* Launch user defined command as a notification. */
|
||||
@ -212,7 +215,8 @@ unsigned notify_launch_cmd(void)
|
||||
return 0;
|
||||
} else if (pid == 0) {
|
||||
/* Child: launch user defined command */
|
||||
if (execlp(nbar.shell, nbar.shell, "-c", nbar.cmd, NULL) < 0) {
|
||||
if (execlp(nbar.shell, nbar.shell, "-c", nbar.cmd, NULL) <
|
||||
0) {
|
||||
ERROR_MSG(_("error while launching command"));
|
||||
_exit(1);
|
||||
}
|
||||
@ -236,7 +240,8 @@ void notify_update_bar(void)
|
||||
date_pos = space;
|
||||
pthread_mutex_lock(¬ify.mutex);
|
||||
|
||||
file_pos = strlen(notify.date) + strlen(notify.time) + 7 + 2 * space;
|
||||
file_pos =
|
||||
strlen(notify.date) + strlen(notify.time) + 7 + 2 * space;
|
||||
app_pos = file_pos + strlen(notify.apts_file) + 2 + space;
|
||||
txt_max_len = col - (app_pos + 12 + space);
|
||||
|
||||
@ -244,7 +249,8 @@ void notify_update_bar(void)
|
||||
custom_apply_attr(notify.win, ATTR_HIGHEST);
|
||||
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);
|
||||
mvwprintw(notify.win, 0, date_pos, "[ %s | %s ]", notify.date,
|
||||
notify.time);
|
||||
mvwprintw(notify.win, 0, file_pos, "(%s)", notify.apts_file);
|
||||
WINS_NBAR_UNLOCK;
|
||||
|
||||
@ -263,12 +269,16 @@ void notify_update_bar(void)
|
||||
int hours_left, minutes_left;
|
||||
|
||||
hours_left = (time_left / HOURINSEC);
|
||||
minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC;
|
||||
minutes_left =
|
||||
(time_left -
|
||||
hours_left * HOURINSEC) / MININSEC;
|
||||
pthread_mutex_lock(&nbar.mutex);
|
||||
|
||||
if (time_left < nbar.cntdwn &&
|
||||
(((notify_app.state & APOINT_NOTIFY) && !nbar.notify_all) ||
|
||||
(!(notify_app.state & APOINT_NOTIFY) && nbar.notify_all)))
|
||||
(((notify_app.state & APOINT_NOTIFY)
|
||||
&& !nbar.notify_all)
|
||||
|| (!(notify_app.state & APOINT_NOTIFY)
|
||||
&& nbar.notify_all)))
|
||||
blinking = 1;
|
||||
else
|
||||
blinking = 0;
|
||||
@ -277,11 +287,14 @@ void notify_update_bar(void)
|
||||
if (blinking)
|
||||
wattron(notify.win, A_BLINK);
|
||||
if (too_long)
|
||||
mvwprintw(notify.win, 0, app_pos, "> %02d:%02d :: %s.. <",
|
||||
mvwprintw(notify.win, 0, app_pos,
|
||||
"> %02d:%02d :: %s.. <",
|
||||
hours_left, minutes_left, buf);
|
||||
else
|
||||
mvwprintw(notify.win, 0, app_pos, "> %02d:%02d :: %s <",
|
||||
hours_left, minutes_left, notify_app.txt);
|
||||
mvwprintw(notify.win, 0, app_pos,
|
||||
"> %02d:%02d :: %s <",
|
||||
hours_left, minutes_left,
|
||||
notify_app.txt);
|
||||
if (blinking)
|
||||
wattroff(notify.win, A_BLINK);
|
||||
WINS_NBAR_UNLOCK;
|
||||
@ -326,8 +339,10 @@ static void *notify_main_thread(void *arg)
|
||||
localtime_r(&ntimer, &ntime);
|
||||
pthread_mutex_lock(¬ify.mutex);
|
||||
pthread_mutex_lock(&nbar.mutex);
|
||||
strftime(notify.time, NOTIFY_FIELD_LENGTH, nbar.timefmt, &ntime);
|
||||
strftime(notify.date, NOTIFY_FIELD_LENGTH, nbar.datefmt, &ntime);
|
||||
strftime(notify.time, NOTIFY_FIELD_LENGTH, nbar.timefmt,
|
||||
&ntime);
|
||||
strftime(notify.date, NOTIFY_FIELD_LENGTH, nbar.datefmt,
|
||||
&ntime);
|
||||
pthread_mutex_unlock(&nbar.mutex);
|
||||
pthread_mutex_unlock(¬ify.mutex);
|
||||
notify_update_bar();
|
||||
@ -418,7 +433,8 @@ static void *notify_thread_app(void *arg)
|
||||
} else {
|
||||
if (force || !notify_same_item(tmp_app.time)) {
|
||||
pthread_mutex_lock(¬ify_app.mutex);
|
||||
notify_update_app(tmp_app.time, tmp_app.state, tmp_app.txt);
|
||||
notify_update_app(tmp_app.time, tmp_app.state,
|
||||
tmp_app.txt);
|
||||
pthread_mutex_unlock(¬ify_app.mutex);
|
||||
}
|
||||
}
|
||||
@ -436,7 +452,8 @@ void notify_check_next_app(int force)
|
||||
pthread_t notify_t_app;
|
||||
void *arg = (force ? (void *)1 : NULL);
|
||||
|
||||
pthread_create(¬ify_t_app, &detached_thread_attr, notify_thread_app, arg);
|
||||
pthread_create(¬ify_t_app, &detached_thread_attr,
|
||||
notify_thread_app, arg);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -475,15 +492,17 @@ void notify_check_repeated(struct recur_apoint *i)
|
||||
|
||||
current_time = time(NULL);
|
||||
pthread_mutex_lock(¬ify_app.mutex);
|
||||
if (recur_item_find_occurrence(i->start, i->dur, &i->exc, i->rpt->type,
|
||||
i->rpt->freq, i->rpt->until, get_today(),
|
||||
&real_app_time)) {
|
||||
if (recur_item_find_occurrence
|
||||
(i->start, i->dur, &i->exc, i->rpt->type, i->rpt->freq,
|
||||
i->rpt->until, get_today(), &real_app_time)) {
|
||||
if (!notify_app.got_app) {
|
||||
if (real_app_time - current_time <= DAYINSEC)
|
||||
update_notify = 1;
|
||||
} else if (real_app_time < notify_app.time && real_app_time >= current_time) {
|
||||
} else if (real_app_time < notify_app.time
|
||||
&& real_app_time >= current_time) {
|
||||
update_notify = 1;
|
||||
} else if (real_app_time == notify_app.time && i->state != notify_app.state) {
|
||||
} else if (real_app_time == notify_app.time
|
||||
&& i->state != notify_app.state) {
|
||||
update_notify = 1;
|
||||
}
|
||||
}
|
||||
@ -512,8 +531,8 @@ int notify_same_recur_item(struct recur_apoint *i)
|
||||
unsigned item_start = 0;
|
||||
|
||||
recur_item_find_occurrence(i->start, i->dur, &i->exc, i->rpt->type,
|
||||
i->rpt->freq, i->rpt->until, get_today(),
|
||||
&item_start);
|
||||
i->rpt->freq, i->rpt->until,
|
||||
get_today(), &item_start);
|
||||
pthread_mutex_lock(¬ify_app.mutex);
|
||||
if (notify_app.got_app && item_start == notify_app.time)
|
||||
same = 1;
|
||||
@ -573,7 +592,8 @@ static unsigned print_config_options(WINDOW * optwin)
|
||||
const int YORIG = 0;
|
||||
const int YOFF = 3;
|
||||
|
||||
enum { SHOW, DATE, CLOCK, WARN, CMD, NOTIFY_ALL, DMON, DMON_LOG, NB_OPT };
|
||||
enum { SHOW, DATE, CLOCK, WARN, CMD, NOTIFY_ALL, DMON, DMON_LOG,
|
||||
NB_OPT };
|
||||
|
||||
struct opt_s {
|
||||
char *name;
|
||||
@ -585,30 +605,36 @@ static unsigned print_config_options(WINDOW * optwin)
|
||||
int i;
|
||||
|
||||
opt[SHOW].name = "appearance.notifybar = ";
|
||||
opt[SHOW].desc = _("(if set to YES, notify-bar will be displayed)");
|
||||
opt[SHOW].desc =
|
||||
_("(if set to YES, notify-bar will be displayed)");
|
||||
|
||||
opt[DATE].name = "format.notifydate = ";
|
||||
opt[DATE].desc = _("(Format of the date to be displayed inside notify-bar)");
|
||||
opt[DATE].desc =
|
||||
_("(Format of the date to be displayed inside notify-bar)");
|
||||
|
||||
opt[CLOCK].name = "format.notifytime = ";
|
||||
opt[CLOCK].desc = _("(Format of the time to be displayed inside notify-bar)");
|
||||
opt[CLOCK].desc =
|
||||
_("(Format of the time to be displayed inside notify-bar)");
|
||||
|
||||
opt[WARN].name = "notification.warning = ";
|
||||
opt[WARN].desc = _("(Warn user if an appointment is within next "
|
||||
"'notify-bar_warning' seconds)");
|
||||
|
||||
opt[CMD].name = "notification.command = ";
|
||||
opt[CMD].desc = _("(Command used to notify user of an upcoming appointment)");
|
||||
opt[CMD].desc =
|
||||
_("(Command used to notify user of an upcoming appointment)");
|
||||
|
||||
opt[NOTIFY_ALL].name = "notification.notifyall = ";
|
||||
opt[NOTIFY_ALL].desc =
|
||||
_("(Notify all appointments instead of flagged ones only)");
|
||||
|
||||
opt[DMON].name = "daemon.enable = ";
|
||||
opt[DMON].desc = _("(Run in background to get notifications after exiting)");
|
||||
opt[DMON].desc =
|
||||
_("(Run in background to get notifications after exiting)");
|
||||
|
||||
opt[DMON_LOG].name = "daemon.log = ";
|
||||
opt[DMON_LOG].desc = _("(Log activity when running in background)");
|
||||
opt[DMON_LOG].desc =
|
||||
_("(Log activity when running in background)");
|
||||
|
||||
pthread_mutex_lock(&nbar.mutex);
|
||||
|
||||
@ -626,8 +652,8 @@ static unsigned print_config_options(WINDOW * optwin)
|
||||
opt[DMON].valnum = dmon.enable;
|
||||
opt[DMON_LOG].valnum = dmon.log;
|
||||
|
||||
opt[SHOW].valstr[0] = opt[NOTIFY_ALL].valstr[0] = opt[DMON].valstr[0] =
|
||||
opt[DMON_LOG].valstr[0] = '\0';
|
||||
opt[SHOW].valstr[0] = opt[NOTIFY_ALL].valstr[0] =
|
||||
opt[DMON].valstr[0] = opt[DMON_LOG].valstr[0] = '\0';
|
||||
|
||||
for (i = 0; i < NB_OPT; i++) {
|
||||
int y;
|
||||
@ -657,15 +683,16 @@ void notify_config_bar(void)
|
||||
{
|
||||
struct scrollwin cwin;
|
||||
char *buf;
|
||||
const char *number_str = _("Enter an option number to change its value");
|
||||
const char *keys = _("(Press '^P' or '^N' to move up or down, 'Q' to quit)");
|
||||
const char *number_str =
|
||||
_("Enter an option number to change its value");
|
||||
const char *keys =
|
||||
_("(Press '^P' or '^N' to move up or down, 'Q' to quit)");
|
||||
const char *date_str =
|
||||
_("Enter the date format (see 'man 3 strftime' for possible formats) ");
|
||||
const char *time_str =
|
||||
_("Enter the time format (see 'man 3 strftime' for possible formats) ");
|
||||
const char *count_str =
|
||||
_
|
||||
("Enter the number of seconds (0 not to be warned before an appointment)");
|
||||
_("Enter the number of seconds (0 not to be warned before an appointment)");
|
||||
const char *cmd_str = _("Enter the notification command ");
|
||||
int ch;
|
||||
|
||||
@ -703,22 +730,26 @@ void notify_config_bar(void)
|
||||
case '2':
|
||||
status_mesg(date_str, "");
|
||||
pthread_mutex_lock(&nbar.mutex);
|
||||
strncpy(buf, nbar.datefmt, strlen(nbar.datefmt) + 1);
|
||||
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);
|
||||
strncpy(nbar.datefmt, buf, strlen(buf) + 1);
|
||||
strncpy(nbar.datefmt, buf,
|
||||
strlen(buf) + 1);
|
||||
pthread_mutex_unlock(&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
case '3':
|
||||
status_mesg(time_str, "");
|
||||
pthread_mutex_lock(&nbar.mutex);
|
||||
strncpy(buf, nbar.timefmt, strlen(nbar.timefmt) + 1);
|
||||
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);
|
||||
strncpy(nbar.timefmt, buf, strlen(buf) + 1);
|
||||
strncpy(nbar.timefmt, buf,
|
||||
strlen(buf) + 1);
|
||||
pthread_mutex_unlock(&nbar.mutex);
|
||||
}
|
||||
break;
|
||||
@ -728,7 +759,8 @@ void notify_config_bar(void)
|
||||
snprintf(buf, BUFSIZ, "%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) {
|
||||
is_all_digit(buf) && atoi(buf) >= 0
|
||||
&& atoi(buf) <= DAYINSEC) {
|
||||
pthread_mutex_lock(&nbar.mutex);
|
||||
nbar.cntdwn = atoi(buf);
|
||||
pthread_mutex_unlock(&nbar.mutex);
|
||||
@ -765,7 +797,9 @@ void notify_config_bar(void)
|
||||
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);
|
||||
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();
|
||||
|
124
src/pcal.c
124
src/pcal.c
@ -71,16 +71,20 @@ foreach_date_dump(const long date_end, struct rpt *rpt, llist_t * exc,
|
||||
item_time = item_first_date - date;
|
||||
|
||||
while (date <= date_end && date <= rpt->until) {
|
||||
if (recur_item_inday(item_first_date, item_dur, exc, rpt->type,
|
||||
rpt->freq, rpt->until, date)) {
|
||||
(*cb_dump) (stream, date + item_time, item_dur, item_mesg);
|
||||
if (recur_item_inday
|
||||
(item_first_date, item_dur, exc, rpt->type, rpt->freq,
|
||||
rpt->until, date)) {
|
||||
(*cb_dump) (stream, date + item_time, item_dur,
|
||||
item_mesg);
|
||||
}
|
||||
switch (rpt->type) {
|
||||
case RECUR_DAILY:
|
||||
date = date_sec_change(date, 0, rpt->freq);
|
||||
break;
|
||||
case RECUR_WEEKLY:
|
||||
date = date_sec_change(date, 0, rpt->freq * WEEKINDAYS);
|
||||
date =
|
||||
date_sec_change(date, 0,
|
||||
rpt->freq * WEEKINDAYS);
|
||||
break;
|
||||
case RECUR_MONTHLY:
|
||||
date = date_sec_change(date, rpt->freq, 0);
|
||||
@ -102,7 +106,8 @@ static void pcal_export_header(FILE * stream)
|
||||
fputs("\n# =======\n# options\n# =======\n", stream);
|
||||
fprintf(stream, "opt -A -K -l -m -F %s\n",
|
||||
ui_calendar_week_begins_on_monday()? "Monday" : "Sunday");
|
||||
fputs("# Display week number (i.e. 1-52) on every Monday\n", stream);
|
||||
fputs("# Display week number (i.e. 1-52) on every Monday\n",
|
||||
stream);
|
||||
fprintf(stream, "all monday in all week %%w\n");
|
||||
fputc('\n', stream);
|
||||
}
|
||||
@ -133,7 +138,8 @@ pcal_dump_apoint(FILE * stream, long apoint_date, long apoint_dur,
|
||||
date_sec2date_fmt(apoint_date, "%R", pcal_beg);
|
||||
date_sec2date_fmt(apoint_date + apoint_dur, "%R", pcal_end);
|
||||
fprintf(stream, "%s ", pcal_date);
|
||||
fprintf(stream, "(%s -> %s) %s\n", pcal_beg, pcal_end, apoint_mesg);
|
||||
fprintf(stream, "(%s -> %s) %s\n", pcal_beg, pcal_end,
|
||||
apoint_mesg);
|
||||
}
|
||||
|
||||
static void pcal_export_recur_events(FILE * stream)
|
||||
@ -144,40 +150,56 @@ static void pcal_export_recur_events(FILE * stream)
|
||||
fputs("\n# =============", stream);
|
||||
fputs("\n# Recur. Events", stream);
|
||||
fputs("\n# =============\n", stream);
|
||||
fputs("# (pcal does not support from..until dates specification\n", stream);
|
||||
fputs("# (pcal does not support from..until dates specification\n",
|
||||
stream);
|
||||
|
||||
LLIST_FOREACH(&recur_elist, i) {
|
||||
struct recur_event *rev = LLIST_GET_DATA(i);
|
||||
if (rev->rpt->until == 0 && rev->rpt->freq == 1) {
|
||||
switch (rev->rpt->type) {
|
||||
case RECUR_DAILY:
|
||||
date_sec2date_fmt(rev->day, "%b %d", pcal_date);
|
||||
fprintf(stream, "all day on_or_after %s %s\n", pcal_date, rev->mesg);
|
||||
date_sec2date_fmt(rev->day, "%b %d",
|
||||
pcal_date);
|
||||
fprintf(stream,
|
||||
"all day on_or_after %s %s\n",
|
||||
pcal_date, rev->mesg);
|
||||
break;
|
||||
case RECUR_WEEKLY:
|
||||
date_sec2date_fmt(rev->day, "%a", pcal_date);
|
||||
fprintf(stream, "all %s on_or_after ", pcal_date);
|
||||
date_sec2date_fmt(rev->day, "%b %d", pcal_date);
|
||||
fprintf(stream, "%s %s\n", pcal_date, rev->mesg);
|
||||
date_sec2date_fmt(rev->day, "%a",
|
||||
pcal_date);
|
||||
fprintf(stream, "all %s on_or_after ",
|
||||
pcal_date);
|
||||
date_sec2date_fmt(rev->day, "%b %d",
|
||||
pcal_date);
|
||||
fprintf(stream, "%s %s\n", pcal_date,
|
||||
rev->mesg);
|
||||
break;
|
||||
case RECUR_MONTHLY:
|
||||
date_sec2date_fmt(rev->day, "%d", pcal_date);
|
||||
fprintf(stream, "day on all %s %s\n", pcal_date, rev->mesg);
|
||||
date_sec2date_fmt(rev->day, "%d",
|
||||
pcal_date);
|
||||
fprintf(stream, "day on all %s %s\n",
|
||||
pcal_date, rev->mesg);
|
||||
break;
|
||||
case RECUR_YEARLY:
|
||||
date_sec2date_fmt(rev->day, "%b %d", pcal_date);
|
||||
fprintf(stream, "%s %s\n", pcal_date, rev->mesg);
|
||||
date_sec2date_fmt(rev->day, "%b %d",
|
||||
pcal_date);
|
||||
fprintf(stream, "%s %s\n", pcal_date,
|
||||
rev->mesg);
|
||||
break;
|
||||
default:
|
||||
EXIT(_("incoherent repetition type"));
|
||||
}
|
||||
} else {
|
||||
const long YEAR_START = ui_calendar_start_of_year();
|
||||
const long YEAR_START =
|
||||
ui_calendar_start_of_year();
|
||||
const long YEAR_END = ui_calendar_end_of_year();
|
||||
|
||||
if (rev->day < YEAR_END && rev->day > YEAR_START)
|
||||
foreach_date_dump(YEAR_END, rev->rpt, &rev->exc, rev->day, 0,
|
||||
rev->mesg, (cb_dump_t) pcal_dump_event, stream);
|
||||
foreach_date_dump(YEAR_END, rev->rpt,
|
||||
&rev->exc, rev->day, 0,
|
||||
rev->mesg,
|
||||
(cb_dump_t)
|
||||
pcal_dump_event, stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -202,48 +224,67 @@ static void pcal_export_recur_apoints(FILE * stream)
|
||||
fputs("\n# ==============", stream);
|
||||
fputs("\n# Recur. Apoints", stream);
|
||||
fputs("\n# ==============\n", stream);
|
||||
fputs("# (pcal does not support from..until dates specification\n", stream);
|
||||
fputs("# (pcal does not support from..until dates specification\n",
|
||||
stream);
|
||||
|
||||
LLIST_TS_FOREACH(&recur_alist_p, i) {
|
||||
struct recur_apoint *rapt = LLIST_TS_GET_DATA(i);
|
||||
|
||||
if (rapt->rpt->until == 0 && rapt->rpt->freq == 1) {
|
||||
date_sec2date_fmt(rapt->start, "%R", pcal_beg);
|
||||
date_sec2date_fmt(rapt->start + rapt->dur, "%R", pcal_end);
|
||||
date_sec2date_fmt(rapt->start + rapt->dur, "%R",
|
||||
pcal_end);
|
||||
switch (rapt->rpt->type) {
|
||||
case RECUR_DAILY:
|
||||
date_sec2date_fmt(rapt->start, "%b %d", pcal_date);
|
||||
fprintf(stream, "all day on_or_after %s (%s -> %s) %s\n",
|
||||
pcal_date, pcal_beg, pcal_end, rapt->mesg);
|
||||
date_sec2date_fmt(rapt->start, "%b %d",
|
||||
pcal_date);
|
||||
fprintf(stream,
|
||||
"all day on_or_after %s (%s -> %s) %s\n",
|
||||
pcal_date, pcal_beg, pcal_end,
|
||||
rapt->mesg);
|
||||
break;
|
||||
case RECUR_WEEKLY:
|
||||
date_sec2date_fmt(rapt->start, "%a", pcal_date);
|
||||
fprintf(stream, "all %s on_or_after ", pcal_date);
|
||||
date_sec2date_fmt(rapt->start, "%b %d", pcal_date);
|
||||
fprintf(stream, "%s (%s -> %s) %s\n", pcal_date, pcal_beg,
|
||||
pcal_end, rapt->mesg);
|
||||
date_sec2date_fmt(rapt->start, "%a",
|
||||
pcal_date);
|
||||
fprintf(stream, "all %s on_or_after ",
|
||||
pcal_date);
|
||||
date_sec2date_fmt(rapt->start, "%b %d",
|
||||
pcal_date);
|
||||
fprintf(stream, "%s (%s -> %s) %s\n",
|
||||
pcal_date, pcal_beg, pcal_end,
|
||||
rapt->mesg);
|
||||
break;
|
||||
case RECUR_MONTHLY:
|
||||
date_sec2date_fmt(rapt->start, "%d", pcal_date);
|
||||
fprintf(stream, "day on all %s (%s -> %s) %s\n", pcal_date,
|
||||
pcal_beg, pcal_end, rapt->mesg);
|
||||
date_sec2date_fmt(rapt->start, "%d",
|
||||
pcal_date);
|
||||
fprintf(stream,
|
||||
"day on all %s (%s -> %s) %s\n",
|
||||
pcal_date, pcal_beg, pcal_end,
|
||||
rapt->mesg);
|
||||
break;
|
||||
case RECUR_YEARLY:
|
||||
date_sec2date_fmt(rapt->start, "%b %d", pcal_date);
|
||||
fprintf(stream, "%s (%s -> %s) %s\n", pcal_date, pcal_beg,
|
||||
pcal_end, rapt->mesg);
|
||||
date_sec2date_fmt(rapt->start, "%b %d",
|
||||
pcal_date);
|
||||
fprintf(stream, "%s (%s -> %s) %s\n",
|
||||
pcal_date, pcal_beg, pcal_end,
|
||||
rapt->mesg);
|
||||
break;
|
||||
default:
|
||||
EXIT(_("incoherent repetition type"));
|
||||
}
|
||||
} else {
|
||||
const long YEAR_START = ui_calendar_start_of_year();
|
||||
const long YEAR_START =
|
||||
ui_calendar_start_of_year();
|
||||
const long YEAR_END = ui_calendar_end_of_year();
|
||||
|
||||
if (rapt->start < YEAR_END && rapt->start > YEAR_START)
|
||||
foreach_date_dump(YEAR_END, rapt->rpt, &rapt->exc, rapt->start,
|
||||
if (rapt->start < YEAR_END
|
||||
&& rapt->start > YEAR_START)
|
||||
foreach_date_dump(YEAR_END, rapt->rpt,
|
||||
&rapt->exc, rapt->start,
|
||||
rapt->dur, rapt->mesg,
|
||||
(cb_dump_t) pcal_dump_apoint, stream);
|
||||
(cb_dump_t)
|
||||
pcal_dump_apoint,
|
||||
stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -252,7 +293,8 @@ static void pcal_export_apoints(FILE * stream)
|
||||
{
|
||||
llist_item_t *i;
|
||||
|
||||
fputs("\n# ============\n# Appointments\n# ============\n", stream);
|
||||
fputs("\n# ============\n# Appointments\n# ============\n",
|
||||
stream);
|
||||
LLIST_TS_LOCK(&alist_p);
|
||||
LLIST_TS_FOREACH(&alist_p, i) {
|
||||
struct apoint *apt = LLIST_TS_GET_DATA(i);
|
||||
|
141
src/recur.c
141
src/recur.c
@ -112,7 +112,8 @@ struct recur_apoint *recur_apoint_dup(struct recur_apoint *in)
|
||||
{
|
||||
EXIT_IF(!in, _("null pointer"));
|
||||
|
||||
struct recur_apoint *rapt = mem_malloc(sizeof(struct recur_apoint));
|
||||
struct recur_apoint *rapt =
|
||||
mem_malloc(sizeof(struct recur_apoint));
|
||||
|
||||
rapt->start = in->start;
|
||||
rapt->dur = in->dur;
|
||||
@ -179,17 +180,20 @@ recur_apoint_cmp_start(struct recur_apoint *a, struct recur_apoint *b)
|
||||
return a->start < b->start ? -1 : (a->start == b->start ? 0 : 1);
|
||||
}
|
||||
|
||||
static int recur_event_cmp_day(struct recur_event *a, struct recur_event *b)
|
||||
static int recur_event_cmp_day(struct recur_event *a,
|
||||
struct recur_event *b)
|
||||
{
|
||||
return a->day < b->day ? -1 : (a->day == b->day ? 0 : 1);
|
||||
}
|
||||
|
||||
/* 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, llist_t * except)
|
||||
long dur, char state, int type,
|
||||
int freq, long until,
|
||||
llist_t * except)
|
||||
{
|
||||
struct recur_apoint *rapt = mem_malloc(sizeof(struct recur_apoint));
|
||||
struct recur_apoint *rapt =
|
||||
mem_malloc(sizeof(struct recur_apoint));
|
||||
|
||||
rapt->rpt = mem_malloc(sizeof(struct rpt));
|
||||
rapt->mesg = mem_strdup(mesg);
|
||||
@ -215,8 +219,8 @@ struct recur_apoint *recur_apoint_new(char *mesg, char *note, long start,
|
||||
}
|
||||
|
||||
/* 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 recur_event *recur_event_new(char *mesg, char *note, long day,
|
||||
int id, int type, int freq, long until,
|
||||
llist_t * except)
|
||||
{
|
||||
struct recur_event *rev = mem_malloc(sizeof(struct recur_event));
|
||||
@ -318,9 +322,10 @@ static void recur_write_exc(llist_t * lexc, 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, llist_t * exc, char state)
|
||||
struct recur_apoint *recur_apoint_scan(FILE * f, struct tm start,
|
||||
struct tm end, char type, int freq,
|
||||
struct tm until, char *note,
|
||||
llist_t * exc, char state)
|
||||
{
|
||||
char buf[BUFSIZ], *nl;
|
||||
time_t tstart, tend, tuntil;
|
||||
@ -329,7 +334,8 @@ struct recur_apoint *recur_apoint_scan(FILE * f, struct tm start, struct tm end,
|
||||
!check_date(end.tm_year, end.tm_mon, end.tm_mday) ||
|
||||
!check_time(start.tm_hour, start.tm_min) ||
|
||||
!check_time(end.tm_hour, end.tm_min) ||
|
||||
(until.tm_year != 0 && !check_date(until.tm_year, until.tm_mon,
|
||||
(until.tm_year != 0
|
||||
&& !check_date(until.tm_year, until.tm_mon,
|
||||
until.tm_mday)),
|
||||
_("date error in appointment"));
|
||||
|
||||
@ -361,8 +367,8 @@ struct recur_apoint *recur_apoint_scan(FILE * f, struct tm start, struct tm end,
|
||||
} else {
|
||||
tuntil = 0;
|
||||
}
|
||||
EXIT_IF(tstart == -1 || tend == -1 || tstart > tend || tuntil == -1,
|
||||
_("date error in appointment"));
|
||||
EXIT_IF(tstart == -1 || tend == -1 || tstart > tend
|
||||
|| tuntil == -1, _("date error in appointment"));
|
||||
|
||||
return recur_apoint_new(buf, note, tstart, tend - tstart, state,
|
||||
recur_char2def(type), freq, tuntil, exc);
|
||||
@ -378,9 +384,9 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
|
||||
|
||||
EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) ||
|
||||
!check_time(start.tm_hour, start.tm_min) ||
|
||||
(until.tm_year != 0 && !check_date(until.tm_year, until.tm_mon,
|
||||
until.tm_mday)),
|
||||
_("date error in event"));
|
||||
(until.tm_year != 0
|
||||
&& !check_date(until.tm_year, until.tm_mon,
|
||||
until.tm_mday)), _("date error in event"));
|
||||
|
||||
/* Read the event description */
|
||||
if (!fgets(buf, sizeof buf, f))
|
||||
@ -406,8 +412,8 @@ struct recur_event *recur_event_scan(FILE * f, struct tm start, int id,
|
||||
tstart = mktime(&start);
|
||||
EXIT_IF(tstart == -1 || tuntil == -1, _("date error in event"));
|
||||
|
||||
return recur_event_new(buf, note, tstart, id, recur_char2def(type), freq,
|
||||
tuntil, exc);
|
||||
return recur_event_new(buf, note, tstart, id, recur_char2def(type),
|
||||
freq, tuntil, exc);
|
||||
}
|
||||
|
||||
/* Writting of a recursive appointment into file. */
|
||||
@ -423,17 +429,18 @@ void recur_apoint_write(struct recur_apoint *o, FILE * f)
|
||||
|
||||
t = o->start + o->dur;
|
||||
localtime_r(&t, <);
|
||||
fprintf(f, " -> %02u/%02u/%04u @ %02u:%02u", lt.tm_mon + 1, lt.tm_mday,
|
||||
1900 + lt.tm_year, lt.tm_hour, lt.tm_min);
|
||||
fprintf(f, " -> %02u/%02u/%04u @ %02u:%02u", lt.tm_mon + 1,
|
||||
lt.tm_mday, 1900 + lt.tm_year, lt.tm_hour, lt.tm_min);
|
||||
|
||||
t = o->rpt->until;
|
||||
if (t == 0) { /* We have an endless recurrent appointment. */
|
||||
fprintf(f, " {%d%c", o->rpt->freq, recur_def2char(o->rpt->type));
|
||||
fprintf(f, " {%d%c", o->rpt->freq,
|
||||
recur_def2char(o->rpt->type));
|
||||
} else {
|
||||
localtime_r(&t, <);
|
||||
fprintf(f, " {%d%c -> %02u/%02u/%04u", o->rpt->freq,
|
||||
recur_def2char(o->rpt->type), lt.tm_mon + 1, lt.tm_mday,
|
||||
1900 + lt.tm_year);
|
||||
recur_def2char(o->rpt->type), lt.tm_mon + 1,
|
||||
lt.tm_mday, 1900 + lt.tm_year);
|
||||
}
|
||||
recur_write_exc(&o->exc, f);
|
||||
fputs("} ", f);
|
||||
@ -461,16 +468,18 @@ void recur_event_write(struct recur_event *o, FILE * f)
|
||||
st_year = lt.tm_year + 1900;
|
||||
t = o->rpt->until;
|
||||
if (t == 0) { /* We have an endless recurrent event. */
|
||||
fprintf(f, "%02u/%02u/%04u [%d] {%d%c", st_mon, st_day, st_year, o->id,
|
||||
o->rpt->freq, recur_def2char(o->rpt->type));
|
||||
fprintf(f, "%02u/%02u/%04u [%d] {%d%c", st_mon, st_day,
|
||||
st_year, o->id, o->rpt->freq,
|
||||
recur_def2char(o->rpt->type));
|
||||
} else {
|
||||
localtime_r(&t, <);
|
||||
end_mon = lt.tm_mon + 1;
|
||||
end_day = lt.tm_mday;
|
||||
end_year = lt.tm_year + 1900;
|
||||
fprintf(f, "%02u/%02u/%04u [%d] {%d%c -> %02u/%02u/%04u", st_mon,
|
||||
st_day, st_year, o->id, o->rpt->freq,
|
||||
recur_def2char(o->rpt->type), end_mon, end_day, end_year);
|
||||
fprintf(f, "%02u/%02u/%04u [%d] {%d%c -> %02u/%02u/%04u",
|
||||
st_mon, st_day, st_year, o->id, o->rpt->freq,
|
||||
recur_def2char(o->rpt->type), end_mon, end_day,
|
||||
end_year);
|
||||
}
|
||||
recur_write_exc(&o->exc, f);
|
||||
fputs("} ", f);
|
||||
@ -563,9 +572,10 @@ static int exc_inday(struct excp *exc, long *day_start)
|
||||
* calculation of recurrent dates after a turn of years.
|
||||
*/
|
||||
unsigned
|
||||
recur_item_find_occurrence(long item_start, long item_dur, llist_t * item_exc,
|
||||
int rpt_type, int rpt_freq, long rpt_until,
|
||||
long day_start, unsigned *occurrence)
|
||||
recur_item_find_occurrence(long item_start, long item_dur,
|
||||
llist_t * item_exc, int rpt_type, int rpt_freq,
|
||||
long rpt_until, long day_start,
|
||||
unsigned *occurrence)
|
||||
{
|
||||
struct date start_date;
|
||||
long diff, span;
|
||||
@ -587,7 +597,8 @@ recur_item_find_occurrence(long item_start, long item_dur, llist_t * item_exc,
|
||||
lt_item_day = lt_item;
|
||||
lt_item_day.tm_sec = lt_item_day.tm_min = lt_item_day.tm_hour = 0;
|
||||
|
||||
span = (item_start - mktime(<_item_day) + item_dur - 1) / DAYINSEC;
|
||||
span =
|
||||
(item_start - mktime(<_item_day) + item_dur - 1) / DAYINSEC;
|
||||
|
||||
switch (rpt_type) {
|
||||
case RECUR_DAILY:
|
||||
@ -597,7 +608,9 @@ recur_item_find_occurrence(long item_start, long item_dur, llist_t * item_exc,
|
||||
lt_item_day.tm_year = lt_day.tm_year;
|
||||
break;
|
||||
case RECUR_WEEKLY:
|
||||
diff = diff_days(lt_item_day, lt_day) % (rpt_freq * WEEKINDAYS);
|
||||
diff =
|
||||
diff_days(lt_item_day,
|
||||
lt_day) % (rpt_freq * WEEKINDAYS);
|
||||
lt_item_day.tm_mday = lt_day.tm_mday - diff;
|
||||
lt_item_day.tm_mon = lt_day.tm_mon;
|
||||
lt_item_day.tm_year = lt_day.tm_year;
|
||||
@ -639,7 +652,9 @@ recur_item_find_occurrence(long item_start, long item_dur, llist_t * item_exc,
|
||||
start_date.mm = lt_item_day.tm_mon + 1;
|
||||
start_date.yyyy = lt_item_day.tm_year + 1900;
|
||||
|
||||
*occurrence = date2sec(start_date, lt_item.tm_hour, lt_item.tm_min);
|
||||
*occurrence =
|
||||
date2sec(start_date, lt_item.tm_hour,
|
||||
lt_item.tm_min);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -652,9 +667,11 @@ unsigned
|
||||
recur_apoint_find_occurrence(struct recur_apoint *rapt, long day_start,
|
||||
unsigned *occurrence)
|
||||
{
|
||||
return recur_item_find_occurrence(rapt->start, rapt->dur, &rapt->exc,
|
||||
rapt->rpt->type, rapt->rpt->freq,
|
||||
rapt->rpt->until, day_start, occurrence);
|
||||
return recur_item_find_occurrence(rapt->start, rapt->dur,
|
||||
&rapt->exc, rapt->rpt->type,
|
||||
rapt->rpt->freq,
|
||||
rapt->rpt->until, day_start,
|
||||
occurrence);
|
||||
}
|
||||
|
||||
unsigned
|
||||
@ -663,42 +680,45 @@ recur_event_find_occurrence(struct recur_event *rev, long day_start,
|
||||
{
|
||||
return recur_item_find_occurrence(rev->day, DAYINSEC, &rev->exc,
|
||||
rev->rpt->type, rev->rpt->freq,
|
||||
rev->rpt->until, day_start, occurrence);
|
||||
rev->rpt->until, day_start,
|
||||
occurrence);
|
||||
}
|
||||
|
||||
/* Check if a recurrent item belongs to the selected day. */
|
||||
unsigned
|
||||
recur_item_inday(long item_start, long item_dur, llist_t * item_exc,
|
||||
int rpt_type, int rpt_freq, long rpt_until, long day_start)
|
||||
int rpt_type, int rpt_freq, long rpt_until,
|
||||
long day_start)
|
||||
{
|
||||
/* We do not need the (real) start time of the occurrence here, so just
|
||||
* ignore the buffer. */
|
||||
return recur_item_find_occurrence(item_start, item_dur, item_exc, rpt_type,
|
||||
rpt_freq, rpt_until, day_start, NULL);
|
||||
return recur_item_find_occurrence(item_start, item_dur, item_exc,
|
||||
rpt_type, rpt_freq, rpt_until,
|
||||
day_start, NULL);
|
||||
}
|
||||
|
||||
unsigned recur_apoint_inday(struct recur_apoint *rapt, long *day_start)
|
||||
{
|
||||
return recur_item_inday(rapt->start, rapt->dur, &rapt->exc, rapt->rpt->type,
|
||||
rapt->rpt->freq, rapt->rpt->until, *day_start);
|
||||
return recur_item_inday(rapt->start, rapt->dur, &rapt->exc,
|
||||
rapt->rpt->type, rapt->rpt->freq,
|
||||
rapt->rpt->until, *day_start);
|
||||
}
|
||||
|
||||
unsigned recur_event_inday(struct recur_event *rev, long *day_start)
|
||||
{
|
||||
return recur_item_inday(rev->day, DAYINSEC, &rev->exc, rev->rpt->type,
|
||||
rev->rpt->freq, rev->rpt->until, *day_start);
|
||||
return recur_item_inday(rev->day, DAYINSEC, &rev->exc,
|
||||
rev->rpt->type, rev->rpt->freq,
|
||||
rev->rpt->until, *day_start);
|
||||
}
|
||||
|
||||
/* Add an exception to a recurrent event. */
|
||||
void
|
||||
recur_event_add_exc(struct recur_event *rev, long date)
|
||||
void recur_event_add_exc(struct recur_event *rev, long date)
|
||||
{
|
||||
recur_add_exc(&rev->exc, date);
|
||||
}
|
||||
|
||||
/* Add an exception to a recurrent appointment. */
|
||||
void
|
||||
recur_apoint_add_exc(struct recur_apoint *rapt, long date)
|
||||
void recur_apoint_add_exc(struct recur_apoint *rapt, long date)
|
||||
{
|
||||
int need_check_notify = 0;
|
||||
|
||||
@ -713,8 +733,7 @@ recur_apoint_add_exc(struct recur_apoint *rapt, long date)
|
||||
* Delete a recurrent event from the list (if delete_whole is not null),
|
||||
* or delete only one occurence of the recurrent event.
|
||||
*/
|
||||
void
|
||||
recur_event_erase(struct recur_event *rev)
|
||||
void recur_event_erase(struct recur_event *rev)
|
||||
{
|
||||
llist_item_t *i = LLIST_FIND_FIRST(&recur_elist, rev, NULL);
|
||||
|
||||
@ -728,8 +747,7 @@ recur_event_erase(struct recur_event *rev)
|
||||
* Delete a recurrent appointment from the list (if delete_whole is not null),
|
||||
* or delete only one occurence of the recurrent appointment.
|
||||
*/
|
||||
void
|
||||
recur_apoint_erase(struct recur_apoint *rapt)
|
||||
void recur_apoint_erase(struct recur_apoint *rapt)
|
||||
{
|
||||
LLIST_TS_LOCK(&recur_alist_p);
|
||||
|
||||
@ -765,8 +783,8 @@ void recur_exc_scan(llist_t * lexc, FILE * data_file)
|
||||
EXIT(_("syntax error in item date"));
|
||||
}
|
||||
|
||||
EXIT_IF(!check_date(day.tm_year, day.tm_mon, day.tm_mday) ||
|
||||
!check_time(day.tm_hour, day.tm_min),
|
||||
EXIT_IF(!check_date(day.tm_year, day.tm_mon, day.tm_mday)
|
||||
|| !check_time(day.tm_hour, day.tm_min),
|
||||
_("date error in item exception"));
|
||||
|
||||
day.tm_hour = 0;
|
||||
@ -789,19 +807,20 @@ static int recur_apoint_starts_before(struct recur_apoint *rapt, long time)
|
||||
* Look in the appointment list if we have an item which starts before the item
|
||||
* stored in the notify_app structure (which is the next item to be notified).
|
||||
*/
|
||||
struct notify_app *recur_apoint_check_next(struct notify_app *app, long start,
|
||||
long day)
|
||||
struct notify_app *recur_apoint_check_next(struct notify_app *app,
|
||||
long start, long day)
|
||||
{
|
||||
llist_item_t *i;
|
||||
unsigned real_recur_start_time;
|
||||
|
||||
LLIST_TS_LOCK(&recur_alist_p);
|
||||
LLIST_TS_FIND_FOREACH(&recur_alist_p, &app->time, recur_apoint_starts_before,
|
||||
i) {
|
||||
LLIST_TS_FIND_FOREACH(&recur_alist_p, &app->time,
|
||||
recur_apoint_starts_before, i) {
|
||||
struct recur_apoint *rapt = LLIST_TS_GET_DATA(i);
|
||||
|
||||
if (recur_apoint_find_occurrence(rapt, day, &real_recur_start_time) &&
|
||||
real_recur_start_time > start) {
|
||||
if (recur_apoint_find_occurrence
|
||||
(rapt, day, &real_recur_start_time)
|
||||
&& real_recur_start_time > start) {
|
||||
app->time = real_recur_start_time;
|
||||
app->txt = mem_strdup(rapt->mesg);
|
||||
app->state = rapt->state;
|
||||
|
@ -219,7 +219,10 @@ void sha1_final(sha1_ctx_t * ctx, uint8_t digest[SHA1_DIGESTLEN])
|
||||
|
||||
sha1_update(ctx, finalcount, 8);
|
||||
for (i = 0; i < SHA1_DIGESTLEN; i++)
|
||||
digest[i] = (uint8_t) ((ctx->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
|
||||
digest[i] =
|
||||
(uint8_t) ((ctx->
|
||||
state[i >> 2] >> ((3 - (i & 3)) *
|
||||
8)) & 255);
|
||||
|
||||
i = j = 0;
|
||||
memset(ctx->buffer, 0, SHA1_BLOCKLEN);
|
||||
|
@ -76,7 +76,8 @@ static void generic_hdlr(int sig)
|
||||
break;
|
||||
case SIGTERM:
|
||||
if (unlink(path_cpid) != 0) {
|
||||
EXIT(_("Could not remove calcurse lock file: %s\n"), strerror(errno));
|
||||
EXIT(_("Could not remove calcurse lock file: %s\n"),
|
||||
strerror(errno));
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
@ -92,7 +93,8 @@ unsigned sigs_set_hdlr(int sig, void (*handler) (int))
|
||||
sa.sa_handler = handler;
|
||||
sa.sa_flags = 0;
|
||||
if (sigaction(sig, &sa, NULL) == -1) {
|
||||
ERROR_MSG(_("Error setting signal #%d : %s\n"), sig, strerror(errno));
|
||||
ERROR_MSG(_("Error setting signal #%d : %s\n"), sig,
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,8 @@ struct todo *todo_add(char *mesg, int id, char *note)
|
||||
todo = mem_malloc(sizeof(struct todo));
|
||||
todo->mesg = mem_strdup(mesg);
|
||||
todo->id = id;
|
||||
todo->note = (note != NULL && note[0] != '\0') ? mem_strdup(note) : NULL;
|
||||
todo->note = (note != NULL
|
||||
&& note[0] != '\0') ? mem_strdup(note) : NULL;
|
||||
|
||||
LLIST_ADD_SORTED(&todolist, todo, todo_cmp_id);
|
||||
|
||||
@ -81,7 +82,8 @@ struct todo *todo_add(char *mesg, int id, char *note)
|
||||
void todo_write(struct todo *todo, FILE * f)
|
||||
{
|
||||
if (todo->note)
|
||||
fprintf(f, "[%d]>%s %s\n", todo->id, todo->note, todo->mesg);
|
||||
fprintf(f, "[%d]>%s %s\n", todo->id, todo->note,
|
||||
todo->mesg);
|
||||
else
|
||||
fprintf(f, "[%d] %s\n", todo->id, todo->mesg);
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ void ui_calendar_view_prev(void)
|
||||
|
||||
void ui_calendar_set_view(int view)
|
||||
{
|
||||
ui_calendar_view = (view < 0 || view >= CAL_VIEWS) ? CAL_MONTH_VIEW : view;
|
||||
ui_calendar_view = (view < 0
|
||||
|| view >= CAL_VIEWS) ? CAL_MONTH_VIEW : view;
|
||||
}
|
||||
|
||||
int ui_calendar_get_view(void)
|
||||
@ -128,7 +129,8 @@ static void *ui_calendar_date_thread(void *arg)
|
||||
/* Launch the calendar date thread. */
|
||||
void ui_calendar_start_date_thread(void)
|
||||
{
|
||||
pthread_create(&ui_calendar_t_date, NULL, ui_calendar_date_thread, NULL);
|
||||
pthread_create(&ui_calendar_t_date, NULL, ui_calendar_date_thread,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* Stop the calendar date thread. */
|
||||
@ -303,7 +305,9 @@ draw_monthly_view(struct window *cwin, struct date *current_day,
|
||||
* the first calendar day will be monday or sunday, depending on
|
||||
* 'week_begins_on_monday' value
|
||||
*/
|
||||
c_day_1 = (int)((ymd_to_scalar(yr, mo, 1 + sunday_first) - (long)1) % 7L);
|
||||
c_day_1 =
|
||||
(int)((ymd_to_scalar(yr, mo, 1 + sunday_first) -
|
||||
(long)1) % 7L);
|
||||
|
||||
/* Write the current month and year on top of the calendar */
|
||||
WINS_CALENDAR_LOCK;
|
||||
@ -317,7 +321,8 @@ draw_monthly_view(struct window *cwin, struct date *current_day,
|
||||
/* print the days, with regards to the first day of the week */
|
||||
custom_apply_attr(cwin->p, ATTR_HIGHEST);
|
||||
for (j = 0; j < WEEKINDAYS; j++) {
|
||||
mvwaddstr(cwin->p, ofs_y, ofs_x + 4 * j, _(daynames[1 + j - sunday_first]));
|
||||
mvwaddstr(cwin->p, ofs_y, ofs_x + 4 * j,
|
||||
_(daynames[1 + j - sunday_first]));
|
||||
}
|
||||
custom_remove_attr(cwin->p, ATTR_HIGHEST);
|
||||
WINS_CALENDAR_UNLOCK;
|
||||
@ -357,23 +362,27 @@ draw_monthly_view(struct window *cwin, struct date *current_day,
|
||||
/* This is today, so print it in yellow. */
|
||||
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);
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
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,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
custom_remove_attr(cwin->p, ATTR_HIGHEST);
|
||||
} else if (item_this_day) {
|
||||
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);
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
custom_remove_attr(cwin->p, ATTR_LOW);
|
||||
} else {
|
||||
/* otherwise, print normal days in black */
|
||||
mvwprintw(cwin->p, ofs_y + 1,
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||
c_day);
|
||||
}
|
||||
WINS_CALENDAR_UNLOCK;
|
||||
}
|
||||
@ -431,8 +440,10 @@ static int ISO8601weeknum(const struct tm *t)
|
||||
dec31ly.tm_year--;
|
||||
dec31ly.tm_mon = 11;
|
||||
dec31ly.tm_mday = 31;
|
||||
dec31ly.tm_wday = (jan1day == SUNDAY) ? 6 : jan1day - 1;
|
||||
dec31ly.tm_yday = 364 + ISLEAP(dec31ly.tm_year + 1900);
|
||||
dec31ly.tm_wday =
|
||||
(jan1day == SUNDAY) ? 6 : jan1day - 1;
|
||||
dec31ly.tm_yday =
|
||||
364 + ISLEAP(dec31ly.tm_year + 1900);
|
||||
wnum = ISO8601weeknum(&dec31ly);
|
||||
}
|
||||
break;
|
||||
@ -483,8 +494,8 @@ draw_weekly_view(struct window *cwin, struct date *current_day,
|
||||
weeknum = ISO8601weeknum(&t);
|
||||
WINS_CALENDAR_LOCK;
|
||||
custom_apply_attr(cwin->p, ATTR_HIGHEST);
|
||||
mvwprintw(cwin->p, conf.compact_panels ? 0 : 2, cwin->w - 9, "(# %02d)",
|
||||
weeknum);
|
||||
mvwprintw(cwin->p, conf.compact_panels ? 0 : 2, cwin->w - 9,
|
||||
"(# %02d)", weeknum);
|
||||
custom_remove_attr(cwin->p, ATTR_HIGHEST);
|
||||
WINS_CALENDAR_UNLOCK;
|
||||
|
||||
@ -496,7 +507,8 @@ draw_weekly_view(struct window *cwin, struct date *current_day,
|
||||
|
||||
/* print the day names, with regards to the first day of the week */
|
||||
custom_apply_attr(cwin->p, ATTR_HIGHEST);
|
||||
mvwaddstr(cwin->p, OFFY, OFFX + 4 * j, _(daynames[1 + j - sunday_first]));
|
||||
mvwaddstr(cwin->p, OFFY, OFFX + 4 * j,
|
||||
_(daynames[1 + j - sunday_first]));
|
||||
custom_remove_attr(cwin->p, ATTR_HIGHEST);
|
||||
|
||||
/* Check if the day to be printed has an item or not. */
|
||||
@ -521,7 +533,8 @@ draw_weekly_view(struct window *cwin, struct date *current_day,
|
||||
WINS_CALENDAR_LOCK;
|
||||
if (attr)
|
||||
custom_apply_attr(cwin->p, attr);
|
||||
mvwprintw(cwin->p, OFFY + 1, OFFX + 1 + 4 * j, "%02d", t.tm_mday);
|
||||
mvwprintw(cwin->p, OFFY + 1, OFFX + 1 + 4 * j, "%02d",
|
||||
t.tm_mday);
|
||||
if (attr)
|
||||
custom_remove_attr(cwin->p, attr);
|
||||
WINS_CALENDAR_UNLOCK;
|
||||
@ -530,24 +543,33 @@ draw_weekly_view(struct window *cwin, struct date *current_day,
|
||||
memset(slices, 0, DAYSLICESNO * sizeof *slices);
|
||||
if (day_chk_busy_slices(date, DAYSLICESNO, slices)) {
|
||||
for (i = 0; i < DAYSLICESNO; i++) {
|
||||
if (j != WEEKINDAYS - 1 && i != DAYSLICESNO - 1) {
|
||||
if (j != WEEKINDAYS - 1
|
||||
&& i != DAYSLICESNO - 1) {
|
||||
WINS_CALENDAR_LOCK;
|
||||
mvwhline(cwin->p, OFFY + 2 + i, OFFX + 3 + 4 * j, ACS_S9, 2);
|
||||
mvwhline(cwin->p, OFFY + 2 + i,
|
||||
OFFX + 3 + 4 * j, ACS_S9,
|
||||
2);
|
||||
WINS_CALENDAR_UNLOCK;
|
||||
}
|
||||
if (slices[i]) {
|
||||
int highlight;
|
||||
|
||||
highlight = (t.tm_mday == slctd_day.dd) ? 1 : 0;
|
||||
highlight =
|
||||
(t.tm_mday ==
|
||||
slctd_day.dd) ? 1 : 0;
|
||||
WINS_CALENDAR_LOCK;
|
||||
if (highlight)
|
||||
custom_apply_attr(cwin->p, attr);
|
||||
custom_apply_attr(cwin->p,
|
||||
attr);
|
||||
wattron(cwin->p, A_REVERSE);
|
||||
mvwaddstr(cwin->p, OFFY + 2 + i, OFFX + 1 + 4 * j, " ");
|
||||
mvwaddstr(cwin->p, OFFY + 2 + i, OFFX + 2 + 4 * j, " ");
|
||||
mvwaddstr(cwin->p, OFFY + 2 + i,
|
||||
OFFX + 1 + 4 * j, " ");
|
||||
mvwaddstr(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);
|
||||
WINS_CALENDAR_UNLOCK;
|
||||
}
|
||||
}
|
||||
@ -578,8 +600,8 @@ void ui_calendar_update_panel(struct window *cwin)
|
||||
ui_calendar_store_current_date(¤t_day);
|
||||
|
||||
WINS_CALENDAR_LOCK;
|
||||
erase_window_part(cwin->p, 1, conf.compact_panels ? 1 : 3, cwin->w - 2,
|
||||
cwin->h - 2);
|
||||
erase_window_part(cwin->p, 1, conf.compact_panels ? 1 : 3,
|
||||
cwin->w - 2, cwin->h - 2);
|
||||
if (!conf.compact_panels)
|
||||
mvwhline(cwin->p, 2, 1, ACS_HLINE, cwin->w - 2);
|
||||
WINS_CALENDAR_UNLOCK;
|
||||
@ -619,19 +641,24 @@ void ui_calendar_change_day(int datefmt)
|
||||
_("The day you entered is not valid "
|
||||
"(should be between 01/01/1902 and 12/31/2037)");
|
||||
const char *mesg_line2 = _("Press [ENTER] to continue");
|
||||
const char *request_date = _("Enter the day to go to [ENTER for today] : %s");
|
||||
const char *request_date =
|
||||
_("Enter the day to go to [ENTER for today] : %s");
|
||||
|
||||
while (wrong_day) {
|
||||
snprintf(outstr, BUFSIZ, request_date, DATEFMT_DESC(datefmt));
|
||||
snprintf(outstr, BUFSIZ, request_date,
|
||||
DATEFMT_DESC(datefmt));
|
||||
status_mesg(outstr, "");
|
||||
if (getstring(win[STA].p, selected_day, LDAY, 0, 1) == GETSTRING_ESC) {
|
||||
if (getstring(win[STA].p, selected_day, LDAY, 0, 1) ==
|
||||
GETSTRING_ESC) {
|
||||
return;
|
||||
} else {
|
||||
if (strlen(selected_day) == 0) {
|
||||
wrong_day = 0;
|
||||
ui_calendar_goto_today();
|
||||
} else if (parse_date(selected_day, datefmt, &dyear, &dmonth, &dday,
|
||||
ui_calendar_get_slctd_day())) {
|
||||
} else
|
||||
if (parse_date
|
||||
(selected_day, datefmt, &dyear, &dmonth,
|
||||
&dday, ui_calendar_get_slctd_day())) {
|
||||
wrong_day = 0;
|
||||
/* go to chosen day */
|
||||
slctd_day.dd = dday;
|
||||
@ -687,19 +714,25 @@ void ui_calendar_move(enum move move, int count)
|
||||
/* Normalize struct tm to get week day number. */
|
||||
mktime(&t);
|
||||
if (ui_calendar_week_begins_on_monday())
|
||||
days_to_remove = ((t.tm_wday == 0) ? WEEKINDAYS - 1 : t.tm_wday - 1);
|
||||
days_to_remove =
|
||||
((t.tm_wday ==
|
||||
0) ? WEEKINDAYS - 1 : t.tm_wday - 1);
|
||||
else
|
||||
days_to_remove = ((t.tm_wday == 0) ? 0 : t.tm_wday);
|
||||
days_to_remove =
|
||||
((t.tm_wday == 0) ? 0 : t.tm_wday);
|
||||
days_to_remove += (count - 1) * WEEKINDAYS;
|
||||
ret = date_change(&t, 0, -days_to_remove);
|
||||
break;
|
||||
case WEEK_END:
|
||||
mktime(&t);
|
||||
if (ui_calendar_week_begins_on_monday())
|
||||
days_to_add = ((t.tm_wday == 0) ? 0 : WEEKINDAYS - t.tm_wday);
|
||||
days_to_add =
|
||||
((t.tm_wday ==
|
||||
0) ? 0 : WEEKINDAYS - t.tm_wday);
|
||||
else
|
||||
days_to_add = ((t.tm_wday == 0) ?
|
||||
WEEKINDAYS - 1 : WEEKINDAYS - 1 - t.tm_wday);
|
||||
WEEKINDAYS - 1 : WEEKINDAYS - 1 -
|
||||
t.tm_wday);
|
||||
days_to_add += (count - 1) * WEEKINDAYS;
|
||||
ret = date_change(&t, 0, days_to_add);
|
||||
break;
|
||||
@ -893,7 +926,8 @@ static double pom(time_t tmpt)
|
||||
*/
|
||||
const char *ui_calendar_get_pom(time_t date)
|
||||
{
|
||||
const char *pom_pict[MOON_PHASES] = { " ", "|) ", "(|)", "(| ", " | " };
|
||||
const char *pom_pict[MOON_PHASES] =
|
||||
{ " ", "|) ", "(|)", "(| ", " | " };
|
||||
enum pom phase = NO_POM;
|
||||
double pom_today, relative_pom, pom_yesterday, pom_tomorrow;
|
||||
const double half = 50.0;
|
||||
@ -908,7 +942,9 @@ const char *ui_calendar_get_pom(time_t date)
|
||||
phase = NEW_MOON;
|
||||
else if (relative_pom < abs(pom_yesterday - half)
|
||||
&& relative_pom < abs(pom_tomorrow - half))
|
||||
phase = (pom_tomorrow > pom_today) ? FIRST_QUARTER : LAST_QUARTER;
|
||||
phase =
|
||||
(pom_tomorrow >
|
||||
pom_today) ? FIRST_QUARTER : LAST_QUARTER;
|
||||
|
||||
return pom_pict[phase];
|
||||
}
|
||||
|
193
src/ui-day.c
193
src/ui-day.c
@ -37,19 +37,23 @@
|
||||
#include "calcurse.h"
|
||||
|
||||
static int hilt;
|
||||
struct day_item day_cut[38] = { { 0, 0, { NULL } } };
|
||||
struct day_item day_cut[38] = { {0, 0, {NULL}} };
|
||||
|
||||
/* Request the user to enter a new time. */
|
||||
static int day_edit_time(int time, unsigned *new_hour, unsigned *new_minute)
|
||||
static int day_edit_time(int time, unsigned *new_hour,
|
||||
unsigned *new_minute)
|
||||
{
|
||||
char *timestr = date_sec2date_str(time, "%H:%M");
|
||||
const char *msg_time = _("Enter the new time ([hh:mm] or [hhmm]) : ");
|
||||
const char *msg_time =
|
||||
_("Enter the new time ([hh:mm] or [hhmm]) : ");
|
||||
const char *enter_str = _("Press [Enter] to continue");
|
||||
const char *fmt_msg = _("You entered an invalid time, should be [hh:mm] or [hhmm]");
|
||||
const char *fmt_msg =
|
||||
_("You entered an invalid time, should be [hh:mm] or [hhmm]");
|
||||
|
||||
for (;;) {
|
||||
status_mesg(msg_time, "");
|
||||
if (updatestring(win[STA].p, ×tr, 0, 1) != GETSTRING_VALID)
|
||||
if (updatestring(win[STA].p, ×tr, 0, 1) !=
|
||||
GETSTRING_VALID)
|
||||
return 0;
|
||||
if (parse_time(timestr, new_hour, new_minute) == 1) {
|
||||
mem_free(timestr);
|
||||
@ -66,24 +70,28 @@ static int day_edit_duration(int start, int dur, unsigned *new_duration)
|
||||
{
|
||||
char *timestr = date_sec2date_str(start + dur, "%H:%M");
|
||||
const char *msg_time =
|
||||
_
|
||||
("Enter new end time ([hh:mm], [hhmm]) or duration ([+hh:mm], [+xxxdxxhxxm] or [+mm]) : ");
|
||||
_("Enter new end time ([hh:mm], [hhmm]) or duration ([+hh:mm], [+xxxdxxhxxm] or [+mm]) : ");
|
||||
const char *enter_str = _("Press [Enter] to continue");
|
||||
const char *fmt_msg = _("You entered an invalid time, should be [hh:mm] or [hhmm]");
|
||||
const char *fmt_msg =
|
||||
_("You entered an invalid time, should be [hh:mm] or [hhmm]");
|
||||
long newtime;
|
||||
unsigned hr, mn;
|
||||
|
||||
for (;;) {
|
||||
status_mesg(msg_time, "");
|
||||
if (updatestring(win[STA].p, ×tr, 0, 1) != GETSTRING_VALID)
|
||||
if (updatestring(win[STA].p, ×tr, 0, 1) !=
|
||||
GETSTRING_VALID)
|
||||
return 0;
|
||||
if (*timestr == '+' && parse_duration(timestr + 1, new_duration) == 1) {
|
||||
if (*timestr == '+'
|
||||
&& parse_duration(timestr + 1, new_duration) == 1) {
|
||||
*new_duration *= MININSEC;
|
||||
break;
|
||||
} else if (parse_time(timestr, &hr, &mn) == 1) {
|
||||
newtime = update_time_in_date(start + dur, hr, mn);
|
||||
*new_duration = (newtime > start) ? newtime - start :
|
||||
DAYINSEC + newtime - start;
|
||||
*new_duration =
|
||||
(newtime >
|
||||
start) ? newtime - start : DAYINSEC +
|
||||
newtime - start;
|
||||
break;
|
||||
} else {
|
||||
status_mesg(fmt_msg, enter_str);
|
||||
@ -169,16 +177,19 @@ static void update_rept(struct rpt **rpt, const long start)
|
||||
rpt_current = msg_rpt_daily;
|
||||
}
|
||||
|
||||
snprintf(msg_rpt_current, BUFSIZ, _("(currently using %s)"), rpt_current);
|
||||
snprintf(msg_rpt_current, BUFSIZ, _("(currently using %s)"),
|
||||
rpt_current);
|
||||
|
||||
char msg_rpt_asktype[BUFSIZ];
|
||||
snprintf(msg_rpt_asktype, BUFSIZ, "%s %s, %s, %s, %s ? %s",
|
||||
msg_rpt_prefix,
|
||||
msg_rpt_daily,
|
||||
msg_rpt_weekly, msg_rpt_monthly, msg_rpt_yearly, msg_rpt_current);
|
||||
msg_rpt_weekly, msg_rpt_monthly, msg_rpt_yearly,
|
||||
msg_rpt_current);
|
||||
|
||||
const char *msg_rpt_choice = _("[dwmy]");
|
||||
const char *msg_wrong_freq = _("The frequence you entered is not valid.");
|
||||
const char *msg_wrong_freq =
|
||||
_("The frequence you entered is not valid.");
|
||||
const char *msg_wrong_time =
|
||||
_("Invalid time: start time must be before end time!");
|
||||
const char *msg_wrong_date = _("The entered date is not valid.");
|
||||
@ -207,7 +218,8 @@ static void update_rept(struct rpt **rpt, const long start)
|
||||
status_mesg(_("Enter the new repetition frequence:"), "");
|
||||
freqstr = mem_malloc(BUFSIZ);
|
||||
snprintf(freqstr, BUFSIZ, "%d", (*rpt)->freq);
|
||||
if (updatestring(win[STA].p, &freqstr, 0, 1) != GETSTRING_VALID) {
|
||||
if (updatestring(win[STA].p, &freqstr, 0, 1) !=
|
||||
GETSTRING_VALID) {
|
||||
mem_free(freqstr);
|
||||
return;
|
||||
}
|
||||
@ -226,11 +238,15 @@ static void update_rept(struct rpt **rpt, const long start)
|
||||
struct date new_date;
|
||||
int newmonth, newday, newyear;
|
||||
|
||||
snprintf(outstr, BUFSIZ, _("Enter the new ending date: [%s] or '0'"),
|
||||
snprintf(outstr, BUFSIZ,
|
||||
_("Enter the new ending date: [%s] or '0'"),
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
status_mesg(outstr, "");
|
||||
timstr = date_sec2date_str((*rpt)->until, DATEFMT(conf.input_datefmt));
|
||||
if (updatestring(win[STA].p, &timstr, 0, 1) != GETSTRING_VALID) {
|
||||
timstr =
|
||||
date_sec2date_str((*rpt)->until,
|
||||
DATEFMT(conf.input_datefmt));
|
||||
if (updatestring(win[STA].p, &timstr, 0, 1) !=
|
||||
GETSTRING_VALID) {
|
||||
mem_free(timstr);
|
||||
return;
|
||||
}
|
||||
@ -238,9 +254,11 @@ static void update_rept(struct rpt **rpt, const long start)
|
||||
newuntil = 0;
|
||||
break;
|
||||
}
|
||||
if (!parse_date(timstr, conf.input_datefmt, &newyear, &newmonth,
|
||||
if (!parse_date
|
||||
(timstr, conf.input_datefmt, &newyear, &newmonth,
|
||||
&newday, ui_calendar_get_slctd_day())) {
|
||||
snprintf(outstr, BUFSIZ, msg_fmts, DATEFMT_DESC(conf.input_datefmt));
|
||||
snprintf(outstr, BUFSIZ, msg_fmts,
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
status_mesg(msg_wrong_date, outstr);
|
||||
wgetch(win[KEY].p);
|
||||
continue;
|
||||
@ -282,7 +300,8 @@ void ui_day_item_edit(void)
|
||||
_("Description"),
|
||||
_("Repetition"),
|
||||
};
|
||||
switch (status_ask_simplechoice(_("Edit: "), choice_recur_evnt, 2)) {
|
||||
switch (status_ask_simplechoice
|
||||
(_("Edit: "), choice_recur_evnt, 2)) {
|
||||
case 1:
|
||||
update_desc(&re->mesg);
|
||||
break;
|
||||
@ -305,7 +324,8 @@ void ui_day_item_edit(void)
|
||||
_("Description"),
|
||||
_("Repetition"),
|
||||
};
|
||||
switch (status_ask_simplechoice(_("Edit: "), choice_recur_appt, 4)) {
|
||||
switch (status_ask_simplechoice
|
||||
(_("Edit: "), choice_recur_appt, 4)) {
|
||||
case 1:
|
||||
need_check_notify = 1;
|
||||
update_start_time(&ra->start, &ra->dur);
|
||||
@ -315,7 +335,8 @@ void ui_day_item_edit(void)
|
||||
break;
|
||||
case 3:
|
||||
if (notify_bar())
|
||||
need_check_notify = notify_same_recur_item(ra);
|
||||
need_check_notify =
|
||||
notify_same_recur_item(ra);
|
||||
update_desc(&ra->mesg);
|
||||
break;
|
||||
case 4:
|
||||
@ -333,7 +354,8 @@ void ui_day_item_edit(void)
|
||||
_("End time"),
|
||||
_("Description"),
|
||||
};
|
||||
switch (status_ask_simplechoice(_("Edit: "), choice_appt, 3)) {
|
||||
switch (status_ask_simplechoice
|
||||
(_("Edit: "), choice_appt, 3)) {
|
||||
case 1:
|
||||
need_check_notify = 1;
|
||||
update_start_time(&a->start, &a->dur);
|
||||
@ -343,7 +365,8 @@ void ui_day_item_edit(void)
|
||||
break;
|
||||
case 3:
|
||||
if (notify_bar())
|
||||
need_check_notify = notify_same_item(a->start);
|
||||
need_check_notify =
|
||||
notify_same_item(a->start);
|
||||
update_desc(&a->mesg);
|
||||
break;
|
||||
default:
|
||||
@ -410,14 +433,12 @@ void ui_day_item_add(void)
|
||||
const char *mesg_1 =
|
||||
_("Enter start time ([hh:mm] or [hhmm]), leave blank for an all-day event : ");
|
||||
const char *mesg_2 =
|
||||
_
|
||||
("Enter end time ([hh:mm] or [hhmm]) or duration ([+hh:mm], [+xxxdxxhxxm] or [+mm]) : ");
|
||||
_("Enter end time ([hh:mm] or [hhmm]) or duration ([+hh:mm], [+xxxdxxhxxm] or [+mm]) : ");
|
||||
const char *mesg_3 = _("Enter description :");
|
||||
const char *format_message_1 =
|
||||
_("You entered an invalid start time, should be [hh:mm] or [hhmm]");
|
||||
const char *format_message_2 =
|
||||
_
|
||||
("Invalid end time/duration, should be [hh:mm], [hhmm], [+hh:mm], [+xxxdxxhxxm] or [+mm]");
|
||||
_("Invalid end time/duration, should be [hh:mm], [hhmm], [+hh:mm], [+xxxdxxhxxm] or [+mm]");
|
||||
const char *enter_str = _("Press [Enter] to continue");
|
||||
char item_time[LDUR] = "";
|
||||
char item_mesg[BUFSIZ] = "";
|
||||
@ -430,7 +451,8 @@ void ui_day_item_add(void)
|
||||
/* Get the starting time */
|
||||
for (;;) {
|
||||
status_mesg(mesg_1, "");
|
||||
if (getstring(win[STA].p, item_time, LTIME, 0, 1) == GETSTRING_ESC)
|
||||
if (getstring(win[STA].p, item_time, LTIME, 0, 1) ==
|
||||
GETSTRING_ESC)
|
||||
return;
|
||||
if (strlen(item_time) == 0) {
|
||||
is_appointment = 0;
|
||||
@ -451,18 +473,26 @@ void ui_day_item_add(void)
|
||||
item_time[0] = '\0';
|
||||
for (;;) {
|
||||
status_mesg(mesg_2, "");
|
||||
if (getstring(win[STA].p, item_time, LDUR, 0, 1) == GETSTRING_ESC)
|
||||
if (getstring(win[STA].p, item_time, LDUR, 0, 1) ==
|
||||
GETSTRING_ESC)
|
||||
return;
|
||||
if (*item_time == '+' && parse_duration(item_time + 1,
|
||||
if (*item_time == '+'
|
||||
&& parse_duration(item_time + 1,
|
||||
&apoint_duration) == 1)
|
||||
break;
|
||||
if (parse_time(item_time, &end_h, &end_m) == 1) {
|
||||
if (end_h < heures || ((end_h == heures) && (end_m < minutes))) {
|
||||
apoint_duration = MININSEC - minutes + end_m
|
||||
+ (24 + end_h - (heures + 1)) * MININSEC;
|
||||
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
|
||||
+ end_m + (end_h - (heures + 1)) * MININSEC;
|
||||
apoint_duration =
|
||||
MININSEC - minutes + end_m +
|
||||
(end_h -
|
||||
(heures + 1)) * MININSEC;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -472,14 +502,21 @@ void ui_day_item_add(void)
|
||||
}
|
||||
|
||||
status_mesg(mesg_3, "");
|
||||
if (getstring(win[STA].p, item_mesg, BUFSIZ, 0, 1) == GETSTRING_VALID) {
|
||||
if (getstring(win[STA].p, item_mesg, BUFSIZ, 0, 1) ==
|
||||
GETSTRING_VALID) {
|
||||
if (is_appointment) {
|
||||
apoint_start = date2sec(*ui_calendar_get_slctd_day(), heures, minutes);
|
||||
apoint_new(item_mesg, 0L, apoint_start, min2sec(apoint_duration), 0L);
|
||||
apoint_start =
|
||||
date2sec(*ui_calendar_get_slctd_day(), heures,
|
||||
minutes);
|
||||
apoint_new(item_mesg, 0L, apoint_start,
|
||||
min2sec(apoint_duration), 0L);
|
||||
if (notify_bar())
|
||||
notify_check_added(item_mesg, apoint_start, 0L);
|
||||
notify_check_added(item_mesg, apoint_start,
|
||||
0L);
|
||||
} else {
|
||||
event_new(item_mesg, 0L, date2sec(*ui_calendar_get_slctd_day(), 0, 0), 1);
|
||||
event_new(item_mesg, 0L,
|
||||
date2sec(*ui_calendar_get_slctd_day(), 0,
|
||||
0), 1);
|
||||
}
|
||||
|
||||
if (ui_day_hilt() == 0)
|
||||
@ -495,7 +532,8 @@ void ui_day_item_add(void)
|
||||
void ui_day_item_delete(unsigned *nb_events, unsigned *nb_apoints,
|
||||
unsigned reg)
|
||||
{
|
||||
const char *del_app_str = _("Do you really want to delete this item ?");
|
||||
const char *del_app_str =
|
||||
_("Do you really want to delete this item ?");
|
||||
|
||||
const char *erase_warning =
|
||||
_("This item is recurrent. "
|
||||
@ -526,7 +564,8 @@ void ui_day_item_delete(unsigned *nb_events, unsigned *nb_apoints,
|
||||
}
|
||||
|
||||
if (day_item_get_note(p)) {
|
||||
switch (status_ask_choice(note_warning, note_choices, nb_note_choices)) {
|
||||
switch (status_ask_choice
|
||||
(note_warning, note_choices, nb_note_choices)) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
@ -538,7 +577,8 @@ void ui_day_item_delete(unsigned *nb_events, unsigned *nb_apoints,
|
||||
}
|
||||
|
||||
if (p->type == RECUR_EVNT || p->type == RECUR_APPT) {
|
||||
switch (status_ask_choice(erase_warning, erase_choices, nb_erase_choices)) {
|
||||
switch (status_ask_choice
|
||||
(erase_warning, erase_choices, nb_erase_choices)) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
@ -602,13 +642,15 @@ void ui_day_item_repeat(void)
|
||||
const char *msg_rpt_yearly = _("(y)early");
|
||||
const char *msg_type_choice = _("[dwmy]");
|
||||
const char *mesg_freq_1 = _("Enter the repetition frequence:");
|
||||
const char *mesg_wrong_freq = _("The frequence you entered is not valid.");
|
||||
const char *mesg_wrong_freq =
|
||||
_("The frequence you entered is not valid.");
|
||||
const char *mesg_until_1 =
|
||||
_("Enter the ending date: [%s] or '0' for an endless repetition");
|
||||
const char *mesg_wrong_1 = _("The entered date is not valid.");
|
||||
const char *mesg_wrong_2 =
|
||||
_("Possible formats are [%s] or '0' for an endless repetition");
|
||||
const char *wrong_type_1 = _("This item is already a repeated one.");
|
||||
const char *wrong_type_1 =
|
||||
_("This item is already a repeated one.");
|
||||
const char *wrong_type_2 = _("Press [ENTER] to continue.");
|
||||
const char *mesg_older =
|
||||
_("Sorry, the date you entered is older than the item start time.");
|
||||
@ -616,7 +658,8 @@ void ui_day_item_repeat(void)
|
||||
char msg_asktype[BUFSIZ];
|
||||
snprintf(msg_asktype, BUFSIZ, "%s %s, %s, %s, %s",
|
||||
msg_rpt_prefix,
|
||||
msg_rpt_daily, msg_rpt_weekly, msg_rpt_monthly, msg_rpt_yearly);
|
||||
msg_rpt_daily, msg_rpt_weekly, msg_rpt_monthly,
|
||||
msg_rpt_yearly);
|
||||
|
||||
int type = 0, freq = 0;
|
||||
int item_nb;
|
||||
@ -651,7 +694,8 @@ void ui_day_item_repeat(void)
|
||||
|
||||
while (freq == 0) {
|
||||
status_mesg(mesg_freq_1, "");
|
||||
if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) != GETSTRING_VALID)
|
||||
if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) !=
|
||||
GETSTRING_VALID)
|
||||
return;
|
||||
freq = atoi(user_input);
|
||||
if (freq == 0) {
|
||||
@ -662,28 +706,34 @@ void ui_day_item_repeat(void)
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
snprintf(outstr, BUFSIZ, mesg_until_1, DATEFMT_DESC(conf.input_datefmt));
|
||||
snprintf(outstr, BUFSIZ, mesg_until_1,
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
status_mesg(outstr, "");
|
||||
if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) != GETSTRING_VALID)
|
||||
if (getstring(win[STA].p, user_input, BUFSIZ, 0, 1) !=
|
||||
GETSTRING_VALID)
|
||||
return;
|
||||
if (strlen(user_input) == 1 && strcmp(user_input, "0") == 0) {
|
||||
if (strlen(user_input) == 1
|
||||
&& strcmp(user_input, "0") == 0) {
|
||||
until = 0;
|
||||
break;
|
||||
}
|
||||
if (parse_date(user_input, conf.input_datefmt,
|
||||
&year, &month, &day, ui_calendar_get_slctd_day())) {
|
||||
&year, &month, &day,
|
||||
ui_calendar_get_slctd_day())) {
|
||||
t = p->start;
|
||||
localtime_r(&t, <);
|
||||
until_date.dd = day;
|
||||
until_date.mm = month;
|
||||
until_date.yyyy = year;
|
||||
until = date2sec(until_date, lt.tm_hour, lt.tm_min);
|
||||
until =
|
||||
date2sec(until_date, lt.tm_hour, lt.tm_min);
|
||||
if (until >= p->start)
|
||||
break;
|
||||
status_mesg(mesg_older, wrong_type_2);
|
||||
wgetch(win[KEY].p);
|
||||
} else {
|
||||
snprintf(outstr, BUFSIZ, mesg_wrong_2, DATEFMT_DESC(conf.input_datefmt));
|
||||
snprintf(outstr, BUFSIZ, mesg_wrong_2,
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
status_mesg(mesg_wrong_1, outstr);
|
||||
wgetch(win[KEY].p);
|
||||
}
|
||||
@ -692,12 +742,13 @@ void ui_day_item_repeat(void)
|
||||
date = ui_calendar_get_slctd_day_sec();
|
||||
if (p->type == EVNT) {
|
||||
struct event *ev = p->item.ev;
|
||||
recur_event_new(ev->mesg, ev->note, ev->day, ev->id, type, freq, until,
|
||||
NULL);
|
||||
recur_event_new(ev->mesg, ev->note, ev->day, ev->id, type,
|
||||
freq, until, NULL);
|
||||
} else if (p->type == APPT) {
|
||||
struct apoint *apt = p->item.apt;
|
||||
ra = recur_apoint_new(apt->mesg, apt->note, apt->start, apt->dur,
|
||||
apt->state, type, freq, until, NULL);
|
||||
ra = recur_apoint_new(apt->mesg, apt->note, apt->start,
|
||||
apt->dur, apt->state, type, freq,
|
||||
until, NULL);
|
||||
if (notify_bar())
|
||||
notify_check_repeated(ra);
|
||||
} else {
|
||||
@ -861,31 +912,37 @@ void ui_day_update_panel(int which_pan)
|
||||
|
||||
/* variable inits */
|
||||
slctd_date = *ui_calendar_get_slctd_day();
|
||||
title_xpos = win[APP].w - (strlen(_(monthnames[slctd_date.mm - 1])) + 16);
|
||||
title_xpos =
|
||||
win[APP].w - (strlen(_(monthnames[slctd_date.mm - 1])) + 16);
|
||||
if (slctd_date.dd < 10)
|
||||
title_xpos++;
|
||||
date = date2sec(slctd_date, 0, 0);
|
||||
day_write_pad(date, app_width, app_length, (which_pan == APP) ? hilt : 0);
|
||||
day_write_pad(date, app_width, app_length,
|
||||
(which_pan == APP) ? hilt : 0);
|
||||
|
||||
/* Print current date in the top right window corner. */
|
||||
erase_window_part(win[APP].p, 1, title_lines, win[APP].w - 2, win[APP].h - 2);
|
||||
erase_window_part(win[APP].p, 1, title_lines, win[APP].w - 2,
|
||||
win[APP].h - 2);
|
||||
custom_apply_attr(win[APP].p, ATTR_HIGHEST);
|
||||
mvwprintw(win[APP].p, title_lines, title_xpos, "%s %s %d, %d",
|
||||
ui_calendar_get_pom(date), _(monthnames[slctd_date.mm - 1]),
|
||||
slctd_date.dd, slctd_date.yyyy);
|
||||
ui_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. */
|
||||
if ((apad.length >= app_length) || (apad.first_onscreen > 0)) {
|
||||
int sbar_length = app_length * app_length / apad.length;
|
||||
int highend = app_length * apad.first_onscreen / apad.length;
|
||||
int highend =
|
||||
app_length * apad.first_onscreen / apad.length;
|
||||
unsigned hilt_bar = (which_pan == APP) ? 1 : 0;
|
||||
int sbar_top = highend + title_lines + 1;
|
||||
|
||||
if ((sbar_top + sbar_length) > win[APP].h - 1)
|
||||
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);
|
||||
draw_scrollbar(win[APP].p, sbar_top, win[APP].w - 2,
|
||||
sbar_length, title_lines + 1,
|
||||
win[APP].h - 1, hilt_bar);
|
||||
}
|
||||
|
||||
wnoutrefresh(win[APP].p);
|
||||
|
@ -51,7 +51,8 @@ void ui_todo_add(void)
|
||||
char todo_input[BUFSIZ] = "";
|
||||
|
||||
status_mesg(mesg, "");
|
||||
if (getstring(win[STA].p, todo_input, BUFSIZ, 0, 1) == GETSTRING_VALID) {
|
||||
if (getstring(win[STA].p, todo_input, BUFSIZ, 0, 1) ==
|
||||
GETSTRING_VALID) {
|
||||
while ((ch < '1') || (ch > '9')) {
|
||||
status_mesg(mesg_id, "");
|
||||
ch = wgetch(win[KEY].p);
|
||||
@ -64,7 +65,8 @@ void ui_todo_add(void)
|
||||
/* Delete an item from the ToDo list. */
|
||||
void ui_todo_delete(void)
|
||||
{
|
||||
const char *del_todo_str = _("Do you really want to delete this task ?");
|
||||
const char *del_todo_str =
|
||||
_("Do you really want to delete this task ?");
|
||||
const char *erase_warning =
|
||||
_("This item has a note attached to it. "
|
||||
"Delete (t)odo or just its (n)ote ?");
|
||||
@ -73,7 +75,8 @@ void ui_todo_delete(void)
|
||||
int answer;
|
||||
|
||||
if ((ui_todo_nb() <= 0) ||
|
||||
(conf.confirm_delete && (status_ask_bool(del_todo_str) != 1))) {
|
||||
(conf.confirm_delete
|
||||
&& (status_ask_bool(del_todo_str) != 1))) {
|
||||
wins_erase_status_bar();
|
||||
return;
|
||||
}
|
||||
@ -82,7 +85,9 @@ void ui_todo_delete(void)
|
||||
if (todo_get_item(ui_todo_hilt())->note == NULL)
|
||||
answer = 1;
|
||||
else
|
||||
answer = status_ask_choice(erase_warning, erase_choice, nb_erase_choice);
|
||||
answer =
|
||||
status_ask_choice(erase_warning, erase_choice,
|
||||
nb_erase_choice);
|
||||
|
||||
switch (answer) {
|
||||
case 1:
|
||||
@ -210,8 +215,8 @@ char *ui_todo_saved_mesg(void)
|
||||
|
||||
/* Display todo items in the corresponding panel. */
|
||||
static void
|
||||
display_todo_item(int incolor, char *msg, int prio, int note, int width, int y,
|
||||
int x)
|
||||
display_todo_item(int incolor, char *msg, int prio, int note, int width,
|
||||
int y, int x)
|
||||
{
|
||||
WINDOW *w;
|
||||
int ch_note;
|
||||
@ -262,7 +267,8 @@ void ui_todo_update_panel(int which_pan)
|
||||
return;
|
||||
|
||||
/* Print todo item in the panel. */
|
||||
erase_window_part(win[TOD].p, 1, title_lines, win[TOD].w - 2, win[TOD].h - 2);
|
||||
erase_window_part(win[TOD].p, 1, title_lines, win[TOD].w - 2,
|
||||
win[TOD].h - 2);
|
||||
LLIST_FOREACH(&todolist, i) {
|
||||
struct todo *todo = LLIST_TS_GET_DATA(i);
|
||||
num_todo++;
|
||||
@ -272,7 +278,8 @@ void ui_todo_update_panel(int which_pan)
|
||||
msgsav = todo->mesg;
|
||||
if (t_realpos >= 0 && t_realpos < max_items) {
|
||||
display_todo_item(incolor, todo->mesg, todo->id,
|
||||
(todo->note != NULL) ? 1 : 0, len, y_offset, x_offset);
|
||||
(todo->note != NULL) ? 1 : 0,
|
||||
len, y_offset, x_offset);
|
||||
y_offset = y_offset + todo_lines;
|
||||
}
|
||||
}
|
||||
@ -287,7 +294,8 @@ void ui_todo_update_panel(int which_pan)
|
||||
if ((sbar_top + sbar_length) > win[TOD].h - 1)
|
||||
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);
|
||||
|
@ -285,7 +285,8 @@ int utf8_width(char *s)
|
||||
val = (s[1] & 0x3f) | (s[0] & 0x1f) << 6;
|
||||
break;
|
||||
case 3:
|
||||
val = ((s[2] & 0x3f) | (s[1] & 0x3f) << 6) | (s[0] & 0x0f) << 12;
|
||||
val = ((s[2] & 0x3f) | (s[1] & 0x3f) << 6) |
|
||||
(s[0] & 0x0f) << 12;
|
||||
break;
|
||||
case 4:
|
||||
val = (((s[3] & 0x3f) | (s[2] & 0x3f) << 6) |
|
||||
@ -293,7 +294,8 @@ int utf8_width(char *s)
|
||||
break;
|
||||
case 5:
|
||||
val = ((((s[4] & 0x3f) | (s[3] & 0x3f) << 6) |
|
||||
(s[2] & 0x3f) << 12) | (s[1] & 0x3f) << 18) | (s[0] & 0x3f) << 24;
|
||||
(s[2] & 0x3f) << 12) | (s[1] & 0x3f) << 18) |
|
||||
(s[0] & 0x3f) << 24;
|
||||
break;
|
||||
case 6:
|
||||
val = (((((s[5] & 0x3f) | (s[4] & 0x3f) << 6) |
|
||||
|
101
src/utils.c
101
src/utils.c
@ -88,7 +88,8 @@ void exit_calcurse(int status)
|
||||
mem_stats();
|
||||
if (was_interactive) {
|
||||
if (unlink(path_cpid) != 0)
|
||||
EXIT(_("Could not remove calcurse lock file: %s\n"), strerror(errno));
|
||||
EXIT(_("Could not remove calcurse lock file: %s\n"),
|
||||
strerror(errno));
|
||||
if (dmon.enable)
|
||||
dmon_start(status);
|
||||
}
|
||||
@ -126,7 +127,8 @@ void fatalbox(const char *errmsg)
|
||||
return;
|
||||
|
||||
strncpy(msg, errmsg, MSGLEN);
|
||||
errwin = newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
|
||||
errwin =
|
||||
newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
|
||||
custom_apply_attr(errwin, ATTR_HIGHEST);
|
||||
box(errwin, 0, 0);
|
||||
wins_show(errwin, label);
|
||||
@ -152,7 +154,8 @@ void warnbox(const char *msg)
|
||||
return;
|
||||
|
||||
strncpy(displmsg, msg, MSGLEN);
|
||||
warnwin = newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
|
||||
warnwin =
|
||||
newwin(WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2);
|
||||
custom_apply_attr(warnwin, ATTR_HIGHEST);
|
||||
box(warnwin, 0, 0);
|
||||
wins_show(warnwin, label);
|
||||
@ -189,7 +192,8 @@ void status_mesg(const char *msg1, const char *msg2)
|
||||
* Returns the index of the key pressed by the user (starting from 1),
|
||||
* or -1 if the user doesn't want to answer (e.g. by escaping).
|
||||
*/
|
||||
int status_ask_choice(const char *message, const char choice[], int nb_choice)
|
||||
int status_ask_choice(const char *message, const char choice[],
|
||||
int nb_choice)
|
||||
{
|
||||
int i, ch;
|
||||
char tmp[BUFSIZ];
|
||||
@ -200,7 +204,8 @@ int status_ask_choice(const char *message, const char choice[], int nb_choice)
|
||||
avail_choice[1] = '\0';
|
||||
|
||||
for (i = 1; i <= nb_choice; i++) {
|
||||
snprintf(tmp, BUFSIZ, (i == nb_choice) ? "%c] " : "%c/", choice[i]);
|
||||
snprintf(tmp, BUFSIZ, (i == nb_choice) ? "%c] " : "%c/",
|
||||
choice[i]);
|
||||
strcat(avail_choice, tmp);
|
||||
}
|
||||
|
||||
@ -238,7 +243,8 @@ int status_ask_bool(const char *msg)
|
||||
* the user doesn't want to answer.
|
||||
*/
|
||||
int
|
||||
status_ask_simplechoice(const char *prefix, const char *choice[], int nb_choice)
|
||||
status_ask_simplechoice(const char *prefix, const char *choice[],
|
||||
int nb_choice)
|
||||
{
|
||||
int i;
|
||||
char tmp[BUFSIZ];
|
||||
@ -254,7 +260,8 @@ status_ask_simplechoice(const char *prefix, const char *choice[], int nb_choice)
|
||||
strcpy(choicestr, prefix);
|
||||
|
||||
for (i = 0; i < nb_choice; i++) {
|
||||
snprintf(tmp, BUFSIZ, ((i + 1) == nb_choice) ? "(%d) %s?" : "(%d) %s, ",
|
||||
snprintf(tmp, BUFSIZ,
|
||||
((i + 1) == nb_choice) ? "(%d) %s?" : "(%d) %s, ",
|
||||
(i + 1), choice[i]);
|
||||
strcat(choicestr, tmp);
|
||||
}
|
||||
@ -276,8 +283,8 @@ erase_window_part(WINDOW * win, int first_col, int first_row, int last_col,
|
||||
}
|
||||
|
||||
/* draws a popup window */
|
||||
WINDOW *popup(int pop_row, int pop_col, int pop_y, int pop_x, const char *title,
|
||||
const char *msg, int hint)
|
||||
WINDOW *popup(int pop_row, int pop_col, int pop_y, int pop_x,
|
||||
const char *title, const char *msg, int hint)
|
||||
{
|
||||
const char *any_key = _("Press any key to continue...");
|
||||
WINDOW *popup_win;
|
||||
@ -286,12 +293,14 @@ WINDOW *popup(int pop_row, int pop_col, int pop_y, int pop_x, const char *title,
|
||||
popup_win = newwin(pop_row, pop_col, pop_y, pop_x);
|
||||
keypad(popup_win, TRUE);
|
||||
if (msg)
|
||||
mvwaddstr(popup_win, MSGXPOS, (pop_col - strlen(msg)) / 2, msg);
|
||||
mvwaddstr(popup_win, MSGXPOS, (pop_col - strlen(msg)) / 2,
|
||||
msg);
|
||||
custom_apply_attr(popup_win, ATTR_HIGHEST);
|
||||
box(popup_win, 0, 0);
|
||||
wins_show(popup_win, title);
|
||||
if (hint)
|
||||
mvwaddstr(popup_win, pop_row - 2, pop_col - (strlen(any_key) + 1), any_key);
|
||||
mvwaddstr(popup_win, pop_row - 2,
|
||||
pop_col - (strlen(any_key) + 1), any_key);
|
||||
custom_remove_attr(popup_win, ATTR_HIGHEST);
|
||||
wins_wrefresh(popup_win);
|
||||
|
||||
@ -341,7 +350,7 @@ int get_item_hour(long date)
|
||||
{
|
||||
struct tm lt;
|
||||
|
||||
localtime_r((time_t *)&date, <);
|
||||
localtime_r((time_t *) & date, <);
|
||||
return lt.tm_hour;
|
||||
}
|
||||
|
||||
@ -349,7 +358,7 @@ int get_item_min(long date)
|
||||
{
|
||||
struct tm lt;
|
||||
|
||||
localtime_r((time_t *)&date, <);
|
||||
localtime_r((time_t *) & date, <);
|
||||
return lt.tm_min;
|
||||
}
|
||||
|
||||
@ -383,7 +392,7 @@ char *date_sec2date_str(long sec, const char *datefmt)
|
||||
if (sec == 0) {
|
||||
strncpy(datestr, "0", BUFSIZ);
|
||||
} else {
|
||||
localtime_r((time_t *)&sec, <);
|
||||
localtime_r((time_t *) & sec, <);
|
||||
strftime(datestr, BUFSIZ, datefmt, <);
|
||||
}
|
||||
|
||||
@ -395,17 +404,17 @@ void date_sec2date_fmt(long sec, const char *fmt, char *datef)
|
||||
{
|
||||
#if ENABLE_NLS
|
||||
/* TODO: Find a better way to deal with localization and strftime(). */
|
||||
char *locale_old = mem_strdup (setlocale (LC_ALL, NULL));
|
||||
setlocale (LC_ALL, "C");
|
||||
char *locale_old = mem_strdup(setlocale(LC_ALL, NULL));
|
||||
setlocale(LC_ALL, "C");
|
||||
#endif
|
||||
|
||||
struct tm lt;
|
||||
localtime_r((time_t *)&sec, <);
|
||||
localtime_r((time_t *) & sec, <);
|
||||
strftime(datef, BUFSIZ, fmt, <);
|
||||
|
||||
#if ENABLE_NLS
|
||||
setlocale (LC_ALL, locale_old);
|
||||
mem_free (locale_old);
|
||||
setlocale(LC_ALL, locale_old);
|
||||
mem_free(locale_old);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -464,8 +473,10 @@ long get_sec_date(struct date date)
|
||||
timer = time(NULL);
|
||||
localtime_r(&timer, &ptrtime);
|
||||
strftime(current_day, strlen(current_day), "%d", &ptrtime);
|
||||
strftime(current_month, strlen(current_month), "%m", &ptrtime);
|
||||
strftime(current_year, strlen(current_year), "%Y", &ptrtime);
|
||||
strftime(current_month, strlen(current_month), "%m",
|
||||
&ptrtime);
|
||||
strftime(current_year, strlen(current_year), "%Y",
|
||||
&ptrtime);
|
||||
date.mm = atoi(current_month);
|
||||
date.dd = atoi(current_day);
|
||||
date.yyyy = atoi(current_year);
|
||||
@ -514,8 +525,8 @@ item_in_popup(const char *a_start, const char *a_end, const char *msg,
|
||||
pad = newpad(padl, padw);
|
||||
popup_win = popup(winl, winw, 1, 2, pop_title, NULL, 1);
|
||||
if (a_start && a_end) {
|
||||
mvwprintw(popup_win, margin_top, margin_left, "- %s -> %s", a_start,
|
||||
a_end);
|
||||
mvwprintw(popup_win, margin_top, margin_left, "- %s -> %s",
|
||||
a_start, a_end);
|
||||
}
|
||||
mvwaddstr(pad, 0, margin_left, msg);
|
||||
wmove(win[STA].p, 0, 0);
|
||||
@ -564,7 +575,8 @@ char *nowstr(void)
|
||||
|
||||
/* Print the given option value with appropriate color. */
|
||||
void
|
||||
print_bool_option_incolor(WINDOW * win, unsigned option, int pos_y, int pos_x)
|
||||
print_bool_option_incolor(WINDOW * win, unsigned option, int pos_y,
|
||||
int pos_x)
|
||||
{
|
||||
int color = 0;
|
||||
const char *option_value;
|
||||
@ -620,12 +632,14 @@ char *new_tempfile(const char *prefix, int trailing_len)
|
||||
memcpy(fullname, prefix, prefix_len);
|
||||
memset(fullname + prefix_len, 'X', trailing_len);
|
||||
fullname[prefix_len + trailing_len] = '\0';
|
||||
if ((fd = mkstemp(fullname)) == -1 || (file = fdopen(fd, "w+")) == NULL) {
|
||||
if ((fd = mkstemp(fullname)) == -1
|
||||
|| (file = fdopen(fd, "w+")) == NULL) {
|
||||
if (fd != -1) {
|
||||
unlink(fullname);
|
||||
close(fd);
|
||||
}
|
||||
ERROR_MSG(_("temporary file \"%s\" could not be created"), fullname);
|
||||
ERROR_MSG(_("temporary file \"%s\" could not be created"),
|
||||
fullname);
|
||||
return NULL;
|
||||
}
|
||||
fclose(file);
|
||||
@ -636,12 +650,12 @@ char *new_tempfile(const char *prefix, int trailing_len)
|
||||
/*
|
||||
* Check if a date is valid.
|
||||
*/
|
||||
int
|
||||
check_date(unsigned year, unsigned month, unsigned day)
|
||||
int check_date(unsigned year, unsigned month, unsigned day)
|
||||
{
|
||||
return (year >= 1902 && year <= 2037 && month >= 1 && month <= 12 &&
|
||||
day >= 1 && day <= days[month - 1] + (month == 2 &&
|
||||
ISLEAP(year)) ? 1 : 0);
|
||||
return (year >= 1902 && year <= 2037 && month >= 1 && month <= 12
|
||||
&& day >= 1 && day <= days[month - 1] + (month == 2
|
||||
&& ISLEAP(year)) ?
|
||||
1 : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -734,13 +748,11 @@ parse_date(const char *date_string, enum datefmt datefmt, int *year,
|
||||
/*
|
||||
* Check if time is valid.
|
||||
*/
|
||||
int
|
||||
check_time(unsigned hours, unsigned minutes)
|
||||
int check_time(unsigned hours, unsigned minutes)
|
||||
{
|
||||
return (hours < DAYINHOURS && minutes < HOURINMIN);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Converts a time string into hours and minutes. Short forms like "23:"
|
||||
* (23:00) or ":45" (0:45) are allowed.
|
||||
@ -861,7 +873,8 @@ int parse_duration(const char *string, unsigned *duration)
|
||||
}
|
||||
|
||||
if ((state == STATE_HHMM_MM && in >= HOURINMIN) ||
|
||||
((state == STATE_DDHHMM_HH || state == STATE_DDHHMM_MM) && in > 0))
|
||||
((state == STATE_DDHHMM_HH || state == STATE_DDHHMM_MM)
|
||||
&& in > 0))
|
||||
return 0;
|
||||
|
||||
dur += in;
|
||||
@ -893,7 +906,8 @@ void psleep(unsigned secs)
|
||||
* If pfdin and/or pfdout point to a valid address, a pipe is created and the
|
||||
* appropriate file descriptors are written to pfdin/pfdout.
|
||||
*/
|
||||
int fork_exec(int *pfdin, int *pfdout, const char *path, const char *const *arg)
|
||||
int fork_exec(int *pfdin, int *pfdout, const char *path,
|
||||
const char *const *arg)
|
||||
{
|
||||
int pin[2], pout[2];
|
||||
int pid;
|
||||
@ -948,7 +962,8 @@ int fork_exec(int *pfdin, int *pfdout, const char *path, const char *const *arg)
|
||||
|
||||
/* Execute an external program in a shell. */
|
||||
int
|
||||
shell_exec(int *pfdin, int *pfdout, const char *path, const char *const *arg)
|
||||
shell_exec(int *pfdin, int *pfdout, const char *path,
|
||||
const char *const *arg)
|
||||
{
|
||||
int argc, i;
|
||||
const char **narg;
|
||||
@ -1163,7 +1178,9 @@ static enum format_specifier parse_fs(const char **s, char *extformat)
|
||||
extformat[i] = **s;
|
||||
}
|
||||
|
||||
extformat[(i < FS_EXT_MAXLEN) ? i : FS_EXT_MAXLEN - 1] = '\0';
|
||||
extformat[(i <
|
||||
FS_EXT_MAXLEN) ? i : FS_EXT_MAXLEN -
|
||||
1] = '\0';
|
||||
}
|
||||
|
||||
if (!strcmp(buf, "start"))
|
||||
@ -1202,7 +1219,7 @@ static void print_date(long date, long day, const char *extformat)
|
||||
time_t t = date;
|
||||
struct tm lt;
|
||||
|
||||
localtime_r((time_t *)&t, <);
|
||||
localtime_r((time_t *) & t, <);
|
||||
|
||||
if (extformat[0] == '\0' || !strcmp(extformat, "default")) {
|
||||
if (date >= day && date <= day + DAYINSEC)
|
||||
@ -1234,7 +1251,8 @@ void print_apoint(const char *format, long day, struct apoint *apt)
|
||||
printf("%ld", apt->dur);
|
||||
break;
|
||||
case FS_ENDDATE:
|
||||
print_date(apt->start + apt->dur, day, extformat);
|
||||
print_date(apt->start + apt->dur, day,
|
||||
extformat);
|
||||
break;
|
||||
case FS_MESSAGE:
|
||||
printf("%s", apt->mesg);
|
||||
@ -1316,7 +1334,8 @@ print_recur_apoint(const char *format, long day, unsigned occurrence,
|
||||
}
|
||||
|
||||
/* Print a formatted recurrent event to stdout. */
|
||||
void print_recur_event(const char *format, long day, struct recur_event *rev)
|
||||
void print_recur_event(const char *format, long day,
|
||||
struct recur_event *rev)
|
||||
{
|
||||
struct event ev;
|
||||
|
||||
|
77
src/wins.c
77
src/wins.c
@ -178,8 +178,10 @@ unsigned wins_sbar_width(void)
|
||||
if (sbarwidth_perc > SBARMAXWIDTHPERC) {
|
||||
return col * SBARMAXWIDTHPERC / 100;
|
||||
} else {
|
||||
unsigned sbarwidth = (unsigned)(col * sbarwidth_perc / 100);
|
||||
return (sbarwidth < SBARMINWIDTH) ? SBARMINWIDTH : sbarwidth;
|
||||
unsigned sbarwidth =
|
||||
(unsigned)(col * sbarwidth_perc / 100);
|
||||
return (sbarwidth <
|
||||
SBARMINWIDTH) ? SBARMINWIDTH : sbarwidth;
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +191,8 @@ unsigned wins_sbar_width(void)
|
||||
*/
|
||||
unsigned wins_sbar_wperc(void)
|
||||
{
|
||||
return sbarwidth_perc > SBARMAXWIDTHPERC ? SBARMAXWIDTHPERC : sbarwidth_perc;
|
||||
return sbarwidth_perc >
|
||||
SBARMAXWIDTHPERC ? SBARMAXWIDTHPERC : sbarwidth_perc;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -243,12 +246,14 @@ static void wins_init_panels(void)
|
||||
wins_sbar_width(), win[CAL].y, win[CAL].x);
|
||||
wins_show(win[CAL].p, _("Calendar"));
|
||||
|
||||
win[APP].p = newwin(win[APP].h, win[APP].w, win[APP].y, win[APP].x);
|
||||
win[APP].p =
|
||||
newwin(win[APP].h, win[APP].w, win[APP].y, win[APP].x);
|
||||
wins_show(win[APP].p, _("Appointments"));
|
||||
apad.width = win[APP].w - 3;
|
||||
apad.ptrwin = newpad(apad.length, apad.width);
|
||||
|
||||
win[TOD].p = newwin(win[TOD].h, win[TOD].w, win[TOD].y, win[TOD].x);
|
||||
win[TOD].p =
|
||||
newwin(win[TOD].h, win[TOD].w, win[TOD].y, win[TOD].x);
|
||||
wins_show(win[TOD].p, _("ToDo"));
|
||||
|
||||
/* Enable function keys (i.e. arrow keys) in those windows */
|
||||
@ -261,7 +266,8 @@ static void wins_init_panels(void)
|
||||
void wins_init(void)
|
||||
{
|
||||
wins_init_panels();
|
||||
win[STA].p = newwin(win[STA].h, win[STA].w, win[STA].y, win[STA].x);
|
||||
win[STA].p =
|
||||
newwin(win[STA].h, win[STA].w, win[STA].y, win[STA].x);
|
||||
win[KEY].p = newwin(1, 1, 1, 1);
|
||||
|
||||
keypad(win[STA].p, TRUE);
|
||||
@ -298,19 +304,24 @@ void wins_scrollwin_display(struct scrollwin *sw)
|
||||
const int visible_lines = sw->win.h - sw->pad.y - 1;
|
||||
|
||||
if (sw->total_lines > visible_lines) {
|
||||
int sbar_length = visible_lines * visible_lines / sw->total_lines;
|
||||
int highend = visible_lines * sw->first_visible_line / sw->total_lines;
|
||||
int sbar_length =
|
||||
visible_lines * visible_lines / sw->total_lines;
|
||||
int highend =
|
||||
visible_lines * sw->first_visible_line /
|
||||
sw->total_lines;
|
||||
int sbar_top = highend + sw->pad.y + 1;
|
||||
|
||||
if ((sbar_top + sbar_length) > sw->win.h - 1)
|
||||
sbar_length = sw->win.h - sbar_top;
|
||||
draw_scrollbar(sw->win.p, sbar_top, sw->win.w + sw->win.x - 2,
|
||||
sbar_length, sw->pad.y + 1, sw->win.h - 1, 1);
|
||||
draw_scrollbar(sw->win.p, sbar_top,
|
||||
sw->win.w + sw->win.x - 2, sbar_length,
|
||||
sw->pad.y + 1, sw->win.h - 1, 1);
|
||||
}
|
||||
wmove(win[STA].p, 0, 0);
|
||||
wnoutrefresh(sw->win.p);
|
||||
pnoutrefresh(sw->pad.p, sw->first_visible_line, 0, sw->pad.y, sw->pad.x,
|
||||
sw->win.h - sw->pad.y + 1, sw->win.w - sw->win.x);
|
||||
pnoutrefresh(sw->pad.p, sw->first_visible_line, 0, sw->pad.y,
|
||||
sw->pad.x, sw->win.h - sw->pad.y + 1,
|
||||
sw->win.w - sw->win.x);
|
||||
wins_doupdate();
|
||||
}
|
||||
|
||||
@ -322,7 +333,8 @@ void wins_scrollwin_up(struct scrollwin *sw, int amount)
|
||||
|
||||
void wins_scrollwin_down(struct scrollwin *sw, int amount)
|
||||
{
|
||||
if (sw->total_lines > (sw->first_visible_line + sw->win.h - sw->pad.y - 1))
|
||||
if (sw->total_lines >
|
||||
(sw->first_visible_line + sw->win.h - sw->pad.y - 1))
|
||||
sw->first_visible_line += amount;
|
||||
}
|
||||
|
||||
@ -629,23 +641,32 @@ void wins_status_bar(void)
|
||||
struct binding othr = { _("OtherCmd"), KEY_GENERIC_OTHER_CMD };
|
||||
|
||||
struct binding *bindings_cal[] = {
|
||||
&help, &quit, &save, &chgvu, &nview, &pview, &up, &down, &left, &right,
|
||||
&togo, &import, &export, &weekb, &weeke, &appt, &todo, &gpday, &gnday,
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &draw, &today,
|
||||
&help, &quit, &save, &chgvu, &nview, &pview, &up, &down,
|
||||
&left, &right,
|
||||
&togo, &import, &export, &weekb, &weeke, &appt, &todo,
|
||||
&gpday, &gnday,
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
|
||||
&draw, &today,
|
||||
&conf
|
||||
};
|
||||
|
||||
struct binding *bindings_apoint[] = {
|
||||
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
|
||||
&pipe, &draw, &rept, &flag, &enote, &vnote, &up, &down, &gpday, &gnday,
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &togo, &today,
|
||||
&help, &quit, &save, &chgvu, &import, &export, &add, &del,
|
||||
&edit, &view,
|
||||
&pipe, &draw, &rept, &flag, &enote, &vnote, &up, &down,
|
||||
&gpday, &gnday,
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
|
||||
&togo, &today,
|
||||
&conf, &appt, &todo, ©, &paste
|
||||
};
|
||||
|
||||
struct binding *bindings_todo[] = {
|
||||
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
|
||||
&pipe, &flag, &rprio, &lprio, &enote, &vnote, &up, &down, &gpday, &gnday,
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &togo, &today,
|
||||
&help, &quit, &save, &chgvu, &import, &export, &add, &del,
|
||||
&edit, &view,
|
||||
&pipe, &flag, &rprio, &lprio, &enote, &vnote, &up, &down,
|
||||
&gpday, &gnday,
|
||||
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear,
|
||||
&togo, &today,
|
||||
&conf, &appt, &todo, &draw
|
||||
};
|
||||
|
||||
@ -657,15 +678,18 @@ void wins_status_bar(void)
|
||||
switch (active_panel) {
|
||||
case CAL:
|
||||
bindings = bindings_cal;
|
||||
bindings_size = sizeof(bindings_cal) / sizeof(bindings_cal[0]);
|
||||
bindings_size =
|
||||
sizeof(bindings_cal) / sizeof(bindings_cal[0]);
|
||||
break;
|
||||
case APP:
|
||||
bindings = bindings_apoint;
|
||||
bindings_size = sizeof(bindings_apoint) / sizeof(bindings_apoint[0]);
|
||||
bindings_size =
|
||||
sizeof(bindings_apoint) / sizeof(bindings_apoint[0]);
|
||||
break;
|
||||
case TOD:
|
||||
bindings = bindings_todo;
|
||||
bindings_size = sizeof(bindings_todo) / sizeof(bindings_todo[0]);
|
||||
bindings_size =
|
||||
sizeof(bindings_todo) / sizeof(bindings_todo[0]);
|
||||
break;
|
||||
default:
|
||||
EXIT(_("unknown panel"));
|
||||
@ -673,7 +697,8 @@ void wins_status_bar(void)
|
||||
}
|
||||
|
||||
keys_display_bindings_bar(win[STA].p, bindings, bindings_size,
|
||||
(KEYS_CMDS_PER_LINE * 2 - 1) * (status_page - 1),
|
||||
(KEYS_CMDS_PER_LINE * 2 -
|
||||
1) * (status_page - 1),
|
||||
KEYS_CMDS_PER_LINE * 2, &othr);
|
||||
}
|
||||
|
||||
|
@ -168,10 +168,12 @@ static int run_test(const char *name, int expect_failure)
|
||||
printf("Running %s...", name);
|
||||
|
||||
if ((pid1 = fork_exec(&pin1, NULL, *arg1, arg1)) < 0)
|
||||
die("failed to execute %s: %s\n", filename, strerror(errno));
|
||||
die("failed to execute %s: %s\n", filename,
|
||||
strerror(errno));
|
||||
|
||||
if ((pid2 = fork_exec(&pin2, NULL, *arg2, arg2)) < 0)
|
||||
die("failed to execute %s: %s\n", filename, strerror(errno));
|
||||
die("failed to execute %s: %s\n", filename,
|
||||
strerror(errno));
|
||||
|
||||
fpin1 = fdopen(pin1, "r");
|
||||
fpin2 = fdopen(pin2, "r");
|
||||
@ -213,7 +215,8 @@ int main(int argc, char **argv)
|
||||
|
||||
if (!argv[1])
|
||||
die("no tests specified, bailing out\n");
|
||||
else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
|
||||
else if (strcmp(argv[1], "-h") == 0
|
||||
|| strcmp(argv[1], "--help") == 0) {
|
||||
usage();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user