|
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 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 | page_next (View *view) |
| Advance to Next Page. | |
| void | page_prev (View *view) |
| display previous page | |
| void | scroll_next (View *view, uint n) |
| Scroll Down by n Lines. | |
| void | scroll_prev (View *view, uint n) |
| Move the view scope n lines toward the beginning of the file. | |
| bool | search (View *view, int search_cmd, char *regex_pattern) |
| Search for Regular Expression Pattern. | |
| void | sync_ln (View *view, off_t ln_no) |
| 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 1973 of file view_engine.c.
References View::ln_no, View::ln_pos_max, 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 __go_to_eof |
Definition at line 1856 of file view_engine.c.
References View::cury, View::f_eod, View::file_size, View::ln_no, View::ln_no_max, page_next(), page_prev(), View::page_top_ln_no, View::scroll_lines, sync_pos(), 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 1898 of file view_engine.c.
References View::file_pos, View::ln_tbl_size, View::page_bot_pos, page_next(), View::page_top_pos, sync_ln(), and ui_perror().
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 1072 of file view_engine.c.
References View::file_pos, go_to_position(), View::mark_tbl, and ui_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 1882 of file view_engine.c.
References View::file_size, go_to_position(), and ui_perror().
Referenced by view_cmd_processor().
| void go_to_position | ( | View * | view, |
| off_t | pos ) |
Go to Specific File Position.
| view | data Structure |
| go_to_pos |
Definition at line 1915 of file view_engine.c.
References page_next(), and sync_pos().
| 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 1992 of file view_engine.c.
References View::file_pos, View::ln_no, View::ln_no_max, View::ln_pos_max, View::ln_tbl, View::ln_tbl_size, and ui_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 1954 of file view_engine.c.
References View::ln_no, View::ln_pos_max, View::ln_tbl, View::ln_tbl_size, and ui_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 1930 of file view_engine.c.
References View::ln_tbl, and View::ln_tbl_size.
| void page_next | ( | 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. __page_next
Definition at line 1349 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_position(), new_view_file(), page_prev(), view_cmd_processor(), and view_file().
| void page_prev | ( | View * | view | ) |
display previous page
| view | data structure |
Displays the previous page starting at (view->page_top_ln_no - view->scroll_lines). __page_prev
Definition at line 1280 of file view_engine.c.
References View::cur, View::cury, fmt_line(), get_line(), View::ln_no, View::ln_no_max, page_next(), 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_next | ( | 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 | add n to page line pointers, moving the scope of the view window toward the end of data (eod). __scroll_next |
Definition at line 1521 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, 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_prev | ( | View * | view, |
| uint | n ) |
Move the view scope n lines toward the beginning of the file.
| 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 | subtract n from page line pointers, moving the scope of the view window toward the beginning of data (bod). __scroll_prev |
Definition at line 1658 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, 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 __search
initialize iteration
get line to scan
non-matching page filler
Display matching lines
Definition at line 1102 of file view_engine.c.
References View::cmplx_buf, cp_nt_rev, 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, View::page_bot_ln_no, View::page_top_ln_no, 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(), ui_perror(), and ui_wclrtobot().
Referenced by view_cmd_processor().
| void sync_ln | ( | View * | view, |
| off_t | ln_no ) |
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.
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 until it matches the file position. __sync_ln
Definition at line 2024 of file view_engine.c.
References View::f_eod, View::file_pos, View::ln_no, View::ln_no_max, and View::ln_tbl.
Referenced by go_to_line(), and search().