2
3
4
5
6
7
8
11
12
27int picker(Init *,
char *field);
49 "vi",
"vim",
"nano",
"nvim",
50 "pico",
"emacs",
"edit",
""};
53
54
55
56
57
58
59
60
61
62
63
64
65
66int init_pick(Init *init,
int argc,
char **argv, uint by, uint bx) {
80 Perror("pipe(pipe_fd) failed in init_pick");
84 if ((pid = fork()) == -1) {
85 Perror("fork() failed in init_pick");
90 int dev_null = open(
"/dev/null", O_WRONLY);
92 Perror("open(/dev/null) failed in init_pick child process");
95 dup2(dev_null, STDERR_FILENO);
103 execvp(s_argv[0], s_argv);
110
119 pick
->in_fp = fdopen(STDIN_FILENO,
"rb");
132 if (sb.st_size == 0) {
153 waitpid(pid,
nullptr, 0);
160 Perror("No pick objects available");
192
193
194
195
196
197
203 if (view
->buf !=
nullptr) {
212
213
214
215
216
217
218
219
232 for (i = 1; i < pick
->argc; i++)
242
243
244
245
246
247
248
249
250
254 uint whitespace_ratio = 15;
256 uint pick_ratio = 50;
257 uint tbl_max_cols, pg_max_objs;
258 bool f_processed =
false;
268 pick
->begy = (maxy * whitespace_ratio) / 200;
269 usable_lines = maxy - (maxy * whitespace_ratio) / 100;
270 usable_lines -= pick
->begy;
274 pick
->lines = usable_lines * pick_ratio / 100;
293 pg_max_objs = pick
->lines * tbl_max_cols;
318 Perror("Failed to open pick window");
360
361
362
363
364
365
366
367
395
396
397
398
399
400
401
419
420
421
422
423
424
425
453
454
455
456
457
458
459
460
467 if (s ==
nullptr || s[0] ==
'\0' || strstr(pick
->m_object[pick
->m_idx], s) !=
nullptr) {
476
477
478
479
480
481
482
483
484
503
504
505
506
507
508
509
510
511
512
544
545
546
547
548
549
550
551
552
553
554
555
570
571
587 SIO *sio = init
->sio;
594
595
596
597
598
599
600
601
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
658 char tmp_str[
MAXLEN] = {
'\0'};
665 bool f_append_objects =
false;
669 if (pick
->cmd[0] ==
'\0')
671 if (pick
->cmd[0] ==
'\\' || pick
->cmd[0] ==
'\"') {
672 size_t len = strlen(pick
->cmd);
673 if (len > 1 && pick
->cmd[len - 1] ==
'\"') {
675 pick
->cmd[len - 2] =
'\0';
681 for (i = 0; i < pick
->d_cnt; i++) {
683 if (tmp_str[0] !=
'\0')
688 eargv[eargc++] = strdup(tmp_str);
690 f_append_objects =
false;
694 if (strstr(eargv[i],
"%%") !=
nullptr) {
696 f_append_objects =
true;
703 for (i = 0; i < pick
->d_cnt; i++) {
706 if (f_append_objects ==
true) {
707 if (tmp_str[0] !=
'\0')
715 if (f_append_objects ==
true) {
716 if (eargv[eargx] !=
nullptr) {
718 eargv[eargx] =
nullptr;
721 if (out_s ==
nullptr || out_s[0] ==
'\0') {
724 if (eargv[i] !=
nullptr)
728 Perror("rep_substring() failed in exec_objects");
732 eargv[eargx] = strdup(out_s);
733 if (out_s !=
nullptr) {
740 eargv[eargc] =
nullptr;
743 tok = strtok_r(tmp_str,
" ", &sav_ptr);
746 if (tmp_str[0] !=
'\0' && (strcmp(tmp_str,
"view") == 0 || strcmp(tmp_str,
"view") == 0)) {
748
753 if (title[0] !=
'\0')
761 if (eargv[i] !=
nullptr)
769 if ((pid = fork()) == -1) {
773 if (eargv[i] !=
nullptr)
777 Perror("fork() failed in exec_objects");
779 }
else if (pid == 0) {
788 execvp(eargv[0], eargv);
792 waitpid(pid,
nullptr, 0);
799
800
801
802
803
804
805
806
807
812 int split_win_lines = 2;
814 ssnprintf(tmp_str
, MAXLEN - 1
, "surface_split_box_win_new(%d, %d, %d, %d, %d, %d, %s) failed",
831
832
833
834
835
836
850 eargv[eargc++] = strdup(
"view");
851 eargv[eargc++] = strdup(
"-Nf");
852 eargv[eargc++] = strdup(tmp_str);
853 eargv[eargc] =
nullptr;
865
866
867
868
869
870
871
872
873
874
875
876
877
879 bool f_insert =
false;
883 char *accept_s = field;
887 char *fend = field + flen;
888 char *str_end = field + strlen(field);
892 char *prev_ptr = prev_field;
893 char view_file[
MAXLEN] = {
'\0'};
903 ui_mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION);
915
916
1020
1049
1118
1136
1161
1170
1184 event
.y = event
.x = -1;
1195
1196
1214 if (accept_s !=
nullptr && accept_s[0] !=
'\0') {
1243 pos = col + strlen(accept_s);
1298 while (*ptr !=
'\0')
1300 pos = col + (ptr - accept_s);
1341 if (ptr > accept_s) {
1354 if (ptr == accept_s) {
1369 if (ptr > accept_s) {
1378 if (ptr < fend && ptr <= str_end) {
1387 if (event
.x < col || event
.x >= col + flen) {
1392 fend = accept_s + flen;
1393 str_end = accept_s + strlen(accept_s);
1394 ptr = accept_s + (pos - col);
1395 ptr =
min(ptr, str_end);
1396 pos = col + (ptr - accept_s);
1402 if (in_key <
' ' || in_key >
'~') {
1411 if (str_end < fend) {
1422 if (ptr < str_end) {
1425 }
else if (ptr == str_end) {
1442
1443
1444
1445
1446
1447
1448
1449
1450
1470 e = getenv(
"VIEW_HELP_FILE");
1471 if (e && e[0] !=
'\0') {
1476 "~/menuapp/help", R_OK
);
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1498 if (view
->buf !=
nullptr) {
1501 view
->buf =
nullptr;
int popup_view(Init *, int, char **, uint, uint, uint, uint)
instantiate a view popup window
size_t rtrim(char *)
Trims trailing spaces from string s in place.
char stdio_names_str[4096]
#define min(x, y)
min macro evaluates two expressions, returning least result
char * stdio_fdnames(char *, char *)
#define max(a, b)
max macro evaluates two expressions, returning greatest result.
int ui_cursor_move(UiSurface *s, uint w, uint y, uint x)
int ui_bkgdset(UiSurface *s, uint w, const UiCell *cell)
int ui_mice_enable(int mask)
int ui_mvwaddstr(UiSurface *s, uint w, uint y, uint x, const char *text)
int ui_setscrreg(UiSurface *s, uint w, uint top, uint bottom)
int ui_scrollok(UiSurface *s, uint w, bool enable)
int ui_mvwadd_wchnstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell, uint m)
void ui_surface_destroy(UiSurface *s)
UiSurface * ui_surface[UI_SFC_MAX]
int ui_werase(UiSurface *s, uint w)
void ui_get_screen_size(uint *lines, uint *cols)
int ui_wclrtoeol(UiSurface *s, uint w)
int ui_wscrl(UiSurface *s, uint w, int rows)
int ui_get_event_multi(UiSurface *s, uint w, UiEvent *ev, int timeout_ms)
int ui_curs_set(int visibility)
int ui_top_panel(UiSurface *s, uint w)
int ui_wnoutrefresh(UiSurface *s, uint w)
int ui_keypad(UiSurface *s, uint w, bool enable)
void ui_getmaxyx(UiSurface *s, uint w, uint *lines, uint *cols)
int ui_mvwaddstr_fill(UiSurface *s, uint w, uint y, uint x, const char *str, int m)
void end_pick_view(Init *)
char const pagers_editors[12][10]
void remove_right_angle(Pick *)
int process_config_file(char *, Init *)
void initialize_cells(SIO *sio)
Initialize local color variables and color pairs based on SIO settings.
int surface_split_box_win_new(uint wlines, uint wcols, uint split_y, uint split_x, uint wbegy, uint wbegx, char *wtitle)
int assign_chyron_win(Chyron *chyron, UiSurface *sfc, uint win, char *y)
int border_ysplit_text(UiSurface *sfc, char *text, uint separator_line)
Draw a box with a separator line and text around the specified window.
int cm_surface_destroy(UiSurface *sfc)
Destroy the most recently created surface.
int border_title(UiSurface *sfc, char *title)
Draw a box with a title around the specified window.
int Perror(char *emsg_str)
Display a simple error message window or print to stderr.
void abend(int ec, char *s)
Abnormal program termination.
void set_chyron_key_cb(Chyron *chyron, uint k, char *s, uint kc, UiCell cell_base)
Set chyron key with color pair (cp).
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
void compile_chyron(Chyron *chyron)
construct the chyron string from the chyron structure
int get_chyron_key(Chyron *chyron, uint x)
Get keycode from chyron.
Chyron * new_chyron()
Create and initialize Chyron structure.
void display_chyron(UiSurface *sfc, uint w, Chyron *chyron, uint line, uint col)
Display chyron on the specified line and column of the surface.
void set_chyron_key(Chyron *chyron, uint k, char *s, uint kc)
Set chyron key with default color pair (cp_nt_rev).
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.
int str_to_args(char **, char *, uint)
Converts a string into an array of argument strings.
bool expand_tilde(char *, uint)
Replaces "~/" in string with the user's home directory.
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".
int destroy_argv(uint argc, char **argv)
Deallocates memory allocated for argument strings in argv.
bool base_name(char *, char *)
Returns the base name of a file specification.
int init_view_boxwin(Init *init)
Initialize the C-Menu View in box window mode.
int view_init_input(Init *init, char *file_name)
Initialize the input for the C-Menu View.
bool verify_spec_arg(char *, char *, char *, char *, uint)
Verify file specification argument.
Pick * new_pick(Init *init, int argc, char **argv, uint begy, uint begx)
Create and initialize Pick structure.
View * destroy_view(Init *init)
Destroy View structure.
View * new_view(Init *init)
Create and initialize View 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 picker(Init *, char *field)
Main loop for handling user input and interactions in the pick interface.
int new_pick_view(Init *)
Initializes a new view for displaying file contents in the pick interface.
void unreverse_object(Pick *)
Unreverses the display of the currently selected object in pick window.
void destroy_pick_view(Init *)
Destroys pick view, unmaps file buffer, and cleans up resources.
void pick_std_chyron(Pick *)
Sets standard chyron key states based on pick structure.
int output_objects(Pick *)
Outputs selected objects to specified output file.
int match_objects(Pick *pick, char *s)
Displays current page of objects in pick window.
void deselect_object(Pick *)
Deselects the currently selected object in pick window.
int init_pick(Init *, int, char **, uint, uint)
Initializes pick structure and opens pick input file or pipe.
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.
void display_pick_page(Pick *)
Displays current page of objects in pick window.
void new_view_file(Init *, char *)
Initializes a new view for displaying the contents of a specified file in the pick interface.
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.
int view_cmd_processor(Init *)
Main Command Processing Loop for View.
void build_prompt(View *)
Build Prompt String.
void initialize_line_table(View *)
Initialize Line Table.
void destroy_line_table(View *)
Destroy Line Table.
void next_page(View *)
Advance to Next Page.
int pad_refresh(View *)
Refresh Pad and Line Number Window.
int display_prompt(View *, char *)
Display Command Line Prompt.
UiMouseAction mouse_action
ChyronKey * key[CHYRON_KEYS]
bool f_selected[OBJ_MAXCNT]
char provider_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char receiver_cmd[MAXLEN]