|
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 and Numeric Argument. | |
| void | lp (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. | |
| 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 44 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 67 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. |
Definition at line 830 of file view_engine.c.
References View::argc, View::argv, base_name(), View::curr_argc, View::f_eod, View::f_is_pipe, View::file_name, View::file_size, View::maxcol, View::page_bot_pos, View::page_top_pos, View::pmincol, View::prompt_str, strnz__cat(), and strnz__cpy().
Referenced by view_cmd_processor().
| void cat_file | ( | View * | view | ) |
Concatenate File to Standard Output.
Definition at line 926 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 2018 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(), Init::view, and 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. |
Basic Editing Keys for Command Line
Definition at line 734 of file view_engine.c.
References View::cmd_arg, View::cmd_line, View::cmdln_win, View::cols, View::curx, View::cury, strnz__cpy(), and xwgetch().
Referenced by view_cmd_processor().
| int get_cmd_char | ( | View * | view, |
| off_t * | n ) |
Get Command Character and Numeric Argument.
| view | Pointer to the View structure containing the state around the view application. This structure is used to access and modify the state |
| n | is used to store the numeric argument entered by the user, if applicable. The function reads user input and extracts both the command character and any numeric argument, allowing for commands that require a numeric parameter to be processed effectively. |
Definition at line 695 of file view_engine.c.
References View::cmd_arg, View::cmd_line, View::cmdln_win, View::curx, pad_refresh(), and xwgetch().
Referenced by view_cmd_processor().
| void lp | ( | char * | PrintFile | ) |
Send File to Print Queue.
| PrintFile | - file to print |
Definition at line 938 of file view_engine.c.
References display_prompt(), shell(), ssnprintf(), and view.
Referenced by view_cmd_processor().
| void remove_file | ( | View * | view | ) |
Remove File.
| view | is the current view data structure |
Definition at line 1935 of file view_engine.c.
References View::cmd_line, View::cmdln_win, View::cur_file_str, View::f_at_end_remove, View::pad, and xwgetch().
| 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 178 of file view_engine.c.
References View::argc, View::argv, build_prompt(), View::cmd, View::cmd_arg, View::cmd_line, View::cols, CT_VIEW, View::cur_file_str, View::curr_argc, 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::in_spec, View::lines, View::ln, View::ln_tbl, View::ln_win, 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, View::srch_beg_pos, View::srch_curr_pos, ssnprintf(), str_subc(), strnz__cat(), strnz__cpy(), View::tab_stop, View::title, View::tmp_file_name_ptr, Init::view, view, view_display_help(), view_display_page(), view_full_screen_resize(), view_win_resize(), and write_view_buffer().
Referenced by 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 129 of file view_engine.c.
References View::argc, View::argv, View::buf, View::cur_file_str, View::curr_argc, 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(), Init::view, view, view_cmd_processor(), and view_init_input().
Referenced by main(), and popup_view().
| 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 879 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().