C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
Error Handling

Display Error messages. More...

Functions

bool ui_action_disposition (char *title, char *action_str)
 Display a simple action disposition message window or print to stderr.
int ui_answer_yn (char *msg0, char *msg1, char *msg2, char *msg3)
 Accept a single letter answer.
int ui_display_error (char *msg0, char *msg1, char *msg2, char *msg3)
 Display an error message window or print to stderr.
int ui_perror (char *emsg_str)
 Display a simple error message window or print to stderr.
int ui_poll_reg_read_fd (int timeout_ms)
 Poll for input on registered external files.
void ui_register_read_fd (int fd, int token_id)
 Register an external file descriptor for polling.
int ui_timeout_prompt (char *msg0, char *msg1, uint timeout_ms, uint timeout_secs)
 Display a timeout prompt window or print to stderr.
void ui_unregister_read_fd (int fd)
 Unregister an external file descriptor from polling.
int ui_update_timeout_prompt (UiSurface *sfc, ss_t w, uint timeout_ms)
 Update the timeout prompt with the remaining time.

Detailed Description

Display Error messages.

Function Documentation

◆ ui_action_disposition()

bool ui_action_disposition ( char * title,
char * action_str )

Display a simple action disposition message window or print to stderr.

ui_action_disposition

Parameters
titleWindow title
action_strAction description string
Returns
true if successful

Definition at line 1311 of file ui_common.c.

1311 {
1312 uint len;
1313 uint line, col;
1314
1316 fprintf(stderr, "\n%s\n", title);
1317 fprintf(stderr, "%s\n", action_str);
1318 return true;
1319 }
1320 len = max(strlen(title), strlen(action_str));
1321 uint maxy, maxx;
1322 ui_get_screen_size(&maxy, &maxx);
1323 col = (maxx - len - 4) / 2;
1324 line = (maxy - 4) / 2;
1325 if (ui_tracked_sfc_box(2, len, line, col, title)) {
1326 ssnprintf(em0, MAXLEN - 1, _("ui_tracked_sfc_box(%d, %d, %d, %d, %s) failed"), 4,
1327 line, line, col, title);
1328 ui_perror(em0);
1329 }
1331 UiChyron *chyron = ui_new_chyron(sfc, WIN);
1332 ui_set_chyron_key(chyron, 10, _("F10 Continue"), UIKEY_F10);
1333 ui_compile_chyron(chyron);
1334 UiEvent event;
1335 ui_draw_text(sfc, WIN, 0, 1, action_str);
1336 ui_display_chyron(sfc, WIN, chyron, 1, 0);
1337 event.y = event.x = -1;
1338 cmd_key = ui_get_event(sfc, WIN, chyron, &event, -1);
1340 ui_destroy_chyron(chyron);
1341 return true;
1342}
#define max(a, b)
max macro evaluates two expressions, returning greatest result.
Definition cm.h:97
bool f_ncurses_open
Definition ui_common.c:50
int ui_draw_text(UiSurface *s, ss_t w, uint y, uint x, const char *text)
on specified window, move to y, x, add string
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
Definition ui_ncurses.c:722
int sfc_ptr
Definition ui_ncurses.c:42
char em0[MAXLEN]
Definition ui_common.c:46
bool f_notcurses_open
Definition ui_common.c:51
#define UIKEY_F10
int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev, int timeout_ms)
Read input events.
unsigned int cmd_key
Definition ui_common.c:32
void ui_set_chyron_key(UiChyron *chyron, uint k, char *s, uint kc)
Set chyron key with default color pair (cp_nt_rev).
Definition ui_common.c:717
UiChyron * ui_new_chyron(UiSurface *sfc, ss_t w)
Create new chyron structure.
Definition ui_common.c:601
int ui_cm_surface_destroy(UiSurface *sfc)
Destroy the most recently created surface.
Definition ui_common.c:466
void ui_display_chyron(UiSurface *sfc, ss_t w, UiChyron *chyron, uint line, uint col)
Display chyron on the specified line and column of the surface.
Definition ui_common.c:837
int ui_tracked_sfc_box(uint wlines, uint wcols, uint wbegy, uint wbegx, const char *wtitle)
Create a new surface with a box window.
Definition ui_common.c:387
UiChyron * ui_destroy_chyron(UiChyron *chyron)
Destroy UiChyron structure.
Definition ui_common.c:656
void ui_compile_chyron(UiChyron *chyron)
construct the chyron string from the chyron structure
Definition ui_common.c:782
UiSurface * ui_surface[UI_SFC_MAX]
Definition ui_ncurses.c:40
#define MAXLEN
Definition curskeys.c:15
#define _(String)
Definition amort.c:23
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:390
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition ui_common.c:1257

