Checks added while loading key bindings configuration.
This commit is contained in:
parent
cf5617e337
commit
639058740a
16
ChangeLog
16
ChangeLog
@ -1,7 +1,23 @@
|
|||||||
|
2008-12-07 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
|
* src/keys.c: arrow keys can now also be used to define key
|
||||||
|
bindings
|
||||||
|
|
||||||
|
2008-12-06 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
|
* src/io.c (io_load_keys): use of a temporary file to log errors
|
||||||
|
when loading user-defined key bindings
|
||||||
|
|
||||||
|
* src/io.c (io_log_init, io_log_dislpay, io_log_free)
|
||||||
|
(io_log_print): new functions
|
||||||
|
|
||||||
2008-12-03 Frederic Culot <frederic@culot.org>
|
2008-12-03 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
* src/help.c (help_screen): help texts size overflow fixed
|
* src/help.c (help_screen): help texts size overflow fixed
|
||||||
|
|
||||||
|
* src/io.c (io_export_data): progress bar now displayed properly
|
||||||
|
when exporting data
|
||||||
|
|
||||||
2008-12-02 Frederic Culot <frederic@culot.org>
|
2008-12-02 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
* src/help.c (help_screen): help pages updated
|
* src/help.c (help_screen): help pages updated
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: apoint.c,v 1.24 2008/11/16 17:42:53 culot Exp $ */
|
/* $calcurse: apoint.c,v 1.25 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -151,7 +151,7 @@ apoint_add (void)
|
|||||||
else if (check_time (item_time) != 1)
|
else if (check_time (item_time) != 1)
|
||||||
{
|
{
|
||||||
status_mesg (format_message_1, enter_str);
|
status_mesg (format_message_1, enter_str);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sscanf (item_time, "%u:%u", &heures, &minutes);
|
sscanf (item_time, "%u:%u", &heures, &minutes);
|
||||||
@ -175,7 +175,7 @@ apoint_add (void)
|
|||||||
else if (check_time (item_time) == 0)
|
else if (check_time (item_time) == 0)
|
||||||
{
|
{
|
||||||
status_mesg (format_message_2, enter_str);
|
status_mesg (format_message_2, enter_str);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -242,7 +242,7 @@ apoint_delete (conf_t *conf, unsigned *nb_events, unsigned *nb_apoints)
|
|||||||
if (conf->confirm_delete)
|
if (conf->confirm_delete)
|
||||||
{
|
{
|
||||||
status_mesg (del_app_str, choices);
|
status_mesg (del_app_str, choices);
|
||||||
answer = keys_getch (win[STA].p);
|
answer = wgetch (win[STA].p);
|
||||||
if ((answer == 'y') && (nb_items != 0))
|
if ((answer == 'y') && (nb_items != 0))
|
||||||
go_for_deletion = true;
|
go_for_deletion = true;
|
||||||
else
|
else
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: args.c,v 1.40 2008/09/21 08:06:43 culot Exp $ */
|
/* $calcurse: args.c,v 1.41 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -765,9 +765,8 @@ parse_args (int argc, char **argv, conf_t *conf)
|
|||||||
vars_init (conf);
|
vars_init (conf);
|
||||||
custom_load_conf (conf, 0);
|
custom_load_conf (conf, 0);
|
||||||
io_load_todo ();
|
io_load_todo ();
|
||||||
io_import_data (IO_MODE_NONINTERACTIVE, IO_IMPORT_ICAL, conf,
|
io_import_data (IO_IMPORT_ICAL, conf, ifile);
|
||||||
ifile);
|
io_save_cal (conf);
|
||||||
io_save_cal (IO_MODE_NONINTERACTIVE, conf);
|
|
||||||
non_interactive = 1;
|
non_interactive = 1;
|
||||||
}
|
}
|
||||||
if (xflag)
|
if (xflag)
|
||||||
@ -775,7 +774,7 @@ parse_args (int argc, char **argv, conf_t *conf)
|
|||||||
notify_init_vars ();
|
notify_init_vars ();
|
||||||
custom_load_conf (conf, 0);
|
custom_load_conf (conf, 0);
|
||||||
io_load_todo ();
|
io_load_todo ();
|
||||||
io_export_data (IO_MODE_NONINTERACTIVE, xfmt, conf);
|
io_export_data (xfmt, conf);
|
||||||
non_interactive = 1;
|
non_interactive = 1;
|
||||||
return (non_interactive);
|
return (non_interactive);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calcurse.c,v 1.71 2008/11/23 20:38:56 culot Exp $ */
|
/* $calcurse: calcurse.c,v 1.72 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -147,7 +147,7 @@ main (int argc, char **argv)
|
|||||||
no_data_file = io_check_data_files ();
|
no_data_file = io_check_data_files ();
|
||||||
custom_load_conf (&conf, background);
|
custom_load_conf (&conf, background);
|
||||||
erase_status_bar ();
|
erase_status_bar ();
|
||||||
io_load_keys ();
|
io_load_keys (conf.pager);
|
||||||
io_load_todo ();
|
io_load_todo ();
|
||||||
io_load_app ();
|
io_load_app ();
|
||||||
wins_reinit ();
|
wins_reinit ();
|
||||||
@ -375,29 +375,29 @@ main (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_GENERIC_SAVE:
|
case KEY_GENERIC_SAVE:
|
||||||
io_save_cal (IO_MODE_INTERACTIVE, &conf);
|
io_save_cal (&conf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_GENERIC_IMPORT:
|
case KEY_GENERIC_IMPORT:
|
||||||
erase_status_bar ();
|
erase_status_bar ();
|
||||||
io_import_data (IO_MODE_INTERACTIVE, IO_IMPORT_ICAL, &conf, NULL);
|
io_import_data (IO_IMPORT_ICAL, &conf, NULL);
|
||||||
do_storage = true;
|
do_storage = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_GENERIC_EXPORT:
|
case KEY_GENERIC_EXPORT:
|
||||||
erase_status_bar ();
|
erase_status_bar ();
|
||||||
io_export_bar ();
|
io_export_bar ();
|
||||||
while ((key = keys_getch (win[STA].p)) != 'q')
|
while ((key = wgetch (win[STA].p)) != 'q')
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 'I':
|
case 'I':
|
||||||
case 'i':
|
case 'i':
|
||||||
io_export_data (IO_MODE_INTERACTIVE, IO_EXPORT_ICAL, &conf);
|
io_export_data (IO_EXPORT_ICAL, &conf);
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
case 'p':
|
case 'p':
|
||||||
io_export_data (IO_MODE_INTERACTIVE, IO_EXPORT_PCAL, &conf);
|
io_export_data (IO_EXPORT_PCAL, &conf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wins_reset ();
|
wins_reset ();
|
||||||
@ -492,7 +492,7 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
case KEY_GENERIC_QUIT:
|
case KEY_GENERIC_QUIT:
|
||||||
if (conf.auto_save)
|
if (conf.auto_save)
|
||||||
io_save_cal (IO_MODE_INTERACTIVE, &conf);
|
io_save_cal (&conf);
|
||||||
|
|
||||||
if (conf.confirm_quit)
|
if (conf.confirm_quit)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calendar.c,v 1.18 2008/11/16 17:42:53 culot Exp $ */
|
/* $calcurse: calendar.c,v 1.19 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -388,7 +388,7 @@ calendar_change_day (int datefmt)
|
|||||||
if (wrong_day)
|
if (wrong_day)
|
||||||
{
|
{
|
||||||
status_mesg (mesg_line1, mesg_line2);
|
status_mesg (mesg_line1, mesg_line2);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
src/custom.c
18
src/custom.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: custom.c,v 1.27 2008/11/25 20:48:58 culot Exp $ */
|
/* $calcurse: custom.c,v 1.28 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -396,11 +396,11 @@ layout_config (void)
|
|||||||
_(" [1]AT [2]AC [3]TA [4]CA [5]TA [6]TC [7]AT [8]CT");
|
_(" [1]AT [2]AC [3]TA [4]CA [5]TA [6]TC [7]AT [8]CT");
|
||||||
|
|
||||||
status_mesg (layout_mesg, choice_mesg);
|
status_mesg (layout_mesg, choice_mesg);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
status_mesg (layout_up_mesg, layout_down_mesg);
|
status_mesg (layout_up_mesg, layout_down_mesg);
|
||||||
wnoutrefresh (win[STA].p);
|
wnoutrefresh (win[STA].p);
|
||||||
doupdate ();
|
doupdate ();
|
||||||
while ((ch = keys_getch (win[STA].p)) != 'q')
|
while ((ch = wgetch (win[STA].p)) != 'q')
|
||||||
{
|
{
|
||||||
if (ch <= '8' && ch >= '1')
|
if (ch <= '8' && ch >= '1')
|
||||||
{
|
{
|
||||||
@ -585,7 +585,7 @@ custom_color_config (void)
|
|||||||
display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
|
display_color_config (&conf_win, &mark_fore, &mark_back, cursor,
|
||||||
need_reset, theme_changed);
|
need_reset, theme_changed);
|
||||||
|
|
||||||
while ((ch = keys_getch (win[STA].p)) != 'q')
|
while ((ch = wgetch (win[STA].p)) != 'q')
|
||||||
{
|
{
|
||||||
need_reset = 0;
|
need_reset = 0;
|
||||||
theme_changed = 0;
|
theme_changed = 0;
|
||||||
@ -611,28 +611,28 @@ custom_color_config (void)
|
|||||||
mark_fore = cursor;
|
mark_fore = cursor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 258:
|
case KEY_DOWN:
|
||||||
case 'J':
|
case 'J':
|
||||||
case 'j':
|
case 'j':
|
||||||
if (cursor < SIZE - 1)
|
if (cursor < SIZE - 1)
|
||||||
++cursor;
|
++cursor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 259:
|
case KEY_UP:
|
||||||
case 'K':
|
case 'K':
|
||||||
case 'k':
|
case 'k':
|
||||||
if (cursor > 0)
|
if (cursor > 0)
|
||||||
--cursor;
|
--cursor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 260:
|
case KEY_LEFT:
|
||||||
case 'H':
|
case 'H':
|
||||||
case 'h':
|
case 'h':
|
||||||
if (cursor > NBUSERCOLORS)
|
if (cursor > NBUSERCOLORS)
|
||||||
cursor -= (NBUSERCOLORS + 1);
|
cursor -= (NBUSERCOLORS + 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 261:
|
case KEY_RIGHT:
|
||||||
case 'L':
|
case 'L':
|
||||||
case 'l':
|
case 'l':
|
||||||
if (cursor <= NBUSERCOLORS)
|
if (cursor <= NBUSERCOLORS)
|
||||||
@ -816,7 +816,7 @@ custom_general_config (conf_t *conf)
|
|||||||
cwin.total_lines = print_general_options (cwin.pad.p, conf);
|
cwin.total_lines = print_general_options (cwin.pad.p, conf);
|
||||||
wins_scrollwin_display (&cwin);
|
wins_scrollwin_display (&cwin);
|
||||||
|
|
||||||
while ((ch = keys_getch (win[STA].p)) != 'q')
|
while ((ch = wgetch (win[STA].p)) != 'q')
|
||||||
{
|
{
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
|
22
src/day.c
22
src/day.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: day.c,v 1.38 2008/11/16 17:42:53 culot Exp $ */
|
/* $calcurse: day.c,v 1.39 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -527,7 +527,7 @@ day_edit_time (long time)
|
|||||||
if (check_time (timestr) != 1 || strlen (timestr) == 0)
|
if (check_time (timestr) != 1 || strlen (timestr) == 0)
|
||||||
{
|
{
|
||||||
status_mesg (fmt_msg, enter_str);
|
status_mesg (fmt_msg, enter_str);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return (timestr);
|
return (timestr);
|
||||||
@ -559,7 +559,7 @@ update_start_time (long *start, long *dur)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
status_mesg (msg_wrong_time, msg_enter);
|
status_mesg (msg_wrong_time, msg_enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
valid_date = 0;
|
valid_date = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ update_rept (struct rpt_s **rpt, const long start, conf_t *conf)
|
|||||||
if (newfreq == 0)
|
if (newfreq == 0)
|
||||||
{
|
{
|
||||||
status_mesg (msg_wrong_freq, msg_enter);
|
status_mesg (msg_wrong_freq, msg_enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -685,7 +685,7 @@ update_rept (struct rpt_s **rpt, const long start, conf_t *conf)
|
|||||||
if (newuntil < start)
|
if (newuntil < start)
|
||||||
{
|
{
|
||||||
status_mesg (msg_wrong_time, msg_enter);
|
status_mesg (msg_wrong_time, msg_enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
date_entered = 0;
|
date_entered = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -696,7 +696,7 @@ update_rept (struct rpt_s **rpt, const long start, conf_t *conf)
|
|||||||
snprintf (outstr, BUFSIZ, msg_fmts,
|
snprintf (outstr, BUFSIZ, msg_fmts,
|
||||||
DATEFMT_DESC (conf->input_datefmt));
|
DATEFMT_DESC (conf->input_datefmt));
|
||||||
status_mesg (msg_wrong_date, _(outstr));
|
status_mesg (msg_wrong_date, _(outstr));
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
date_entered = 0;
|
date_entered = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -737,7 +737,7 @@ day_edit_item (conf_t *conf)
|
|||||||
re = recur_get_event (date, day_item_nb (date, item_num, RECUR_EVNT));
|
re = recur_get_event (date, day_item_nb (date, item_num, RECUR_EVNT));
|
||||||
status_mesg (_("Edit: (1)Description or (2)Repetition?"), "[1/2] ");
|
status_mesg (_("Edit: (1)Description or (2)Repetition?"), "[1/2] ");
|
||||||
while (ch != '1' && ch != '2' && ch != KEY_GENERIC_ESCAPE)
|
while (ch != '1' && ch != '2' && ch != KEY_GENERIC_ESCAPE)
|
||||||
ch = keys_getch (win[STA].p);
|
ch = wgetch (win[STA].p);
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case '1':
|
case '1':
|
||||||
@ -760,7 +760,7 @@ day_edit_item (conf_t *conf)
|
|||||||
"(3)Description or (4)Repetition?"), "[1/2/3/4] ");
|
"(3)Description or (4)Repetition?"), "[1/2/3/4] ");
|
||||||
while (ch != STRT && ch != END && ch != DESC &&
|
while (ch != STRT && ch != END && ch != DESC &&
|
||||||
ch != REPT && ch != KEY_GENERIC_ESCAPE)
|
ch != REPT && ch != KEY_GENERIC_ESCAPE)
|
||||||
ch = keys_getch (win[STA].p);
|
ch = wgetch (win[STA].p);
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case STRT:
|
case STRT:
|
||||||
@ -784,7 +784,7 @@ day_edit_item (conf_t *conf)
|
|||||||
status_mesg (_("Edit: (1)Start time, (2)End time "
|
status_mesg (_("Edit: (1)Start time, (2)End time "
|
||||||
"or (3)Description?"), "[1/2/3] ");
|
"or (3)Description?"), "[1/2/3] ");
|
||||||
while (ch != STRT && ch != END && ch != DESC && ch != KEY_GENERIC_ESCAPE)
|
while (ch != STRT && ch != END && ch != DESC && ch != KEY_GENERIC_ESCAPE)
|
||||||
ch = keys_getch (win[STA].p);
|
ch = wgetch (win[STA].p);
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
case STRT:
|
case STRT:
|
||||||
@ -833,7 +833,7 @@ day_erase_item (long date, int item_number, erase_flag_e flag)
|
|||||||
while (ans != 'i' && ans != 'n')
|
while (ans != 'i' && ans != 'n')
|
||||||
{
|
{
|
||||||
status_mesg (note_warning, note_choice);
|
status_mesg (note_warning, note_choice);
|
||||||
ans = keys_getch (win[STA].p);
|
ans = wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
if (ans == 'i')
|
if (ans == 'i')
|
||||||
flag = ERASE_FORCE;
|
flag = ERASE_FORCE;
|
||||||
@ -855,7 +855,7 @@ day_erase_item (long date, int item_number, erase_flag_e flag)
|
|||||||
while ((ch != 'a') && (ch != 'o') && (ch != KEY_GENERIC_ESCAPE))
|
while ((ch != 'a') && (ch != 'o') && (ch != KEY_GENERIC_ESCAPE))
|
||||||
{
|
{
|
||||||
status_mesg (erase_warning, erase_choice);
|
status_mesg (erase_warning, erase_choice);
|
||||||
ch = keys_getch (win[STA].p);
|
ch = wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
if (ch == 'a')
|
if (ch == 'a')
|
||||||
{
|
{
|
||||||
|
262
src/io.c
262
src/io.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: io.c,v 1.44 2008/12/03 19:31:03 culot Exp $ */
|
/* $calcurse: io.c,v 1.45 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -168,18 +168,15 @@ progress_bar (progress_bar_t type, int progress)
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case PROGRESS_BAR_SAVE:
|
case PROGRESS_BAR_SAVE:
|
||||||
EXIT_IF (progress < 0 || progress > PROGRESS_BAR_KEYS,
|
EXIT_IF (progress < 0 || progress > PROGRESS_BAR_KEYS, error_msg);
|
||||||
error_msg);
|
|
||||||
status_mesg (mesg_sav, file[progress]);
|
status_mesg (mesg_sav, file[progress]);
|
||||||
break;
|
break;
|
||||||
case PROGRESS_BAR_LOAD:
|
case PROGRESS_BAR_LOAD:
|
||||||
EXIT_IF (progress < 0 || progress > PROGRESS_BAR_KEYS,
|
EXIT_IF (progress < 0 || progress > PROGRESS_BAR_KEYS, error_msg);
|
||||||
error_msg);
|
|
||||||
status_mesg (mesg_load, file[progress]);
|
status_mesg (mesg_load, file[progress]);
|
||||||
break;
|
break;
|
||||||
case PROGRESS_BAR_EXPORT:
|
case PROGRESS_BAR_EXPORT:
|
||||||
EXIT_IF (progress < 0 || progress > PROGRESS_BAR_TODO,
|
EXIT_IF (progress < 0 || progress > PROGRESS_BAR_EXPORT_TODO, error_msg);
|
||||||
error_msg);
|
|
||||||
status_mesg (mesg_export, data[progress]);
|
status_mesg (mesg_export, data[progress]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -233,7 +230,7 @@ get_export_stream (export_type_t type)
|
|||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
{
|
{
|
||||||
status_mesg (wrong_name, press_enter);
|
status_mesg (wrong_name, press_enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free (stream_name);
|
free (stream_name);
|
||||||
@ -751,7 +748,7 @@ io_extract_data (char *dst_data, const char *org, int len)
|
|||||||
|
|
||||||
/* Save the calendar data */
|
/* Save the calendar data */
|
||||||
void
|
void
|
||||||
io_save_cal (io_mode_t mode, conf_t *conf)
|
io_save_cal (conf_t *conf)
|
||||||
{
|
{
|
||||||
FILE *data_file;
|
FILE *data_file;
|
||||||
struct event_s *k;
|
struct event_s *k;
|
||||||
@ -773,7 +770,7 @@ io_save_cal (io_mode_t mode, conf_t *conf)
|
|||||||
char *enter = _("Press [ENTER] to continue");
|
char *enter = _("Press [ENTER] to continue");
|
||||||
bool show_bar = false;
|
bool show_bar = false;
|
||||||
|
|
||||||
if (mode == IO_MODE_INTERACTIVE && !conf->skip_progress_bar)
|
if (ui_mode == UI_CURSES && !conf->skip_progress_bar)
|
||||||
show_bar = true;
|
show_bar = true;
|
||||||
|
|
||||||
/* Save the user configuration. */
|
/* Save the user configuration. */
|
||||||
@ -833,7 +830,7 @@ io_save_cal (io_mode_t mode, conf_t *conf)
|
|||||||
fprintf (data_file, "layout=\n");
|
fprintf (data_file, "layout=\n");
|
||||||
fprintf (data_file, "%d\n", wins_layout ());
|
fprintf (data_file, "%d\n", wins_layout ());
|
||||||
|
|
||||||
if (mode == IO_MODE_INTERACTIVE)
|
if (ui_mode == UI_CURSES)
|
||||||
pthread_mutex_lock (&nbar->mutex);
|
pthread_mutex_lock (&nbar->mutex);
|
||||||
fprintf (data_file,
|
fprintf (data_file,
|
||||||
"\n# If this option is set to yes, "
|
"\n# If this option is set to yes, "
|
||||||
@ -875,7 +872,7 @@ io_save_cal (io_mode_t mode, conf_t *conf)
|
|||||||
fprintf (data_file, "input_datefmt=\n");
|
fprintf (data_file, "input_datefmt=\n");
|
||||||
fprintf (data_file, "%d\n", conf->input_datefmt);
|
fprintf (data_file, "%d\n", conf->input_datefmt);
|
||||||
|
|
||||||
if (mode == IO_MODE_INTERACTIVE)
|
if (ui_mode == UI_CURSES)
|
||||||
pthread_mutex_unlock (&nbar->mutex);
|
pthread_mutex_unlock (&nbar->mutex);
|
||||||
|
|
||||||
fclose (data_file);
|
fclose (data_file);
|
||||||
@ -913,11 +910,11 @@ io_save_cal (io_mode_t mode, conf_t *conf)
|
|||||||
{
|
{
|
||||||
recur_save_data (data_file);
|
recur_save_data (data_file);
|
||||||
|
|
||||||
if (mode == IO_MODE_INTERACTIVE)
|
if (ui_mode == UI_CURSES)
|
||||||
pthread_mutex_lock (&(alist_p->mutex));
|
pthread_mutex_lock (&(alist_p->mutex));
|
||||||
for (j = alist_p->root; j != 0; j = j->next)
|
for (j = alist_p->root; j != 0; j = j->next)
|
||||||
apoint_write (j, data_file);
|
apoint_write (j, data_file);
|
||||||
if (mode == IO_MODE_INTERACTIVE)
|
if (ui_mode == UI_CURSES)
|
||||||
pthread_mutex_unlock (&(alist_p->mutex));
|
pthread_mutex_unlock (&(alist_p->mutex));
|
||||||
|
|
||||||
for (k = eventlist; k != 0; k = k->next)
|
for (k = eventlist; k != 0; k = k->next)
|
||||||
@ -938,10 +935,10 @@ io_save_cal (io_mode_t mode, conf_t *conf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Print a message telling data were saved */
|
/* Print a message telling data were saved */
|
||||||
if (mode == IO_MODE_INTERACTIVE && !conf->skip_system_dialogs)
|
if (ui_mode == UI_CURSES && !conf->skip_system_dialogs)
|
||||||
{
|
{
|
||||||
status_mesg (save_success, enter);
|
status_mesg (save_success, enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1155,7 +1152,7 @@ io_load_todo (void)
|
|||||||
if (data_file == NULL)
|
if (data_file == NULL)
|
||||||
{
|
{
|
||||||
status_mesg (mesg_line1, mesg_line2);
|
status_mesg (mesg_line1, mesg_line2);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -1232,14 +1229,18 @@ static int is_blank (int c)
|
|||||||
* Load user-definable keys from file.
|
* Load user-definable keys from file.
|
||||||
* A hash table is used to speed up loading process in avoiding string
|
* A hash table is used to speed up loading process in avoiding string
|
||||||
* comparisons.
|
* comparisons.
|
||||||
|
* A log file is also built in case some errors were found in the key
|
||||||
|
* configuration file.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
io_load_keys (void)
|
io_load_keys (char *pager)
|
||||||
{
|
{
|
||||||
struct ht_keybindings_s keys[NBKEYS];
|
struct ht_keybindings_s keys[NBKEYS];
|
||||||
FILE *keyfp;
|
FILE *keyfp;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int i;
|
io_file_t *log;
|
||||||
|
int i, skipped, loaded, line;
|
||||||
|
const int MAX_ERRORS = 5;
|
||||||
|
|
||||||
#define HSIZE 256
|
#define HSIZE 256
|
||||||
HTABLE_HEAD (ht_keybindings, HSIZE, ht_keybindings_s) ht_keys =
|
HTABLE_HEAD (ht_keybindings, HSIZE, ht_keybindings_s) ht_keys =
|
||||||
@ -1256,24 +1257,51 @@ io_load_keys (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyfp = fopen (path_keys, "r");
|
keyfp = fopen (path_keys, "r");
|
||||||
|
EXIT_IF (keyfp == NULL,
|
||||||
|
_("FATAL ERROR in io_load_keys: could not find any key file."));
|
||||||
|
log = io_log_init ();
|
||||||
|
skipped = loaded = line = 0;
|
||||||
while (fgets (buf, BUFSIZ, keyfp) != NULL)
|
while (fgets (buf, BUFSIZ, keyfp) != NULL)
|
||||||
{
|
{
|
||||||
char key_label[BUFSIZ], *p;
|
char key_label[BUFSIZ], *p;
|
||||||
struct ht_keybindings_s *ht_elm, ht_entry;
|
struct ht_keybindings_s *ht_elm, ht_entry;
|
||||||
const int AWAITED = 1;
|
const int AWAITED = 1;
|
||||||
|
int assigned;
|
||||||
|
|
||||||
|
line++;
|
||||||
|
if (skipped > MAX_ERRORS)
|
||||||
|
{
|
||||||
|
char *too_many =
|
||||||
|
_("\nToo many errors while reading configuration file!\n"
|
||||||
|
"Please backup your keys file, remove it from directory, "
|
||||||
|
"and launch calcurse again.\n");
|
||||||
|
|
||||||
|
io_log_print (log, line, too_many);
|
||||||
|
break;
|
||||||
|
}
|
||||||
for (p = buf; is_blank ((int)*p); p++)
|
for (p = buf; is_blank ((int)*p); p++)
|
||||||
;
|
;
|
||||||
if (p != buf)
|
if (p != buf)
|
||||||
memmove (buf, p, strlen (p));
|
memmove (buf, p, strlen (p));
|
||||||
if (buf[0] == '#')
|
if (buf[0] == '#' || buf[0] == '\n')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sscanf (buf, "%s", key_label) != AWAITED)
|
if (sscanf (buf, "%s", key_label) != AWAITED)
|
||||||
|
{
|
||||||
|
skipped++;
|
||||||
|
io_log_print (log, line, _("Could not read key label"));
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
ht_entry.label = key_label;
|
ht_entry.label = key_label;
|
||||||
p = buf + strlen (key_label) + 1;
|
p = buf + strlen (key_label) + 1;
|
||||||
ht_elm = HTABLE_LOOKUP (ht_keybindings, &ht_keys, &ht_entry);
|
ht_elm = HTABLE_LOOKUP (ht_keybindings, &ht_keys, &ht_entry);
|
||||||
|
if (!ht_elm)
|
||||||
|
{
|
||||||
|
skipped++;
|
||||||
|
io_log_print (log, line, _("Key label not recognized"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
assigned = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char key_ch[BUFSIZ], tmpbuf[BUFSIZ];
|
char key_ch[BUFSIZ], tmpbuf[BUFSIZ];
|
||||||
@ -1283,26 +1311,58 @@ io_load_keys (void)
|
|||||||
strncpy (tmpbuf, p, BUFSIZ);
|
strncpy (tmpbuf, p, BUFSIZ);
|
||||||
if (sscanf (tmpbuf, "%s", key_ch) == AWAITED)
|
if (sscanf (tmpbuf, "%s", key_ch) == AWAITED)
|
||||||
{
|
{
|
||||||
int ch, used;
|
int ch;
|
||||||
char *unknown_key = _("Error reading key: \"%s\"");
|
|
||||||
char *already_used =
|
|
||||||
_("\"%s\" assigned multiple times in keys file!");
|
|
||||||
|
|
||||||
if ((ch = keys_str2int (key_ch)) < 0)
|
if ((ch = keys_str2int (key_ch)) < 0)
|
||||||
ERROR_MSG (unknown_key, key_ch);
|
{
|
||||||
|
char unknown_key[BUFSIZ];
|
||||||
|
|
||||||
|
skipped++;
|
||||||
|
snprintf (unknown_key, BUFSIZ, _("Error reading key: \"%s\""),
|
||||||
|
key_ch);
|
||||||
|
io_log_print (log, line, unknown_key);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p += strlen (key_ch) + 1;
|
int used;
|
||||||
|
|
||||||
used = keys_assign_binding (ch, ht_elm->key);
|
used = keys_assign_binding (ch, ht_elm->key);
|
||||||
if (used)
|
if (used)
|
||||||
ERROR_MSG (already_used, key_ch);
|
{
|
||||||
}
|
char already_assigned[BUFSIZ];
|
||||||
|
|
||||||
|
skipped++;
|
||||||
|
snprintf (already_assigned, BUFSIZ,
|
||||||
|
_("\"%s\" assigned multiple times!"), key_ch);
|
||||||
|
io_log_print (log, line, already_assigned);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
assigned++;
|
||||||
|
}
|
||||||
|
p += strlen (key_ch) + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (assigned)
|
||||||
|
loaded++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fclose (keyfp);
|
fclose (keyfp);
|
||||||
|
fclose (log->fd);
|
||||||
|
if (skipped > 0)
|
||||||
|
{
|
||||||
|
char *view_log =
|
||||||
|
_("There were some errors when loading keys file, see log file ?");
|
||||||
|
|
||||||
|
io_log_display (log, view_log, pager);
|
||||||
|
}
|
||||||
|
io_log_free (log);
|
||||||
|
EXIT_IF (skipped > MAX_ERRORS,
|
||||||
|
_("Too many errors while reading keys file, aborting..."));
|
||||||
|
if (loaded < NBKEYS)
|
||||||
|
ERROR_MSG (_("Some actions do not have any associated key bindings!"));
|
||||||
#undef HSIZE
|
#undef HSIZE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1388,18 +1448,18 @@ io_startup_screen (bool skip_dialogs, int no_data_file)
|
|||||||
if (no_data_file != 0)
|
if (no_data_file != 0)
|
||||||
{
|
{
|
||||||
status_mesg (welcome_mesg, enter);
|
status_mesg (welcome_mesg, enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
else if (!skip_dialogs)
|
else if (!skip_dialogs)
|
||||||
{
|
{
|
||||||
status_mesg (data_mesg, enter);
|
status_mesg (data_mesg, enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Export calcurse data. */
|
/* Export calcurse data. */
|
||||||
void
|
void
|
||||||
io_export_data (io_mode_t mode, export_type_t type, conf_t *conf)
|
io_export_data (export_type_t type, conf_t *conf)
|
||||||
{
|
{
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
char *wrong_mode = _("FATAL ERROR in io_export_data: wrong export mode\n");
|
char *wrong_mode = _("FATAL ERROR in io_export_data: wrong export mode\n");
|
||||||
@ -1412,12 +1472,12 @@ io_export_data (io_mode_t mode, export_type_t type, conf_t *conf)
|
|||||||
fputs (wrong_type, stderr);
|
fputs (wrong_type, stderr);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
switch (mode)
|
switch (ui_mode)
|
||||||
{
|
{
|
||||||
case IO_MODE_NONINTERACTIVE:
|
case UI_CMDLINE:
|
||||||
stream = stdout;
|
stream = stdout;
|
||||||
break;
|
break;
|
||||||
case IO_MODE_INTERACTIVE:
|
case UI_CURSES:
|
||||||
stream = get_export_stream (type);
|
stream = get_export_stream (type);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1431,18 +1491,18 @@ io_export_data (io_mode_t mode, export_type_t type, conf_t *conf)
|
|||||||
|
|
||||||
cb_export_header[type] (stream);
|
cb_export_header[type] (stream);
|
||||||
|
|
||||||
if (!conf->skip_progress_bar && mode == IO_MODE_INTERACTIVE)
|
if (!conf->skip_progress_bar && ui_mode == UI_CURSES)
|
||||||
progress_bar (PROGRESS_BAR_EXPORT, 0);
|
progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_EVENTS);
|
||||||
cb_export_recur_events[type] (stream);
|
cb_export_recur_events[type] (stream);
|
||||||
cb_export_events[type] (stream);
|
cb_export_events[type] (stream);
|
||||||
|
|
||||||
if (!conf->skip_progress_bar && mode == IO_MODE_INTERACTIVE)
|
if (!conf->skip_progress_bar && ui_mode == UI_CURSES)
|
||||||
progress_bar (PROGRESS_BAR_EXPORT, 1);
|
progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_APOINTS);
|
||||||
cb_export_recur_apoints[type] (stream);
|
cb_export_recur_apoints[type] (stream);
|
||||||
cb_export_apoints[type] (stream);
|
cb_export_apoints[type] (stream);
|
||||||
|
|
||||||
if (!conf->skip_progress_bar && mode == IO_MODE_INTERACTIVE)
|
if (!conf->skip_progress_bar && ui_mode == UI_CURSES)
|
||||||
progress_bar (PROGRESS_BAR_EXPORT, 2);
|
progress_bar (PROGRESS_BAR_EXPORT, PROGRESS_BAR_EXPORT_TODO);
|
||||||
cb_export_todo[type] (stream);
|
cb_export_todo[type] (stream);
|
||||||
|
|
||||||
cb_export_footer[type] (stream);
|
cb_export_footer[type] (stream);
|
||||||
@ -1450,10 +1510,10 @@ io_export_data (io_mode_t mode, export_type_t type, conf_t *conf)
|
|||||||
if (stream != stdout)
|
if (stream != stdout)
|
||||||
fclose (stream);
|
fclose (stream);
|
||||||
|
|
||||||
if (!conf->skip_system_dialogs && mode == IO_MODE_INTERACTIVE)
|
if (!conf->skip_system_dialogs && ui_mode == UI_CURSES)
|
||||||
{
|
{
|
||||||
status_mesg (success, enter);
|
status_mesg (success, enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1501,6 +1561,7 @@ ical_log_init (FILE *log, float version)
|
|||||||
"| * DESCRIPTION indicates why the item could not be imported |\n"
|
"| * DESCRIPTION indicates why the item could not be imported |\n"
|
||||||
"+-------------------------------------------------------------------+\n\n";
|
"+-------------------------------------------------------------------+\n\n";
|
||||||
|
|
||||||
|
if (log)
|
||||||
fprintf (log, header, version);
|
fprintf (log, header, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1517,6 +1578,7 @@ ical_log (FILE *log, ical_types_e type, unsigned lineno, char *msg)
|
|||||||
|
|
||||||
RETURN_IF (type < 0 || type >= ICAL_TYPES,
|
RETURN_IF (type < 0 || type >= ICAL_TYPES,
|
||||||
_("ERROR in ical_log: unknown ical type"));
|
_("ERROR in ical_log: unknown ical type"));
|
||||||
|
if (log)
|
||||||
fprintf (log, "%s [%d]: %s\n", typestr[type], lineno, msg);
|
fprintf (log, "%s [%d]: %s\n", typestr[type], lineno, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2493,7 +2555,7 @@ get_import_stream (export_type_t type)
|
|||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
{
|
{
|
||||||
status_mesg (wrong_file, press_enter);
|
status_mesg (wrong_file, press_enter);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mem_free (stream_name);
|
mem_free (stream_name);
|
||||||
@ -2508,10 +2570,8 @@ get_import_stream (export_type_t type)
|
|||||||
* and is cleared at the end.
|
* and is cleared at the end.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
io_import_data (io_mode_t mode, import_type_t type, conf_t *conf,
|
io_import_data (import_type_t type, conf_t *conf, char *stream_name)
|
||||||
char *stream_name)
|
|
||||||
{
|
{
|
||||||
const char *logprefix = "/tmp/calcurse_log.";
|
|
||||||
const string_t vevent = STRING_BUILD ("BEGIN:VEVENT");
|
const string_t vevent = STRING_BUILD ("BEGIN:VEVENT");
|
||||||
const string_t vtodo = STRING_BUILD ("BEGIN:VTODO");
|
const string_t vtodo = STRING_BUILD ("BEGIN:VTODO");
|
||||||
char *proc_report = _("Import process report: %04d lines read ");
|
char *proc_report = _("Import process report: %04d lines read ");
|
||||||
@ -2519,8 +2579,9 @@ io_import_data (io_mode_t mode, import_type_t type, conf_t *conf,
|
|||||||
_("%d apps / %d events / %d todos / %d skipped ");
|
_("%d apps / %d events / %d todos / %d skipped ");
|
||||||
char *lines_stats_interactive =
|
char *lines_stats_interactive =
|
||||||
_("%d apps / %d events / %d todos / %d skipped ([ENTER] to continue)");
|
_("%d apps / %d events / %d todos / %d skipped ([ENTER] to continue)");
|
||||||
char *logname, flogname[BUFSIZ], buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
FILE *stream = NULL, *logfd;
|
FILE *stream = NULL;
|
||||||
|
io_file_t *log;
|
||||||
float ical_version;
|
float ical_version;
|
||||||
struct {
|
struct {
|
||||||
unsigned events, apoints, todos, lines, skipped;
|
unsigned events, apoints, todos, lines, skipped;
|
||||||
@ -2528,15 +2589,15 @@ io_import_data (io_mode_t mode, import_type_t type, conf_t *conf,
|
|||||||
|
|
||||||
EXIT_IF (type < 0 || type >= IO_IMPORT_NBTYPES,
|
EXIT_IF (type < 0 || type >= IO_IMPORT_NBTYPES,
|
||||||
_("FATAL ERROR in io_import_data: unknown import type"));
|
_("FATAL ERROR in io_import_data: unknown import type"));
|
||||||
switch (mode)
|
switch (ui_mode)
|
||||||
{
|
{
|
||||||
case IO_MODE_NONINTERACTIVE:
|
case UI_CMDLINE:
|
||||||
stream = fopen (stream_name, "r");
|
stream = fopen (stream_name, "r");
|
||||||
EXIT_IF (stream == NULL,
|
EXIT_IF (stream == NULL,
|
||||||
_("FATAL ERROR: the input file cannot be accessed, "
|
_("FATAL ERROR: the input file cannot be accessed, "
|
||||||
"Aborting..."));
|
"Aborting..."));
|
||||||
break;
|
break;
|
||||||
case IO_MODE_INTERACTIVE:
|
case UI_CURSES:
|
||||||
stream = get_import_stream (type);
|
stream = get_import_stream (type);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2553,15 +2614,14 @@ io_import_data (io_mode_t mode, import_type_t type, conf_t *conf,
|
|||||||
_("Warning: ical header malformed or wrong version number. "
|
_("Warning: ical header malformed or wrong version number. "
|
||||||
"Aborting..."));
|
"Aborting..."));
|
||||||
|
|
||||||
logname = new_tempfile (logprefix, NOTESIZ);
|
log = io_log_init ();
|
||||||
RETURN_IF (logname == NULL,
|
if (log == 0)
|
||||||
_("Warning: could not create new note file to store "
|
{
|
||||||
"description. Aborting...\n"));
|
if (stream != stdin)
|
||||||
snprintf (flogname, BUFSIZ, "%s%s", logprefix, logname);
|
fclose (stream);
|
||||||
logfd = fopen (flogname, "w");
|
return;
|
||||||
RETURN_IF (logfd == NULL,
|
}
|
||||||
_("Warning: could not open temporary log file, Aborting..."));
|
ical_log_init (log->fd, ical_version);
|
||||||
ical_log_init (logfd, ical_version);
|
|
||||||
|
|
||||||
while (fgets (buf, BUFSIZ, stream) != NULL)
|
while (fgets (buf, BUFSIZ, stream) != NULL)
|
||||||
{
|
{
|
||||||
@ -2569,19 +2629,19 @@ io_import_data (io_mode_t mode, import_type_t type, conf_t *conf,
|
|||||||
str_toupper (buf);
|
str_toupper (buf);
|
||||||
if (strncmp (buf, vevent.str, vevent.len) == 0)
|
if (strncmp (buf, vevent.str, vevent.len) == 0)
|
||||||
{
|
{
|
||||||
ical_read_event (stream, logfd, &stats.events, &stats.apoints,
|
ical_read_event (stream, log->fd, &stats.events, &stats.apoints,
|
||||||
&stats.skipped, &stats.lines);
|
&stats.skipped, &stats.lines);
|
||||||
}
|
}
|
||||||
else if (strncmp (buf, vtodo.str, vtodo.len) == 0)
|
else if (strncmp (buf, vtodo.str, vtodo.len) == 0)
|
||||||
{
|
{
|
||||||
ical_read_todo (stream, logfd, &stats.todos, &stats.skipped,
|
ical_read_todo (stream, log->fd, &stats.todos, &stats.skipped,
|
||||||
&stats.lines);
|
&stats.lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stream != stdin)
|
if (stream != stdin)
|
||||||
fclose (stream);
|
fclose (stream);
|
||||||
|
|
||||||
if (mode == IO_MODE_INTERACTIVE && !conf->skip_system_dialogs)
|
if (ui_mode == UI_CURSES && !conf->skip_system_dialogs)
|
||||||
{
|
{
|
||||||
char read[BUFSIZ], stat[BUFSIZ];
|
char read[BUFSIZ], stat[BUFSIZ];
|
||||||
|
|
||||||
@ -2589,9 +2649,9 @@ io_import_data (io_mode_t mode, import_type_t type, conf_t *conf,
|
|||||||
snprintf (stat, BUFSIZ, lines_stats_interactive, stats.apoints,
|
snprintf (stat, BUFSIZ, lines_stats_interactive, stats.apoints,
|
||||||
stats.events, stats.todos, stats.skipped);
|
stats.events, stats.todos, stats.skipped);
|
||||||
status_mesg (read, stat);
|
status_mesg (read, stat);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
else if (mode == IO_MODE_NONINTERACTIVE)
|
else if (ui_mode == UI_CMDLINE)
|
||||||
{
|
{
|
||||||
printf (proc_report, stats.lines);
|
printf (proc_report, stats.lines);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
@ -2603,43 +2663,91 @@ io_import_data (io_mode_t mode, import_type_t type, conf_t *conf,
|
|||||||
/* User has the choice to look at the log file if some items could not be
|
/* User has the choice to look at the log file if some items could not be
|
||||||
imported.
|
imported.
|
||||||
*/
|
*/
|
||||||
fclose (logfd);
|
fclose (log->fd);
|
||||||
if (stats.skipped > 0)
|
if (stats.skipped > 0)
|
||||||
{
|
{
|
||||||
char *view_log = _("Some items could not be imported, see log file ?");
|
char *view_log = _("Some items could not be imported, see log file ?");
|
||||||
|
|
||||||
|
io_log_display (log, view_log, conf->pager);
|
||||||
|
}
|
||||||
|
io_log_free (log);
|
||||||
|
}
|
||||||
|
|
||||||
|
io_file_t *
|
||||||
|
io_log_init (void)
|
||||||
|
{
|
||||||
|
const char *logprefix = "/tmp/calcurse_log.";
|
||||||
|
char *logname;
|
||||||
|
io_file_t *log;
|
||||||
|
|
||||||
|
logname = new_tempfile (logprefix, NOTESIZ);
|
||||||
|
RETVAL_IF (logname == 0, 0,
|
||||||
|
_("Warning: could not create temporary log file, Aborting..."));
|
||||||
|
log = malloc (sizeof (io_file_t));
|
||||||
|
RETVAL_IF (log == 0, 0,
|
||||||
|
_("Warning: could not open temporary log file, Aborting..."));
|
||||||
|
snprintf (log->name, sizeof (log->name), "%s%s", logprefix, logname);
|
||||||
|
mem_free (logname);
|
||||||
|
log->fd = fopen (log->name, "w");
|
||||||
|
if (log->fd == 0)
|
||||||
|
{
|
||||||
|
ERROR_MSG (_("Warning: could not open temporary log file, Aborting..."));
|
||||||
|
mem_free (log);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
io_log_print (io_file_t *log, int line, char *msg)
|
||||||
|
{
|
||||||
|
if (log && log->fd)
|
||||||
|
fprintf (log->fd, "[%d]: %s\n", line, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
io_log_display (io_file_t *log, char *msg, char *pager)
|
||||||
|
{
|
||||||
char *choices = "[y/n] ";
|
char *choices = "[y/n] ";
|
||||||
int ans;
|
int ans;
|
||||||
|
|
||||||
if (mode == IO_MODE_NONINTERACTIVE)
|
RETURN_IF (log == 0, _("No log file to display!"));
|
||||||
|
if (ui_mode == UI_CMDLINE)
|
||||||
{
|
{
|
||||||
int ans;
|
printf ("\n%s %s", msg, choices);
|
||||||
|
|
||||||
printf ("\n%s %s", view_log, choices);
|
|
||||||
ans = fgetc (stdin);
|
ans = fgetc (stdin);
|
||||||
if (ans == 'y')
|
if (ans == 'y')
|
||||||
{
|
{
|
||||||
char cmd[BUFSIZ];
|
char cmd[BUFSIZ];
|
||||||
|
|
||||||
snprintf (cmd, BUFSIZ, "%s %s", conf->pager, flogname);
|
snprintf (cmd, BUFSIZ, "%s %s", pager, log->name);
|
||||||
system (cmd);
|
system (cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
status_mesg (view_log, choices);
|
status_mesg (msg, choices);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ans = keys_getch (win[STA].p);
|
ans = wgetch (win[STA].p);
|
||||||
if (ans == 'y')
|
if (ans == 'y')
|
||||||
{
|
{
|
||||||
wins_launch_external (flogname, conf->pager);
|
wins_launch_external (log->name, pager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (ans != 'y' && ans != 'n');
|
while (ans != 'y' && ans != 'n');
|
||||||
erase_status_bar ();
|
erase_status_bar ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXIT_IF (unlink (flogname) != 0,
|
|
||||||
_("Warning: could not erase temporary log file, Aborting..."));
|
void
|
||||||
mem_free (logname);
|
io_log_free (io_file_t *log)
|
||||||
|
{
|
||||||
|
if (!log)
|
||||||
|
return;
|
||||||
|
EXIT_IF (unlink (log->name) != 0,
|
||||||
|
_("Warning: could not erase temporary log file %s, Aborting..."),
|
||||||
|
log->name);
|
||||||
|
mem_free (log);
|
||||||
}
|
}
|
||||||
|
34
src/io.h
34
src/io.h
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: io.h,v 1.16 2008/11/09 20:10:18 culot Exp $ */
|
/* $calcurse: io.h,v 1.17 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -29,36 +29,36 @@
|
|||||||
|
|
||||||
#include "vars.h"
|
#include "vars.h"
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
IO_MODE_NONINTERACTIVE,
|
|
||||||
IO_MODE_INTERACTIVE,
|
|
||||||
IO_NBMODES
|
|
||||||
} io_mode_t;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
IO_IMPORT_ICAL,
|
IO_IMPORT_ICAL,
|
||||||
IO_IMPORT_NBTYPES
|
IO_IMPORT_NBTYPES
|
||||||
} import_type_t;
|
} import_type_t;
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
IO_EXPORT_ICAL,
|
IO_EXPORT_ICAL,
|
||||||
IO_EXPORT_PCAL,
|
IO_EXPORT_PCAL,
|
||||||
IO_EXPORT_NBTYPES
|
IO_EXPORT_NBTYPES
|
||||||
} export_type_t;
|
} export_type_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
FILE *fd;
|
||||||
|
char name[BUFSIZ];
|
||||||
|
} io_file_t;
|
||||||
|
|
||||||
void io_init (char *, char *);
|
void io_init (char *, char *);
|
||||||
void io_extract_data (char *, const char *, int);
|
void io_extract_data (char *, const char *, int);
|
||||||
void io_save_cal (io_mode_t, conf_t *);
|
void io_save_cal (conf_t *);
|
||||||
void io_load_app (void);
|
void io_load_app (void);
|
||||||
void io_load_todo (void);
|
void io_load_todo (void);
|
||||||
void io_load_keys (void);
|
void io_load_keys (char *);
|
||||||
int io_check_data_files (void);
|
int io_check_data_files (void);
|
||||||
void io_startup_screen (bool, int);
|
void io_startup_screen (bool, int);
|
||||||
void io_export_data (io_mode_t, export_type_t, conf_t *);
|
void io_export_data (export_type_t, conf_t *);
|
||||||
void io_export_bar (void);
|
void io_export_bar (void);
|
||||||
void io_import_data (io_mode_t, import_type_t, conf_t *, char *);
|
void io_import_data (import_type_t, conf_t *, char *);
|
||||||
|
io_file_t *io_log_init (void);
|
||||||
|
void io_log_print (io_file_t *, int, char *);
|
||||||
|
void io_log_display (io_file_t *, char *, char *);
|
||||||
|
void io_log_free (io_file_t *);
|
||||||
|
|
||||||
#endif /* CALCURSE_IO_H */
|
#endif /* !CALCURSE_IO_H */
|
||||||
|
27
src/keys.c
27
src/keys.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: keys.c,v 1.6 2008/11/30 20:48:10 culot Exp $ */
|
/* $calcurse: keys.c,v 1.7 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -32,7 +32,7 @@
|
|||||||
#include "custom.h"
|
#include "custom.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
|
|
||||||
#define MAXKEYVAL 256
|
#define MAXKEYVAL KEY_MAX /* ncurses defines KEY_MAX as maximum key value */
|
||||||
|
|
||||||
struct keydef_s {
|
struct keydef_s {
|
||||||
char *label;
|
char *label;
|
||||||
@ -106,7 +106,8 @@ dump_intro (FILE *fd)
|
|||||||
"# To define bindings which use the CONTROL key, prefix the key with "
|
"# To define bindings which use the CONTROL key, prefix the key with "
|
||||||
"'C-'.\n"
|
"'C-'.\n"
|
||||||
"# The escape and horizontal Tab key can be specified using the 'ESC'\n"
|
"# The escape and horizontal Tab key can be specified using the 'ESC'\n"
|
||||||
"# and 'TAB' keyword, respectively.\n#\n"
|
"# and 'TAB' keyword, respectively. Arrow keys can also be specified\n"
|
||||||
|
"# with the UP, DWN, LFT, RGT keywords.\n#\n"
|
||||||
"# A description of what each ACTION keyword is used for is available\n"
|
"# A description of what each ACTION keyword is used for is available\n"
|
||||||
"# from calcurse online configuration menu.\n");
|
"# from calcurse online configuration menu.\n");
|
||||||
|
|
||||||
@ -253,6 +254,10 @@ keys_str2int (char *key)
|
|||||||
const string_t CONTROL_KEY = STRING_BUILD ("C-");
|
const string_t CONTROL_KEY = STRING_BUILD ("C-");
|
||||||
const string_t TAB_KEY = STRING_BUILD ("TAB");
|
const string_t TAB_KEY = STRING_BUILD ("TAB");
|
||||||
const string_t ESCAPE_KEY = STRING_BUILD ("ESC");
|
const string_t ESCAPE_KEY = STRING_BUILD ("ESC");
|
||||||
|
const string_t CURSES_KEY_UP = STRING_BUILD ("UP");
|
||||||
|
const string_t CURSES_KEY_DOWN = STRING_BUILD ("DWN");
|
||||||
|
const string_t CURSES_KEY_LEFT = STRING_BUILD ("LFT");
|
||||||
|
const string_t CURSES_KEY_RIGHT = STRING_BUILD ("RGT");
|
||||||
|
|
||||||
if (!key)
|
if (!key)
|
||||||
return -1;
|
return -1;
|
||||||
@ -268,6 +273,14 @@ keys_str2int (char *key)
|
|||||||
return TAB;
|
return TAB;
|
||||||
else if (!strncmp (key, ESCAPE_KEY.str, ESCAPE_KEY.len))
|
else if (!strncmp (key, ESCAPE_KEY.str, ESCAPE_KEY.len))
|
||||||
return ESCAPE;
|
return ESCAPE;
|
||||||
|
else if (!strncmp (key, CURSES_KEY_UP.str, CURSES_KEY_UP.len))
|
||||||
|
return KEY_UP;
|
||||||
|
else if (!strncmp (key, CURSES_KEY_DOWN.str, CURSES_KEY_DOWN.len))
|
||||||
|
return KEY_DOWN;
|
||||||
|
else if (!strncmp (key, CURSES_KEY_LEFT.str, CURSES_KEY_LEFT.len))
|
||||||
|
return KEY_LEFT;
|
||||||
|
else if (!strncmp (key, CURSES_KEY_RIGHT.str, CURSES_KEY_RIGHT.len))
|
||||||
|
return KEY_RIGHT;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -282,6 +295,14 @@ keys_int2str (int key)
|
|||||||
return "TAB";
|
return "TAB";
|
||||||
case ESCAPE:
|
case ESCAPE:
|
||||||
return "ESC";
|
return "ESC";
|
||||||
|
case KEY_UP:
|
||||||
|
return "UP";
|
||||||
|
case KEY_DOWN:
|
||||||
|
return "DWN";
|
||||||
|
case KEY_LEFT:
|
||||||
|
return "LFT";
|
||||||
|
case KEY_RIGHT:
|
||||||
|
return "RGT";
|
||||||
default:
|
default:
|
||||||
return (char *)keyname (key);
|
return (char *)keyname (key);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: notify.c,v 1.29 2008/11/23 20:38:56 culot Exp $ */
|
/* $calcurse: notify.c,v 1.30 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -539,7 +539,7 @@ notify_config_bar (void)
|
|||||||
status_mesg (number_str, "");
|
status_mesg (number_str, "");
|
||||||
notify_print_options (conf_win.p, col);
|
notify_print_options (conf_win.p, col);
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
ch = keys_getch (win[STA].p);
|
ch = wgetch (win[STA].p);
|
||||||
|
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
|
14
src/recur.c
14
src/recur.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: recur.c,v 1.39 2008/11/16 17:42:53 culot Exp $ */
|
/* $calcurse: recur.c,v 1.40 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -689,7 +689,7 @@ recur_repeat_item (conf_t *conf)
|
|||||||
if (p->type != APPT && p->type != EVNT)
|
if (p->type != APPT && p->type != EVNT)
|
||||||
{
|
{
|
||||||
status_mesg (wrong_type_1, wrong_type_2);
|
status_mesg (wrong_type_1, wrong_type_2);
|
||||||
ch = keys_getch (win[STA].p);
|
ch = wgetch (win[STA].p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,10 +697,10 @@ recur_repeat_item (conf_t *conf)
|
|||||||
&& (ch != 'Y') && (ch != KEY_GENERIC_ESCAPE))
|
&& (ch != 'Y') && (ch != KEY_GENERIC_ESCAPE))
|
||||||
{
|
{
|
||||||
status_mesg (mesg_type_1, mesg_type_2);
|
status_mesg (mesg_type_1, mesg_type_2);
|
||||||
ch = keys_getch (win[STA].p);
|
ch = wgetch (win[STA].p);
|
||||||
ch = toupper (ch);
|
ch = toupper (ch);
|
||||||
}
|
}
|
||||||
if (ch == KEY_GENERIC_ESCAPE)
|
if (ch == ESCAPE)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -719,7 +719,7 @@ recur_repeat_item (conf_t *conf)
|
|||||||
if (freq == 0)
|
if (freq == 0)
|
||||||
{
|
{
|
||||||
status_mesg (mesg_wrong_freq, wrong_type_2);
|
status_mesg (mesg_wrong_freq, wrong_type_2);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
user_input[0] = '\0';
|
user_input[0] = '\0';
|
||||||
}
|
}
|
||||||
@ -753,7 +753,7 @@ recur_repeat_item (conf_t *conf)
|
|||||||
if (until < p->start)
|
if (until < p->start)
|
||||||
{
|
{
|
||||||
status_mesg (mesg_older, wrong_type_2);
|
status_mesg (mesg_older, wrong_type_2);
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
date_entered = 0;
|
date_entered = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -766,7 +766,7 @@ recur_repeat_item (conf_t *conf)
|
|||||||
snprintf (outstr, BUFSIZ, mesg_wrong_2,
|
snprintf (outstr, BUFSIZ, mesg_wrong_2,
|
||||||
DATEFMT_DESC (conf->input_datefmt));
|
DATEFMT_DESC (conf->input_datefmt));
|
||||||
status_mesg (mesg_wrong_1, _(outstr));
|
status_mesg (mesg_wrong_1, _(outstr));
|
||||||
keys_getch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
date_entered = 0;
|
date_entered = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: todo.c,v 1.24 2008/11/16 17:42:53 culot Exp $ */
|
/* $calcurse: todo.c,v 1.25 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -146,7 +146,7 @@ todo_new_item (void)
|
|||||||
while ((ch < '1') || (ch > '9'))
|
while ((ch < '1') || (ch > '9'))
|
||||||
{
|
{
|
||||||
status_mesg (mesg_id, "");
|
status_mesg (mesg_id, "");
|
||||||
ch = keys_getch (win[STA].p);
|
ch = wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
todo_add (todo_input, ch - '0', NULL);
|
todo_add (todo_input, ch - '0', NULL);
|
||||||
todos++;
|
todos++;
|
||||||
@ -249,7 +249,7 @@ todo_delete (conf_t *conf)
|
|||||||
if (conf->confirm_delete)
|
if (conf->confirm_delete)
|
||||||
{
|
{
|
||||||
status_mesg (del_todo_str, choices);
|
status_mesg (del_todo_str, choices);
|
||||||
answer = keys_getch (win[STA].p);
|
answer = wgetch (win[STA].p);
|
||||||
if ((answer == 'y') && (todos > 0))
|
if ((answer == 'y') && (todos > 0))
|
||||||
{
|
{
|
||||||
go_for_todo_del = true;
|
go_for_todo_del = true;
|
||||||
@ -277,7 +277,7 @@ todo_delete (conf_t *conf)
|
|||||||
while (answer != 't' && answer != 'n' && answer != KEY_GENERIC_ESCAPE)
|
while (answer != 't' && answer != 'n' && answer != KEY_GENERIC_ESCAPE)
|
||||||
{
|
{
|
||||||
status_mesg (erase_warning, erase_choice);
|
status_mesg (erase_warning, erase_choice);
|
||||||
answer = keys_getch (win[STA].p);
|
answer = wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (answer)
|
switch (answer)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: utils.c,v 1.54 2008/11/23 20:38:56 culot Exp $ */
|
/* $calcurse: utils.c,v 1.55 2008/12/07 09:20:38 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -86,7 +86,7 @@ ierror (const char *errmsg, ierror_sev_e sev)
|
|||||||
exitmsg);
|
exitmsg);
|
||||||
custom_remove_attr (errwin, ATTR_HIGHEST);
|
custom_remove_attr (errwin, ATTR_HIGHEST);
|
||||||
wrefresh (errwin);
|
wrefresh (errwin);
|
||||||
keys_getch (errwin);
|
(void)wgetch (errwin);
|
||||||
if (sev == IERROR_FATAL)
|
if (sev == IERROR_FATAL)
|
||||||
exit_calcurse (EXIT_FAILURE);
|
exit_calcurse (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ warnbox (const char *msg)
|
|||||||
warnwin = popup (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2,
|
warnwin = popup (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2,
|
||||||
"/!\\", displmsg, 1);
|
"/!\\", displmsg, 1);
|
||||||
wrefresh (warnwin);
|
wrefresh (warnwin);
|
||||||
keys_getch (warnwin);
|
(void)wgetch (warnwin);
|
||||||
delwin (warnwin);
|
delwin (warnwin);
|
||||||
doupdate ();
|
doupdate ();
|
||||||
}
|
}
|
||||||
@ -758,7 +758,7 @@ item_in_popup (char *saved_a_start, char *saved_a_end, char *msg,
|
|||||||
wmove (win[STA].p, 0, 0);
|
wmove (win[STA].p, 0, 0);
|
||||||
pnoutrefresh (pad, 0, 0, margin_top + 2, margin_left, padl, winw);
|
pnoutrefresh (pad, 0, 0, margin_top + 2, margin_left, padl, winw);
|
||||||
doupdate ();
|
doupdate ();
|
||||||
keys_getch (popup_win);
|
(void)wgetch (popup_win);
|
||||||
delwin (pad);
|
delwin (pad);
|
||||||
delwin (popup_win);
|
delwin (popup_win);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user