MCPcopy Create free account
hub / github.com/Entware/Entware / show_scroll_win_ext

Function show_scroll_win_ext

scripts/config/nconf.gui.c:508–641  ·  view source on GitHub ↗

layman's scrollable window... */

Source from the content-addressed store, hash-verified

506
507/* layman's scrollable window... */
508int show_scroll_win_ext(WINDOW *main_window, const char *title, char *text,
509 int *vscroll, int *hscroll,
510 extra_key_cb_fn extra_key_cb, void *data)
511{
512 int res;
513 int total_lines = get_line_no(text);
514 int x, y, lines, columns;
515 int start_x = 0, start_y = 0;
516 int text_lines = 0, text_cols = 0;
517 int total_cols = 0;
518 int win_cols = 0;
519 int win_lines = 0;
520 int i = 0;
521 WINDOW *win;
522 WINDOW *pad;
523 PANEL *panel;
524 bool done = false;
525
526 if (hscroll)
527 start_x = *hscroll;
528 if (vscroll)
529 start_y = *vscroll;
530
531 getmaxyx(stdscr, lines, columns);
532
533 /* find the widest line of msg: */
534 total_lines = get_line_no(text);
535 for (i = 0; i < total_lines; i++) {
536 const char *line = get_line(text, i);
537 int len = get_line_length(line);
538 total_cols = max(total_cols, len+2);
539 }
540
541 /* create the pad */
542 pad = newpad(total_lines+10, total_cols+10);
543 wattrset(pad, attr_scrollwin_text);
544 fill_window(pad, text);
545
546 win_lines = min(total_lines+4, lines-2);
547 win_cols = min(total_cols+2, columns-2);
548 text_lines = max(win_lines-4, 0);
549 text_cols = max(win_cols-2, 0);
550
551 /* place window in middle of screen */
552 y = (lines-win_lines)/2;
553 x = (columns-win_cols)/2;
554
555 win = newwin(win_lines, win_cols, y, x);
556 keypad(win, TRUE);
557 /* show the help in the help window, and show the help panel */
558 wattrset(win, attr_scrollwin_box);
559 box(win, 0, 0);
560 wattrset(win, attr_scrollwin_heading);
561 mvwprintw(win, 0, 3, " %s ", title);
562 panel = new_panel(win);
563
564 /* handle scrolling */
565 while (!done) {

Callers 2

search_confFunction · 0.85
show_scroll_winFunction · 0.85

Calls 6

get_line_noFunction · 0.85
get_line_lengthFunction · 0.85
fill_windowFunction · 0.85
print_in_middleFunction · 0.85
refresh_all_windowsFunction · 0.85
get_lineFunction · 0.70

Tested by

no test coverage detected