References cmd_key, em0, f_ncurses_open, f_notcurses_open, sfc_ptr, ssnprintf(), ui_cm_surface_destroy(), ui_compile_chyron(), ui_destroy_chyron(), ui_display_chyron(), ui_draw_text(), ui_get_event(), ui_get_screen_size(), ui_new_chyron(), ui_perror(), ui_set_chyron_key(), ui_surface, ui_tracked_sfc_box(), UiEvent::x, and UiEvent::y.

Here is the call graph for this function:

◆ ui_answer_yn()

int ui_answer_yn ( char * msg0,
char * msg1,
char * msg2,
char * msg3 )

Accept a single letter answer.

ui_answer_yn

Parameters
msg0First error message line
msg1Second error message line
msg2Third error message line
msg3Fourth error message line
Returns
Key code of user command

Definition at line 972 of file ui_common.c.

972 {
973 char title[MAXLEN];
974 uint line, pos, msg_l, msg0_l, msg1_l, msg2_l, msg3_l;
975
977 fprintf(stderr, _("\n\n%s\n%s\n%s\n%s\n\n"), msg0, msg1, msg2, msg3);
978 return 1;
979 }
980 uint maxy, maxx;
981 ui_get_screen_size(&maxy, &maxx);
982 msg0_l = strlen(msg0);
983 msg1_l = strlen(msg1);
984 msg2_l = strlen(msg2);
985 msg3_l = strlen(msg3);
986 msg_l = max(msg0_l, msg1_l);
987 msg_l = max(msg_l, msg2_l);
988 msg_l = max(msg_l, msg3_l);
989 msg_l = max(msg_l, 50);
990 msg_l = min(msg_l, maxx - 4);
991 pos = ((maxx - msg_l) - 4) / 2;
992 line = (maxy - 6) / 2;
993 strnz__cpy(title, _("Notification"), MAXLEN - 1);
994 if (ui_tracked_sfc_box(5, msg_l, line, pos, title)) {
995 ssnprintf(title, MAXLEN - 1, _("ui_tracked_sfc_box(%d, %d, %d, %d, %s) failed"), 5,
996 msg_l + 2, line, pos, title);
997 ui_abend(-1, title);
998 }
1000 UiChyron *chyron = ui_new_chyron(sfc, WIN);
1001 ui_set_chyron_key(chyron, 1, _("F1 Help"), UIKEY_F01);
1002 ui_set_chyron_key(chyron, 2, _("N - No"), 'n');
1003 ui_set_chyron_key(chyron, 3, _("Y - Yes"), 'y');
1004 ui_compile_chyron(chyron);
1005 UiEvent event;
1006 ui_draw_text(sfc, WIN, 0, 1, msg0);
1007 ui_draw_text(sfc, WIN, 1, 1, msg1);
1008 ui_draw_text(sfc, WIN, 2, 1, msg2);
1009 ui_draw_text(sfc, WIN, 3, 1, msg3);
1010 ui_display_chyron(sfc, WIN, chyron, 4, chyron->l + 1);
1011 do {
1012 ui_curs_set(1);
1013 event.y = event.x = -1;
1014 cmd_key = ui_get_event(sfc, WIN, chyron, &event, -1);
1015 if (cmd_key == UIKEY_F01 || cmd_key == 'N' || cmd_key == 'n' || cmd_key == 'Y' || cmd_key == 'y')
1016 break;
1017 } while (1);
1019 ui_destroy_chyron(chyron);
1020 return (cmd_key);
1021}
#define min(x, y)
min macro evaluates two expressions, returning least result
Definition cm.h:104
int ui_curs_set(int visibility)
Set the visibility of the cursor.
Definition ui_ncurses.c:840
#define UIKEY_F01
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
Definition ui_common.c:362
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition whence.c:291

References cmd_key, f_ncurses_open, f_notcurses_open, sfc_ptr, ssnprintf(), strnz__cpy(), ui_abend(), ui_cm_surface_destroy(), ui_compile_chyron(), ui_curs_set(), ui_destroy_chyron(), ui_display_chyron(), ui_draw_text(), ui_get_event(), ui_get_screen_size(), ui_new_chyron(), ui_set_chyron_key(), ui_surface, ui_tracked_sfc_box(), UiEvent::x, and UiEvent::y.

