|
C-Menu 0.2.9
A User Interface Toolkit
|
Manage the View Display. More...
Functions | |
| void | display_line (View *view) |
| Display Line on Padparam View *view data structure. | |
| int | display_prompt (View *view, char *s) |
| Display Command Line Prompt. | |
| int | fmt_line (View *view) |
| Format Line for Display. | |
| int | pad_refresh (View *view) |
| Refresh Pad and Line Number Window. | |
| void | parse_ansi_str (char *ansi_str, attr_t *attr, int *cpx) |
| Parse ANSI SGR Escape Sequence. | |
| void | view_display_help (Init *init) |
| Display View Help File. | |
| void | view_display_page (View *view) |
| Display Current Page. | |
| void | view_restore_wins () |
| Restore View Windows. | |
Manage the View Display.
| void display_line | ( | View * | view | ) |
Display Line on Padparam View *view data structure.
This function displays a single line of text on the ncurses pad. If line numbering is enabled (view->f_ln), it is formatted and displayed at the beginning of the line with the specified attributes and color pair.
Because get_next_char calls increment_ln upon encountering a line feed and increment_ln advances view->ln after updating the line table, the line number displayed is one greater than the index to the line table. That means the line counter begins with 1, while the table origin is 0.
Definition at line 1624 of file view_engine.c.
References View::cmplx_buf, View::cury, View::f_ln, View::ln, View::ln_win, View::pad, View::scroll_lines, and ssnprintf().
Referenced by scroll_down_n_lines(), scroll_up_n_lines(), search(), and view_display_page().
| int display_prompt | ( | View * | view, |
| char * | s ) |
Display Command Line Prompt.
| view | is the current view data structure |
| s | is the prompt string |
Definition at line 1914 of file view_engine.c.
References View::cmd_line, View::cmdln_win, View::curx, and strnz__cpy().
Referenced by lp(), and view_cmd_processor().
| int fmt_line | ( | View * | view | ) |
Format Line for Display.
| view | pointer to View structure containing line input and output buffers |
This function processes the input line from view->line_in_s, handling ANSI escape sequences for text attributes and colors, as well as multi-byte characters. It converts the input line into a formatted line suitable for display in the terminal, storing the result in view->cmplx_buf and view->stripped_line_out. The function returns the length of the formatted line in characters, which may be used for tracking the maximum column width of the displayed content.
This section calls the decoder for ANSI escape sequences
This section converts the input string to wide characters, handling tabs and multi-byte characters, and stores the result in the complex buffer for display. ANSI escape sequences are ignored in this section since they are handled separately above.
Definition at line 1655 of file view_engine.c.
References View::cmplx_buf, cp_win, View::line_in_s, View::line_out_s, View::maxcol, parse_ansi_str(), rtrim(), View::stripped_line_out, and View::tab_stop.
Referenced by scroll_down_n_lines(), scroll_up_n_lines(), search(), and view_display_page().
| int pad_refresh | ( | View * | view | ) |
Refresh Pad and Line Number Window.
| view | data structure |
Definition at line 1169 of file view_engine.c.
References View::cmdln_win, View::f_ln, View::ln_win, View::pad, Perror(), View::pmincol, View::pminrow, View::smaxcol, View::smaxrow, View::smincol, and View::sminrow.
Referenced by get_cmd_char(), and view_cmd_processor().
| void parse_ansi_str | ( | char * | ansi_str, |
| attr_t * | attr, | ||
| int * | cpx ) |
Parse ANSI SGR Escape Sequence.
| ansi_str | is the ANSI escape sequence string to parse |
| attr | is a pointer to an attr_t variable where the parsed attributes will be stored |
| cpx | is a pointer to an int variable where the parsed color pair index will be stored |
This function parses an ANSI escape sequence and updates the color pair and color tables according to the attributes specified. Despite the depth of nested conditionals, with an understanding of the ANSI Select Graphics Rendition (SGR) scheme, which is defined in the ECMA-48 standard (ISO/IEC 6429), you will find that it is exceptionally simple and straightforward.
This function converts the following SGR specification types to the
appropriate curses color pair index for use in the terminal display.
RGB:
foreground \033[38;2;r;g;bm
background \033[48;2;r;g;bm
Where r, g, b are the red, green, and blue color components
(0-255)
XTERM 256-color:
foreground \033[38;5;xm
background \033[48;5;xm
Where x is the 256-color index (0-255)
uses xterm256_idx_to_rgb() to convert the 256-color index to
RGB
8-color:
foreground \033[3cm
background \033[4cm
Where c is the color code (0 for black, 1 for red, 2 for green, 3
for yellow, 4 for blue, 5 for magenta, 6 for cyan, 7 for white).
Attributes:
\033[am
Where a is the attribute code (1 for bold, 2 for dim, 3 for italic,
4 for underline, 5 for blink, 7 for reverse, 8 for invis). The function
also supports resetting attributes and colors to default using \033[0m.
@sa xterm256_idx_to_rgb(), rgb_to_curses_clr(), extended_pair_content(),
get_clr_pair()
Definition at line 1796 of file view_engine.c.
References a_toi(), RGB::b, CLR_BG, CLR_FG, clr_pair_idx, RGB::g, get_clr_pair(), RGB::r, rgb_to_curses_clr(), and xterm256_idx_to_rgb().
Referenced by fmt_line().
| void view_display_help | ( | Init * | init | ) |
Display View Help File.
| init | is the current initialization data structure. |
The current View context is set aside by assigning the view structure to "view_save" while the help file is displayed using a new, separate view structure. The help file is specified by the VIEW_HELP_FILE macro can be set to a default help file path or overridden by the user through an environment variable. After the help file is closed, the original view is restored and the page is redisplayed. It may be necessary to reassign view after calling this function because the init->view pointer is temporarily set to nullptr during the help file display, and the original view is restored afterward. The default screen size for help can be set in the code below. If set to 0, popup_view will determine reasonable maximal size based on the terminal dimensions. The help file may contain Unicode characters and ANSI escape sequences for formatting, which will be properly handled and displayed by popup_view.
Definition at line 1967 of file view_engine.c.
References Init::begx, Init::begy, Init::cols, destroy_argv(), View::f_help_spec, View::f_redisplay_page, View::help_spec, Init::lines, Init::mapp_help, popup_view(), strnz__cat(), strnz__cpy(), Init::title, Init::view, and view.
Referenced by view_cmd_processor().
| void view_display_page | ( | View * | view | ) |
Display Current Page.
| view | data structure |
Definition at line 1229 of file view_engine.c.
References View::cury, display_line(), View::f_eod, View::file_pos, fmt_line(), get_next_line(), View::ln, View::ln_tbl, View::ln_win, View::pad, View::page_bot_ln, View::page_bot_pos, View::page_top_ln, View::page_top_pos, and View::scroll_lines.
Referenced by next_page(), and view_cmd_processor().
| void view_restore_wins | ( | ) |
Restore View Windows.
This function restores the content of the view windows (line number window and command line window) after they may have been overwritten by a popup or other temporary display. It uses wnoutrefresh to update the virtual screen with the content of the windows and then calls wrefresh to update the physical screen.
Definition at line 2000 of file view_engine.c.
References View::cmdln_win, View::ln_win, and view.