summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/apoint.c9
-rw-r--r--src/calcurse.c14
-rw-r--r--src/calcurse.h1
-rw-r--r--src/event.c6
-rw-r--r--src/io.c5
-rw-r--r--src/recur.c2
-rw-r--r--src/todo.c3
-rw-r--r--src/utils.c13
8 files changed, 24 insertions, 29 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 98e8e5e..60a7c19 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -264,7 +264,6 @@ apoint_add (void)
void
apoint_delete (unsigned *nb_events, unsigned *nb_apoints)
{
- char *choices = "[y/n] ";
const char *del_app_str = _("Do you really want to delete this item ?");
long date;
int nb_items = *nb_apoints + *nb_events;
@@ -277,7 +276,7 @@ apoint_delete (unsigned *nb_events, unsigned *nb_apoints)
if (conf.confirm_delete)
{
- status_mesg (del_app_str, choices);
+ status_mesg_yesno (del_app_str);
if (wgetch (win[STA].p) != 'y')
{
wins_erase_status_bar ();
@@ -375,11 +374,7 @@ apoint_paste (unsigned *nb_events, unsigned *nb_apoints, int cut_item_type)
unsigned
apoint_inday (struct apoint *i, long start)
{
- if (i->start <= start + DAYINSEC && i->start + i->dur > start)
- {
- return 1;
- }
- return 0;
+ return (i->start <= start + DAYINSEC && i->start + i->dur > start);
}
void
diff --git a/src/calcurse.c b/src/calcurse.c
index d3b1d03..f681d12 100644
--- a/src/calcurse.c
+++ b/src/calcurse.c
@@ -65,11 +65,8 @@ int
main (int argc, char **argv)
{
struct day_items_nb inday;
- int non_interactive;
int no_data_file = 1;
int cut_item = 0;
- const char *quit_message = _("Do you really want to quit ?");
- char choices[] = "[y/n] ";
int count;
#if ENABLE_NLS
@@ -90,9 +87,11 @@ main (int argc, char **argv)
* Begin by parsing and handling command line arguments.
* The data path is also initialized here.
*/
- non_interactive = parse_args (argc, argv);
- if (non_interactive)
- exit_calcurse (EXIT_SUCCESS);
+ if (parse_args (argc, argv))
+ {
+ /* Non-interactive mode. */
+ exit_calcurse (EXIT_SUCCESS);
+ }
else
{
no_data_file = io_check_data_files ();
@@ -136,7 +135,6 @@ main (int argc, char **argv)
init_pair (COLR_DEFAULT, foreground, background);
init_pair (COLR_HIGH, COLOR_BLACK, COLOR_GREEN);
init_pair (COLR_CUSTOM, COLOR_RED, background);
-
}
else
{
@@ -543,7 +541,7 @@ main (int argc, char **argv)
if (conf.confirm_quit)
{
- status_mesg (_(quit_message), choices);
+ status_mesg_yesno (_("Do you really want to quit ?"));
key = wgetch (win[STA].p);
if (key == 'y')
exit_calcurse (EXIT_SUCCESS);
diff --git a/src/calcurse.h b/src/calcurse.h
index 238d8b3..b170032 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -895,6 +895,7 @@ void free_user_data (void);
void fatalbox (const char *);
void warnbox (const char *);
void status_mesg (const char *, const char *);
+void status_mesg_yesno (const char *);
void erase_window_part (WINDOW *, int, int, int, int);
WINDOW *popup (int, int, int, int, char *, char *, int);
void print_in_middle (WINDOW *, int, int, int, const char *);
diff --git a/src/event.c b/src/event.c
index fbfa1d2..c27c078 100644
--- a/src/event.c
+++ b/src/event.c
@@ -115,11 +115,7 @@ event_new (char *mesg, char *note, long day, int id)
unsigned
event_inday (struct event *i, long start)
{
- if (i->day < start + DAYINSEC && i->day >= start)
- {
- return 1;
- }
- return 0;
+ return (i->day < start + DAYINSEC && i->day >= start);
}
/* Write to file the event in user-friendly format */
diff --git a/src/io.c b/src/io.c
index d1d2f44..ded7889 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1239,13 +1239,12 @@ io_log_print (struct io_file *log, int line, const char *msg)
void
io_log_display (struct io_file *log, const char *msg, char *pager)
{
- char *choices = "[y/n] ";
int ans;
RETURN_IF (log == NULL, _("No log file to display!"));
if (ui_mode == UI_CMDLINE)
{
- printf ("\n%s %s", msg, choices);
+ printf ("\n%s [y/n] ", msg);
ans = fgetc (stdin);
if (ans == 'y')
{
@@ -1258,7 +1257,7 @@ io_log_display (struct io_file *log, const char *msg, char *pager)
}
else
{
- status_mesg (msg, choices);
+ status_mesg_yesno (msg);
do
{
ans = wgetch (win[STA].p);
diff --git a/src/recur.c b/src/recur.c
index e1be22a..bf18d55 100644
--- a/src/recur.c
+++ b/src/recur.c
@@ -611,7 +611,7 @@ diff_years (struct tm lt_start, struct tm lt_end)
static int
exc_inday (struct excp *exc, long day_start)
{
- return exc->st >= day_start && exc->st < day_start + DAYINSEC;
+ return (exc->st >= day_start && exc->st < day_start + DAYINSEC);
}
/*
diff --git a/src/todo.c b/src/todo.c
index d72b64c..7419222 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -242,7 +242,6 @@ todo_flag (void)
void
todo_delete (void)
{
- char *choices = "[y/n] ";
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. "
@@ -252,7 +251,7 @@ todo_delete (void)
if (conf.confirm_delete)
{
- status_mesg (del_todo_str, choices);
+ status_mesg_yesno (del_todo_str);
answer = wgetch (win[STA].p);
if ((answer != 'y') || (todos <= 0))
{
diff --git a/src/utils.c b/src/utils.c
index 3ee24e0..73c1eea 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -160,15 +160,22 @@ warnbox (const char *msg)
* Message texts for first line and second line are to be provided.
*/
void
-status_mesg (const char *mesg_line1, const char *mesg_line2)
+status_mesg (const char *msg1, const char *msg2)
{
wins_erase_status_bar ();
custom_apply_attr (win[STA].p, ATTR_HIGHEST);
- mvwprintw (win[STA].p, 0, 0, mesg_line1);
- mvwprintw (win[STA].p, 1, 0, mesg_line2);
+ mvwprintw (win[STA].p, 0, 0, msg1);
+ mvwprintw (win[STA].p, 1, 0, msg2);
custom_remove_attr (win[STA].p, ATTR_HIGHEST);
}
+/* Print a status message, followed by a "[y/n]" prompt. */
+void
+status_mesg_yesno (const char *msg)
+{
+ status_mesg (msg, "[y/n] ");
+}
+
/* Erase part of a window. */
void
erase_window_part (WINDOW *win, int first_col, int first_row, int last_col,