2
3
4
5
6
7
8
9
12
13
14
23#include <sys/sysmacros.h>
33
34
35
36
37
38
39
40
41
42
43
44
54 ssnprintf(em0, MAXLEN - 1,
55 "init_view_full_screen(): lines=%d, cols=%d, "
56 "ln_win_lines=%d, ln_win_cols=%d, "
58 view->lines, view->cols, view->ln_win_lines, view->ln_win_cols,
71 immedok(view->cmdln_win, true);
83 immedok(view->ln_win, true);
93 abend(-1
, "init_view_full_screen: newpad() failed");
103 immedok(view->pad, true);
108
109
110
111
112
113
114
117 wnoutrefresh(stdscr);
133
134
135
136
137
138
139
149 "view->lines=%d, view->cols=%d, view->maxrows=%d, view->maxcols=%d",
150 view->lines, view->cols, view->smaxrow, view->smaxcol);
151 write_cmenu_log_nt(em0);
164
165
166
167
168
169
170
171
181 if (title !=
nullptr && title[0] !=
'\0')
189 ssnprintf(em0, MAXLEN - 1,
190 "init_view_boxwin(): view->box: begy=%d, begx=%d, lines=%d, "
192 view->begy, view->begx, view->lines + 2, view->cols + 2,
194 write_cmenu_log_nt(em0);
217 immedok(view->cmdln_win, true);
222 ssnprintf(em0, MAXLEN - 1,
223 "init_view_boxwin(): view->ln_win: begy=%d, begx=%d, lines=%d, "
224 "cols=%d, scroll_lines=%d",
225 view->begy, view->begx, view->ln_win_lines, view->ln_win_cols,
227 write_cmenu_log_nt(em0);
241 immedok(view->ln_win, true);
253 immedok(view->pad, true);
258
259
260
261
262
263
264
268 wnoutrefresh(stdscr);
272 ssnprintf(em0, MAXLEN - 1,
"view->box: begy=%d, begx=%d, lines=%d, cols=%d",
273 view->begy, view->begx, view->lines + 2, view->cols + 2);
274 write_cmenu_log_nt(em0);
281 if (title !=
nullptr && *title !=
'\0') {
288 int len = strlen(title);
295 int s = strlen(title);
303 ssnprintf(em0, MAXLEN - 1,
304 "view->cmdln_win: begy=%d, begx=%d, lines=%d, cols=%d",
305 view->begy + view->lines, view->begx + 1, 1, view->cols);
306 write_cmenu_log_nt(em0);
312 ssnprintf(em0, MAXLEN - 1,
313 "(285)view->ln_win: begy=%d, begx=%d, lines=%d, cols=%d, "
315 view->begy + 1, view->begx + 1, view->ln_win_lines + 2,
316 view->ln_win_cols, view->scroll_lines);
317 write_cmenu_log_nt(em0);
331 immedok(view->ln_win, true);
348 ssnprintf(em0, MAXLEN - 1,
349 "view->pad: sminrow=%d, smincol=%d, smaxrow=%d, smaxcol=%d",
350 view->sminrow, view->smincol, view->smaxrow, view->smaxcol);
351 write_cmenu_log_nt(em0);
357
358
359
360
361
362
363
364
365
366
368 int scr_lines, scr_cols;
370 getmaxyx(stdscr, scr_lines, scr_cols);
371 int len = strlen(title);
374
375
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
452 if (strcmp(file_name,
"-") == 0) {
453 file_name =
"/dev/stdin";
458 if (pipe(pipe_fd) == -1) {
459 Perror("pipe(pipe_fd) failed in init_view");
462 if ((pid = fork()) == -1) {
463 Perror("fork() failed in init_view");
468 dup2(pipe_fd[
P_WRITE], STDOUT_FILENO);
470 execvp(s_argv[0], s_argv);
479 dup2(pipe_fd[
P_READ], STDIN_FILENO);
480 view
->in_fd = dup(STDIN_FILENO);
484 view
->in_fd = dup(STDIN_FILENO);
489 view
->in_fd = open(file_name, O_RDONLY);
498 if (fstat(view
->in_fd, &sb) == -1) {
517 if (!S_ISREG(sb.st_mode))
523 char tmp_filename[] =
"/tmp/view_XXXXXX";
525 ssize_t bytes_read = 0;
526 ssize_t bytes_written = 0;
528 view
->in_fd = mkstemp(tmp_filename);
533 unlink(tmp_filename);
538 struct timeval timeout;
543 FD_SET(STDIN_FILENO, &read_fds);
545 timeout.tv_usec = 200000;
546 ready = select(STDIN_FILENO + 1, &read_fds,
nullptr,
nullptr, &timeout);
554 while (ready == 0 && remaining > 0 &&
cmd_key != KEY_F(9)) {
559 FD_SET(STDIN_FILENO, &read_fds);
573
582 Perror("Error waiting for view input");
585
593 Perror("Timeout waiting for view input");
596
603 if (ready == 1 && !FD_ISSET(STDIN_FILENO, &read_fds)) {
604 Perror("Unexpected error waiting for view input");
607
615 while ((bytes_read = read(STDIN_FILENO, buf,
sizeof(buf))) > 0) {
616 if (write(view
->in_fd, buf, bytes_read) != bytes_read) {
620 bytes_written += bytes_read;
622 if (bytes_written == 0) {
626 if (fstat(view
->in_fd, &sb) == -1) {
643 if (view
->buf == MAP_FAILED) {
657 for (idx = 0; idx <
NMARKS; idx++)
bool waitpid_with_timeout(pid_t pid, int timeout)
void view_win_resize(Init *, char *)
Resize the current window and its box, and update the title.
int box_new(int, int, int, int, char *, bool)
Create a new window with optional box and title.
void view_full_screen_resize(Init *)
Resize the full screen view and its components.
void cbox(WINDOW *)
Draw a box around the specified window.
bool wait_destroy(Chyron *)
Destroy the waiting message window and chyron.
int wait_continue(WINDOW *, Chyron *, int)
Update the waiting message with remaining time and check for user input.
WINDOW * wait_mk_win(Chyron *, char *)
Display a popup waiting message.
int Perror(char *)
Display a simple error message window or print to stderr.
int display_error(char *em0, char *em1, char *em2, char *em3)
Display an error message window or print to stderr.
void abend(int, char *)
Abnormal program termination.
Chyron * wait_mk_chyron()
Create a Chyron struct for the waiting message.
void destroy_argv(int argc, char **argv)
Deallocates memory allocated for argument strings in argv.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
bool expand_tilde(char *, int)
Replace Leading Tilde With Home Directory.
bool base_name(char *, char *)
Returns the base name of a file specification.
int str_to_args(char **, char *, int)
Converts a string into an array of argument strings.
void view_calc_win_dimensions(Init *, char *title)
Calculate the dimensions and position of the box window for C-Menu View.
int init_view_full_screen(Init *)
Initialize C-Menu View in full screen mode.
int init_view_boxwin(Init *, char *)
Initialize the C-Menu View in box window mode.
void view_calc_full_screen_dimensions(Init *)
Calculate the dimensions for full screen mode.
int view_init_input(View *, char *)
Initialize the input for a C-Menu View.
char provider_cmd[MAXLEN]
char cur_file_str[MAXLEN]