diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-12 18:29:26 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-13 17:39:44 +0100 |
commit | c58087d5914322ab8f693729605a9508d67bb676 (patch) | |
tree | 8a1c58b51ca6f05c24c99bfd73a8c41276385f9d | |
parent | 6d9129764bebb775951c2c8629a291407c25a693 (diff) | |
download | calcurse-c58087d5914322ab8f693729605a9508d67bb676.tar.gz calcurse-c58087d5914322ab8f693729605a9508d67bb676.zip |
Add command line option to suppress dialogs
Implement a -q/--quiet command line option to disable system dialogs
temporarily.
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r-- | src/args.c | 6 | ||||
-rw-r--r-- | src/calcurse.c | 2 | ||||
-rw-r--r-- | src/calcurse.h | 2 | ||||
-rw-r--r-- | src/io.c | 8 | ||||
-rw-r--r-- | src/utils.c | 5 | ||||
-rw-r--r-- | src/vars.c | 3 |
6 files changed, 20 insertions, 6 deletions
@@ -459,7 +459,7 @@ int parse_args(int argc, char **argv) int ch; regex_t reg; - static const char *optstr = "FgGhvnNax::t::d:c:r::s::S:D:i:l:Q"; + static const char *optstr = "FgGhvnNax::t::d:c:r::s::S:D:i:l:qQ"; struct option longopts[] = { {"appointment", no_argument, NULL, 'a'}, @@ -480,6 +480,7 @@ int parse_args(int argc, char **argv) {"todo", optional_argument, NULL, 't'}, {"version", no_argument, NULL, 'v'}, {"export", optional_argument, NULL, 'x'}, + {"quiet", no_argument, NULL, 'q'}, {"query", optional_argument, NULL, 'Q'}, {"filter-type", required_argument, NULL, OPT_FILTER_TYPE}, @@ -602,6 +603,9 @@ int parse_args(int argc, char **argv) optarg); } break; + case 'q': + quiet = 1; + break; case 'Q': query = 1; break; diff --git a/src/calcurse.c b/src/calcurse.c index 3b7b7ff..72c8fe3 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -610,7 +610,7 @@ int main(int argc, char **argv) * implicitly calling wrefresh() later (causing ncurses race conditions). */ wins_wrefresh(win[KEY].p); - if (conf.system_dialogs) { + if (show_dialogs()) { wins_update(FLAG_ALL); io_startup_screen(no_data_file); } diff --git a/src/calcurse.h b/src/calcurse.h index 41f7681..7693d79 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -1122,6 +1122,7 @@ int asprintf(char **, const char *, ...); int starts_with(const char *, const char *); int starts_with_ci(const char *, const char *); int hash_matches(const char *, const char *); +int show_dialogs(void); /* vars.c */ extern int col, row; @@ -1130,6 +1131,7 @@ extern unsigned colorize; extern int foreground, background; extern enum ui_mode ui_mode; extern int read_only; +extern int quiet; extern int want_reload; extern const char *datefmt_str[DATE_FORMATS]; extern int days[12]; @@ -425,7 +425,7 @@ void io_save_cal(enum save_display display) /* Print a message telling data were saved */ if (ui_mode == UI_CURSES && display == IO_SAVE_DISPLAY_BAR && - conf.system_dialogs) { + show_dialogs()) { status_mesg(save_success, enter); wgetch(win[KEY].p); } @@ -794,7 +794,7 @@ void io_reload_data(void) ui_todo_load_items(); ui_todo_sel_reset(); - if (conf.system_dialogs) { + if (show_dialogs()) { status_mesg(reload_success, enter); wgetch(win[KEY].p); } @@ -1113,7 +1113,7 @@ void io_export_data(enum export_type type) else if (type == IO_EXPORT_PCAL) pcal_export_data(stream); - if (conf.system_dialogs && ui_mode == UI_CURSES) { + if (show_dialogs() && ui_mode == UI_CURSES) { status_mesg(success, enter); wgetch(win[KEY].p); } @@ -1211,7 +1211,7 @@ void io_import_data(enum import_type type, const char *stream_name) stats.todos); asprintf(&stats_str[3], _("%d skipped"), stats.skipped); - if (ui_mode == UI_CURSES && conf.system_dialogs) { + if (ui_mode == UI_CURSES && show_dialogs()) { char *read, *stat; asprintf(&read, proc_report, stats.lines); diff --git a/src/utils.c b/src/utils.c index 528657e..deff631 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1653,3 +1653,8 @@ int hash_matches(const char *pattern, const char *hash) return (starts_with(hash, pattern) != invert); } + +int show_dialogs(void) +{ + return (!quiet) && conf.system_dialogs; +} @@ -61,6 +61,9 @@ enum ui_mode ui_mode = UI_CMDLINE; /* Don't save anything if this is set. */ int read_only = 0; +/* Hide system dialogs if set. */ +int quiet = 0; + /* Applications can trigger a reload by sending SIGUSR1. */ int want_reload = 0; |