|
C-Menu 0.2.9
A User Interface Toolkit
|
File mapping, user input, command processing, and display logic. More...
Macros | |
| #define | get_next_char() |
| read the next characater from the virtual file | |
| #define | get_prev_char() |
| read the previous characater from the virtual fileThere is no need to track line numbers when moving backwards as they are stored in the line table and accessed as needed. When reading in reverse, the Beginning of Data (BOD) flag is set when the file position is zero, and cleared when the position or reading direction changes. Carriage-returns are ignored as they should be. | |
Functions | |
| void | build_prompt (View *view) |
| Build Prompt String. | |
| void | cat_file (View *view) |
| Concatenate File to Standard Output. | |
| bool | enter_file_spec (Init *init, char *file_spec) |
| use form to enter a file specification | |
| int | get_cmd_arg (View *view, char *prompt) |
| Get Command Argument from User Input. | |
| int | get_cmd_char (View *view, off_t *n) |
| Get Command Character from User Input. | |
| void | lp (View *view, char *PrintFile) |
| Send File to Print Queue. | |
| void | remove_file (View *view) |
| Remove File. | |
| int | view_cmd_processor (Init *init) |
| Main Command Processing Loop for View. | |
| int | view_file (Init *init) |
| Start view. | |
| void | view_stack_free (ViewStack *s) |
| Free View Stack. | |
| bool | view_stack_init (ViewStack *s, size_t initial_capacity) |
| Initialize View Stack. | |
| bool | view_stack_peek (const ViewStack *s, View *out_item) |
| Peek at Top Item of View Stack. | |
| bool | view_stack_pop (ViewStack *s, View *out_item) |
| Pop Item from View Stack. | |
| bool | view_stack_push (ViewStack *s, View item) |
| Push Item onto View Stack. | |
| int | write_view_buffer (Init *init, bool f_strip_ansi) |
| Write buffer contents to files. | |
File mapping, user input, command processing, and display logic.
| #define get_next_char | ( | ) |
read the next characater from the virtual file
Line numbers are tracked when reading forward and stored in a line table for quick access when moving backwards. When reading forward, the End of Data (EOD) flag is set when the position is equal to the file size, and cleared when the position or reading direction changes. Carriage-returns are ignored as they should be. View uses the kernel's demand paged virtual address space to map files directly into memory. This allows for efficient access to file contents without the need for explicit buffering or read system calls, as the kernel handles loading the necessary pages into memory on demand.
Definition at line 45 of file view_engine.c.
| #define get_prev_char | ( | ) |
read the previous characater from the virtual fileThere is no need to track line numbers when moving backwards as they are stored in the line table and accessed as needed. When reading in reverse, the Beginning of Data (BOD) flag is set when the file position is zero, and cleared when the position or reading direction changes. Carriage-returns are ignored as they should be.
Definition at line 68 of file view_engine.c.
| void build_prompt | ( | View * | view | ) |
Build Prompt String.
| 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. |
This function constructs a prompt string that provides information about the current state of the view application. The prompt includes details such as the file name, current column, file number, file position, and whether the end of the document has been reached. The constructed prompt string is stored in the view->prompt_str buffer for display to the user.
Definition at line 915 of file view_engine.c.
References View::argc, View::argv, base_name(), View::cols, View::curr_argc, View::f_eod, View::f_is_pipe, View::file_name, View::file_size, View::ln_tbl, View::maxcol, View::page_bot_ln, View::page_bot_pos, View::page_top_ln, View::page_top_pos, View::pmincol, View::prompt_str, strnz__cat(), and strnz__cpy().
Referenced by get_cmd_char(), new_view_file(), and view_cmd_processor().
| void cat_file | ( | View * | view | ) |
Concatenate File to Standard Output.
Definition at line 1033 of file view_engine.c.
References View::f_eod.
| bool enter_file_spec | ( | Init * | init, |
| char * | file_spec ) |
use form to enter a file specification
| init | data structure |
| file_spec | - pointer to file specification the file_spec |
the user must provide a character array large enough to hold file_spec without overflowing
call form to get file_name write the name to a temporary file
Definition at line 2132 of file view_engine.c.
References View::begy, destroy_argv(), display_error(), em0, em1, em2, expand_tilde(), FA_CANCEL, View::in_fd, View::lines, Init::mapp_home, mk_dir(), popup_form(), restore_wins(), ssnprintf(), str_to_args(), strnz(), strnz__cat(), strnz__cpy(), verify_spec_arg(), and Init::view.
Referenced by view_cmd_processor().
| int get_cmd_arg | ( | View * | view, |
| char * | prompt ) |
Get Command Argument from User Input.
| 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. |
| prompt | A string containing the prompt to be displayed to the user when requesting input for the command argument. This prompt is shown on the command line to guide the user in providing the necessary input for the command being executed. |
Definition at line 872 of file view_engine.c.
References CC_NT, CC_NT_REV, cf_accept(), View::cmd_arg, View::cmd_line, View::cmdln_win, View::cols, View::curx, pad_refresh(), ran, and strnz__cpy().
Referenced by view_cmd_processor().
| int get_cmd_char | ( | View * | view, |
| off_t * | n ) |
Get Command Character from User Input.
| 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 | Pointer to an off_t variable where the numeric argument entered by the user will be stored. If the user enters a numeric argument, it will be converted to an off_t value and stored in this variable for use by the calling function. |
Definition at line 727 of file view_engine.c.
References build_prompt(), CC_IND, View::cmd_arg, View::cmd_line, View::cmdln_win, View::cols, View::curx, View::cury, display_prompt(), pad_refresh(), View::prompt_str, ran, sp, and vgetch().
Referenced by view_cmd_processor().
| void lp | ( | View * | view, |
| char * | PrintFile ) |
Send File to Print Queue.
| view | Pointer to the View structure containing the state and |
| PrintFile | - file to print |
Definition at line 1046 of file view_engine.c.
References display_prompt(), shell(), and ssnprintf().
Referenced by view_cmd_processor().
| void remove_file | ( | View * | view | ) |
Remove File.
| view | is the current view data structure |
Definition at line 2059 of file view_engine.c.
References View::cmd_line, View::cmdln_win, View::cur_file_str, View::f_at_end_remove, View::pad, and vgetch().
| int view_cmd_processor | ( | Init * | init | ) |
Main Command Processing Loop for View.
| init | Pointer to the Init structure containing initialization parameters and state for the view application. This structure is used to pass necessary information and maintain state across different functions within the view application. |
< Ctrl('R') or KEY_RESIZE - Handle terminal resize
< KEY_ALTHOME - horizontal scroll to the first column
< KEY_ALTEND horizontal scroll to the last column
< 'h', Ctrl('H'), KEY_LEFT, KEY_BACKSPACE - Horizontal scroll left by two thirds of the page width
< 'l', 'L', KEY_RIGHT - Horizontal scroll right by two thirds of the page width
'k', 'K', KEY_UP, Ctrl('K') - Scroll up one line
'j', 'J', KEY_DOWN, KEY_ENTER, SPACE - scroll down one line
'b', 'B', Ctrl('B'), KEY_PPAGE - Previous Page
'f', 'F', Ctrl('F'), KEY_NPAGE Next Page
'g', KEY_HOME - Go to the beginning of the document
KEY_LL - Go to the end of the document
'!', Execute Shell Command from within C-Menu View
'+', Set Startup Command
'-', Change View Settings
-i ignore_case in search
-n line numbers
-s squeeze multiple blank lines
-t n set tab stop columns
-h display help
-n line numbers
-s Squeeze Multiple Blank Lines
-t n Set Tab Stop Columns
-h Display Help
Pedantic reassignment of view pointer as the init->view pointer was was reassigned during view_display_help
':' - Set a Prompt String
'n' - Repeat Previous Search
'/' or '?' - Search Forward fromk top of page
'?' - Search Backward
'o' or 'O' - Open a File
'g' or 'G' - Go to the End of the Document
'H' or KEY_F(1) - Display Help Information
'm' - Set a Mark at the Current Position
'M' - Go to a Mark
'N' - Close Current File and Open Next File
'p' or '' - Go to a Percent of the File
Ctrl('Z') - Send File to Print Queue with Notation
'P' or KEY_CATAB or KEY_PRINT - Print Current File
'P' or KEY_F(9) or ESC - Close Current File and Open Next
'q' or 'Q' or KEY_F(9) or ESC - Quit the Application
'v' - Open Current File in Editor
'w' - Write the current buffer to file
'V' - Display Version Information
Definition at line 184 of file view_engine.c.
References View::argc, View::argv, build_prompt(), View::cmd, View::cmd_arg, View::cmd_line, View::cmdln_win, View::cols, CT_VIEW, View::cur_file_str, View::curr_argc, View::curx, View::cury, display_error(), display_prompt(), Init::editor, em0, em1, em2, enter_file_spec(), View::f_displaying_help, View::f_first_iter, View::f_full_screen, View::f_ignore_case, View::f_is_pipe, View::f_ln, View::f_redisplay_page, View::f_search_complete, View::f_squeeze, View::f_strip_ansi, View::file_pos, View::file_spec_ptr, full_screen_shell(), get_cmd_arg(), get_cmd_char(), go_to_eof(), go_to_line(), go_to_mark(), go_to_percent(), View::h_shift, View::in_spec, View::lines, View::ln, View::ln_tbl, View::ln_win_cols, lp(), View::mark_tbl, View::maxcol, View::next_cmd_char, View::next_file_spec_ptr, next_page(), View::out_spec, View::pad, pad_refresh(), View::page_bot_pos, View::page_top_ln, View::page_top_pos, Perror(), View::pmincol, View::prev_file_pos, prev_page(), prev_regex_pattern, View::prompt_str, restore_wins(), scroll_down_n_lines(), View::scroll_lines, scroll_up_n_lines(), search(), shell(), View::smaxcol, View::smincol, sp, View::srch_beg_pos, View::srch_curr_pos, ssnprintf(), str_subc(), strnz__cat(), strnz__cpy(), View::tab_stop, View::tmp_file_name_ptr, Init::view, view_boxwin_resize(), view_display_help(), view_display_page(), view_full_screen_resize(), and write_view_buffer().
Referenced by picker(), and view_file().
| int view_file | ( | Init * | init | ) |
Start view.
| init | Pointer to the Init structure containing initialization parameters and state for the view application. This structure is used to pass necessary information and maintain state across different functions within the view application. |
Definition at line 130 of file view_engine.c.
References View::argc, View::argv, border_title(), View::box_win, View::buf, View::cur_file_str, View::curr_argc, destroy_line_table(), destroy_view(), destroy_view_win(), View::f_bod, View::f_eod, View::file_pos, View::file_size, View::file_spec_ptr, initialize_line_table(), View::ln, View::ln_max_pos, View::maxcol, View::next_file_spec_ptr, next_page(), View::page_bot_ln, View::page_bot_pos, View::page_top_ln, View::page_top_pos, strnz__cpy(), View::title, Init::view, view_cmd_processor(), and view_init_input().
Referenced by main(), and popup_view().
| void view_stack_free | ( | ViewStack * | s | ) |
Free View Stack.
| s | pointer to ViewStack structure |
This function frees the memory allocated for the items array in the ViewStack structure and resets the capacity and top index to zero.
Definition at line 2284 of file view_engine.c.
References ViewStack::capacity, ViewStack::items, and ViewStack::top.
| bool view_stack_init | ( | ViewStack * | s, |
| size_t | initial_capacity ) |
Initialize View Stack.
| s | pointer to ViewStack structure |
| initial_capacity | initial capacity of the stack |
This function initializes a ViewStack structure by allocating memory for the items array with the specified initial capacity. It sets the capacity and top index accordingly. If memory allocation fails, it returns false.
Definition at line 2218 of file view_engine.c.
References ViewStack::capacity, ViewStack::items, and ViewStack::top.
Peek at Top Item of View Stack.
| s | pointer to ViewStack structure |
| out_item | pointer to View structure where the top item will be stored |
This function retrieves the top item of the stack without removing it. If the stack is empty, it returns false.
Definition at line 2272 of file view_engine.c.
References ViewStack::items, and ViewStack::top.
Pop Item from View Stack.
| s | pointer to ViewStack structure |
| out_item | pointer to View structure where the popped item will be stored |
This function pops a View item from the stack and stores it in the provided out_item pointer. If the stack is empty, it returns false.
Definition at line 2257 of file view_engine.c.
References ViewStack::items, and ViewStack::top.
Push Item onto View Stack.
This function pushes a View item onto the stack. If the stack is full, it reallocates memory to double the capacity. If memory allocation fails during resizing, it returns false.
Definition at line 2236 of file view_engine.c.
References ViewStack::capacity, ViewStack::items, and ViewStack::top.
| int write_view_buffer | ( | Init * | init, |
| bool | f_strip_ansi ) |
Write buffer contents to files.
| init | data structure |
| f_strip_ansi | strip ANSI escape sequences |
write the buffer
Definition at line 986 of file view_engine.c.
References answer_yn(), display_error(), em0, em1, em2, View::f_eod, get_next_line(), View::in_spec, View::line_in_s, View::out_fd, View::out_spec, restore_wins(), ssnprintf(), strip_ansi(), strnlf(), strnz__cat(), strnz__cpy(), and Init::view.
Referenced by view_cmd_processor().