aboutsummaryrefslogtreecommitdiffstats
path: root/src/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/io.c')
-rw-r--r--src/io.c80
1 files changed, 40 insertions, 40 deletions
diff --git a/src/io.c b/src/io.c
index de46cce..d59aeac 100644
--- a/src/io.c
+++ b/src/io.c
@@ -136,7 +136,6 @@ static char *ical_recur_type[RECUR_TYPES] =
static void
progress_bar (progress_bar_t type, int progress)
{
-#define SLEEPTIME 125000
#define NBFILES 4
#define NBEXPORTED 3
#define LABELENGTH 15
@@ -194,8 +193,6 @@ progress_bar (progress_bar_t type, int progress)
custom_remove_attr (win[STA].p, ATTR_HIGHEST);
wmove (win[STA].p, 0, 0);
wins_wrefresh (win[STA].p);
- (void)usleep (SLEEPTIME);
-#undef SLEEPTIME
#undef NBFILES
#undef NBEXPORTED
#undef LABELENGTH
@@ -809,9 +806,10 @@ io_extract_data (char *dst_data, const char *org, int len)
{
int i;
+ for (; *org == ' ' || *org == '\t'; org++);
for (i = 0; i < len - 1; i++)
{
- if (*org == '\n' || *org == '\0')
+ if (*org == '\n' || *org == '\0' || *org == '#')
break;
*dst_data++ = *org++;
}
@@ -849,8 +847,9 @@ io_save_conf (struct conf *conf)
"# options are usually set from within Calcurse. A line beginning with \n"
"# a space or tab is considered to be a continuation of the previous "
"line.\n"
- "# For a variable to be unset its value must be blank.\n"
- "# To set a variable to the empty string its value should be \"\".\n"
+ "# For a variable to be unset its value must be blank, followed by an\n"
+ "# empty line. To set a variable to the empty string its value should be "
+ "\"\".\n"
"# Lines beginning with \"#\" are comments, and ignored by Calcurse.\n";
char theme_name[BUFSIZ];
FILE *fp;
@@ -864,56 +863,56 @@ io_save_conf (struct conf *conf)
(void)fprintf (fp, "# If this option is set to yes, "
"automatic save is done when quitting\n");
- (void)fprintf (fp, "auto_save=\n");
+ (void)fprintf (fp, "auto_save=");
(void)fprintf (fp, "%s\n", (conf->auto_save) ? "yes" : "no");
(void)fprintf (fp, "\n# If not null, perform automatic saves every "
"'periodic_save' minutes\n");
- (void)fprintf (fp, "periodic_save=\n");
+ (void)fprintf (fp, "periodic_save=");
(void)fprintf (fp, "%d\n", conf->periodic_save);
(void)fprintf (fp, "\n# If this option is set to yes, "
"confirmation is required before quitting\n");
- (void)fprintf (fp, "confirm_quit=\n");
+ (void)fprintf (fp, "confirm_quit=");
(void)fprintf (fp, "%s\n", (conf->confirm_quit) ? "yes" : "no");
(void)fprintf (fp, "\n# If this option is set to yes, "
"confirmation is required before deleting an event\n");
- (void)fprintf (fp, "confirm_delete=\n");
+ (void)fprintf (fp, "confirm_delete=");
(void)fprintf (fp, "%s\n", (conf->confirm_delete) ? "yes" : "no");
(void)fprintf (fp, "\n# If this option is set to yes, "
"messages about loaded and saved data will not be displayed\n");
- (void)fprintf (fp, "skip_system_dialogs=\n");
+ (void)fprintf (fp, "skip_system_dialogs=");
(void)fprintf (fp, "%s\n", (conf->skip_system_dialogs) ? "yes" : "no");
(void)fprintf (fp,
"\n# If this option is set to yes, progress bar appearing "
"when saving data will not be displayed\n");
- (void)fprintf (fp, "skip_progress_bar=\n");
+ (void)fprintf (fp, "skip_progress_bar=");
(void)fprintf (fp, "%s\n", (conf->skip_progress_bar) ? "yes" : "no");
(void)fprintf (fp, "\n# Default calendar view (0)monthly (1)weekly:\n");
- (void)fprintf (fp, "calendar_default_view=\n");
+ (void)fprintf (fp, "calendar_default_view=");
(void)fprintf (fp, "%d\n", calendar_get_view ());
(void)fprintf (fp, "\n# If this option is set to yes, "
"monday is the first day of the week, else it is sunday\n");
- (void)fprintf (fp, "week_begins_on_monday=\n");
+ (void)fprintf (fp, "week_begins_on_monday=");
(void)fprintf (fp, "%s\n",
(calendar_week_begins_on_monday ())? "yes" : "no");
(void)fprintf (fp, "\n# This is the color theme used for menus :\n");
- (void)fprintf (fp, "color-theme=\n");
+ (void)fprintf (fp, "color-theme=");
(void)fprintf (fp, "%s\n", theme_name);
(void)fprintf (fp, "\n# This is the layout of the calendar :\n");
- (void)fprintf (fp, "layout=\n");
+ (void)fprintf (fp, "layout=");
(void)fprintf (fp, "%d\n", wins_layout ());
(void)fprintf (fp, "\n# Width (in percentage, 0 being minimun width) "
"of the side bar :\n");
- (void)fprintf (fp, "side-bar_width=\n");
+ (void)fprintf (fp, "side-bar_width=");
(void)fprintf (fp, "%d\n", wins_sbar_wperc ());
if (ui_mode == UI_CURSES)
@@ -921,39 +920,39 @@ io_save_conf (struct conf *conf)
(void)fprintf (fp,
"\n# If this option is set to yes, "
"notify-bar will be displayed :\n");
- (void)fprintf (fp, "notify-bar_show=\n");
+ (void)fprintf (fp, "notify-bar_show=");
(void)fprintf (fp, "%s\n", (nbar.show) ? "yes" : "no");
(void)fprintf (fp,
"\n# Format of the date to be displayed inside notify-bar :\n");
- (void)fprintf (fp, "notify-bar_date=\n");
+ (void)fprintf (fp, "notify-bar_date=");
(void)fprintf (fp, "%s\n", nbar.datefmt);
(void)fprintf (fp,
"\n# Format of the time to be displayed inside notify-bar :\n");
- (void)fprintf (fp, "notify-bar_clock=\n");
+ (void)fprintf (fp, "notify-bar_clock=");
(void)fprintf (fp, "%s\n", nbar.timefmt);
(void)fprintf (fp,
"\n# Warn user if he has an appointment within next "
"'notify-bar_warning' seconds :\n");
- (void)fprintf (fp, "notify-bar_warning=\n");
+ (void)fprintf (fp, "notify-bar_warning=");
(void)fprintf (fp, "%d\n", nbar.cntdwn);
(void)fprintf (fp, "\n# Command used to notify user of "
"an upcoming appointment :\n");
- (void)fprintf (fp, "notify-bar_command=\n");
+ (void)fprintf (fp, "notify-bar_command=");
(void)fprintf (fp, "%s\n", nbar.cmd);
(void)fprintf (fp, "\n# Format of the date to be displayed "
"in non-interactive mode :\n");
- (void)fprintf (fp, "output_datefmt=\n");
+ (void)fprintf (fp, "output_datefmt=");
(void)fprintf (fp, "%s\n", conf->output_datefmt);
(void)fprintf (fp, "\n# Format to be used when entering a date "
"(1)mm/dd/yyyy (2)dd/mm/yyyy (3)yyyy/mm/dd) "
"(4)yyyy-mm-dd:\n");
- (void)fprintf (fp, "input_datefmt=\n");
+ (void)fprintf (fp, "input_datefmt=");
(void)fprintf (fp, "%d\n", conf->input_datefmt);
if (ui_mode == UI_CURSES)
@@ -962,12 +961,12 @@ io_save_conf (struct conf *conf)
(void)fprintf (fp, "\n# If this option is set to yes, "
"calcurse will run in background to get notifications "
"after exiting\n");
- (void)fprintf (fp, "notify-daemon_enable=\n");
+ (void)fprintf (fp, "notify-daemon_enable=");
(void)fprintf (fp, "%s\n", dmon.enable ? "yes" : "no");
(void)fprintf (fp, "\n# If this option is set to yes, "
"activity will be logged when running in background\n");
- (void)fprintf (fp, "notify-daemon_log=\n");
+ (void)fprintf (fp, "notify-daemon_log=");
(void)fprintf (fp, "%s\n", dmon.log ? "yes" : "no");
file_close (fp, __FILE_POS__);
@@ -1024,10 +1023,7 @@ io_save_todo (void)
LLIST_FOREACH (&todolist, i)
{
struct todo *todo = LLIST_TS_GET_DATA (i);
- if (todo->note)
- (void)fprintf (fp, "[%d]>%s %s\n", todo->id, todo->note, todo->mesg);
- else
- (void)fprintf (fp, "[%d] %s\n", todo->id, todo->mesg);
+ todo_write (todo, fp);
}
file_close (fp, __FILE_POS__);
@@ -2758,10 +2754,7 @@ io_import_data (enum import_type type, struct conf *conf, char *stream_name)
const struct string vevent = STRING_BUILD ("BEGIN:VEVENT");
const struct string vtodo = STRING_BUILD ("BEGIN:VTODO");
char *proc_report = _("Import process report: %04d lines read ");
- char *lines_stats =
- _("%d apps / %d events / %d todos / %d skipped ");
- char *lines_stats_interactive =
- _("%d apps / %d events / %d todos / %d skipped ([ENTER] to continue)");
+ char stats_str[4][BUFSIZ];
char buf[BUFSIZ];
FILE *stream = NULL;
struct io_file *log;
@@ -2823,23 +2816,30 @@ io_import_data (enum import_type type, struct conf *conf, char *stream_name)
if (stream != stdin)
file_close (stream, __FILE_POS__);
+ snprintf (stats_str[0], BUFSIZ,
+ ngettext ("%d app", "%d apps", stats.apoints), stats.apoints);
+ snprintf (stats_str[1], BUFSIZ,
+ ngettext ("%d event", "%d events", stats.events), stats.events);
+ snprintf (stats_str[2], BUFSIZ,
+ ngettext ("%d todo", "%d todos", stats.todos), stats.todos);
+ snprintf (stats_str[3], BUFSIZ, _("%d skipped"), stats.skipped);
+
if (ui_mode == UI_CURSES && !conf->skip_system_dialogs)
{
char read[BUFSIZ], stat[BUFSIZ];
(void)snprintf (read, BUFSIZ, proc_report, stats.lines);
- (void)snprintf (stat, BUFSIZ, lines_stats_interactive, stats.apoints,
- stats.events, stats.todos, stats.skipped);
+ (void)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);
(void)wgetch (win[STA].p);
}
else if (ui_mode == UI_CMDLINE)
{
printf (proc_report, stats.lines);
- printf ("\n");
- printf (lines_stats, stats.apoints, stats.events, stats.todos,
- stats.skipped);
- printf ("\n");
+ printf ("\n%s / %s / %s / %s\n", stats_str[0], stats_str[1],
+ stats_str[2], stats_str[3]);
}
/* User has the choice to look at the log file if some items could not be