Referenced by write_view_buffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_display_error()

int ui_display_error ( char * msg0,
char * msg1,
char * msg2,
char * msg3 )

Display an error message window or print to stderr.

ui_display_error

Parameters
msg0First error message line
msg1Second error message line
msg2Third error message line
msg3Fourth error message line
Returns
Key code of user command

Definition at line 1200 of file ui_common.c.

1200 {
1201 char title[MAXLEN];
1202 uint line, pos, msg_l, msg0_l, msg1_l, msg2_l, msg3_l;
1204 fprintf(stderr, "\n\n%s\n", msg0);
1205 fprintf(stderr, "%s\n", msg1);
1206 fprintf(stderr, "%s\n", msg2);
1207 fprintf(stderr, "%s\n\n", msg3);
1208 return 1;
1209 }
1210 uint maxy, maxx;
1211 ui_get_screen_size(&maxy, &maxx);
1212 msg0_l = strlen(msg0);
1213 msg1_l = strlen(msg1);
1214 msg2_l = strlen(msg2);
1215 msg3_l = strlen(msg3);
1216 msg_l = max(msg0_l, msg1_l);
1217 msg_l = max(msg_l, msg2_l);
1218 msg_l = max(msg_l, msg3_l);
1219 msg_l = max(msg_l, 50);
1220 msg_l = min(msg_l, maxx - 4);
1221
1222 pos = ((maxx - msg_l) - 4) / 2;
1223 line = (maxy - 6) / 2;
1224 strnz__cpy(title, _("Notification"), MAXLEN - 1);
1225 if (ui_tracked_sfc_box(5, msg_l, line, pos, title)) {
1226 ssnprintf(title, MAXLEN - 1, _("ui_tracked_sfc_box(%d, %d, %d, %d, %s) failed"), 5,
1227 msg_l + 2, line, pos, title);
1228 ui_abend(-1, title);
1229 }
1231 UiChyron *chyron = ui_new_chyron(sfc, WIN);
1232 ui_set_chyron_key(chyron, 1, _("F1 Help"), UIKEY_F01);
1233 ui_set_chyron_key(chyron, 9, _("F9 Cancel"), UIKEY_F09);
1234 ui_set_chyron_key(chyron, 10, _("F10 Continue"), UIKEY_F10);
1235 ui_compile_chyron(chyron);
1236 UiEvent event;
1237 ui_draw_text(sfc, WIN, 0, 1, msg0);
1238 ui_draw_text(sfc, WIN, 1, 1, msg1);
1239 ui_draw_text(sfc, WIN, 2, 1, msg2);
1240 ui_draw_text(sfc, WIN, 3, 1, msg3);
1241 ui_display_chyron(sfc, WIN, chyron, 4, chyron->l + 1);
1242 do {
1243 event.y = event.x = -1;
1244 cmd_key = ui_get_event(sfc, WIN, chyron, &event, -1);
1245 if (cmd_key == UIKEY_F09 || cmd_key == UIKEY_F10 || cmd_key == 'q' || cmd_key == 'Q')
1246 break;
1247 } while (1);
1249 ui_destroy_chyron(chyron);
1250 return (cmd_key);
1251}
#define UIKEY_F09

References cmd_key, f_ncurses_open, f_notcurses_open, sfc_ptr, ssnprintf(), strnz__cpy(), ui_abend(), ui_cm_surface_destroy(), ui_compile_chyron(), ui_destroy_chyron(), ui_display_chyron(), ui_draw_text(), ui_get_event(), ui_get_screen_size(), ui_new_chyron(), ui_set_chyron_key(), ui_surface, ui_tracked_sfc_box(), UiEvent::x, and UiEvent::y.

Referenced by enter_file_spec(), form_desc_error(), form_parse_desc(), form_process(), form_read_data(), form_write(), mk_dir(), new_init(), new_pick(), new_view(), parse_menu_description(), ui_add_pair(), ui_get_event(), ui_surface_box(), ui_surface_new(), verify_dir(), verify_file(), view_cmd_processor(), view_init_input(), and write_view_buffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_perror()

int ui_perror ( char * emsg_str)

Display a simple error message window or print to stderr.

ui_perror

Parameters
emsg_strError message string
Returns
Key code of user command

Definition at line 1257 of file ui_common.c.

