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>
This commit is contained in:
parent
6d9129764b
commit
c58087d591
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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];
|
||||
|
8
src/io.c
8
src/io.c
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user