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);
|
const char *keys_get_label(enum key);
|
||||||
enum key keys_get_action(int);
|
enum key keys_get_action(int);
|
||||||
int keys_wgetch(WINDOW *);
|
int keys_wgetch(WINDOW *);
|
||||||
|
void keys_wait_for_any_key(WINDOW *);
|
||||||
enum key keys_get(WINDOW *, int *, int *);
|
enum key keys_get(WINDOW *, int *, int *);
|
||||||
int keys_assign_binding(int, enum key);
|
int keys_assign_binding(int, enum key);
|
||||||
void keys_remove_binding(int, enum key);
|
void keys_remove_binding(int, enum key);
|
||||||
|
@ -1102,7 +1102,7 @@ void custom_config_main(void)
|
|||||||
colorize = 0;
|
colorize = 0;
|
||||||
wins_erase_status_bar();
|
wins_erase_status_bar();
|
||||||
mvwaddstr(win[STA].p, 0, 0, no_color_support);
|
mvwaddstr(win[STA].p, 0, 0, no_color_support);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'L':
|
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");
|
stream = fopen(stream_name, "w");
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
status_mesg(wrong_name, press_enter);
|
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 &&
|
if (ui_mode == UI_CURSES && display == IO_SAVE_DISPLAY_BAR &&
|
||||||
show_dialogs()) {
|
show_dialogs()) {
|
||||||
status_mesg(save_success, enter);
|
status_mesg(save_success, enter);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&io_save_mutex);
|
pthread_mutex_unlock(&io_save_mutex);
|
||||||
@ -873,7 +873,7 @@ void io_reload_data(void)
|
|||||||
|
|
||||||
if (show_dialogs()) {
|
if (show_dialogs()) {
|
||||||
status_mesg(reload_success, enter);
|
status_mesg(reload_success, enter);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notify_bar())
|
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."),
|
status_mesg(_("Data files found. Data will be loaded now."),
|
||||||
enter);
|
enter);
|
||||||
|
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Export calcurse data. */
|
/* 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) {
|
if (show_dialogs() && ui_mode == UI_CURSES) {
|
||||||
status_mesg(success, enter);
|
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");
|
stream = fopen(stream_name, "r");
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
status_mesg(wrong_file, press_enter);
|
status_mesg(wrong_file, press_enter);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mem_free(stream_name);
|
mem_free(stream_name);
|
||||||
@ -1305,7 +1305,7 @@ void io_import_data(enum import_type type, const char *stream_name,
|
|||||||
status_mesg(read, stat);
|
status_mesg(read, stat);
|
||||||
mem_free(read);
|
mem_free(read);
|
||||||
mem_free(stat);
|
mem_free(stat);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
} else if (ui_mode == UI_CMDLINE && show_dialogs()) {
|
} else if (ui_mode == UI_CMDLINE && show_dialogs()) {
|
||||||
printf(proc_report, stats.lines);
|
printf(proc_report, stats.lines);
|
||||||
printf("\n%s / %s / %s / %s\n", stats_str[0], stats_str[1],
|
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)
|
enum key keys_get(WINDOW *win, int *count, int *reg)
|
||||||
{
|
{
|
||||||
int ch = '0';
|
int ch = '0';
|
||||||
|
@ -658,7 +658,7 @@ void ui_calendar_change_day(int datefmt)
|
|||||||
}
|
}
|
||||||
if (wrong_day) {
|
if (wrong_day) {
|
||||||
status_mesg(mesg_line1, mesg_line2);
|
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))
|
if (parse_datetime(input, &ts))
|
||||||
return ts;
|
return ts;
|
||||||
status_mesg(fmt_msg, enter_str);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
status_mesg(fmt_msg, enter_str);
|
status_mesg(fmt_msg, enter_str);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_free(timestr);
|
mem_free(timestr);
|
||||||
@ -152,7 +152,7 @@ static void update_start_time(long *start, long *dur, int update_dur)
|
|||||||
valid_date = 1;
|
valid_date = 1;
|
||||||
} else {
|
} else {
|
||||||
status_mesg(msg_wrong_time, msg_enter);
|
status_mesg(msg_wrong_time, msg_enter);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
valid_date = 0;
|
valid_date = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,7 +250,7 @@ static void update_rept(struct rpt **rpt, const long start)
|
|||||||
newfreq = atoi(freqstr);
|
newfreq = atoi(freqstr);
|
||||||
if (newfreq == 0) {
|
if (newfreq == 0) {
|
||||||
status_mesg(msg_wrong_freq, msg_enter);
|
status_mesg(msg_wrong_freq, msg_enter);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (newfreq == 0);
|
while (newfreq == 0);
|
||||||
@ -284,7 +284,7 @@ static void update_rept(struct rpt **rpt, const long start)
|
|||||||
DATEFMT_DESC(conf.input_datefmt));
|
DATEFMT_DESC(conf.input_datefmt));
|
||||||
status_mesg(msg_wrong_date, outstr);
|
status_mesg(msg_wrong_date, outstr);
|
||||||
mem_free(outstr);
|
mem_free(outstr);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
t = start;
|
t = start;
|
||||||
@ -301,7 +301,7 @@ static void update_rept(struct rpt **rpt, const long start)
|
|||||||
DATEFMT_DESC(conf.input_datefmt));
|
DATEFMT_DESC(conf.input_datefmt));
|
||||||
status_mesg(msg_wrong_date, outstr);
|
status_mesg(msg_wrong_date, outstr);
|
||||||
mem_free(outstr);
|
mem_free(outstr);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
t = start;
|
t = start;
|
||||||
@ -314,7 +314,7 @@ static void update_rept(struct rpt **rpt, const long start)
|
|||||||
if (newuntil >= start)
|
if (newuntil >= start)
|
||||||
break;
|
break;
|
||||||
status_mesg(msg_wrong_time, msg_enter);
|
status_mesg(msg_wrong_time, msg_enter);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*rpt)->type = recur_char2def(newtype);
|
(*rpt)->type = recur_char2def(newtype);
|
||||||
@ -542,7 +542,7 @@ void ui_day_item_add(void)
|
|||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
status_mesg(format_message_1, enter_str);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
status_mesg(format_message_2, enter_str);
|
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);
|
p = day_get_item(item_nb);
|
||||||
if (p->type != APPT && p->type != EVNT) {
|
if (p->type != APPT && p->type != EVNT) {
|
||||||
status_mesg(wrong_type_1, wrong_type_2);
|
status_mesg(wrong_type_1, wrong_type_2);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -757,7 +757,7 @@ void ui_day_item_repeat(void)
|
|||||||
freq = atoi(user_input);
|
freq = atoi(user_input);
|
||||||
if (freq == 0) {
|
if (freq == 0) {
|
||||||
status_mesg(mesg_wrong_freq, wrong_type_2);
|
status_mesg(mesg_wrong_freq, wrong_type_2);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
}
|
}
|
||||||
user_input[0] = '\0';
|
user_input[0] = '\0';
|
||||||
}
|
}
|
||||||
@ -780,7 +780,7 @@ void ui_day_item_repeat(void)
|
|||||||
DATEFMT_DESC(conf.input_datefmt));
|
DATEFMT_DESC(conf.input_datefmt));
|
||||||
status_mesg(mesg_wrong_1, outstr);
|
status_mesg(mesg_wrong_1, outstr);
|
||||||
mem_free(outstr);
|
mem_free(outstr);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
t = p->start;
|
t = p->start;
|
||||||
@ -802,7 +802,7 @@ void ui_day_item_repeat(void)
|
|||||||
DATEFMT_DESC(conf.input_datefmt));
|
DATEFMT_DESC(conf.input_datefmt));
|
||||||
status_mesg(mesg_wrong_1, outstr);
|
status_mesg(mesg_wrong_1, outstr);
|
||||||
mem_free(outstr);
|
mem_free(outstr);
|
||||||
wgetch(win[KEY].p);
|
keys_wait_for_any_key(win[KEY].p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,7 +810,7 @@ void ui_day_item_repeat(void)
|
|||||||
if (until >= p->start)
|
if (until >= p->start)
|
||||||
break;
|
break;
|
||||||
status_mesg(mesg_older, wrong_type_2);
|
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();
|
date = ui_calendar_get_slctd_day_sec();
|
||||||
|
@ -145,7 +145,7 @@ void fatalbox(const char *errmsg)
|
|||||||
mvwaddstr(errwin, 5, (WINCOL - strlen(msg)) / 2, msg);
|
mvwaddstr(errwin, 5, (WINCOL - strlen(msg)) / 2, msg);
|
||||||
custom_remove_attr(errwin, ATTR_HIGHEST);
|
custom_remove_attr(errwin, ATTR_HIGHEST);
|
||||||
wins_wrefresh(errwin);
|
wins_wrefresh(errwin);
|
||||||
wgetch(errwin);
|
keys_wait_for_any_key(errwin);
|
||||||
delwin(errwin);
|
delwin(errwin);
|
||||||
wins_doupdate();
|
wins_doupdate();
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ void warnbox(const char *msg)
|
|||||||
mvwaddstr(warnwin, 5, (WINCOL - strlen(displmsg)) / 2, displmsg);
|
mvwaddstr(warnwin, 5, (WINCOL - strlen(displmsg)) / 2, displmsg);
|
||||||
custom_remove_attr(warnwin, ATTR_HIGHEST);
|
custom_remove_attr(warnwin, ATTR_HIGHEST);
|
||||||
wins_wrefresh(warnwin);
|
wins_wrefresh(warnwin);
|
||||||
wgetch(warnwin);
|
keys_wait_for_any_key(warnwin);
|
||||||
delwin(warnwin);
|
delwin(warnwin);
|
||||||
wins_doupdate();
|
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);
|
wmove(win[STA].p, 0, 0);
|
||||||
pnoutrefresh(pad, 0, 0, margin_top + 2, margin_left, padl, winw);
|
pnoutrefresh(pad, 0, 0, margin_top + 2, margin_left, padl, winw);
|
||||||
wins_doupdate();
|
wins_doupdate();
|
||||||
wgetch(popup_win);
|
keys_wait_for_any_key(popup_win);
|
||||||
delwin(pad);
|
delwin(pad);
|
||||||
delwin(popup_win);
|
delwin(popup_win);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user