1257 {
1258 char emsg[MAXLEN];
1259 unsigned in_key;
1260 uint line, pos, cols;
1261 char title[MAXLEN];
1262 char tmp_str[MAXLEN];
1263 bool f_xwgetch = true;
1264 if (emsg_str[0] == '␛' && emsg_str[1] == 'w') {
1265 emsg_str += 2;
1266 f_xwgetch = false;
1267 }
1268 strnz__cpy(emsg, emsg_str, 79);
1270 fprintf(stderr, "\n%s\n", emsg);
1271 return 1;
1272 }
1273 uint maxy, maxx;
1274 ui_get_screen_size(&maxy, &maxx);
1275 cols = strnz(emsg, maxx - 4);
1276 cols = max(cols, 50);
1277 pos = (maxx - cols - 4) / 2;
1278 line = (maxy - 4) / 2;
1279 strnz__cpy(title, _("Notification"), MAXLEN - 1);
1280 if (ui_tracked_sfc_box(2, cols, line, pos, title)) {
1281 ssnprintf(tmp_str, MAXLEN - 1, _("ui_tracked_sfc_box(%d, %d, %d, %d, %s, %b) failed"),
1282 4, line, line, pos, title);
1283 ui_log(ERROR, "%s", tmp_str);
1284 exit(EXIT_FAILURE);
1285 }
1287 UiChyron *chyron = ui_new_chyron(sfc, WIN);
1288 ui_set_chyron_key(chyron, 1, _("F1 Help"), UIKEY_F01);
1289 ui_set_chyron_key(chyron, 9, _("F9 Cancel"), UIKEY_F09);
1290 ui_set_chyron_key(chyron, 10, _("F10 Continue"), UIKEY_F10);
1291 ui_compile_chyron(chyron);
1292 UiEvent event;
1293 ui_draw_text(sfc, WIN, 0, 1, emsg_str);
1294 ui_display_chyron(sfc, WIN, chyron, 1, chyron->l + 1);
1295 if (f_xwgetch) {
1296 event.y = event.x = -1;
1297 in_key = ui_get_event(sfc, WIN, chyron, &event, -1);
1298 } else {
1299 in_key = UIKEY_F10;
1300 }
1301 ui_destroy_chyron(chyron);
1303 return (in_key);
1304}
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
Definition futil.c:599

References f_ncurses_open, f_notcurses_open, sfc_ptr, ssnprintf(), strnz(), strnz__cpy(), ui_cm_surface_destroy(), ui_compile_chyron(), ui_destroy_chyron(), ui_display_chyron(), ui_draw_text(), ui_get_event(), ui_get_screen_size(), ui_new_chyron(), ui_set_chyron_key(), ui_surface, ui_tracked_sfc_box(), UiEvent::x, and UiEvent::y.

Referenced by display_form(), exec_objects(), field_editor(), fork_exec(), form_engine(), form_exec_receiver(), form_fmt_field(), form_process(), form_validate_field(), go_to_line(), go_to_mark(), go_to_percent(), increment_ln(), init_form(), init_pick(), initialize_line_table(), mapp_initialization(), menu_engine(), new_pick(), open_pick_win(), pad_refresh(), parse_menu_description(), popup_ckeys(), search(), ui_action_disposition(), view_cmd_processor(), view_init_input(), and write_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_poll_reg_read_fd()

int ui_poll_reg_read_fd ( int timeout_ms)

Poll for input on registered external files.

ui_poll_reg_read_fd

Parameters
timeout_msTimeout in milliseconds
Returns
Token ID of the external file that has input, or 0 if no input

This function polls for input on registered external files. It uses the poll() system call to wait for input on the file descriptors of the registered external files. If input is available, it returns the token ID of the external file that has input. If no input is available within the specified timeout, it returns 0. If an error occurs during polling, it returns -1.

Definition at line 1155 of file ui_common.c.

