Add a function to wait for any key press
Introduce a new function keys_wait_for_any_key() and use it instead of wgetch() whenever the return value is discarded. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
8373ecfe51
commit
53f0f1d2e3
@ -873,6 +873,7 @@ void keys_dump_defaults(char *);
|
||||
const char *keys_get_label(enum key);
|
||||
enum key keys_get_action(int);
|
||||
int keys_wgetch(WINDOW *);
|
||||
void keys_wait_for_any_key(WINDOW *);
|
||||
enum key keys_get(WINDOW *, int *, int *);
|
||||
int keys_assign_binding(int, enum key);
|
||||
void keys_remove_binding(int, enum key);
|
||||
|
@ -1102,7 +1102,7 @@ void custom_config_main(void)
|
||||
colorize = 0;
|
||||
wins_erase_status_bar();
|
||||
mvwaddstr(win[STA].p, 0, 0, no_color_support);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
|
14
src/io.c
14
src/io.c
@ -182,7 +182,7 @@ static FILE *get_export_stream(enum export_type type)
|
||||
stream = fopen(stream_name, "w");
|
||||
if (stream == NULL) {
|
||||
status_mesg(wrong_name, press_enter);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,7 +470,7 @@ void io_save_cal(enum save_display display)
|
||||
if (ui_mode == UI_CURSES && display == IO_SAVE_DISPLAY_BAR &&
|
||||
show_dialogs()) {
|
||||
status_mesg(save_success, enter);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&io_save_mutex);
|
||||
@ -873,7 +873,7 @@ void io_reload_data(void)
|
||||
|
||||
if (show_dialogs()) {
|
||||
status_mesg(reload_success, enter);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
|
||||
if (notify_bar())
|
||||
@ -1157,7 +1157,7 @@ void io_startup_screen(int no_data_file)
|
||||
status_mesg(_("Data files found. Data will be loaded now."),
|
||||
enter);
|
||||
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
|
||||
/* Export calcurse data. */
|
||||
@ -1192,7 +1192,7 @@ void io_export_data(enum export_type type, int export_uid)
|
||||
|
||||
if (show_dialogs() && ui_mode == UI_CURSES) {
|
||||
status_mesg(success, enter);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1217,7 +1217,7 @@ static FILE *get_import_stream(enum import_type type)
|
||||
stream = fopen(stream_name, "r");
|
||||
if (stream == NULL) {
|
||||
status_mesg(wrong_file, press_enter);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
}
|
||||
mem_free(stream_name);
|
||||
@ -1305,7 +1305,7 @@ void io_import_data(enum import_type type, const char *stream_name,
|
||||
status_mesg(read, stat);
|
||||
mem_free(read);
|
||||
mem_free(stat);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
} else if (ui_mode == UI_CMDLINE && show_dialogs()) {
|
||||
printf(proc_report, stats.lines);
|
||||
printf("\n%s / %s / %s / %s\n", stats_str[0], stats_str[1],
|
||||
|
@ -239,6 +239,11 @@ int keys_wgetch(WINDOW *win)
|
||||
|
||||
}
|
||||
|
||||
void keys_wait_for_any_key(WINDOW *win)
|
||||
{
|
||||
keys_wgetch(win);
|
||||
}
|
||||
|
||||
enum key keys_get(WINDOW *win, int *count, int *reg)
|
||||
{
|
||||
int ch = '0';
|
||||
|
@ -658,7 +658,7 @@ void ui_calendar_change_day(int datefmt)
|
||||
}
|
||||
if (wrong_day) {
|
||||
status_mesg(mesg_line1, mesg_line2);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
src/ui-day.c
28
src/ui-day.c
@ -76,7 +76,7 @@ static int day_edit_time(int time)
|
||||
if (parse_datetime(input, &ts))
|
||||
return ts;
|
||||
status_mesg(fmt_msg, enter_str);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ static int day_edit_duration(int start, int dur, unsigned *new_duration)
|
||||
break;
|
||||
}
|
||||
status_mesg(fmt_msg, enter_str);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
|
||||
mem_free(timestr);
|
||||
@ -152,7 +152,7 @@ static void update_start_time(long *start, long *dur, int update_dur)
|
||||
valid_date = 1;
|
||||
} else {
|
||||
status_mesg(msg_wrong_time, msg_enter);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
valid_date = 0;
|
||||
}
|
||||
}
|
||||
@ -250,7 +250,7 @@ static void update_rept(struct rpt **rpt, const long start)
|
||||
newfreq = atoi(freqstr);
|
||||
if (newfreq == 0) {
|
||||
status_mesg(msg_wrong_freq, msg_enter);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
}
|
||||
while (newfreq == 0);
|
||||
@ -284,7 +284,7 @@ static void update_rept(struct rpt **rpt, const long start)
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
status_mesg(msg_wrong_date, outstr);
|
||||
mem_free(outstr);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
continue;
|
||||
}
|
||||
t = start;
|
||||
@ -301,7 +301,7 @@ static void update_rept(struct rpt **rpt, const long start)
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
status_mesg(msg_wrong_date, outstr);
|
||||
mem_free(outstr);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
continue;
|
||||
}
|
||||
t = start;
|
||||
@ -314,7 +314,7 @@ static void update_rept(struct rpt **rpt, const long start)
|
||||
if (newuntil >= start)
|
||||
break;
|
||||
status_mesg(msg_wrong_time, msg_enter);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
|
||||
(*rpt)->type = recur_char2def(newtype);
|
||||
@ -542,7 +542,7 @@ void ui_day_item_add(void)
|
||||
if (ret)
|
||||
break;
|
||||
status_mesg(format_message_1, enter_str);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -581,7 +581,7 @@ void ui_day_item_add(void)
|
||||
break;
|
||||
}
|
||||
status_mesg(format_message_2, enter_str);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -728,7 +728,7 @@ void ui_day_item_repeat(void)
|
||||
p = day_get_item(item_nb);
|
||||
if (p->type != APPT && p->type != EVNT) {
|
||||
status_mesg(wrong_type_1, wrong_type_2);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@ -757,7 +757,7 @@ void ui_day_item_repeat(void)
|
||||
freq = atoi(user_input);
|
||||
if (freq == 0) {
|
||||
status_mesg(mesg_wrong_freq, wrong_type_2);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
user_input[0] = '\0';
|
||||
}
|
||||
@ -780,7 +780,7 @@ void ui_day_item_repeat(void)
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
status_mesg(mesg_wrong_1, outstr);
|
||||
mem_free(outstr);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
continue;
|
||||
}
|
||||
t = p->start;
|
||||
@ -802,7 +802,7 @@ void ui_day_item_repeat(void)
|
||||
DATEFMT_DESC(conf.input_datefmt));
|
||||
status_mesg(mesg_wrong_1, outstr);
|
||||
mem_free(outstr);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -810,7 +810,7 @@ void ui_day_item_repeat(void)
|
||||
if (until >= p->start)
|
||||
break;
|
||||
status_mesg(mesg_older, wrong_type_2);
|
||||
wgetch(win[KEY].p);
|
||||
keys_wait_for_any_key(win[KEY].p);
|
||||
}
|
||||
|
||||
date = ui_calendar_get_slctd_day_sec();
|
||||
|
@ -145,7 +145,7 @@ void fatalbox(const char *errmsg)
|
||||
mvwaddstr(errwin, 5, (WINCOL - strlen(msg)) / 2, msg);
|
||||
custom_remove_attr(errwin, ATTR_HIGHEST);
|
||||
wins_wrefresh(errwin);
|
||||
wgetch(errwin);
|
||||
keys_wait_for_any_key(errwin);
|
||||
delwin(errwin);
|
||||
wins_doupdate();
|
||||
}
|
||||
@ -172,7 +172,7 @@ void warnbox(const char *msg)
|
||||
mvwaddstr(warnwin, 5, (WINCOL - strlen(displmsg)) / 2, displmsg);
|
||||
custom_remove_attr(warnwin, ATTR_HIGHEST);
|
||||
wins_wrefresh(warnwin);
|
||||
wgetch(warnwin);
|
||||
keys_wait_for_any_key(warnwin);
|
||||
delwin(warnwin);
|
||||
wins_doupdate();
|
||||
}
|
||||
@ -614,7 +614,7 @@ item_in_popup(const char *a_start, const char *a_end, const char *msg,
|
||||
wmove(win[STA].p, 0, 0);
|
||||
pnoutrefresh(pad, 0, 0, margin_top + 2, margin_left, padl, winw);
|
||||
wins_doupdate();
|
||||
wgetch(popup_win);
|
||||
keys_wait_for_any_key(popup_win);
|
||||
delwin(pad);
|
||||
delwin(popup_win);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user