2
3
4
5
6
7
8
11
12
27int picker(Init *,
char *field);
51 "vi",
"vim",
"nano",
"nvim",
52 "pico",
"emacs",
"edit",
""};
55
56
57
58
59
60
61
62
63
64
65
66
67
68int init_pick(Init *init,
int argc,
char **argv, uint by, uint bx) {
86 if ((pid = fork()) == -1) {
92 int dev_null = open(
"/dev/null", O_WRONLY);
94 ui_perror(_(
"open(/dev/null) failed in init_pick child process"));
97 dup2(dev_null, STDERR_FILENO);
105 execvp(s_argv[0], s_argv);
112
121 pick
->in_fp = fdopen(STDIN_FILENO,
"rb");
134 if (sb.st_size == 0) {
155 waitpid(pid,
nullptr, 0);
181 if (ui_mm.ncv !=
nullptr) {
182 ncvisual_destroy(ui_mm.ncv);
185 if (ui_mm.sfc !=
nullptr) {
186 ui_surface_destroy(ui_mm.sfc);
196
197
198
199
200
201
209 if (view
->buf !=
nullptr) {
218
219
220
221
222
223
224
225
238 for (i = 1; i < pick
->argc; i++)
249 uint whitespace_ratio = 15;
251 uint pick_ratio = 50;
252 uint tbl_max_cols, pg_max_objs;
262 pick
->begy = (maxy * whitespace_ratio) / 200;
263 usable_lines = maxy - (maxy * whitespace_ratio) / 100;
264 usable_lines -= pick
->begy;
268 pick
->lines = usable_lines * pick_ratio / 100;
292 pg_max_objs = pick
->lines * tbl_max_cols;
311 int ui_split_win_lines = 2;
313 ssnprintf(tmp_str
, MAXLEN - 1
, "ui_tracked_sfc_split_box(%d, %d, %d, %d, %d, %d, %s) failed",
355 bool f_processed =
false;
358
394
395
396
397
398
399
400
401
415 pick
->chyron->key[1]->active =
true;
416 pick
->chyron->key[2]->active =
true;
419 pick
->chyron->key[5]->active =
false;
422 pick
->chyron->key[9]->active =
true;
423 pick
->chyron->key[10]->active =
false;
426 pick
->chyron->key[13]->active =
false;
429
430
431
432
433
434
435
453
454
455
456
457
458
459
487
488
489
490
491
492
493
494
501 if (s ==
nullptr || s[0] ==
'\0' || strstr(pick
->m_object[pick
->m_idx], s) !=
nullptr) {
510
511
512
513
514
515
516
517
518
537
538
539
540
541
542
543
544
545
546
578
579
580
581
582
583
584
585
586
587
588
589
604
605
621 SIO *sio = init
->sio;
628
629
630
631
632
633
634
635
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
692 char tmp_str[
MAXLEN] = {
'\0'};
699 bool f_append_objects =
false;
703 if (pick
->cmd[0] ==
'\0')
705 if (pick
->cmd[0] ==
'\\' || pick
->cmd[0] ==
'\"') {
706 size_t len = strlen(pick
->cmd);
707 if (len > 1 && pick
->cmd[len - 1] ==
'\"') {
709 pick
->cmd[len - 2] =
'\0';
715 for (i = 0; i < pick
->d_cnt; i++) {
717 if (tmp_str[0] !=
'\0')
722 eargv[eargc++] = strdup(tmp_str);
724 f_append_objects =
false;
728 if (strstr(eargv[i],
"%%") !=
nullptr) {
730 f_append_objects =
true;
737 for (i = 0; i < pick
->d_cnt; i++) {
740 if (f_append_objects ==
true) {
741 if (tmp_str[0] !=
'\0')
749 if (f_append_objects ==
true) {
750 if (eargv[eargx] !=
nullptr) {
752 eargv[eargx] =
nullptr;
755 if (out_s ==
nullptr || out_s[0] ==
'\0') {
758 if (eargv[i] !=
nullptr)
766 eargv[eargx] = strdup(out_s);
767 if (out_s !=
nullptr) {
774 eargv[eargc] =
nullptr;
777 tok = strtok_r(tmp_str,
" ", &sav_ptr);
780 if (tmp_str[0] !=
'\0' && (strcmp(tmp_str,
"view") == 0 || strcmp(tmp_str,
"view") == 0)) {
782
787 if (title[0] !=
'\0')
795 if (eargv[i] !=
nullptr)
803 if ((pid = fork()) == -1) {
807 if (eargv[i] !=
nullptr)
813 }
else if (pid == 0) {
823 execvp(eargv[0], eargv);
827 waitpid(pid,
nullptr, 0);
834
835
836
837
838
839
853 eargv[eargc++] = strdup(
"view");
854 eargv[eargc++] = strdup(
"-Nf");
855 eargv[eargc++] = strdup(tmp_str);
856 eargv[eargc] =
nullptr;
868
869
870
871
872
873
874
875
876
877
878
879
880
882 bool f_insert =
false;
886 char *accept_s = field;
890 char *fend = field + flen;
891 char *str_end = field + strlen(field);
895 char *prev_ptr = prev_field;
896 char view_file[
MAXLEN] = {
'\0'};
918
919
973 pick
->chyron->key[1]->active =
true;
974 pick
->chyron->key[2]->active =
true;
975 pick
->chyron->key[4]->active =
false;
976 pick
->chyron->key[5]->active =
true;
977 pick
->chyron->key[6]->active =
false;
978 pick
->chyron->key[7]->active =
false;
979 pick
->chyron->key[9]->active =
false;
980 pick
->chyron->key[10]->active =
false;
981 pick
->chyron->key[11]->active =
true;
982 pick
->chyron->key[12]->active =
true;
983 pick
->chyron->key[13]->active =
false;
1012
1041
1110
1128
1153
1164
1178 event
.y = event
.x = -1;
1189
1190
1191 pick
->chyron->key[1]->active =
true;
1192 pick
->chyron->key[2]->active =
true;
1193 pick
->chyron->key[3]->active =
false;
1194 pick
->chyron->key[4]->active =
true;
1195 pick
->chyron->key[5]->active =
false;
1196 pick
->chyron->key[6]->active =
false;
1197 pick
->chyron->key[7]->active =
false;
1198 pick
->chyron->key[9]->active =
false;
1199 pick
->chyron->key[10]->active =
true;
1200 pick
->chyron->key[11]->active =
false;
1201 pick
->chyron->key[12]->active =
false;
1202 pick
->chyron->key[13]->active =
true;
1208 if (accept_s !=
nullptr && accept_s[0] !=
'\0') {
1237 pos = col + strlen(accept_s);
1246 if (event
.in_win == WIN2 && event
.y == maxy - 1)
1292 pick
->chyron->key[1]->active =
true;
1293 pick
->chyron->key[2]->active =
true;
1294 pick
->chyron->key[4]->active =
false;
1295 pick
->chyron->key[5]->active =
true;
1296 pick
->chyron->key[6]->active =
false;
1297 pick
->chyron->key[7]->active =
false;
1298 pick
->chyron->key[9]->active =
false;
1299 pick
->chyron->key[10]->active =
false;
1300 pick
->chyron->key[11]->active =
true;
1301 pick
->chyron->key[12]->active =
true;
1302 pick
->chyron->key[13]->active =
false;
1317 while (*ptr !=
'\0')
1319 pos = col + (ptr - accept_s);
1360 if (ptr > accept_s) {
1373 if (ptr == accept_s) {
1388 if (ptr > accept_s) {
1397 if (ptr < fend && ptr <= str_end) {
1406 if (event
.x < col || event
.x >= col + flen) {
1411 fend = accept_s + flen;
1412 str_end = accept_s + strlen(accept_s);
1413 ptr = accept_s + (pos - col);
1414 ptr =
min(ptr, str_end);
1415 pos = col + (ptr - accept_s);
1421 if (in_key <
' ' || in_key >
'~') {
1430 if (str_end < fend) {
1441 if (ptr < str_end) {
1444 }
else if (ptr == str_end) {
1461
1462
1463
1464
1465
1466
1467
1468
1469
1489 e = getenv(
"VIEW_HELP_FILE");
1490 if (e && e[0] !=
'\0') {
1495 "~/menuapp/help", R_OK
);
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1521 view
->buf =
nullptr;
1524 if (ui_mm.ncv !=
nullptr) {
1525 ncvisual_destroy(ui_mm.ncv);
1526 ui_mm.ncv =
nullptr;
1527 ui_surface_destroy(ui_mm.sfc);
1528 ui_mm.sfc =
nullptr;
1532 FileType ft = file_type(file);
1536 if (init->view !=
nullptr) {
1537 destroy_pick_view(init);
1538 init->view =
nullptr;
1539 destroy_line_table(view);
1540 munmap(view->buf, view->file_size);
1541 view->buf =
nullptr;
1543 ui_display_image(ui->nc, &ui_mm, file, -1, -1, 35, 0);
1544 if (ui_mm.sfc ==
nullptr) {
1545 ui_log(ERROR, _(
"ui_display_image() failed in new_view_file"));
1548 if (ui_mm.ncv ==
nullptr) {
1549 ui_log(ERROR, _(
"ui_display_image() failed in new_view_file"));
1556 if (init->view !=
nullptr) {
1557 destroy_pick_view(init);
1558 init->view =
nullptr;
1559 destroy_line_table(view);
1560 munmap(view->buf, view->file_size);
1561 view->buf =
nullptr;
1563 ui_display_image(ui->nc, &ui_mm, file, -1, -1, 35, 0);
1564 if (ui_mm.sfc ==
nullptr) {
1565 ui_log(ERROR, _(
"ui_display_image() failed in new_view_file"));
1568 if (ui_mm.ncv ==
nullptr) {
1569 ui_log(ERROR, _(
"ui_display_image() failed in new_view_file"));
1579 if (init
->view ==
nullptr) {
1586 view
->buf =
nullptr;
int open_pick_win(Init *)
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.
char * rep_substring(const char *, const char *, const char *) __attribute__((nonnull(1
Replace all occurrences of "tgt_s" in "org_s" with "rep_s".
void ui_render()
Render the UI by updating panels and refreshing the display.
int ui_tracked_sfc_split_box(uint wlines, uint wcols, uint split_y, uint split_x, uint wbegy, uint wbegx, const char *wtitle)
Create a new surface with a split box window.
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the maximum dimensions of a UiSurface.
int ui_cursor_enable_yx(UiSurface *s, ss_t w, uint y, uint x, bool visible)
Enable or disable the cursor at a specific position within a UiSurface.
int ui_wscrl(UiSurface *s, ss_t w, int rows)
Scroll the contents of a UiSurface by a specified number of lines.
int ui_cursor_move(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
int ui_cm_surface_destroy(UiSurface *sfc)
Destroy the most recently created surface.
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
int ui_border_title(UiSurface *sfc, const char *title)
Draw a box with a title around the specified window.
void ui_restore_wins()
Restore the state of all windows in the UI. This function refreshes the standard screen and all surfa...
int ui_border_ysplit_text(UiSurface *sfc, char *text, uint separator_line)
Draw a box with a separator line and text around the specified window.
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
int ui_mousemask(int mask)
Enable or disable mouse support.
void ui_initialize_sio(SIO *sio)
int ui_top_surface(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
void ui_endwin()
End the UI application, cleaning up resources and shutting down the UI runtime.
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
int ui_wclrtoeol(UiSurface *s, ss_t w)
Clear to the end of the line in a surface window.
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.
int ui_werase(UiSurface *s, ss_t w)
Erase the contents of a UiSurface or all surfaces.
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev, int timeout_ms)
Read input events.
void ui_set_chyron_key(UiChyron *chyron, uint k, char *s, uint kc)
Set chyron key with default color pair (cp_nt_rev).
UiChyron * ui_new_chyron(UiSurface *sfc, ss_t w)
Create new chyron structure.
void ui_display_chyron(UiSurface *sfc, ss_t w, UiChyron *chyron, uint line, uint col)
Display chyron on the specified line and column of the surface.
void ui_set_chyron_key_cb(UiChyron *chyron, uint k, char *s, uint kc, UiCell cell_base)
Set chyron key with color pair (cp).
void ui_abend(int ec, char *s)
Convert multibyte string to complex character array.
UiChyron * ui_destroy_chyron(UiChyron *chyron)
Destroy UiChyron structure.
int ui_get_chyron_key(UiChyron *chyron, uint x)
Get keycode from chyron.
void ui_compile_chyron(UiChyron *chyron)
construct the chyron string from the chyron structure
UiSurface * ui_surface[UI_SFC_MAX]
int ui_mvwadd_wchnstr(UiSurface *s, ss_t w, uint y, uint x, const UiCell *cmplx_buf, uint n)
Draw a complex character string at a specific position in a surface window, with a maximum length.
int ui_mvwaddstr(UiSurface *s, ss_t w, uint y, uint x, const char *text)
Draw a text string at a specific position in a surface window.
int ui_mvwaddstr_fill(UiSurface *s, ss_t w, uint y, uint x, const char *str, int m)
Draw a text string at a specific position in a surface window, filling the remaining space with space...
void end_pick_view(Init *)
char const pagers_editors[12][10]
void remove_right_angle(Pick *)
int process_config_file(char *, Init *)
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
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.
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 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 page_next(View *)
Advance to Next Page.
int pad_refresh(View *)
Refresh Pad and Line Number Window.
int display_prompt(View *, char *)
Display Command Line Prompt.
int ui_perror(char *emsg_str)
Display a simple error message window or print to stderr.
UiMouseAction mouse_action
bool f_selected[OBJ_MAXCNT]
char provider_cmd[MAXLEN]
char provider_cmd[MAXLEN]
char receiver_cmd[MAXLEN]