1155 {
1156 if (timeout_ms <= 0)
1157 return 0;
1158 // ------------------------------------------------------------
1159 // Poll for input on registered external files
1160 // ------------------------------------------------------------
1161 int token_id = 0;
1162 int reg_idx;
1163 nfds_t nfds = 0;
1164 nfds_t ext_start_idx = ui_ctx.ext_nfds;
1165 struct pollfd fds[1 + MAX_EXT_FDS];
1166 memset(fds, 0, sizeof(fds));
1167 for (nfds_t i = 0; i < ui_ctx.ext_nfds; i++) {
1168 fds[nfds].fd = ui_ctx.ext_fds[i].fd;
1169 fds[nfds].events = POLLIN; // also POLLERR | POLLHUP | POLLNVAL
1170 nfds++;
1171 }
1172 int poll_rc = poll(fds, nfds, timeout_ms);
1173 if (poll_rc < 0) {
1174 if (errno == EINTR)
1175 return 0;
1176 return -1;
1177 }
1178 if (poll_rc == 0)
1179 return 0;
1180 for (nfds_t i = ext_start_idx; i < nfds; i++) {
1181 if (fds[i].revents & (POLLIN | POLLHUP | POLLERR)) {
1182 reg_idx = i - ext_start_idx;
1183 token_id = ui_ctx.ext_fds[reg_idx].token_id;
1184 return token_id;
1185 }
1186 }
1187 return 0;
1188}
#define MAX_EXT_FDS
Definition ui_backend.h:131
ui_context_t ui_ctx
Definition ui_common.c:59

References ui_context_t::ext_fds, ui_context_t::ext_nfds, ext_fd_reg_t::fd, ext_fd_reg_t::token_id, and ui_ctx.

Referenced by view_init_input().

Here is the caller graph for this function:

◆ ui_register_read_fd()

void ui_register_read_fd ( int fd,
int token_id )

Register an external file descriptor for polling.

ui_register_read_fd

Parameters
fdFile descriptor to register
token_idToken ID associated with the file descriptor

This function registers an external file descriptor for polling. It adds the file descriptor and its associated token ID to the list of registered external file descriptors. If the maximum number of registered file descriptors is reached, it does not register the new file descriptor.

Definition at line 1117 of file ui_common.c.

1117 {
1118 char tmp_str[MAXLEN];
1119 if (ui_ctx.ext_nfds < MAX_EXT_FDS) {
1120 ui_ctx.ext_fds[ui_ctx.ext_nfds] = (ext_fd_reg_t){fd, token_id};
1121 ui_ctx.ext_nfds++;
1122 ssnprintf(tmp_str, MAXLEN - 1, "ui_ctx.ext_nfds = %ld", ui_ctx.ext_nfds);
1123 }
1124}

References ui_context_t::ext_fds, ui_context_t::ext_nfds, ssnprintf(), and ui_ctx.

Referenced by view_init_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_timeout_prompt()

int ui_timeout_prompt ( char * msg0,
char * msg1,
uint timeout_ms,
uint timeout_secs )

Display a timeout prompt window or print to stderr.

ui_timeout_prompt

Parameters
msg0First message line
msg1Second message line
timeout_msTimeout in milliseconds
timeout_secsTimeout in seconds to add if F10 is pressed
Returns
Key code of user command

Definition at line 1033 of file ui_common.c.

1033 {
1034 char title[MAXLEN];
1035 uint line, pos, msg_l, msg0_l, msg1_l;
1037 fprintf(stderr, "\n\n%s\n", msg0);
1038 fprintf(stderr, "%s\n", msg1);
1039 return 1;
1040 }
1041 uint maxy, maxx;
1042 ui_get_screen_size(&maxy, &maxx);
1043 msg0_l = strlen(msg0);
1044 msg1_l = strlen(msg1);
1045 msg_l = max(msg0_l, msg1_l);
1046 msg_l = max(msg_l, 50);
1047 msg_l = min(msg_l, maxx - 4);
1048
1049 pos = ((maxx - msg_l) - 4) / 2;
1050 line = (maxy - 6) / 2;
1051 strnz__cpy(title, _("Notification"), MAXLEN - 1);
1052 if (ui_tracked_sfc_box(5, msg_l, line, pos, title)) {
1053 ssnprintf(title, MAXLEN - 1, _("ui_tracked_sfc_box(%d, %d, %d, %d, %s) failed"), 5,
1054 msg_l + 2, line, pos, title);
1055 ui_abend(-1, title);
1056 }
1058 UiChyron *chyron = ui_new_chyron(sfc, WIN);
1059 ui_set_chyron_key(chyron, 1, _("F1 Help"), UIKEY_F01);
1060 ui_set_chyron_key(chyron, 9, _("F9 Cancel"), UIKEY_F09);
1061 ui_set_chyron_key(chyron, 10, _("F10 Continue"), UIKEY_F10);
1062 ui_compile_chyron(chyron);
1063 UiEvent event;
1064 ui_draw_text(sfc, WIN, 0, 1, msg0);
1065 ui_draw_text(sfc, WIN, 1, 1, msg1);
1066 ssnprintf(em3, MAXLEN - 1, _("Timeout in %d seconds"), timeout_ms / 1000);
1067 ui_draw_text(sfc, WIN, 3, 1, em3);
1068 ui_display_chyron(sfc, WIN, chyron, 4, chyron->l + 1);
1069 do {
1070 event.y = event.x = -1;
1071 cmd_key = ui_get_event(sfc, WIN, chyron, &event, 1000);
1072 if (cmd_key == UIKEY_F09 || cmd_key == 'q' || cmd_key == 'Q' || cmd_key == UIKEY_STREAM_DATA)
1073 break;
1074 if (cmd_key == UIKEY_F10)
1075 timeout_ms += timeout_secs * 1000;
1076 else
1077 timeout_ms -= 1000;
1078 ui_update_timeout_prompt(sfc, WIN, timeout_ms);
1079 } while (timeout_ms > 0);
1081 ui_destroy_chyron(chyron);
1082 ui_render();
1083 return cmd_key;
1084}
void ui_render()
Render the UI by updating panels and refreshing the display.
Definition ui_ncurses.c:884
char em3[MAXLEN]
Definition ui_common.c:49
#define UIKEY_STREAM_DATA
int ui_update_timeout_prompt(UiSurface *sfc, ss_t w, uint timeout_ms)
Update the timeout prompt with the remaining time.
Definition ui_common.c:1096

