|
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. | |
| void | display_line_eod (View *view) |
| Display End of Data. | |
| int | display_prompt (View *view, char *s) |
| Display Command Line Prompt. | |
| void | display_split_line (View *view) |
| Display Split Line on Pad. | |
| int | fmt_line (View *view) |
| Format Line for Display. | |
| void | log_cc_buf (View *view) |
| Log Complex Character Buffer. | |
| void | log_split_lines (View *view) |
| Log Split Lines. | |
| void | log_stripped_line_out (View *view) |
| Log Stripped Line Output. | |
| void | log_strnz (char *str, uint len) |
| Log String with Specified Length. | |
| int | pad_refresh (View *view) |
| Refresh Pad and Line Number Window. | |
| void | parse_ansi_str (char *ansi_str, attr_t *attr, ushort *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. | |
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_no 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 1395 of file view_engine.c.
References View::cmplx_buf, View::cur, View::cury, display_split_line(), View::f_ln, View::ln_no, LNNO, PAD, View::page_bot_ln_no, View::page_top_ln_no, View::scroll_lines, View::sfc, SplitLine::sl_cnt, SplitLine::sl_idx, ssnprintf(), ui_cursor_move(), ui_mvwadd_wchstr(), ui_mvwaddstr(), ui_wclrtoeol(), and View::wrap.
Referenced by scroll_down(), scroll_up(), search(), and view_display_page().
| void display_line_eod | ( | View * | view | ) |
Display End of Data.
| view | data structure |
This function is called when the end of the file is reached and there are no more lines to display. It clears the remaining lines in the pad and line number window (if line numbering is enabled) to ensure that no residual content from previous lines is displayed.
Definition at line 1485 of file view_engine.c.
References View::cury, View::f_ln, View::ln_no, LNNO, PAD, View::page_bot_ln_no, View::sfc, ui_cursor_move(), and ui_wclrtobot().
Referenced by 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 2538 of file view_engine.c.
References cell_nt, cell_nt_rev, View::cmd_line, CMDLN, View::curx, View::sfc, strnz__cpy(), ui_bkgdset(), ui_cursor_move(), ui_getyx(), ui_mvwaddstr(), ui_waddstr(), and ui_wclrtoeol().
Referenced by get_cmd_char(), lp(), new_view_file(), and view_cmd_processor().
| void display_split_line | ( | View * | view | ) |
Display Split Line on Pad.
| view | data structure |
This function is used to display a line that has been split into multiple segments due to wrapping. It iterates through the segments of the current line (stored in view->cur.sl_cc and view->cur.sl_cells) and displays each segment on the pad, along with the corresponding line number if line numbering is enabled. The function also updates the top and bottom line numbers of the page based on the current position in the split line.
Definition at line 1436 of file view_engine.c.
References View::cur, View::cury, View::f_ln, View::ln_no, LNNO, PAD, View::page_bot_ln_no, View::page_bot_sl, View::page_bot_sl_cnt, View::page_bot_sl_idx, View::page_top_ln_no, View::page_top_sl, View::page_top_sl_cnt, View::page_top_sl_idx, View::scroll_lines, View::sfc, SplitLine::sl_cc, SplitLine::sl_cells, SplitLine::sl_cnt, SplitLine::sl_idx, ssnprintf(), ui_cursor_move(), ui_mvwaddstr(), ui_wadd_wchnstr(), and ui_wclrtoeol().
Referenced by display_line().
| 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.
Definition at line 2073 of file view_engine.c.
References View::cmplx_buf, View::cols, cp_nt, View::cur, View::f_eod, View::f_ln, View::line_in_s, View::line_out_s, View::ln_no, View::ln_win_cols, View::maxcol, parse_ansi_str(), rtrim(), SplitLine::sl_cc, SplitLine::sl_cells, SplitLine::sl_cnt, SplitLine::sl_cols, SplitLine::sl_idx, SplitLine::sl_ln_no, SplitLine::sl_s, View::stripped_line_out, View::tab_stop, ui_getcchar(), ui_setcchar(), and View::wrap.
Referenced by prev_page(), scroll_down(), scroll_up(), search(), and view_display_page().
| void log_cc_buf | ( | View * | view | ) |
Log Complex Character Buffer.
| view | pointer to View structure containing complex character buffer (view->cmplx_buf) |
This function logs the contents of the complex character buffer (view->cmplx_buf) for debugging purposes. It iterates through the split lines (if any) and logs each line to the cmenu log, converting wide characters to their corresponding single-byte representation for easier viewing.
Definition at line 2312 of file view_engine.c.
References View::cur, SplitLine::sl_cc, SplitLine::sl_cells, SplitLine::sl_cnt, ui_getcchar(), and write_cmenu_log().
| void log_split_lines | ( | View * | view | ) |
Log Split Lines.
| view | pointer to View structure containing split line information |
This function logs the contents of the split lines stored in the view structure for debugging purposes. It iterates through the split lines and logs each line to the cmenu log, converting wide characters to their corresponding single-byte representation for easier viewing.
Definition at line 2353 of file view_engine.c.
References View::cur, SplitLine::sl_cnt, SplitLine::sl_cols, SplitLine::sl_s, and write_cmenu_log().
| void log_stripped_line_out | ( | View * | view | ) |
Log Stripped Line Output.
| view | pointer to View structure containing stripped line output buffer |
This function logs the contents of the stripped line output buffer (view->stripped_line_out) for debugging purposes. It iterates through the split lines (if any) and logs each line to the cmenu log.
Definition at line 2290 of file view_engine.c.
References View::cur, SplitLine::sl_cnt, SplitLine::sl_cols, SplitLine::sl_s, and write_cmenu_log().
| void log_strnz | ( | char * | str, |
| uint | len ) |
Log String with Specified Length.
| str | pointer to the string to log |
| len | length of the string to log |
This function logs a specified number of characters from a given string to the cmenu log. It copies the specified length of the string into a temporary buffer and then writes it to the log.
Definition at line 2340 of file view_engine.c.
References strnz__cpy(), and write_cmenu_log().
| int pad_refresh | ( | View * | view | ) |
Refresh Pad and Line Number Window.
| view | data structure |
Definition at line 2034 of file view_engine.c.
References ui_render().
Referenced by get_cmd_arg(), get_cmd_char(), and new_view_file().
| void parse_ansi_str | ( | char * | ansi_str, |
| attr_t * | attr, | ||
| ushort * | 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 ANSI escape sequences, which it converts to color pairs and attributes used to construct complex character cells or extended grapheme clusters.
SGR specification types:
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.
see also: xterm256_idx_to_rgb(), ui_add_color_rgb(), extended_pair_content(),
ui_add_pair()
Definition at line 2422 of file view_engine.c.
References a_toi(), CLR_NT_BG, CLR_NT_FG, ui_add_color_rgb(), ui_add_pair(), ui_pair_content(), 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 2576 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, and Init::view.
Referenced by view_cmd_processor().
| void view_display_page | ( | View * | view | ) |
Display Current Page.
| view | data structure |
Definition at line 1352 of file view_engine.c.
References View::cur, View::cury, display_line(), display_line_eod(), View::f_eod, View::f_ln, View::file_pos, fmt_line(), get_line(), View::ln_no, LNNO, PAD, View::page_bot_end_pos, View::page_bot_ln_no, View::page_bot_pos, View::page_bot_sl, View::page_top_ln_no, View::page_top_sl, View::page_top_sl_idx, View::scroll_lines, View::sfc, SplitLine::sl_idx, ui_cursor_move(), ui_render(), and View::wrap.
Referenced by next_page(), and view_cmd_processor().