2
3
4
5
6
7
8
11
12
42 "vi",
"vim",
"nano",
"nvim",
43 "pico",
"emacs",
"edit",
""};
46
47
48
49
50
51
52
53
54
55
56
57
58
59int init_pick(Init *init,
int argc,
char **argv,
int begy,
int begx) {
76 Perror("pipe(pipe_fd) failed in init_pick");
79 if ((pid = fork()) == -1) {
80 Perror("fork() failed in init_pick");
85
92 execvp(s_argv[0], s_argv);
95 m -= strlen(s_argv[0]);
101
109 strcmp(pick
->in_spec,
"/dev/stdin") == 0) {
111 pick
->in_fp = fdopen(STDIN_FILENO,
"rb");
125 if (sb.st_size == 0) {
146 struct timeval timeout;
155 int in_fd = fileno(pick
->in_fp);
157 FD_SET(in_fd, &read_fds);
169 while (ready == 0 && remaining > 0 &&
cmd_key != KEY_F(9)) {
174 FD_SET(in_fd, &read_fds);
187
197 Perror("Error waiting for pick input");
200
209 Perror("Timeout waiting for pick input");
212
220 if (ready == 1 && !FD_ISSET(in_fd, &read_fds)) {
221 Perror("Unexpected error waiting for pick input");
224
243 keypad(pick
->win, true);
246 Perror("No pick objects available");
257
258
259
260
261
262
263
264
279 for (i = 1; i < pick
->argc; i++)
290
291
292
293
294
295
296
297
298
299
303 int maxy, maxx, win_maxy, win_maxx;
304 int tbl_max_cols, pg_max_objs;
307 getmaxyx(stdscr, maxy, maxx);
309
319 pg_max_objs = win_maxy * tbl_max_cols;
365 mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED,
nullptr);
383
384
385
386
387
388
389
407
408
409
410
411
412
413
414
415
416
417
420 int display_tbl_page;
421 bool f_no_reset_cmd_key;
426 tcflush(
tty_fd, TCIFLUSH);
427 f_no_reset_cmd_key = false;
454
490
503
544
567
576
589 f_no_reset_cmd_key = true;
595 if (!f_no_reset_cmd_key)
601
602
603
604
605
606
607
611 wmove(pick
->win, y, 0);
612 wclrtoeol(pick
->win);
617 for (y = 0; y < pick
->pg_lines; y++, pidx++) {
620 mvwaddstr(pick
->win, y, pick
->x - 1,
"*");
630
631
632
633
634
635
636
637
638
644 wattron(pick
->win, WA_REVERSE);
647 wattroff(pick
->win, WA_REVERSE);
651
652
653
654
655
656
657
658
659
660
669
670
671
672
673
674
675
676
677
678
679
680
694
695
705
706
707
708
709
710
711
712
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
776 bool f_append_args = false;
784 if (len > 1 &&
pick->cmd[len - 1] ==
'\"') {
794 if (tmp_str[0] !=
'\0')
799 eargv[eargc++] = strdup(tmp_str);
801 f_append_args = false;
805 if (strstr(eargv[i],
"%%") !=
nullptr) {
807 f_append_args = true;
817 if (f_append_args == true) {
818 if (tmp_str[0] !=
'\0')
826 if (f_append_args == true) {
832 if (out_s ==
nullptr || out_s[0] ==
'\0') {
839 Perror("rep_substring() failed in exec_objects");
843 eargv[eargx] = strdup(out_s);
858 tok = strtok_r(tmp_str,
" ", &sp);
861 if (tmp_str[0] !=
'\0' &&
862 (strcmp(tmp_str,
"view") == 0 || strcmp(tmp_str,
"view") == 0)) {
864
869 if (title[0] !=
'\0')
883 if ((pid = fork()) == -1) {
891 Perror("fork() failed in exec_objects");
896 execvp(eargv[0], eargv);
898
919
920
921
922
923
924
925
926
927
947
948
949
950
951
952
int popup_view(Init *, int, char **, int, int, int, int)
#define min(x, y)
min macro evaluates two expressions, returning least result
#define max(a, b)
max macro evaluates two expressions, returning greatest result.
char const pagers_editors[12][10]
bool waitpid_with_timeout(pid_t pid, int timeout)
void display_chyron(WINDOW *win, Chyron *chyron, int line, int col)
void set_chyron_key(Chyron *, int, char *, int)
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
void restore_wins()
Restore all windows after a screen resize.
int win_new(int, int, int, int, char *, int)
Create a new window with optional box and title.
WINDOW * win_del()
Delete the current window and its associated box window.
void mvwaddstr_fill(WINDOW *, int, int, char *, int)
For lines shorter than their display area, fill the rest with spaces.
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
Chyron * new_chyron()
Create and initialize Chyron structure.
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.
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 strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
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
char * rep_substring(const char *, const char *, const char *)
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
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.
Pick * new_pick(Init *, int, char **, int, int)
Create and initialize Pick structure.
Pick * destroy_pick(Init *init)
Destroy Pick structure.
void save_object(Pick *, char *)
Saves a string as an object in the pick structure.
void toggle_object(Pick *)
Toggles the selection state of the currently selected object in pick window.
int init_pick(Init *, int, char **, int, int)
Initializes pick structure and opens pick input file or pipe.
void unreverse_object(Pick *)
Unreverses the display of the currently selected object in pick window.
int output_objects(Pick *)
Outputs selected objects to specified output file.
void deselect_object(Pick *)
Deselects the currently selected object in pick window.
int read_pick_input(Init *)
Reads pick input from file pointer and saves objects into pick structure.
void reverse_object(Pick *)
Reverses the display of the currently selected object in pick window.
int pick_engine(Init *)
Initializes pick interface, calculates window size and position, and enters picker loop.
int picker(Init *)
Main loop to handle user input and interactions for pick interface.
void display_page(Pick *)
Displays current page of objects in pick window.
void display_pick_help(Init *)
Displays the help screen for the pick interface using view.
int open_pick_win(Init *)
Initializes the pick window based on the parameters specified in the Pick structure.
int exec_objects(Init *)
Executes specified command with selected objects as arguments.
bool restore_curses_tioctl()
restore_curses_tioctl() - restore curses terminal settings
void sig_prog_mode()
Set up signal handlers for interrupt signals.
bool f_selected[OBJ_MAXCNT]
char provider_cmd[MAXLEN]