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->win: Top Level Container
43 2. view->lnno: Line numbers
44 1. view->cmdln: Command Line
45 3. view->pad: Content
46 @endverbatim
47 */
48int init_view_full_screen(Init *init) {
49 View *view = init->view;
50 view->f_full_screen = true;
52 // -------------------> 1. WIN <-------------------
53 view->sfc = ui_surface_new(WIN, nullptr, 0, view->lines, view->cols, 0, 0);
55 ui_werase(view->sfc, WIN);
56 // -------------------> 2. LNNO <-------------------
57 if (view->f_ln) {
59 ui_bkgd(view->sfc, LNNO, &cell_ln);
61 ui_scrollok(view->sfc, LNNO, true);
63 }
64 // -------------------> 3. CMDLN <-------------------
66 ui_bkgd(view->sfc, CMDLN, &cell_nt);
67 ui_keypad(view->sfc, CMDLN, true);
68 ui_idlok(view->sfc, CMDLN, false);
69 ui_idcok(view->sfc, CMDLN, false);
70 ui_scrollok(view->sfc, CMDLN, false);
71 // -------------------> 4. PAD <-------------------
72 ui_surface_addpad(view->sfc, PAD, WIN, view->lines - 1, PAD_COLS - 1, 0, view->ln_win_cols + 1, false);
73 // ui_scrollok(view->sfc, PAD, true);
74 // ui_setscrreg(view->sfc, PAD, 0, view->scroll_lines);
75 ui_keypad(view->sfc, PAD, true);
76 UiCaps caps;
77 ui_get_caps(&caps);
78 if (caps.pad_relative_yx) {
79 view->sminrow = 0;
80 view->smincol = 0;
81 }
82 // ------------------------------------------------
83 return 0;
84}
85/** @brief Resize the full screen view and its components.
86 @ingroup window_support
87 @param init Pointer to the Init structure containing view settings.
88 @details This function resizes the full screen view and its components,
89 including the command line window, line number window, and main content pad.
90 It also recalculates the dimensions for the full screen mode and updates the
91 scroll regions accordingly.
92 */
93void view_full_screen_resize(Init *init) {
96 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);
97 View *view = init->view;
101}
102/** @brief Calculate the dimensions for full screen mode.
103 @ingroup init_view
104 @details This function calculates the dimensions for the full screen mode of
105 the C-Menu View. It retrieves the maximum dimensions of the standard screen
106 and sets the view parameters accordingly. It also resizes the line number
107 window and command line window based on the new dimensions.
108 @param init Pointer to the Init structure containing view settings.
109 */
111 View *view = init->view;
113 view->ln_win_lines = view->lines;
114 view->ln_win_cols = 8;
115 view->scroll_lines = view->lines - 1;
116 view->h_shift = view->cols / 3;
117#ifdef DEBUG_RESIZE
118 char file[MAXLEN];
119 ssnprintf(
120 em0, MAXLEN - 1,
121 _("%s:%d view->lines=%d, view->cols=%d, view->maxrows=%d, view->maxcols=%d"),
122 __FILE__, __LINE__,
123 view->lines, view->cols, view->smaxrow, view->smaxcol);
124 write_cmenu_log(em0);
125#endif
126
127 view->pminrow = 0;
128 view->pmincol = 0;
129 view->sminrow = 0;
130 view->smincol = view->ln_win_cols;
131 view->smaxrow = view->lines - 1;
132 view->smaxcol = view->cols - 1;
133
135 view->page_bot_ln_no = view->ln_no;
136}
137/** @brief Initialize the C-Menu View in box window mode.
138 @ingroup init_view
139 @param init Pointer to the Init structure containing view settings.
140 @return 0 on success, -1 on failure.
141 @details sets up the view structure for box window mode, adjusts dimensions
142 based on screen size, and creates a new pad for the view. It also configures
143 various parameters such as scroll lines, command line position, and tab size.
144 */
145int init_view_boxwin(Init *init) {
146 View *view = init->view;
147 view->f_full_screen = false;
149 // -------------------> 1. BOX <-------------------
150 view->sfc = ui_surface_box(NULL, BOX, view->lines + 2, view->cols + 2, view->begy, view->begx, NULL);
151#ifdef DEBUG_Z_STACK
152 ui_bkgd(view->sfc, BOX, &cell_magenta_bg);
153 ui_bkgdset(view->sfc, BOX, &cell_magenta_bg);
154 ui_mvwaddstr(view->sfc, BOX, 1, 1, "-- BOX --");
155#endif
156#ifdef DEBUG_IMMED_UI
157 ui_render();
158#endif
159 // -------------------> 2. WIN <-------------------
160 ui_surface_addwin(view->sfc, WIN, BOX, view->lines, view->cols, 1, 1);
161 ui_bkgd(view->sfc, WIN, &cell_nt);
162 ui_werase(view->sfc, WIN);
163#ifdef DEBUG_Z_STACK
164 ui_bkgd(view->sfc, WIN, &cell_cyan_bg);
165 ui_mvwaddstr(view->sfc, WIN, 1, 1, "-- WIN --");
166#endif
167#ifdef DEBUG_IMMED_UI
168 ui_render();
169#endif
170 // -------------------> 3. LNNO <-------------------
171 if (view->f_ln) {
172 ui_surface_addwin(view->sfc, LNNO, WIN, view->lines - 1, view->ln_win_cols, 0, 0);
173 ui_bkgd(view->sfc, LNNO, &cell_ln);
175 ui_scrollok(view->sfc, LNNO, true);
177#ifdef DEBUG_Z_STACK
178 ui_bkgd(view->sfc, LNNO, &cell_blue_bg);
179 ui_bkgdset(view->sfc, LNNO, &cell_blue_bg);
180 ui_mvwaddstr(view->sfc, LNNO, 1, 1, "-- LNNO --");
181#endif
182#ifdef DEBUG_IMMED_UI
183 ui_render();
184#endif
185 }
186 // -------------------> 4. CMDLN <-------------------
187 ui_surface_addwin(view->sfc, CMDLN, WIN, 1, view->cols, view->lines - 1, 0);
188 ui_bkgd(view->sfc, CMDLN, &cell_nt);
189 ui_keypad(view->sfc, CMDLN, true);
190 ui_idlok(view->sfc, CMDLN, false);
191 ui_idcok(view->sfc, CMDLN, false);
192 ui_scrollok(view->sfc, CMDLN, false);
193#ifdef DEBUG_Z_STACK
194 ui_bkgd(view->sfc, CMDLN, &cell_red_bg);
195 ui_bkgdset(view->sfc, CMDLN, &cell_red_bg);
196 ui_mvwaddstr(view->sfc, CMDLN, 1, 1, "-- CMDLN --");
197#endif
198#ifdef DEBUG_IMMED_UI
199 ui_render();
200#endif
201 // -------------------> 5. PAD <-------------------
202 ui_surface_addpad(view->sfc, PAD, WIN, view->lines - 1, PAD_COLS - 1, 0, view->ln_win_cols + 1, true);
203 ui_bkgd(view->sfc, PAD, &cell_nt);
204 UiCaps caps;
205 ui_get_caps(&caps);
206 if (caps.pad_relative_yx) {
207 view->sminrow = 0;
208 view->smincol = 0;
209 view->smaxrow = view->lines - 1;
210 view->smaxcol = view->cols - 1;
211 }
212 // ui_scrollok(view->sfc, PAD, true)
213 //
214#ifdef DEBUG_Z_STACK
215 ui_bkgd(view->sfc, PAD, &cell_yellow_bg);
216 ui_bkgdset(view->sfc, PAD, &cell_yellow_bg);
217 ui_mvwaddstr(view->sfc, PAD, 1, 1, "-- PAD --");
218#endif
220 return (0);
221}
222//------------------------------------------------------------------------------
223/** @brief Resize the current window and its box
224 @ingroup window_support
225 @param init Pointer to the Init structure containing view settings.
226 @details This function resizes the current window and its associated box
227 window to the specified number of lines and columns. */
228void view_boxwin_resize(Init *init) {
229 View *view = init->view;
234 // initialize_line_table(init->view);
235}
236/** @brief Calculate the dimensions and position of the box window for C-Menu
237 View.
238 @ingroup init_view
239 @details This function calculates the dimensions and position of the box
240 window for the C-Menu View based on the screen size and any specified
241 parameters in the Init structure. It ensures that the box window fits within
242 the screen dimensions and adjusts its size and position accordingly.
243 @param init Pointer to the Init structure containing view settings.
244 */
246 View *view = init->view;
247
248 /** Use view->lines and view->cols if set, otherwise calculate based on
249 * screen size with some padding. Ensure the view fits within the screen
250 * dimensions. */
251 uint scr_lines, scr_cols;
252 ui_get_screen_size(&scr_lines, &scr_cols);
253#ifdef DEBUG_RESIZE
254 ssnprintf(em0, MAXLEN - 1,
255 _("%s:%d=%d calc lines=%d, cols=%d, begy=%d, begx=%d"),
256 __FILE__, __LINE__, 526, view->lines, view->cols, view->begy, view->begx);
257 write_cmenu_log(em0);
258#endif
259 if (view->lines == 0 && view->cols == 0 && view->begy == 0 && view->begx == 0) {
260 view->lines = scr_lines - 3;
261 view->cols = scr_cols - 2;
262 view->begy = 0;
263 view->begx = 0;
264 }
265 uint lines = max(scr_lines / 10, 8);
266 view->lines = max(view->lines, lines);
267 if (view->lines > scr_lines - 3)
268 view->lines = scr_lines - 3;
269 if (view->lines + view->begy > scr_lines - 3)
270 view->begy = scr_lines - (view->lines + 3);
271
272 uint cols = max(scr_cols / 3, 40);
273 view->cols = max(view->cols, cols);
274 if (view->cols > scr_cols - 2)
275 view->cols = scr_cols - 2;
276 if (view->cols + view->begx > scr_cols - 2)
277 view->begx = scr_cols - (view->cols + 2);
278
279 view->h_shift = view->cols / 3;
280 view->ln_win_lines = view->lines - 1;
281 if (view->f_ln)
282 view->ln_win_cols = 8;
283 else
284 view->ln_win_cols = 0;
285 view->scroll_lines = view->lines - 1;
286 view->cmd_line = 0;
287
288 view->pminrow = 0;
289 view->pmincol = 0;
290 view->sminrow = view->begy + 1;
291 view->smincol = view->begx + view->ln_win_cols;
292 view->smaxrow = view->begy + view->lines;
293 view->smaxcol = view->begx + view->cols;
294
296 view->page_bot_ln_no = view->ln_no;
297#ifdef DEBUG_RESIZE
298 ssnprintf(em0, MAXLEN - 1,
299 _("%s:%d calc BOX lines=%d, cols=%d, begy=%d, begx=%d"),
300 __FILE__, __LINE__, view->lines + 2, view->cols + 2, view->begy, view->begx);
301 write_cmenu_log(em0);
302 ssnprintf(em0, MAXLEN - 1,
303 _("%s:%d calc WIN lines=%d, cols=%d, begy=%d, begx=%d"),
304 __FILE__, __LINE__, view->lines, view->cols, 1, 1);
305 write_cmenu_log(em0);
306 ssnprintf(em0, MAXLEN - 1,
307 _("%s:%d calc CMDLN lines=%d, cols=%d, begy=%d, begx=%d"),
308 __FILE__, __LINE__, 1, view->cols, view->lines - 1, 1);
309 write_cmenu_log(em0);
310 ssnprintf(em0, MAXLEN - 1,
311 _("%s:%d calc LNNO lines=%d, cols=%d, begy=%d, begx=%d"),
312 __FILE__, __LINE__, view->lines - 1, view->ln_win_cols, 0, 0);
313 write_cmenu_log(em0);
314 ssnprintf(em0, MAXLEN - 1,
315 _("%s:%d calc PAD lines=%d, cols=%d, begy=%d, begx=%d"),
316 __FILE__, __LINE__, view->lines - 1, view->cols - view->ln_win_cols, 0, view->ln_win_cols);
317 write_cmenu_log(em0);
318
319#endif
320}
321/** @brief Initialize the input for the C-Menu View.
322 @ingroup init_view
323 @param init Pointer to the Init structure containing view settings.
324 @param file_name Name of the input file or "-" for standard input.
325 @return 0 on success, -1 on failure.
326 @details This function initializes the input for the C-Menu View. It handles
327 both regular files and standard input, setting up pipes if necessary. It also
328 memory-maps the input file for efficient access and sets up the view structure
329 accordingly.
330 */
331int view_init_input(Init *init, char *file_name) {
332 struct stat sb;
333 int idx = 0;
334 pid_t pid = -1;
335 int pipe_fd[2];
336 int s_argc = 0;
337 char *s_argv[MAXARGS];
338 char tmp_str[MAXLEN];
339 View *view = init->view;
340 view->f_in_pipe = false;
341 if (strcmp(file_name, "-") == 0) {
342 file_name = _("/dev/stdin");
343 view->f_in_pipe = true;
344 }
345 if (view->provider_cmd[0] != '\0') {
346 s_argc = str_to_args(s_argv, view->provider_cmd, MAXARGS - 1);
347 if (pipe(pipe_fd) == -1) {
348 ui_perror(_("pipe(pipe_fd) failed in init_view"));
349 return -1;
350 }
351 // endwin();
352 if ((pid = fork()) == -1) {
353 ui_perror(_("fork() failed in init_view"));
354 return -1;
355 }
356 if (pid == 0) { // Child
357 /** Prevent child process from writing to terminal */
358 int dev_null = open(_("/dev/null"), O_WRONLY);
359 if (dev_null == -1) {
360 ui_perror(_("open(/dev/null) failed in init_pick child process"));
361 exit(EXIT_FAILURE);
362 }
363 dup2(dev_null, STDERR_FILENO);
364 close(dev_null);
365 close(pipe_fd[P_READ]);
366 dup2(pipe_fd[P_WRITE], STDOUT_FILENO);
367 close(pipe_fd[P_WRITE]);
368 execvp(s_argv[0], s_argv);
369 strnz__cpy(tmp_str, _("Can't exec view start cmd: "), MAXLEN - 1);
370 strnz__cat(tmp_str, s_argv[0], MAXLEN - 1);
371 ui_perror(tmp_str);
372 exit(EXIT_FAILURE);
373 }
374 // Back to parent
375 destroy_argv(s_argc, s_argv);
378 close(pipe_fd[P_WRITE]);
379 view->in_fd = dup(pipe_fd[P_READ]);
380 view->f_in_pipe = true;
381 } else {
382 if (view->f_in_pipe)
383 view->in_fd = dup(STDIN_FILENO);
384 else {
385 /*----------------------------------------------------------------------*/
386 /* Open the input file for reading and get its size. */
387 expand_tilde(file_name, MAXLEN - 1);
388 view->in_fd = open(file_name, O_RDONLY);
389 if (view->in_fd == -1) {
390 ssnprintf(em0, MAXLEN - 1, _("%s, line: %d"), __FILE__,
391 __LINE__ - 3);
392 ssnprintf(em1, MAXLEN - 1, _("open %s"), file_name);
395 nullptr);
396 return -1;
397 }
398 if (fstat(view->in_fd, &sb) == -1) {
399 ssnprintf(em0, MAXLEN - 1, _("%s, line: %d"), __FILE__,
400 __LINE__ - 1);
401 ssnprintf(em1, MAXLEN - 1, _("fstat %s"), file_name);
404 close(view->in_fd);
405 return -1;
406 }
407 view->file_size = sb.st_size;
408 if (view->file_size == 0) {
409 close(view->in_fd);
410 ssnprintf(em0, MAXLEN - 1, _("%s, line: %d"), __FILE__,
411 __LINE__ - 1);
412 ssnprintf(em1, MAXLEN - 1, _("file %s is empty"), file_name);
415 return -1;
416 }
417 if (!S_ISREG(sb.st_mode))
418 view->f_in_pipe = true;
419 }
420 /*----------------------------------------------------------------------*/
421 }
422 if (view->f_in_pipe) {
423 errno = 0;
424 view->tmp_fd = memfd_create(_("view_input"), MFD_CLOEXEC);
425 if (view->in_fd < 0 || errno != 0) {
426 ssnprintf(em0, MAXLEN - 1, "memfd_create failed\n");
427 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
428 ssnprintf(em2, MAXLEN - 1, _("%s, line: %d, errno: %d"), __FILE__,
429 __LINE__ - 4, errno);
431 exit(EXIT_FAILURE);
432 }
433 // ------------------------------------------------------
434 // transfer view->in_fd to view->tmp_fd
435 // ------------------------------------------------------
436 char buf[VBUFSIZ];
437 ssize_t bytes_read = 0;
438 // ------------------------------------------------------
439 // countdown to timeout if view->in_fd not ready
440 // ------------------------------------------------------
443 int status = ui_poll_reg_read_fd(500);
444 if (status == 0) {
445 int timeout_ms = init->timeout_secs * 1000;
446 status = ui_timeout_prompt(_("Waiting for input..."), _("from view_input"), timeout_ms, init->timeout_secs);
448 if (status != UIKEY_STREAM_DATA) {
449 if (status == UIKEY_F09)
450 cmenu_abend(init, -1, _("view: user pressed F9"));
451 if (status == UIKEY_TIMEOUT)
452 cmenu_abend(init, -1, _("view: timed out waiting for input"));
453 cmenu_abend(init, -1, _("view: no input data"));
454 }
455 }
456 // ------------------------------------------------------
457 // end wait
458 // ------------------------------------------------------
459 bytes_read = read(view->in_fd, buf, sizeof(buf));
460 if (bytes_read > 0) {
461 if (write(view->tmp_fd, buf, bytes_read) != bytes_read)
462 cmenu_abend(init, EXIT_FAILURE, _("view: unable to write view->tmp_fd"));
463 } else if (bytes_read == 0)
464 cmenu_abend(init, EXIT_FAILURE, _("view: unable to read view->tmp_fd"));
465 // ------------------------------------------------------
466 // end transfer
467 // ------------------------------------------------------
468 if (fstat(view->tmp_fd, &sb) == -1) {
469 ssnprintf(em0, MAXLEN - 1, "fstat(view->in_fd) failed\n");
470 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
471 ssnprintf(em2, MAXLEN - 1, _("%s, line: %d, errno: %d"), __FILE__,
472 __LINE__ - 4, errno);
474 exit(EXIT_FAILURE);
475 }
476 view->file_size = sb.st_size;
477 if (view->file_size == 0) {
478 close(view->tmp_fd);
479 strnz__cpy(tmp_str, _("view: no standard input"), MAXLEN - 1);
480 ui_abend(-1, tmp_str);
481 exit(EXIT_FAILURE);
482 }
483 waitpid(-1, nullptr, 0);
484 view->in_fd = view->tmp_fd;
485 }
486 view->buf =
487 mmap(nullptr, view->file_size, PROT_READ, MAP_PRIVATE, view->in_fd, 0);
488 if (view->buf == MAP_FAILED) {
489 ssnprintf(em0, MAXLEN - 1, _("%s, line: %d"), __FILE__, __LINE__ - 2);
490 ssnprintf(em1, MAXLEN - 1, _("mmap %s"), file_name);
493 close(view->in_fd);
494 return -1;
495 }
496 close(view->in_fd);
497 stdio_fdnames(stdio_names_str, _("init_view.c 422"));
498 view->file_size = sb.st_size;
500 view->buf_curr_ptr = view->buf;
501 if (view->cmd_all[0] != '\0')
503 for (idx = 0; idx < NMARKS; idx++)
504 view->mark_tbl[idx] = NULL_POSITION;
505 strnz__cpy(view->cur_file_str, file_name, MAXLEN - 1);
507 return 0;
508}
#define P_READ
Definition common.h:53
#define P_WRITE
Definition common.h:54
char stdio_names_str[4096]
Definition futil.c:121
#define MAXARGS
Definition cm.h:67
char * stdio_fdnames(char *, char *)
Definition futil.c:1130
UiSurface * ui_surface_box(UiSurface *parent, ss_t 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:293
void ui_render()
Render the UI by updating panels and refreshing the display.
Definition ui_ncurses.c:931
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
Definition ui_ncurses.c:230
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
Definition ui_ncurses.c:861
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:844
int ui_surface_addwin(UiSurface *s, ss_t w, ss_t p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
Definition ui_ncurses.c:423
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
Definition ui_ncurses.c:499
int ui_surface_addpad(UiSurface *s, ss_t w, ss_t view_win, uint lines, uint cols, uint y, uint x, bool hidden)
Add a new pad to the specified UiSurface.
Definition ui_ncurses.c:381
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:974
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:828
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
Definition ui_ncurses.c:754
int ui_erase()
Erase the entire screen.
Definition ui_ncurses.c:623
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
Definition ui_ncurses.c:796
void ui_get_caps(UiCaps *caps)
Get the UI backend capabilities.
Definition ui_ncurses.c:62
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:988
int ui_werase(UiSurface *s, ss_t w)
Erase the contents of a UiSurface or all surfaces.
Definition ui_ncurses.c:582
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
Definition ui_ncurses.c:812
#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...
UiCell cell_nt
Definition ui_common.c:123
UiCell cell_ln
Definition ui_common.c:131
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
Definition ui_common.c:404
int ui_border_title(UiSurface *sfc, ss_t w, const char *title)
Draw a box with a title around the specified window.
Definition ui_common.c:621
void ui_log_write(const UiLogLevel level, const char *file, const char *func, const int line, const char *fmt,...)
Definition ui_common.c:1476
void view_full_screen_resize(Init *)
Resize the full screen view and its components.
Definition init_view.c:93
void view_boxwin_resize(Init *)
Resize the current window and its box.
Definition init_view.c:228
ViewStack view_stack
Definition init_view.c:32
#define MAXLEN
Definition lf.h:38
#define max(a, b)
Definition lf.h:152
void cmenu_abend(Init *init, int ec, char *s)
Definition menu.c:94
char em1[MAXLEN]
Definition lf.c:43
char em2[MAXLEN]
Definition lf.c:44
char em0[MAXLEN]
Definition lf.c:42
#define _(String)
Definition amort.c:23
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition lf.c:2299
size_t ssnprintf(char *, size_t, const char *,...)
Custom safe string formatting utility (Variadic version).
Definition futil.c:398
int str_to_args(char **, char *, uint)
Converts a string into an array of argument strings.
Definition futil.c:418
bool expand_tilde(char *, uint)
Expand a tilde (~) in a file path to the user's home directory.
Definition lf.c:2089
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition lf.c:2330
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:770
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:474
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:1154
void view_calc_boxwin_dimensions(Init *)
Calculate the dimensions and position of the box window for C-Menu View.
Definition init_view.c:245
int init_view_full_screen(Init *init)
Initialize C-Menu View in full screen mode.
Definition init_view.c:48
int init_view_boxwin(Init *init)
Initialize the C-Menu View in box window mode.
Definition init_view.c:145
void view_calc_full_screen_dimensions(Init *)
Calculate the dimensions for full screen mode.
Definition init_view.c:110
int view_init_input(Init *init, char *file_name)
Initialize the input for the C-Menu View.
Definition init_view.c:331
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:1323
void ui_unregister_read_fd(int fd)
Unregister an external file descriptor from polling.
Definition ui_common.c:1195
void ui_register_read_fd(int fd, int token_id)
Register an external file descriptor for polling.
Definition ui_common.c:1178
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:1094
int ui_poll_reg_read_fd(int timeout_ms)
Poll for input on registered external files.
Definition ui_common.c:1216
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:1261
View * view
Definition common.h:193
uint timeout_secs
Definition common.h:182
uint smaxrow
Definition view.h:133
char provider_cmd[MAXLEN]
Definition view.h:74
uint sminrow
Definition view.h:129
off_t page_top_ln_no
Definition view.h:158
char * buf
Definition view.h:173
uint smincol
Definition view.h:131
int in_fd
Definition view.h:165
uint lines
Definition view.h:70
off_t ln_no
Definition view.h:184
off_t prev_file_pos
Definition view.h:152
uint begx
Definition view.h:73
char cmd[MAXLEN]
Definition view.h:76
bool f_in_pipe
Definition view.h:163
int tmp_fd
Definition view.h:166
char * buf_curr_ptr
Definition view.h:174
bool f_full_screen
Definition view.h:108
bool f_ln
Definition view.h:183
off_t mark_tbl[NMARKS]
Definition view.h:162
uint cmd_line
Definition view.h:125
uint ln_win_cols
Definition view.h:182
off_t file_size
Definition view.h:150
uint scroll_lines
Definition view.h:124
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:159
uint begy
Definition view.h:72
int h_shift
Definition view.h:96
uint pmincol
Definition view.h:128
uint smaxcol
Definition view.h:135
UiSurface * sfc
Definition view.h:89
char file_name[MAXLEN]
Definition view.h:103
uint ln_win_lines
Definition view.h:181
uint pminrow
Definition view.h:127
bool pad_relative_yx
Definition ui_backend.h:504