|
C-Menu 0.2.9
A User Interface Toolkit
|
Navigation functions for the view application. More...
Functions | |
| void | destroy_line_table (View *view) |
| Destroy Line Table. | |
| void | go_to_eof (View *view) |
| Go to End of File. | |
| int | go_to_line (View *view, off_t line_idx) |
| Go to Specific Line. | |
| void | go_to_mark (View *view, uint c) |
| Go to Mark. | |
| void | go_to_percent (View *view, uint percent) |
| Go to Percent of File. | |
| void | go_to_position (View *view, off_t go_to_pos) |
| Go to Specific File Position. | |
| void | increment_ln (View *view) |
| Increment Line Index and Update Line Table. | |
| void | initialize_line_table (View *view) |
| Initialize Line Table. | |
| off_t | line_number (View *view, off_t position) |
| Get Line Number for a Given File Position. | |
| void | next_page (View *view) |
| Advance to Next Page. | |
| void | prev_page (View *view) |
| display previous page | |
| void | scroll_down (View *view, uint n) |
| Scroll Down by n Lines. | |
| void | scroll_up (View *view, uint n) |
| Scroll Up by n Lines. | |
| bool | search (View *view, int search_cmd, char *regex_pattern) |
| Search for Regular Expression Pattern. | |
| void | sync_ln (View *view) |
| Synchronize Line Table with Current File Position. | |
Navigation functions for the view application.
| void destroy_line_table | ( | View * | view | ) |
Destroy Line Table.
| view | data structure |
This function frees the memory allocated for the line table and resets the relevant fields in the View structure. It ensures that the line table is properly cleaned up when it is no longer needed, preventing memory leaks.
Definition at line 1945 of file view_engine.c.
References View::ln_max_pos, View::ln_no, View::ln_tbl, and View::ln_tbl_size.
Referenced by destroy_pick_view(), new_view_file(), and view_file().
| void go_to_eof | ( | View * | view | ) |
Go to End of File.
| view | data structure |
Definition at line 1814 of file view_engine.c.
References View::cury, View::f_eod, View::file_pos, View::file_size, View::ln_no, View::ln_no_max, next_page(), View::page_top_ln_no, prev_page(), View::scroll_lines, sync_ln(), and View::wrap.
Referenced by view_cmd_processor().
| int go_to_line | ( | View * | view, |
| off_t | line_idx ) |
Go to Specific Line.
| view | data structure |
| line_idx | line number to go to (1-based index) |
Definition at line 1866 of file view_engine.c.
References View::file_pos, View::ln_no, View::ln_tbl, View::ln_tbl_size, next_page(), View::page_bot_pos, View::page_top_pos, Perror(), and sync_ln().
Referenced by view_cmd_processor().
| void go_to_mark | ( | View * | view, |
| uint | c ) |
Go to Mark.
| view | Pointer to the View structure containing the state and parameters of the view application. This structure is used to access and modify the state of the application as needed. |
| c | The character representing the mark to go to. This character is typically a lowercase letter (a-z) corresponding to a mark that has been set previously in the view application. The function will attempt to navigate to the position associated with this mark, allowing the user to quickly jump to specific locations in the file based on the marks they have set. If the mark is not set, an error message will be displayed to the user. |
Definition at line 1065 of file view_engine.c.
References View::file_pos, go_to_position(), View::mark_tbl, and Perror().
Referenced by view_cmd_processor().
| void go_to_percent | ( | View * | view, |
| uint | percent ) |
Go to Percent of File.
| view | data structure |
| percent | of file |
Definition at line 1841 of file view_engine.c.
References View::file_pos, View::file_size, line_number(), View::ln_no, View::ln_tbl, next_page(), View::page_bot_pos, View::page_top_ln_no, View::page_top_pos, Perror(), View::scroll_lines, and sync_ln().
Referenced by view_cmd_processor().
| void go_to_position | ( | View * | view, |
| off_t | go_to_pos ) |
Go to Specific File Position.
| view | data Structure |
| go_to_pos |
Definition at line 1885 of file view_engine.c.
References View::file_pos, line_number(), View::ln_no, View::ln_tbl, next_page(), and sync_ln().
Referenced by go_to_mark().
| void increment_ln | ( | View * | view | ) |
Increment Line Index and Update Line Table.
| view | data structure |
This function is called when a line feed character is encountered while reading the file. It increments the line index (view->ln_no) and checks if the current file position exceeds the maximum position recorded in the line table. If it does, it updates the line table with the new file position. If the line index exceeds the current size of the line table, the table is resized by allocating more memory.
Definition at line 1964 of file view_engine.c.
References View::file_pos, View::ln_max_pos, View::ln_no, View::ln_tbl, View::ln_tbl_cnt, View::ln_tbl_size, and Perror().
| void initialize_line_table | ( | View * | view | ) |
Initialize Line Table.
| view | data structure |
The line table is initialized with a specified increment size (LINE_TBL_INCR). Memory is allocated for the line table, and the first entry is set to 0, indicating the file position of the first line. The line index (view->ln_no) is initialized to 0.
Definition at line 1926 of file view_engine.c.
References View::ln_max_pos, View::ln_no, View::ln_tbl, View::ln_tbl_size, and Perror().
Referenced by new_view_file(), and view_file().
| off_t line_number | ( | View * | view, |
| off_t | position ) |
Get Line Number for a Given File Position.
| view | data structure |
| target | file position |
This function performs a binary search on the line table (view->ln_tbl) to find the line number corresponding to the specified file position (target). It returns the index of the line in the line table that is closest to the target position without exceeding it. If the target position is not found, it returns the previous line number.
Definition at line 1902 of file view_engine.c.
References View::ln_tbl, and View::ln_tbl_size.
Referenced by go_to_percent(), and go_to_position().
| void next_page | ( | View * | view | ) |
Advance to Next Page.
| view | data structure |
Advances from view->page_bot_pos to view the next page of content. view->page_bot_pos must be set properly when calling this function. If the current bottom position of the page is at the end of the file, the function returns without making any changes. Otherwise, it resets the maximum column and current line position to the top of the page, updates the file position to the current bottom position of the page, and sets the top position and line number of the page accordingly. Finally, it calls the function to display the new page content.
Definition at line 1338 of file view_engine.c.
References View::cury, View::file_pos, View::file_size, View::ln_no, View::ln_tbl, View::maxcol, View::page_top_ln_no, and view_display_page().
Referenced by go_to_eof(), go_to_line(), go_to_percent(), go_to_position(), new_view_file(), prev_page(), view_cmd_processor(), and view_file().
| void prev_page | ( | View * | view | ) |
display previous page
| view | data structure |
Displays the previous page starting at (view->page_top_ln_no - view->scroll_lines).
Definition at line 1270 of file view_engine.c.
References View::cur, View::cury, fmt_line(), get_line(), View::ln_no, View::ln_no_max, next_page(), View::page_top_ln_no, View::page_top_sl, View::page_top_sl_cnt, View::page_top_sl_idx, View::scroll_lines, SplitLine::sl_cnt, SplitLine::sl_idx, and View::wrap.
Referenced by go_to_eof(), and view_cmd_processor().
| void scroll_down | ( | View * | view, |
| uint | n ) |
Scroll Down by n Lines.
| view | Pointer to the View structure containing the state and parameters of the view application. This structure is used to access and modify the state of the application as needed. |
| n | The number of lines to scroll down. This parameter specifies how many lines the view should move down in the file, effectively advancing the display by n lines. The function will handle scrolling, updating the current line number, and refreshing the display accordingly. |
Definition at line 1505 of file view_engine.c.
References View::cur, View::cury, display_line(), View::f_bod, View::f_eod, View::f_ln, fmt_line(), get_line(), View::ln_no, View::ln_no_max, 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_cnt, SplitLine::sl_idx, ui_cursor_move(), ui_wclrtobot(), ui_wscrl(), and View::wrap.
Referenced by view_cmd_processor().
| void scroll_up | ( | View * | view, |
| uint | n ) |
Scroll Up by n Lines.
| view | Pointer to the View structure containing the state and parameters of the view application. This structure is used to access and modify the state of the application as needed. |
| n | The number of lines to scroll up. This parameter specifies how many lines the view should move up in the file, effectively moving the display up by n lines. The function will handle scrolling, updating the current line number, and refreshing the display accordingly. |
Definition at line 1629 of file view_engine.c.
References View::cur, View::cury, display_line(), View::f_bod, View::f_eod, View::f_ln, fmt_line(), get_line(), 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_cnt, SplitLine::sl_idx, ui_cursor_move(), ui_wclrtobot(), ui_wscrl(), and View::wrap.
Referenced by view_cmd_processor().
| bool search | ( | View * | view, |
| int | search_cmd, | ||
| char * | regex_pattern ) |
Search for Regular Expression Pattern.
| view | Pointer to View Structure |
| search_cmd | Search Command Character ('/' or '?') |
| regex_pattern | Regular Expression Pattern to Search For |
The search performs extended regular expression matching, ignoring ANSI sequences and Unicode characters. Matches are highlighted on the screen, and the search continues until the page is full or the end of the file is reached. If the search wraps around the file, a message is displayed indicating that the search is complete. The search state is maintained in the view structure, allowing for repeat searches and tracking of the current search line. This function highlights all matches in the current ncurses pad, including those not displayed on the screen, and tracks the first and last match columns for prompt display. ANSI sequences and Unicode characters are stripped before matching, so matching corresponds to the visual display
initialize iteration
get line to scan
non-matching page filler
Display matching lines
Definition at line 1094 of file view_engine.c.
References cell_nt_rev, nccell::channels, CMDLN, View::cmplx_buf, View::cury, display_line(), View::f_first_iter, View::f_ignore_case, View::f_search_complete, View::file_size, View::first_match_x, fmt_line(), get_line(), View::last_match_x, View::line_out_p, View::ln_no, PAD, View::page_bot_ln_no, View::page_top_ln_no, Perror(), View::scroll_lines, View::sfc, View::srch_beg_ln_no, View::srch_curr_ln_no, View::stripped_line_out, strnz__cat(), strnz__cpy(), sync_ln(), ui_cursor_move(), and ui_wclrtobot().
Referenced by view_cmd_processor().
| void sync_ln | ( | View * | view | ) |
Synchronize Line Table with Current File Position.
| view | data Structure |
The line table (view->ln_tbl) is an array that stores the file position of each line. The index (view->ln_no + 1) corresponds to the current line number. (the line number table is 0-based, while line numbering starts at 1).
If the line or position requested is not in the line table, this function reads forward to sycn. If the line or positione requested is behind the current line table index, the line index will be decremented it matches the file position.
Definition at line 1996 of file view_engine.c.
References View::f_eod, View::file_pos, View::ln_max_pos, View::ln_no, View::ln_tbl, and View::ln_tbl_cnt.
Referenced by go_to_eof(), go_to_line(), go_to_percent(), go_to_position(), and search().