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 *);
31void destroy_view_win(Init *);
32void view_win_del(PANEL *, WINDOW *);
33
34ViewStack view_stack;
35
36/** @brief Initialize C-Menu View in full screen mode.
37 @ingroup init_view
38 @param init Pointer to the Init structure containing view settings.
39 @return 0 on success, -1 on failure.
40 @details This function sets up the view structure for full screen mode and
41 creates a new pad for the view.
42 @verbatim
43 The function creates the following windows:
44 1. view->cmdln_win: Status or Command Line
45 2. view->lnno_win: Line Number Window
46 3. view->pad: Main Content Pad
47 @endverbatim
48 */
49int init_view_full_screen(Init *init) {
50 View *view = init->view;
51
52 if (view->tab_stop <= 0)
53 view->tab_stop = TABSIZE;
54 set_tabsize(view->tab_stop);
55 view->f_full_screen = true;
56
57 // -------------------> 1. WIN <-------------------
59 view->win_win = newwin(LINES, COLS, 0, 0);
60 if (view->win_win == nullptr) {
61 ssnprintf(em0, MAXLEN - 1, "newwin(LINES, COLS, 0, 0) failed in init_view_full_screen");
63 return -1;
64 }
65 view->win_pan = new_panel(view->win_win);
66 wbkgrnd(view->win_win, &CC_NT);
67
68 // -------------------> 2. LNNO <-------------------
69 view->lnno_win = derwin(view->win_win, LINES - 1, COLS, 0, 0);
70 if (view->lnno_win == nullptr) {
71 ssnprintf(em0, MAXLEN - 1, "derwin(view->win_win, LINES - 1, COLS, 0, 0) failed in init_view_full_screen");
73 return -1;
74 }
75 view->lnno_pan = new_panel(view->lnno_win);
76 wbkgrnd(view->lnno_win, &CC_LN);
77 keypad(view->lnno_win, false);
78 idlok(view->lnno_win, false);
79 idcok(view->lnno_win, false);
80 scrollok(view->lnno_win, true);
81 wsetscrreg(view->lnno_win, 0, view->scroll_lines - 1);
82
83 // -------------------> 3. CMDLN <-------------------
84 view->cmdln_win = derwin(view->win_win, 1, COLS, LINES - 1, 0);
85 if (view->cmdln_win == nullptr) {
86 ssnprintf(em0, MAXLEN - 1, "derwin(view->win_win, 1, COLS, LINES - 1, 0) failed in init_view_full_screen");
88 return -1;
89 }
90 view->cmdln_pan = new_panel(view->cmdln_win);
91 wbkgrnd(view->cmdln_win, &CC_NT);
92 keypad(view->cmdln_win, true);
93 idlok(view->cmdln_win, false);
94 idcok(view->cmdln_win, false);
95 scrollok(view->cmdln_win, false);
96
97 // view->pad_container_win = derwin(view->win_win, LINES - 1, COLS -
98 // view->ln_win_cols, 0, view->ln_win_cols);
99 // if (view->pad_container_win == nullptr) {
100 // ssnprintf(em0, MAXLEN - 1,
101 // "derwin(view->win_win, LINES - 1, COLS - view->ln_win_cols,
102 // 0, view->ln_win_cols) failed in init_view_full_screen");
103 // Perror(em0);
104 // return -1;
105 // }
106 // view->pad_container_pan = new_panel(view->pad_container_win);
107 // -------------------> 4. PAD <-------------------
108 view->pad = newpad(LINES - 1, PAD_COLS - 1);
109 if (view->pad == nullptr) {
110 ssnprintf(em0, MAXLEN - 1, "newpad(LINES - 1, PAD_COLS - 1) failed in init_view_full_screen");
112 return -1;
113 }
114 view->pad_view_win = subpad(view->pad, LINES - 1, PAD_COLS - 1, 0, 0);
115 immedok(view->pad, true);
116 if (view->pad_view_win == nullptr) {
118 "subpad(view->pad, LINES - 1, COLS - view->ln_win_cols, 0, 0) failed in init_view_full_screen");
120 return -1;
121 }
122 view->pad_view_pan = new_panel(view->pad_view_win);
123 wbkgrnd(view->pad, &CC_NT);
124 keypad(view->pad, true);
125 keypad(view->pad, true);
126 idlok(view->pad, false);
127 idcok(view->pad, false);
128 scrollok(view->pad, true);
129 wsetscrreg(view->pad, 0, view->scroll_lines - 1);
130 return 0;
131}
132/** @brief Resize the full screen view and its components.
133 @ingroup window_support
134 @param init Pointer to the Init structure containing view settings.
135 @details This function resizes the full screen view and its components,
136 including the command line window, line number window, and main content pad.
137 It also recalculates the dimensions for the full screen mode and updates the
138 scroll regions accordingly.
139 */
140void view_full_screen_resize(Init *init) {
141 erase();
142 View *view = init->view;
144 mvwin(view->cmdln_win, view->lines - 1, 0);
145 wresize(view->cmdln_win, 1, view->cols);
146 wresize(view->lnno_win, view->ln_win_lines - 1, view->ln_win_cols);
147 wsetscrreg(view->lnno_win, 0, view->scroll_lines - 1);
148 wresize(view->pad, view->lines - 1, PAD_COLS);
149 wsetscrreg(view->pad, 0, view->lines - 1);
150}
151/** @brief Calculate the dimensions for full screen mode.
152 @ingroup init_view
153 @details This function calculates the dimensions for the full screen mode of
154 the C-Menu View. It retrieves the maximum dimensions of the standard screen
155 and sets the view parameters accordingly. It also resizes the line number
156 window and command line window based on the new dimensions.
157 @param init Pointer to the Init structure containing view settings.
158 */
160 View *view = init->view;
161 getmaxyx(stdscr, view->lines, view->cols);
162 view->ln_win_lines = view->lines;
163 view->ln_win_cols = 8;
164 view->scroll_lines = view->lines - 1;
165 view->h_shift = view->cols / 3;
166#ifdef DEBUG_RESIZE
167 char file[MAXLEN];
168 ssnprintf(
169 em0, MAXLEN - 1,
170 "%s:%d view->lines=%d, view->cols=%d, view->maxrows=%d, view->maxcols=%d",
171 __FILE__, __LINE__,
172 view->lines, view->cols, view->smaxrow, view->smaxcol);
173 write_cmenu_log_nt(em0);
174#endif
175 view->cmd_line = 0;
176 view->pminrow = 0;
177 view->pmincol = 0;
178 view->sminrow = 0;
179 view->smincol = view->ln_win_cols;
180 view->smaxrow = view->lines - 1;
181 view->smaxcol = view->cols - 1;
182 view->ln = view->page_top_ln + view->scroll_lines;
183 view->page_bot_ln = view->ln;
184}
185
186/** @brief Initialize the C-Menu View in box window mode.
187 @ingroup init_view
188 @param init Pointer to the Init structure containing view settings.
189 @return 0 on success, -1 on failure.
190 @details sets up the view structure for box window mode, adjusts dimensions
191 based on screen size, and creates a new pad for the view. It also configures
192 various parameters such as scroll lines, command line position, and tab size.
193 */
194int init_view_boxwin(Init *init) {
195 View *view = init->view;
196 if (view->tab_stop <= 0)
197 view->tab_stop = TABSIZE;
198 set_tabsize(view->tab_stop);
199 view->f_full_screen = false;
201 // -------------------> 1. BOX <-------------------
202 view->box_win = newwin(view->lines + 2, view->cols + 2, view->begy, view->begx);
203 if (view->box_win == nullptr) {
204 ssnprintf(em0, MAXLEN - 1, "view->box_win: lines=%d, cols=%d, begy=%d, begx=%d",
205 view->lines + 2, view->cols + 2, view->begy, view->begx);
207 return -1;
208 }
209 view->box_pan = new_panel(view->box_win);
210 wbkgrnd(view->box_win, &CC_BOX);
211 wbkgrndset(view->box_win, &CC_BOX);
212#ifdef DEBUG_RESIZE
213 ssnprintf(em0, MAXLEN - 1,
214 "%s:%d init BOX: lines=%d, cols=%d, begy=%d, begx=%d",
215 __FILE__, __LINE__, view->lines + 2, view->cols + 2, view->begy, view->begx);
216 write_cmenu_log_nt(em0);
217#endif
218 wborder_set(view->box_win, &ls, &rs, &ts, &bs, &tl, &tr, &bl, &br);
219
220 // -------------------> 2. WIN <-------------------
221 view->win_win = derwin(view->box_win, view->lines, view->cols, 1, 1);
222 if (view->win_win == nullptr) {
223 ssnprintf(em0, MAXLEN - 1, "%s:%d WIN: lines=%d, cols=%d, begy=%d, begx=%d",
224 __FILE__, __LINE__, view->lines, view->cols, 1, 1);
226 return -1;
227 }
228 view->win_pan = new_panel(view->win_win);
229 wbkgrnd(view->win_win, &CC_NT);
230 wbkgrndset(view->win_win, &CC_NT);
231 // -------------------> 3. CMDLN <-------------------
232 view->cmdln_win = derwin(view->win_win, 1, view->cols, view->lines - 1, 0);
233 if (view->cmdln_win == nullptr) {
234 ssnprintf(em0, MAXLEN - 1, "%s:%d CMDLN: lines=%d, cols=%d, begy=%d, begx=%d",
235 __FILE__, __LINE__, 1, view->cols, view->lines - 1, 0);
237 return -1;
238 }
239 view->cmdln_pan = new_panel(view->cmdln_win);
240 wbkgrnd(view->cmdln_win, &CC_NT);
241 wbkgrndset(view->cmdln_win, &CC_NT);
242 keypad(view->cmdln_win, true);
243 idlok(view->cmdln_win, false);
244 idcok(view->cmdln_win, false);
245 scrollok(view->cmdln_win, false);
246
247 // -------------------> 4. LNNO <-------------------
248 view->lnno_win = derwin(view->win_win, view->lines - 1, view->ln_win_cols, 0, 0);
249 if (view->lnno_win == nullptr) {
250 ssnprintf(em0, MAXLEN - 1, "%s:%d LNNO: lines=%d, cols=%d, begy=%d, begx=%d",
251 __FILE__, __LINE__, view->lines - 1, view->ln_win_cols, 0, 0);
253 return -1;
254 }
255 view->lnno_pan = new_panel(view->lnno_win);
256 wbkgrnd(view->lnno_win, &CC_LN);
257 wbkgrndset(view->lnno_win, &CC_LN);
258 keypad(view->lnno_win, false);
259 idlok(view->lnno_win, false);
260 idcok(view->lnno_win, false);
261 scrollok(view->lnno_win, true);
262 wsetscrreg(view->lnno_win, 0, view->scroll_lines);
263
264 // -------------------> 5. PAD CONTAINER <---------
265 // view->pad_container_win = derwin(view->win_win, view->lines - 1,
266 // view->cols - view->ln_win_cols, 0, view->ln_win_cols);
267 // if (view->pad_container_win == nullptr) {
268 // ssnprintf(em0, MAXLEN - 1,
269 // "derwin(view->win_win, view->lines - 1, view->cols -
270 // view->ln_win_cols, 0, view->ln_win_cols) failed in
271 // init_view_full_screen");
272 // Perror(em0);
273 // return -1;
274 // }
275 // view->pad_container_pan = new_panel(view->pad_container_win);
276
277 // -------------------> 5. PAD <-------------------
278 view->pad = newpad(view->lines - 1, PAD_COLS - 1);
279 if (view->pad == nullptr) {
280 ssnprintf(em0, MAXLEN - 1, "newpad(view->lines - 1, PAD_COLS - 1) failed in init_view_full_screen");
282 return -1;
283 }
284 // view->pad = newpad(view->lines - 1, PAD_COLS - 1);
285
286 // -------------------> 5. PAD_VIEW <--------------
287 view->pad_view_win = subpad(view->pad,
288 view->lines - 1,
289 PAD_COLS - 1,
290 0,
291 0);
292 if (view->pad_view_win == nullptr) {
294 "%s:%d PAD: lines=%d, cols=%d, begy=%d, begx=%d",
295 __FILE__, __LINE__,
296 view->lines - 1,
297 view->cols - view->ln_win_cols,
298 0,
299 0);
301 return -1;
302 }
303 view->pad_view_pan = new_panel(view->pad_view_win);
304
305 // -----------------------------
306#ifdef DEBUG_LAYOUT
307 wbkgrnd(view->pad, &CC_GREEN);
308 wbkgrndset(view->pad, &CC_GREEN);
309#else
310 wbkgrnd(view->pad, &CC_NT);
311 wbkgrndset(view->pad, &CC_NT);
312#endif
313 scrollok(view->pad, true);
314 wsetscrreg(view->pad, 0, view->scroll_lines - 1);
315 return (0);
316}
317
318void destroy_view_win(Init *init) {
319 View *view = init->view;
320 if (!view)
321 return;
323 delwin(view->pad);
328 wnoutrefresh(stdscr);
329 update_panels();
330 doupdate();
331}
332void view_win_del(PANEL *pan, WINDOW *win) {
333 if (pan) {
334 del_panel(pan);
335 pan = nullptr;
336 delwin(win);
337 win = nullptr;
338 }
339}
340//------------------------------------------------------------------------------
341/** @brief Resize the current window and its box
342 @ingroup window_support
343 @param init Pointer to the Init structure containing view settings.
344 @details This function resizes the current window and its associated box
345 window to the specified number of lines and columns. */
346void view_boxwin_resize(Init *init) {
350 // initialize_line_table(init->view);
351}
352
353/** @brief Calculate the dimensions and position of the box window for C-Menu
354 View.
355 @ingroup init_view
356 @details This function calculates the dimensions and position of the box
357 window for the C-Menu View based on the screen size and any specified
358 parameters in the Init structure. It ensures that the box window fits within
359 the screen dimensions and adjusts its size and position accordingly.
360 @param init Pointer to the Init structure containing view settings.
361 */
363 int scr_lines, scr_cols;
364 View *view = init->view;
365
366 /** Use view->lines and view->cols if set, otherwise calculate based on
367 * screen size with some padding. Ensure the view fits within the screen
368 * dimensions. */
369
370 getmaxyx(stdscr, scr_lines, scr_cols);
371#ifdef DEBUG_RESIZE
372 ssnprintf(em0, MAXLEN - 1,
373 "%s:%d=%d calc lines=%d, cols=%d, begy=%d, begx=%d",
374 __FILE__, __LINE__, 526, view->lines, view->cols, view->begy, view->begx);
375 write_cmenu_log_nt(em0);
376#endif
377 if (view->lines == 0 && view->cols == 0 && view->begy == 0 && view->begx == 0) {
378 view->lines = scr_lines - 3;
379 view->cols = scr_cols - 2;
380 view->begy = 0;
381 view->begx = 0;
382 }
383 int lines = max(scr_lines / 10, 8);
384 view->lines = max(view->lines, lines);
385 if (view->lines > scr_lines - 3)
386 view->lines = scr_lines - 3;
387 if (view->lines + view->begy > scr_lines - 3)
388 view->begy = scr_lines - (view->lines + 3);
389
390 int cols = max(scr_cols / 3, 40);
391 view->cols = max(view->cols, cols);
392 if (view->cols > scr_cols - 2)
393 view->cols = scr_cols - 2;
394 if (view->cols + view->begx > scr_cols - 2)
395 view->begx = scr_cols - (view->cols + 2);
396
397 view->h_shift = view->cols / 3;
398 view->ln_win_lines = view->lines - 1;
399 if (view->f_ln)
400 view->ln_win_cols = 8;
401 else
402 view->ln_win_cols = 0;
403 view->scroll_lines = view->lines - 1;
404 view->cmd_line = 0;
405 view->pminrow = 0;
406 view->pmincol = 0;
407 view->sminrow = view->begy + 1;
408 view->smincol = view->begx + view->ln_win_cols + 1;
409 view->smaxrow = view->begy + view->lines;
410 view->smaxcol = view->begx + view->cols;
411 view->ln = view->page_top_ln + view->scroll_lines;
412 view->page_bot_ln = view->ln;
413#ifdef DEBUG_RESIZE
414 ssnprintf(em0, MAXLEN - 1,
415 "%s:%d calc BOX lines=%d, cols=%d, begy=%d, begx=%d",
416 __FILE__, __LINE__, view->lines + 2, view->cols + 2, view->begy, view->begx);
417 write_cmenu_log_nt(em0);
418 ssnprintf(em0, MAXLEN - 1,
419 "%s:%d calc WIN lines=%d, cols=%d, begy=%d, begx=%d",
420 __FILE__, __LINE__, view->lines, view->cols, 1, 1);
421 write_cmenu_log_nt(em0);
422 ssnprintf(em0, MAXLEN - 1,
423 "%s:%d calc CMDLN lines=%d, cols=%d, begy=%d, begx=%d",
424 __FILE__, __LINE__, 1, view->cols, view->lines - 1, 1);
425 write_cmenu_log_nt(em0);
426 ssnprintf(em0, MAXLEN - 1,
427 "%s:%d calc LNNO lines=%d, cols=%d, begy=%d, begx=%d",
428 __FILE__, __LINE__, view->lines - 1, view->ln_win_cols, 0, 0);
429 write_cmenu_log_nt(em0);
430 ssnprintf(em0, MAXLEN - 1,
431 "%s:%d calc PAD lines=%d, cols=%d, begy=%d, begx=%d",
432 __FILE__, __LINE__, view->lines - 1, view->cols - view->ln_win_cols, 0, view->ln_win_cols);
433 write_cmenu_log_nt(em0);
434
435#endif
436}
437/** @brief Initialize the input for the C-Menu View.
438 @ingroup init_view
439 @param init Pointer to the Init structure containing view settings.
440 @param file_name Name of the input file or "-" for standard input.
441 @return 0 on success, -1 on failure.
442 @details This function initializes the input for the C-Menu View. It handles
443 both regular files and standard input, setting up pipes if necessary. It also
444 memory-maps the input file for efficient access and sets up the view structure
445 accordingly.
446 */
447int view_init_input(Init *init, char *file_name) {
448 struct stat sb;
449 int idx = 0;
450 pid_t pid = -1;
451 int pipe_fd[2];
452 int s_argc = 0;
453 char *s_argv[MAXARGS];
454 char tmp_str[MAXLEN];
455 View *view = init->view;
456 view->f_in_pipe = false;
457 if (strcmp(file_name, "-") == 0) {
458 file_name = "/dev/stdin";
459 view->f_in_pipe = true;
460 }
461 if (view->provider_cmd[0] != '\0') {
462 s_argc = str_to_args(s_argv, view->provider_cmd, MAXARGS - 1);
463 if (pipe(pipe_fd) == -1) {
464 Perror("pipe(pipe_fd) failed in init_view");
465 return -1;
466 }
467 // endwin();
468 if ((pid = fork()) == -1) {
469 Perror("fork() failed in init_view");
470 return -1;
471 }
472 if (pid == 0) { // Child
473 /** Prevent child process from writing to terminal */
474 int dev_null = open("/dev/null", O_WRONLY);
475 if (dev_null == -1) {
476 Perror("open(/dev/null) failed in init_pick child process");
477 exit(EXIT_FAILURE);
478 }
479 dup2(dev_null, STDERR_FILENO);
480 close(dev_null);
481 close(pipe_fd[P_READ]);
482 dup2(pipe_fd[P_WRITE], STDOUT_FILENO);
483 close(pipe_fd[P_WRITE]);
484 execvp(s_argv[0], s_argv);
485 strnz__cpy(tmp_str, "Can't exec view start cmd: ", MAXLEN - 1);
486 strnz__cat(tmp_str, s_argv[0], MAXLEN - 1);
487 Perror(tmp_str);
488 exit(EXIT_FAILURE);
489 }
490 // Back to parent
491 destroy_argv(s_argc, s_argv);
492 reset_prog_mode();
494 close(pipe_fd[P_WRITE]);
495 dup2(pipe_fd[P_READ], STDIN_FILENO);
496 view->in_fd = dup(STDIN_FILENO);
497 view->f_in_pipe = true;
498 } else {
499 if (view->f_in_pipe)
500 view->in_fd = dup(STDIN_FILENO);
501 else {
502 /*----------------------------------------------------------------------*/
503 /* Open the input file for reading and get its size. */
504 expand_tilde(file_name, MAXLEN - 1);
505 view->in_fd = open(file_name, O_RDONLY);
506 if (view->in_fd == -1) {
507 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__,
508 __LINE__ - 3);
509 ssnprintf(em1, MAXLEN - 1, "open %s", file_name);
510 strerror_r(errno, em2, MAXLEN);
512 return -1;
513 }
514 if (fstat(view->in_fd, &sb) == -1) {
515 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__,
516 __LINE__ - 1);
517 ssnprintf(em1, MAXLEN - 1, "fstat %s", file_name);
518 strerror_r(errno, em2, MAXLEN);
520 close(view->in_fd);
521 return -1;
522 }
523 view->file_size = sb.st_size;
524 if (view->file_size == 0) {
525 close(view->in_fd);
526 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__,
527 __LINE__ - 1);
528 ssnprintf(em1, MAXLEN - 1, "file %s is empty", file_name);
529 strerror_r(errno, em2, MAXLEN);
531 return -1;
532 }
533 if (!S_ISREG(sb.st_mode))
534 view->f_in_pipe = true;
535 }
536 /*----------------------------------------------------------------------*/
537 }
538 if (view->f_in_pipe) {
539 close(view->in_fd);
540 errno = 0;
541 view->in_fd = memfd_create("view_input", MFD_CLOEXEC);
542 if (view->in_fd < 0 || errno != 0) {
543 ssnprintf(em0, MAXLEN - 1, "memfd_create failed\n");
544 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
545 ssnprintf(em2, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
546 __LINE__ - 4, errno);
548 exit(EXIT_FAILURE);
549 }
550 char buf[VBUFSIZ];
551 ssize_t bytes_read = 0;
552 ssize_t bytes_written = 0;
553 while ((bytes_read = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
554 if ((bytes_written = write(view->in_fd, buf, bytes_read)) != bytes_read) {
555 abend(-1, "unable to write view->in_fd");
556 exit(EXIT_FAILURE);
557 }
558 }
559 if (fstat(view->in_fd, &sb) == -1) {
560 ssnprintf(em0, MAXLEN - 1, "fstat(view->in_fd) failed\n");
561 ssnprintf(em1, MAXLEN - 1, "%s", strerror(errno));
562 ssnprintf(em2, MAXLEN - 1, "%s, line: %d, errno: %d", __FILE__,
563 __LINE__ - 4, errno);
565 exit(EXIT_FAILURE);
566 }
567 view->file_size = sb.st_size;
568 if (view->file_size == 0) {
569 close(view->in_fd);
570 strnz__cpy(tmp_str, "no standard input", MAXLEN - 1);
571 abend(-1, tmp_str);
572 exit(EXIT_FAILURE);
573 }
574 waitpid(-1, nullptr, 0);
575 }
576 view->buf =
577 mmap(nullptr, view->file_size, PROT_READ, MAP_PRIVATE, view->in_fd, 0);
578 if (view->buf == MAP_FAILED) {
579 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 2);
580 ssnprintf(em1, MAXLEN - 1, "mmap %s", file_name);
581 strerror_r(errno, em2, MAXLEN);
583 close(view->in_fd);
584 return -1;
585 }
586 close(view->in_fd);
587 SIO *sio = init->sio;
588 stdio_names(stdio_names_str, "init_view.c 673");
589 stdio_fdnames(stdio_names_str, "init_view.c 674");
590 dup2(sio->stdin_fd, STDIN_FILENO);
591 stdio_names(stdio_names_str, "init_view.c 673");
592 stdio_fdnames(stdio_names_str, "init_view.c 674");
593 view->file_size = sb.st_size;
595 view->buf_curr_ptr = view->buf;
596 if (view->cmd_all[0] != '\0')
598 for (idx = 0; idx < NMARKS; idx++)
599 view->mark_tbl[idx] = NULL_POSITION;
600 strnz__cpy(view->cur_file_str, file_name, MAXLEN - 1);
602 return 0;
603}
#define P_READ
Definition common.h:50
void destroy_view_win(Init *)
Definition init_view.c:318
ViewStack view_stack
Definition init_view.c:34
#define P_WRITE
Definition common.h:51
cchar_t tl
Definition cm.h:501
char em1[MAXLEN]
Definition dwin.c:176
#define MAXARGS
Definition cm.h:48
cchar_t br
Definition cm.h:501
cchar_t CC_NT
Definition dwin.c:204
cchar_t rs
Definition cm.h:501
char * stdio_names(char *, char *)
Definition futil.c:1064
cchar_t CC_BOX
Definition dwin.c:199
cchar_t bl
Definition cm.h:501
char stdio_names_str[MAXLEN]
Definition futil.c:134
char em0[MAXLEN]
Definition dwin.c:175
cchar_t ts
Definition cm.h:501
char * stdio_fdnames(char *, char *)
Definition futil.c:1089
cchar_t tr
Definition cm.h:501
cchar_t ls
Definition cm.h:631
char em2[MAXLEN]
Definition dwin.c:177
cchar_t bs
Definition cm.h:501
cchar_t CC_LN
Definition dwin.c:201
#define max(a, b)
max macro evaluates two expressions, returning greatest result.
Definition cm.h:82
#define NMARKS
Definition view.h:26
#define VBUFSIZ
Definition view.h:30
#define PAD_COLS
Definition view.h:32
#define NULL_POSITION
Definition view.h:29
void view_win_del(PANEL *, WINDOW *)
Definition init_view.c:332
#define MAXLEN
Definition curskeys.c:15
int border_title(WINDOW *, char *)
Draw a box with a title around the specified window.
Definition dwin.c:1327
void restore_wins()
Restore all windows after a screen resize.
Definition dwin.c:1225
void view_full_screen_resize(Init *)
Resize the full screen view and its components.
Definition init_view.c:140
void view_boxwin_resize(Init *)
Resize the current window and its box.
Definition init_view.c:346
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1526
void abend(int, char *)
Abnormal program termination.
Definition dwin.c:2018
int display_error(char *, char *, char *, char *)
Display an error message window or print to stderr.
Definition dwin.c:1467
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:544
int destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
Definition futil.c:494
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:420
bool expand_tilde(char *, int)
Replaces "~/" in string with the user's home directory.
Definition futil.c:970
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
Definition futil.c:573
bool base_name(char *, char *)
Returns the base name of a file specification.
Definition futil.c:1123
int str_to_args(char **, char *, int)
Converts a string into an array of argument strings.
Definition futil.c:440
void view_calc_boxwin_dimensions(Init *)
Calculate the dimensions and position of the box window for C-Menu View.
Definition init_view.c:362
int init_view_full_screen(Init *)
Initialize C-Menu View in full screen mode.
Definition init_view.c:49
int init_view_boxwin(Init *)
Initialize the C-Menu View in box window mode.
Definition init_view.c:194
void view_calc_full_screen_dimensions(Init *)
Calculate the dimensions for full screen mode.
Definition init_view.c:159
int view_init_input(Init *, char *)
Initialize the input for the C-Menu View.
Definition init_view.c:447
SIO * sio
Definition common.h:114
View * view
Definition common.h:188
int stdin_fd
Definition cm.h:860
char provider_cmd[MAXLEN]
Definition view.h:57
int smaxrow
Definition view.h:128
char * buf
Definition view.h:161
int in_fd
Definition view.h:154
WINDOW * pad
Definition view.h:82
off_t page_top_ln
Definition view.h:178
int smincol
Definition view.h:126
off_t prev_file_pos
Definition view.h:147
PANEL * pad_view_pan
Definition view.h:84
PANEL * lnno_pan
Definition view.h:77
char cmd[MAXLEN]
Definition view.h:59
off_t ln
Definition view.h:172
WINDOW * lnno_win
Definition view.h:76
bool f_in_pipe
Definition view.h:153
WINDOW * cmdln_win
Definition view.h:78
char * buf_curr_ptr
Definition view.h:162
int smaxcol
Definition view.h:130
int cols
Definition view.h:54
bool f_full_screen
Definition view.h:104
int ln_win_cols
Definition view.h:170
bool f_ln
Definition view.h:171
off_t mark_tbl[NMARKS]
Definition view.h:152
int lines
Definition view.h:53
WINDOW * win_win
Definition view.h:74
int pminrow
Definition view.h:122
int pmincol
Definition view.h:123
off_t file_size
Definition view.h:145
char cur_file_str[MAXLEN]
Definition view.h:109
int sminrow
Definition view.h:124
int cmd_line
Definition view.h:120
PANEL * box_pan
Definition view.h:73
int tab_stop
Definition view.h:91
off_t page_bot_ln
Definition view.h:179
char title[MAXLEN]
Definition view.h:62
char cmd_all[MAXLEN]
Definition view.h:60
int begy
Definition view.h:55
int h_shift
Definition view.h:92
PANEL * win_pan
Definition view.h:75
int scroll_lines
Definition view.h:119
PANEL * cmdln_pan
Definition view.h:79
int ln_win_lines
Definition view.h:169
char file_name[MAXLEN]
Definition view.h:99
int begx
Definition view.h:56
WINDOW * pad_view_win
Definition view.h:83
WINDOW * box_win
Definition view.h:72