References cmd_key, em3, f_ncurses_open, f_notcurses_open, sfc_ptr, ssnprintf(), strnz__cpy(), ui_abend(), ui_cm_surface_destroy(), ui_compile_chyron(), ui_destroy_chyron(), ui_display_chyron(), ui_draw_text(), ui_get_event(), ui_get_screen_size(), ui_new_chyron(), ui_render(), ui_set_chyron_key(), ui_surface, ui_tracked_sfc_box(), ui_update_timeout_prompt(), UiEvent::x, and UiEvent::y.

Referenced by view_init_input().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_unregister_read_fd()

void ui_unregister_read_fd ( int fd)

Unregister an external file descriptor from polling.

ui_unregister_read_fd

Parameters
fdFile descriptor to unregister

This function unregisters an external file descriptor from polling. It removes the file descriptor and its associated token ID from the list of registered external file descriptors. If the file descriptor is not found in the list, it does nothing.

Definition at line 1134 of file ui_common.c.

1134 {
1135 for (nfds_t i = 0; i < ui_ctx.ext_nfds; i++) {
1136 if (ui_ctx.ext_fds[i].fd == fd) {
1137 ui_ctx.ext_fds[i] = ui_ctx.ext_fds[ui_ctx.ext_nfds - 1];
1138 ui_ctx.ext_nfds--;
1139 break;
1140 }
1141 }
1142}

References ui_context_t::ext_fds, ui_context_t::ext_nfds, ext_fd_reg_t::fd, and ui_ctx.

Referenced by view_init_input().

Here is the caller graph for this function:

◆ ui_update_timeout_prompt()

int ui_update_timeout_prompt ( UiSurface * sfc,
ss_t w,
uint timeout_ms )

Update the timeout prompt with the remaining time.

ui_update_timeout_prompt

Parameters
sfcPointer to the UiSurface structure
wWindow index (WIN or BOX)
timeout_msRemaining timeout in milliseconds
Returns
0 on success, 1 if not in a curses environment

This function updates the timeout prompt displayed on the specified surface and window with the remaining time in seconds. If not in a curses environment, it prints the timeout message to stderr.

Definition at line 1096 of file ui_common.c.

1096 {
1098 fprintf(stderr, _("Timeout in %d seconds\n"), timeout_ms / 1000);
1099 return 1;
1100 }
1101 ssnprintf(em3, MAXLEN - 1, _("%d seconds"), timeout_ms / 1000);
1102 ui_draw_text(sfc, w, 3, 12, em3);
1103 ui_wclrtoeol(sfc, w);
1104 ui_render();
1105 return 0;
1106}
int ui_wclrtoeol(UiSurface *s, ss_t w)
Clear to the end of the line in a surface window.

References em3, f_ncurses_open, f_notcurses_open, ssnprintf(), ui_draw_text(), ui_render(), and ui_wclrtoeol().

Referenced by ui_timeout_prompt().

Here is the call graph for this function:
Here is the caller graph for this function: