C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
init_view.c
Go to the documentation of this file.
1/** @file init_view.c
2 @brief Initialize C-Menu View Screen IO and Input
3 @ingroup init_view
4 @author Bill Waller
5 Copyright (c) 2025
6 MIT License
7 billxwaller@gmail.com
8 @date 2026-02-09
9 */
10
11/**
12 @defgroup init_view Initializing View I/O
13 @brief Populate the C-Menu View Struct and Connect Input
14 */
15#include <common.h>
16#include <errno.h>
17#include <fcntl.h>
18#include <stddef.h>
19#include <stdlib.h>
20#include <string.h>
21#include <sys/mman.h>
22#include <sys/stat.h>
23#include <sys/sysmacros.h>
24#include <unistd.h>
25#include <wait.h>
26
28void view_full_screen_resize(Init *);
30void view_boxwin_resize(Init *);
31
32ViewStack view_stack;
33
34/** @brief Initialize C-Menu View in full screen mode.
35 @ingroup init_view
36 @param init Pointer to the Init structure containing view settings.
37 @return 0 on success, -1 on failure.
38 @details This function sets up the view structure for full screen mode and
39 creates a new pad for the view.
40 @verbatim
41 The function creates the following windows:
42 1. view->cmdln_win: Status or Command Line
43 2. view->lnno_win: Line Number Window
44 3. view->pad: Main Content Pad
45 @endverbatim
46 */
47int init_view_full_screen(Init *init) {
48 View *view = init->view;
49 view->f_full_screen = true;
50 // -------------------> 1. WIN <-------------------
52 ui_log(INFO, _("lines=%d, cols=%d"), view->lines, view->cols);
53 view->sfc = ui_surface_new(WIN, NULL, 0, view->lines, view->cols, 0, 0);
54 if (!view->sfc) {
55 ssnprintf(em0, MAXLEN - 1, _("newwin(LINES, COLS, 0, 0) failed in init_view_full_screen"));
56 ui_log(INFO, "%s", em0);
57 exit(EXIT_FAILURE);
58 return -1;
59 }
60 ui_log(INFO, _("created view->sfc"));
62 // -------------------> 2. LNNO <-------------------
63 if (view->f_ln) {
65 if (view->sfc->lnno == nullptr) {
66 ssnprintf(em0, MAXLEN - 1, _("ui_sfc_addwin(LNNO, LINES - 1, COLS, 0, 0) failed in init_view_full_screen"));
67 ui_log(INFO, "%s", em0);
68 exit(EXIT_FAILURE);
69 }
70 ui_log(INFO, _("created view->sfc->lnno"));
71 ui_bkgd(view->sfc, LNNO, &cell_ln);
73 ui_scrollok(view->sfc, LNNO, true);
75 }
76 // -------------------> 3. CMDLN <-------------------
78 if (view->sfc->cmdln == nullptr) {
79 ssnprintf(em0, MAXLEN - 1, _("ui_sfc_addwin(CMDLN, 1, COLS, LINES - 1, 0) failed in init_view_full_screen"));
80 ui_log(INFO, "%s", em0);
81 exit(EXIT_FAILURE);
82 }
83 ui_log(INFO, _("created view->sfc->cmdln"));
84 ui_bkgd(view->sfc, CMDLN, &cell_nt);
85 ui_keypad(view->sfc, CMDLN, true);
86 ui_idlok(view->sfc, CMDLN, false);
87 ui_idcok(view->sfc, CMDLN, false);
88 ui_scrollok(view->sfc, CMDLN, false);
89 // -------------------> 4. PAD <-------------------
90
92 ui_log(INFO, _("created view->sfc->mplane[PAD]"));
93 if (view->sfc->pad == nullptr) {
94 ssnprintf(em0, MAXLEN - 1, _("ui_sfc_addpan(CMDLN, 1, COLS, LINES - 1, 0) failed in init_view_full_screen"));
95 ui_log(INFO, "%s", em0);
96 exit(EXIT_FAILURE);
97 }
98 ui_scrollok(view->sfc, PAD, true);
99
100 // ------------------------------------------------
101 return 0;
102}
103/** @brief Resize the full screen view and its components.
104 @ingroup window_support
105 @param init Pointer to the Init structure containing view settings.
106 @details This function resizes the full screen view and its components,
107 including the command line window, line number window, and main content pad.
108 It also recalculates the dimensions for the full screen mode and updates the
109 scroll regions accordingly.
110 */
111void view_full_screen_resize(Init *init) {
114 ui_log(INFO, _("view_full_screen_resize: lines=%d, cols=%d, ln_win_lines=%d, ln_win_cols=%d, scroll_lines=%d"), init->view->lines, init->view->cols, init->view->ln_win_lines, init->view->ln_win_cols, init->view->scroll_lines);
115 View *view = init->view;
119}
120/** @brief Calculate the dimensions for full screen mode.
121 @ingroup init_view
122 @details This function calculates the dimensions for the full screen mode of
123 the C-Menu View. It retrieves the maximum dimensions of the standard screen
124 and sets the view parameters accordingly. It also resizes the line number
125 window and command line window based on the new dimensions.
126 @param init Pointer to the Init structure containing view settings.
127 */
129 View *view = init->view;
131 view->ln_win_lines = view->lines;
132 view->ln_win_cols = 8;
133 view->scroll_lines = view->lines - 1;
134 view->h_shift = view->cols / 3;
135#ifdef DEBUG_RESIZE
136 char file[MAXLEN];
137 ssnprintf(
138 em0, MAXLEN - 1,
139 _("%s:%d view->lines=%d, view->cols=%d, view->maxrows=%d, view->maxcols=%d"),
140 __FILE__, __LINE__,
141 view->lines, view->cols, view->smaxrow, view->smaxcol);
142 write_cmenu_log(em0);
143#endif
144 view->cmd_line = 0;
145 view->pminrow = 0;
146 view->pmincol = 0;
147 view->sminrow = 0;
148 view->smincol = view->ln_win_cols;
149 view->smaxrow = view->lines - 1;
150 view->smaxcol = view->cols - 1;
152 view->page_bot_ln_no = view->ln_no;
153}
154/** @brief Initialize the C-Menu View in box window mode.
155 @ingroup init_view
156 @param init Pointer to the Init structure containing view settings.
157 @return 0 on success, -1 on failure.
158 @details sets up the view structure for box window mode, adjusts dimensions
159 based on screen size, and creates a new pad for the view. It also configures
160 various parameters such as scroll lines, command line position, and tab size.
161 */
162int init_view_boxwin(Init *init) {
163 View *view = init->view;
164 view->f_full_screen = false;
165 // -------------------> 1. BOX / WIN <-------------------
167
168 view->sfc = ui_surface_box(NULL, 0, view->lines + 2, view->cols + 2, view->begy, view->begx, NULL);
169
170 ui_surface_addwin(view->sfc, WIN, BOX, view->lines, view->cols, 1, 1);
171 // -------------------> 2. LNNO <-------------------
172 if (view->f_ln) {
173 ui_surface_addwin(view->sfc, LNNO, WIN, view->lines - 1, view->ln_win_cols, 0, 0);
174 ui_bkgd(view->sfc, LNNO, &cell_ln);
176 ui_scrollok(view->sfc, LNNO, true);
178 }
179 // -------------------> 3. CMDLN <-------------------
180 ui_surface_addwin(view->sfc, CMDLN, WIN, 1, view->cols, view->lines - 1, 0);
181 ui_bkgd(view->sfc, CMDLN, &cell_nt);
182 ui_keypad(view->sfc, CMDLN, true);
183 ui_idlok(view->sfc, CMDLN, false);
184 ui_idcok(view->sfc, CMDLN, false);
185 ui_scrollok(view->sfc, CMDLN, false);
186 // -------------------> 4. PAD <-------------------
187 ui_surface_addpad(view->sfc, PAD, WIN, view->lines - 1, PAD_COLS - 1, 0, view->ln_win_cols);
188 ui_scrollok(view->sfc, PAD, true);
189 // ------------------------------------------------
190 return (0);
191}
192//------------------------------------------------------------------------------
193/** @brief Resize the current window and its box
194 @ingroup window_support
195 @param init Pointer to the Init structure containing view settings.
196 @details This function resizes the current window and its associated box
197 window to the specified number of lines and columns. */
198void view_boxwin_resize(Init *init) {
199 View *view = init->view;
204 // initialize_line_table(init->view);
205}
206/** @brief Calculate the dimensions and position of the box window for C-Menu
207 View.
208 @ingroup init_view
209 @details This function calculates the dimensions and position of the box
210 window for the C-Menu View based on the screen size and any specified
211 parameters in the Init structure. It ensures that the box window fits within
212 the screen dimensions and adjusts its size and position accordingly.
213 @param init Pointer to the Init structure containing view settings.
214 */
216 View *view = init->view;
217
218 /** Use view->lines and view->cols if set, otherwise calculate based on
219 * screen size with some padding. Ensure the view fits within the screen
220 * dimensions. */
221 uint scr_lines, scr_cols;
222 ui_get_screen_size(&scr_lines, &scr_cols);
223#ifdef DEBUG_RESIZE
224 ssnprintf(em0, MAXLEN - 1,
225 _("%s:%d=%d calc lines=%d, cols=%d, begy=%d, begx=%d"),
226 __FILE__, __LINE__, 526, view->lines, view->cols, view->begy, view->begx);
227 write_cmenu_log(em0);
228#endif
229 if (view->lines == 0 && view->cols == 0 && view->begy == 0 && view->begx == 0) {
230 view->lines = scr_lines - 3;
231 view->cols = scr_cols - 2;
232 view->begy = 0;
233 view->begx = 0;
234 }
235 uint lines = max(scr_lines / 10, 8);
236 view->lines = max(view->lines, lines);
237 if (view->lines > scr_lines - 3)
238 view->lines = scr_lines - 3;
239 if (view->lines + view->begy > scr_lines - 3)
240 view->begy = scr_lines - (view->lines + 3);
241
242 uint cols = max(scr_cols / 3, 40);
243 view->cols = max(view->cols, cols);
244 if (view->cols > scr_cols - 2)
245 view->cols = scr_cols - 2;
246 if (view->cols + view->begx > scr_cols - 2)
247 view->begx = scr_cols - (view->cols + 2);
248
249 view->h_shift = view->cols / 3;
250 view->ln_win_lines = view->lines - 1;
251 if (view->f_ln)
252 view->ln_win_cols = 8;
253 else
254 view->ln_win_cols = 0;
255 view->scroll_lines = view->lines - 1;
256 view->cmd_line = 0;
257 view->pminrow = 0;
258 view->pmincol = 0;
259 view->sminrow = view->begy + 1;
260 view->smincol = view->begx + view->ln_win_cols + 1;
261 view->smaxrow = view->begy + view->lines;
262 view->smaxcol = view->begx + view->cols;
264 view->page_bot_ln_no = view->ln_no;
265#ifdef DEBUG_RESIZE
266 ssnprintf(em0, MAXLEN - 1,
267 _("%s:%d calc BOX lines=%d, cols=%d, begy=%d, begx=%d"),
268 __FILE__, __LINE__, view->lines + 2, view->cols + 2, view->begy, view->begx);
269 write_cmenu_log(em0);
270 ssnprintf(em0, MAXLEN - 1,
271 _("%s:%d calc WIN lines=%d, cols=%d, begy=%d, begx=%d"),
272 __FILE__, __LINE__, view->lines, view->cols, 1, 1);
273 write_cmenu_log(em0);
274 ssnprintf(em0, MAXLEN - 1,
275 _("%s:%d calc CMDLN lines=%d, cols=%d, begy=%d, begx=%d"),
276 __FILE__, __LINE__, 1, view->cols, view->lines - 1, 1);
277 write_cmenu_log(em0);
278 ssnprintf(em0, MAXLEN - 1,
279 _("%s:%d calc LNNO lines=%d, cols=%d, begy=%d, begx=%d"),
280 __FILE__, __LINE__, view->lines - 1, view->ln_win_cols, 0, 0);
281 write_cmenu_log(em0);
282 ssnprintf(em0, MAXLEN - 1,
283 _("%s:%d calc PAD lines=%d, cols=%d, begy=%d, begx=%d"),
284 __FILE__, __LINE__, view->lines - 1, view->cols - view->ln_win_cols, 0, view->ln_win_cols);
285 write_cmenu_log(em0);
286
287#endif
288}
289/** @brief Initialize the input for the C-Menu View.
290 @ingroup init_view
291 @param init Pointer to the Init structure containing view settings.
292 @param file_name Name of the input file or "-" for standard input.
293 @return 0 on success, -1 on failure.
294 @details This function initializes the input for the C-Menu View. It handles
295 both regular files and standard input, setting up pipes if necessary. It also
296 memory-maps the input file for efficient access and sets up the view structure
297 accordingly.
298 */
299int view_init_input(Init *init, char *file_name) {
300 struct stat sb;
301 int idx = 0;
302 pid_t pid = -1;
303 int pipe_fd[2];
304 int s_argc = 0;
305 char *s_argv[MAXARGS];
306 char tmp_str[MAXLEN];
307 View *view = init->view;
308 view->f_in_pipe = false;
309 if (strcmp(file_name, "-") == 0) {
310 file_name = _("/dev/stdin");
311 view->f_in_pipe = true;
312 }
313 if (view->provider_cmd[0] != '\0') {
314 s_argc = str_to_args(s_argv, view->provider_cmd, MAXARGS - 1);
315 if (pipe(pipe_fd) == -1) {
316 ui_perror(_("pipe(pipe_fd) failed in init_view"));
317 return -1;
318 }
319 // endwin();
320 if ((pid = fork()) == -1) {
321 ui_perror(_("fork() failed in init_view"));
322 return -1;
323 }
324 if (pid == 0) { // Child
325 /** Prevent child process from writing to terminal */
326 int dev_null = open(_("/dev/null"), O_WRONLY);
327 if (dev_null == -1) {
328 ui_perror(_("open(/dev/null) failed in init_pick child process"));
329 exit(EXIT_FAILURE);
330 }
331 dup2(dev_null, STDERR_FILENO);
332 close(dev_null);
333 close(pipe_fd[P_READ]);
334 dup2(pipe_fd[P_WRITE], STDOUT_FILENO);
335 close(pipe_fd[P_WRITE]);
336 execvp(s_argv[0], s_argv);
337 strnz__cpy(tmp_str, _("Can't exec view start cmd: "), MAXLEN - 1);
338 strnz__cat(tmp_str, s_argv[0], MAXLEN - 1);
339 ui_perror(tmp_str);
340 exit(EXIT_FAILURE);
341 }
342 // Back to parent
343 destroy_argv(s_argc, s_argv);
346 close(pipe_fd[P_WRITE]);
347 view->in_fd = dup(pipe_fd[P_READ]);
348 view->f_in_pipe = true;
349 } else {
350 if (view->f_in_pipe)
351 view->in_fd = dup(STDIN_FILENO);
352 else {
353 /*----------------------------------------------------------------------*/
354 /* Open the input file for reading and get its size. */
355 expand_tilde(file_name, MAXLEN - 1);
356 view->in_fd = open(file_name, O_RDONLY);
357 if (view->in_fd == -1) {
358 ssnprintf(em0, MAXLEN - 1, _("%s, line: %d"), __FILE__,
359 __LINE__ - 3);
360 ssnprintf(em1, MAXLEN - 1, _("open %s"), file_name);
363 nullptr);
364 return -1;
365 }
366 if (fstat(view->in_fd, &sb) == -1) {
367 ssnprintf(em0, MAXLEN - 1, _("%s, line: %d"), __FILE__,
368 __LINE__ - 1);
369 ssnprintf(em1, MAXLEN - 1, _("fstat %s"), file_name);
372 close(view->in_fd);
373 return -1;
374 }
375 view->file_size = sb.st_size;
376 if (view->file_size == 0) {
377 close(view->in_fd);
378 ssnprintf(em0, MAXLEN - 1, _("%s, line: %d"), __FILE__,
379 __LINE__ - 1);
380 ssnprintf(em1, MAXLEN - 1, _("file %s is empty"), file_name);
383 return -1;
384 }
385 if (!S_ISREG(sb.st_mode))
386 view->f_in_pipe = true;
387 }
388 /*----------------------------------------------------------------------*/
389 }
390 if (view->f_in_pipe) {
391 errno = 0;
392 view->tmp_fd = memfd_create(_("view_input"), MFD_CLOEXEC);
393 if (view->in_fd < 0 || errno != 0) {
394 ssnprintf(em0, MAXLEN - 1, "memfd_create failed\n");
395 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
396 ssnprintf(em2, MAXLEN - 1, _("%s, line: %d, errno: %d"), __FILE__,
397 __LINE__ - 4, errno);
399 exit(EXIT_FAILURE);
400 }
401 // ------------------------------------------------------
402 // transfer view->in_fd to view->tmp_fd
403 // ------------------------------------------------------
404 char buf[VBUFSIZ];
405 ssize_t bytes_read = 0;
406 // ------------------------------------------------------
407 // countdown to timeout if view->in_fd not ready
408 // ------------------------------------------------------
411 int status = ui_poll_reg_read_fd(500);
412 if (status == 0) {
413 int timeout_ms = init->timeout_secs * 1000;
414 status = ui_timeout_prompt(_("Waiting for input..."), _("from view_input"), timeout_ms, init->timeout_secs);
416 if (status != UIKEY_STREAM_DATA) {
417 if (status == UIKEY_F09)
418 cmenu_abend(init, -1, _("view: user pressed F9"));
419 if (status == UIKEY_TIMEOUT)
420 cmenu_abend(init, -1, _("view: timed out waiting for input"));
421 cmenu_abend(init, -1, _("view: no input data"));
422 }
423 }
424 // ------------------------------------------------------
425 // end wait
426 // ------------------------------------------------------
427 bytes_read = read(view->in_fd, buf, sizeof(buf));
428 if (bytes_read > 0) {
429 if (write(view->tmp_fd, buf, bytes_read) != bytes_read)
430 cmenu_abend(init, EXIT_FAILURE, _("view: unable to write view->tmp_fd"));
431 } else if (bytes_read == 0)
432 cmenu_abend(init, EXIT_FAILURE, _("view: unable to read view->tmp_fd"));
433 // ------------------------------------------------------
434 // end transfer
435 // ------------------------------------------------------
436 if (fstat(view->tmp_fd, &sb) == -1) {
437 ssnprintf(em0, MAXLEN - 1, "fstat(view->in_fd) failed\n");
438 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
439 ssnprintf(em2, MAXLEN - 1, _("%s, line: %d, errno: %d"), __FILE__,
440 __LINE__ - 4, errno);
442 exit(EXIT_FAILURE);
443 }
444 view->file_size = sb.st_size;
445 if (view->file_size == 0) {
446 close(view->tmp_fd);
447 strnz__cpy(tmp_str, _("view: no standard input"), MAXLEN - 1);
448 ui_abend(-1, tmp_str);
449 exit(EXIT_FAILURE);
450 }
451 waitpid(-1, nullptr, 0);
452 view->in_fd = view->tmp_fd;
453 }
454 view->buf =
455 mmap(nullptr, view->file_size, PROT_READ, MAP_PRIVATE, view->in_fd, 0);
456 if (view->buf == MAP_FAILED) {
457 ssnprintf(em0, MAXLEN - 1, _("%s, line: %d"), __FILE__, __LINE__ - 2);
458 ssnprintf(em1, MAXLEN - 1, _("mmap %s"), file_name);
461 close(view->in_fd);
462 return -1;
463 }
464 close(view->in_fd);
465 stdio_fdnames(stdio_names_str, _("init_view.c 422"));
466 view->file_size = sb.st_size;
468 view->buf_curr_ptr = view->buf;
469 if (view->cmd_all[0] != '\0')
471 for (idx = 0; idx < NMARKS; idx++)
472 view->mark_tbl[idx] = NULL_POSITION;
473 strnz__cpy(view->cur_file_str, file_name, MAXLEN - 1);
475 return 0;
476}
#define P_READ
Definition common.h:53
#define P_WRITE
Definition common.h:54
char stdio_names_str[4096]
Definition futil.c:122
#define MAXARGS
Definition cm.h:64
char * stdio_fdnames(char *, char *)
Definition futil.c:1108
#define max(a, b)
max macro evaluates two expressions, returning greatest result.
Definition cm.h:97
int ui_surface_addwin(UiSurface *s, ss_t w, uint p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
Definition ui_ncurses.c:395
void ui_render()
Render the UI by updating panels and refreshing the display.
Definition ui_ncurses.c:884
UiCell cell_nt
Definition ui_common.c:106
char em1[MAXLEN]
Definition ui_common.c:47
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
Definition ui_ncurses.c:820
char em2[MAXLEN]
Definition ui_common.c:48
int ui_idcok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete character capabilities for a UiSurface.
Definition ui_ncurses.c:803
UiCell cell_ln
Definition ui_common.c:114
int ui_surface_addpad(UiSurface *s, ss_t w, uint view_win, uint lines, uint cols, uint begy, uint begx)
Add a new pad to the specified UiSurface.
Definition ui_ncurses.c:369
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
Definition ui_ncurses.c:468
int ui_border_title(UiSurface *sfc, const char *title)
Draw a box with a title around the specified window.
Definition ui_common.c:563
int ui_bkgd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
Definition ui_ncurses.c:927
void ui_restore_wins()
Restore the state of all windows in the UI. This function refreshes the standard screen and all surfa...
int ui_idlok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete line capabilities for a UiSurface.
Definition ui_ncurses.c:787
UiSurface * ui_surface_box(UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x, const char *title)
Create a new UI surface with a border box and optional title.
Definition ui_ncurses.c:288
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 ui_erase()
Erase the entire screen.
Definition ui_ncurses.c:591
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
Definition ui_ncurses.c:229
char em0[MAXLEN]
Definition ui_common.c:46
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
Definition ui_ncurses.c:755
int ui_bkgdset(UiSurface *s, ss_t w, const UiCell *cell)
Set the background for new content to be written to a specific window within a UiSurface.
Definition ui_ncurses.c:941
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
Definition ui_ncurses.c:771
#define NMARKS
Definition view.h:33
#define VBUFSIZ
Definition view.h:37
#define PAD_COLS
Definition view.h:39
#define NULL_POSITION
Definition view.h:36
#define UIKEY_TIMEOUT
#define UIKEY_STREAM_DATA
#define UIKEY_F09
void ui_flush_input()
Flush any pending input events from the NotCurses context. This function discards any input events th...
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
Definition ui_common.c:362
void view_full_screen_resize(Init *)
Resize the full screen view and its components.
Definition init_view.c:111
void view_boxwin_resize(Init *)
Resize the current window and its box.
Definition init_view.c:198
ViewStack view_stack
Definition init_view.c:32
#define MAXLEN
Definition curskeys.c:15
void cmenu_abend(Init *init, int ec, char *s)
Definition menu.c:94
#define _(String)
Definition amort.c:23
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition whence.c:291
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:390
int str_to_args(char **, char *, uint)
Converts a string into an array of argument strings.
Definition futil.c:412
bool expand_tilde(char *, uint)
Replaces "~/" in string with the user's home directory.
Definition futil.c:989
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition whence.c:320
char * strerror__r(int errnum, char *buf, size_t buflen)
A thread-safe alternative to strerror() that writes the error message corresponding to errnum into th...
Definition futil.c:748
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:468
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:1132
void view_calc_boxwin_dimensions(Init *)
Calculate the dimensions and position of the box window for C-Menu View.
Definition init_view.c:215
int init_view_full_screen(Init *init)
Initialize C-Menu View in full screen mode.
Definition init_view.c:47
int init_view_boxwin(Init *init)
Initialize the C-Menu View in box window mode.
Definition init_view.c:162
void view_calc_full_screen_dimensions(Init *)
Calculate the dimensions for full screen mode.
Definition init_view.c:128
int view_init_input(Init *init, char *file_name)
Initialize the input for the C-Menu View.
Definition init_view.c:299
void sig_prog_mode()
Set up signal handlers for interrupt signals.
Definition sig.c:61
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition ui_common.c:1257
void ui_unregister_read_fd(int fd)
Unregister an external file descriptor from polling.
Definition ui_common.c:1134
void ui_register_read_fd(int fd, int token_id)
Register an external file descriptor for polling.
Definition ui_common.c:1117
int ui_timeout_prompt(char *msg0, char *msg1, uint timeout_ms, uint timeout_secs)
Display a timeout prompt window or print to stderr.
Definition ui_common.c:1033
int ui_poll_reg_read_fd(int timeout_ms)
Poll for input on registered external files.
Definition ui_common.c:1155
int ui_display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
Definition ui_common.c:1200
View * view
Definition common.h:193
uint timeout_secs
Definition common.h:182
uint smaxrow
Definition view.h:132
char provider_cmd[MAXLEN]
Definition view.h:74
uint sminrow
Definition view.h:128
off_t page_top_ln_no
Definition view.h:157
char * buf
Definition view.h:171
uint smincol
Definition view.h:130
int in_fd
Definition view.h:163
uint lines
Definition view.h:70
off_t ln_no
Definition view.h:182
off_t prev_file_pos
Definition view.h:151
uint begx
Definition view.h:73
char cmd[MAXLEN]
Definition view.h:76
bool f_in_pipe
Definition view.h:162
int tmp_fd
Definition view.h:164
char * buf_curr_ptr
Definition view.h:172
bool f_full_screen
Definition view.h:108
bool f_ln
Definition view.h:181
off_t mark_tbl[NMARKS]
Definition view.h:161
uint cmd_line
Definition view.h:124
uint ln_win_cols
Definition view.h:180
off_t file_size
Definition view.h:149
uint scroll_lines
Definition view.h:123
char cur_file_str[MAXLEN]
Definition view.h:113
char title[MAXLEN]
Definition view.h:79
uint cols
Definition view.h:71
char cmd_all[MAXLEN]
Definition view.h:77
off_t page_bot_ln_no
Definition view.h:158
uint begy
Definition view.h:72
int h_shift
Definition view.h:96
uint pmincol
Definition view.h:127
uint smaxcol
Definition view.h:134
UiSurface * sfc
Definition view.h:89
char file_name[MAXLEN]
Definition view.h:103
uint ln_win_lines
Definition view.h:179
uint pminrow
Definition view.h:126