|
C-Menu 0.2.9
A User Interface Toolkit
|
Manage NCurses windows and color settings. More...
Functions | |
| int | bare_box_new (int wlines, int wcols, int wbegy, int wbegx, char *wtitle) |
| Create a new window with optional box and title. | |
| int | border_hsplit (WINDOW *box, int y) |
| Draw a box with a separator line around the specified window. | |
| int | border_hsplit_text (WINDOW *box, char *text, int separator_line) |
| Draw a box with a separator line and text around the specified window. | |
| int | border_title (WINDOW *box, char *title) |
| Draw a box with a title around the specified window. | |
| int | box_hsplit_new (int wlines, int split_win_lines, int wcols, int wbegy, int wbegx, char *wtitle) |
| Create a new window with optional box and title, and a second window inside it, split horizontally. | |
| int | box_new (int wlines, int wcols, int wbegy, int wbegx, char *wtitle) |
| Create a new window with optional box and title. | |
| void | check_panels (int i) |
| Check and display the panels for a given window index. | |
| void | destroy_curses () |
| Gracefully shut down NCurses and restore terminal settings. | |
| int | dxwgetch (WINDOW *win_0, WINDOW *win_1, WINDOW *win_2, WINDOW *win_3, WINDOW *win_c, Chyron *chyron, int n) |
| Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line, and accepts a sinigle character answer. | |
| void | mvwaddstr_fill (WINDOW *w, int y, int x, char *s, int l) |
| For lines shorter than their display area, fill the rest with spaces. | |
| bool | open_curses (SIO *sio) |
| Initialize NCurses and color settings. | |
| void | restore_wins () |
| Restore all windows after a screen resize. | |
| int | vgetch (WINDOW *win, int n) |
| Wrapper for wgetch that handles signals and mouse events, and accepts a single character answer. | |
| void | view_boxwin_resize (Init *init) |
| Resize the current window and its box. | |
| void | view_full_screen_resize (Init *init) |
| Resize the full screen view and its components. | |
| int | win2_box_new (int wlines, int wcols, int wbegy, int wbegx, char *wtitle) |
| Create a new window with optional box and title, and a second window inside it. | |
| int | win2_new (int wlines, int wcols, int wbegy, int wbegx) |
| Create a new subwindow (win2) with specified dimensions and position. | |
| void | win_del () |
| Delete the current window and its associated box window. | |
| void | win_init_attrs () |
| Initialize window attributes. | |
| int | win_new (int wlines, int wcols) |
| Create a new window with specified dimensions and position. | |
| void | win_redraw (WINDOW *win) |
| Redraw the specified window. | |
| void | win_resize (int wlines, int wcols, char *title) |
| Resize the current window and its box, and update the title. | |
| int | xwgetch (WINDOW *win, Chyron *chyron, int n) |
| Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line, and accepts a sinigle character answer. | |
Manage NCurses windows and color settings.
| int bare_box_new | ( | int | wlines, |
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx, | ||
| char * | wtitle ) |
Create a new window with optional box and title.
box_new
| wlines | Number of lines |
| wcols | Number of columns |
| wbegy | Beginning Y position |
| wbegx | Beginning X position |
| wtitle | Window title |
Definition at line 981 of file dwin.c.
References border_draw(), border_title(), CC_BOX, panel_box, Perror(), ui_get_screen_size(), ui_runtime, win_box, and win_ptr.
Referenced by box_hsplit_new(), box_new(), and win2_box_new().
| int border_hsplit | ( | WINDOW * | box, |
| int | y ) |
Draw a box with a separator line around the specified window.
border-hsplit
| box | Pointer to the window to draw the box around |
| y | Line number where the separator line should be drawn |
This function draws a box around the specified window, similar to border_draw(), but it also includes a horizontal separator line that divides the box into two sections. The separator line is drawn at a fixed position (line 00, page 00) and extends across the width of the box. Use this function when you want to visually separate two sections within a window, such as for a header and content area.
Definition at line 1269 of file dwin.c.
References bw_ho, bw_lt, and bw_rt.
Referenced by box_hsplit_new().
| int border_hsplit_text | ( | WINDOW * | box, |
| char * | text, | ||
| int | separator_line ) |
Draw a box with a separator line and text around the specified window.
border_hsplit_text
| box | Pointer to the window to draw the box around |
| text | Text to display in the middle of the separator line |
| separator_line | Line number where the separator line should be drawn |
This function draws a box around the specified window, similar to border_draw(), but it also includes a horizontal separator line that divides the box into two sections. The separator line is drawn at the specified line number and extends across the width of the box, with the provided text displayed in the middle of the line. Use this function when you want to visually separate two sections within a window and label the separator with descriptive text.
Definition at line 1289 of file dwin.c.
References cp_box, lt, mb_to_cc(), rt, sp, strnz(), and ts.
Referenced by picker().
| int border_title | ( | WINDOW * | box, |
| char * | title ) |
Draw a box with a title around the specified window.
border_title
| box | Pointer to the window to draw the box around |
| title | Title text to display at the top of the box |
This function draws a box around the specified window, similar to border_draw(), but it also includes a title at the top of the box. The title is displayed in the center of the top edge of the box, and the horizontal line is drawn on either side of the title. Use this function when you want to visually label a window with a title.
Definition at line 1327 of file dwin.c.
References cp_title, lt, mb_to_cc(), rt, sp, tl, and ts.
Referenced by bare_box_new(), new_view_file(), view_boxwin_resize(), and view_file().
| int box_hsplit_new | ( | int | wlines, |
| int | split_win_lines, | ||
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx, | ||
| char * | wtitle ) |
Create a new window with optional box and title, and a second window inside it, split horizontally.
box_hsplit_new
| wlines | Number of lines for the first window |
| split_win_lines | Number of lines for the second window |
| wcols | Number of columns for the first window |
| wbegy | Beginning Y position for the first window |
| wbegx | Beginning X position for the first window |
| wtitle | Window title for the first window |
Definition at line 925 of file dwin.c.
References bare_box_new(), border_hsplit(), CC_BOX, Perror(), win2_new(), win_box, win_new(), and win_ptr.
Referenced by open_pick_win().
| int box_new | ( | int | wlines, |
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx, | ||
| char * | wtitle ) |
Create a new window with optional box and title.
box_new
| wlines | Number of lines |
| wcols | Number of columns |
| wbegy | Beginning Y position |
| wbegx | Beginning X position |
| wtitle | Window title |
Definition at line 967 of file dwin.c.
References bare_box_new(), and win_new().
Referenced by action_disposition(), answer_yn(), display_error(), display_form(), menu_engine(), Perror(), popup_ckeys(), and wait_mk_win().
| void check_panels | ( | int | i | ) |
Check and display the panels for a given window index.
check_panels
| i | Index of the window to check |
This function checks the panels associated with the specified window index. It sets the background color for each panel, displays a label indicating the panel type, and updates the display. The function pauses after displaying each panel to allow the user to view the changes.
Definition at line 1090 of file dwin.c.
References CC_BLUE, CC_GREEN, CC_RED, panel_box, panel_win, panel_win2, ssnprintf(), win_box, win_win, and win_win2.
| void destroy_curses | ( | ) |
Gracefully shut down NCurses and restore terminal settings.
destroy_curses
This function should be called before exiting the program to ensure that the terminal is left in a usable state. It checks if NCurses was initialized and, if so, it erases the screen, and ends the NCurses session. It also restores the original terminal settings using restore_shell_tioctl and resets signal handlers to their default state with sig_dfl_mode.
Definition at line 670 of file dwin.c.
References f_curses_open, panel_box, restore_shell_tioctl(), screen, sig_dfl_mode(), tty_fp, win_box, win_ptr, win_win, and win_win2.
Referenced by abend(), main(), and open_curses().
| int dxwgetch | ( | WINDOW * | win_0, |
| WINDOW * | win_1, | ||
| WINDOW * | win_2, | ||
| WINDOW * | win_3, | ||
| WINDOW * | win_c, | ||
| Chyron * | chyron, | ||
| int | n ) |
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line, and accepts a sinigle character answer.
dxwgetch
| win_0 | Pointer to window 0 |
| win_1 | Pointer to window 1 |
| win_2 | Pointer to window 2 |
| win_3 | Pointer to window 3 |
| win_c | Pointer to chyron window |
| chyron | Pointer to chyron struct |
| n | Number of seconds to wait before timing out 0: Wait indefinitely for user input (raw mode)
accept a single character answer, and don't wait for Enter key
1: Wait for 1 decisecond
n > 1: Wait for n/10 seconds
|
Get mouse event and check if it's a left click or double click. If the click is outside the windows, ignore it. If it's on the chyron line, get the corresponding key command. Otherwise, store the click coordinates as click_y and click_x for later use.
Definition at line 2180 of file dwin.c.
References click_x, click_y, curses_tioctl, display_error(), em0, em1, em2, get_chyron_key(), handle_signal(), mk_raw_tioctl(), mouse_win, restore_curses_tioctl(), and sig_received.
Referenced by picker().
| void mvwaddstr_fill | ( | WINDOW * | w, |
| int | y, | ||
| int | x, | ||
| char * | s, | ||
| int | l ) |
For lines shorter than their display area, fill the rest with spaces.
mvwaddstr_fill
| w | Pointer to window |
| y | Y coordinate |
| x | X coordinate |
| s | String to display |
| l | Length of display area |
Definition at line 1941 of file dwin.c.
Referenced by display_pick_page(), menu_cmd_processor(), menu_engine(), picker(), reverse_object(), and unreverse_object().
| bool open_curses | ( | SIO * | sio | ) |
Initialize NCurses and color settings.
open_curses
| sio | Pointer to SIO struct with terminal and color settings |
This function initializes NCurses and sets up color pairs based on the settings in the SIO struct. It also applies gamma correction to colors. Use this function to initialize NCurses if you don't want NCurses to receive data from the stdin pipe
Definition at line 244 of file dwin.c.
References abend(), CC_NORM, destroy_curses(), f_curses_open, panel_box, panel_main, screen, SIO::stderr_fd, SIO::stdin_fd, SIO::stdout_fd, strnz__cat(), strnz__cpy(), tty_fp, SIO::tty_name, ui_box, ui_win, ui_win2, win_box, win_ptr, win_win, and win_win2.
Referenced by main().
| void restore_wins | ( | ) |
Restore all windows after a screen resize.
restore_wins
This function is used to restore the display of all windows after a screen resize event. It clears the standard screen and then iterates through all existing windows, touching them to ensure they are redrawn correctly on the resized screen. Use this function in response to a SIGWINCH signal to handle terminal resizing gracefully.
Definition at line 1225 of file dwin.c.
References win_box, win_ptr, win_win, and win_win2.
Referenced by enter_file_spec(), exec_objects(), fork_exec(), form_exec_receiver(), full_screen_shell(), menu_cmd_processor(), menu_engine(), view_cmd_processor(), view_init_input(), and write_view_buffer().
| int vgetch | ( | WINDOW * | win, |
| int | n ) |
Wrapper for wgetch that handles signals and mouse events, and accepts a single character answer.
vgetch
| win | Pointer to window |
| n | Number of seconds to wait before timing out |
This function is similar to xwgetch, but it does not handle chyron clicks. It sets the terminal to raw mode if n is -1, or halfdelay mode if n is 0 or greater. It waits for user input and returns the key code. If a signal is received, it handles the signal and may display an error message. If the user presses 'q', 'Q', or F9, the program exits.
Definition at line 2258 of file dwin.c.
References curses_tioctl, and mk_raw_tioctl().
Referenced by cf_accept(), get_cmd_char(), and remove_file().
| void view_boxwin_resize | ( | Init * | init | ) |
Resize the current window and its box.
| init | Pointer to the Init structure containing view settings. |
This function resizes the current window and its associated box window to the specified number of lines and columns.
Definition at line 346 of file init_view.c.
References border_title(), View::box_win, destroy_view_win(), init_view_boxwin(), View::title, and Init::view.
Referenced by view_cmd_processor().
| void view_full_screen_resize | ( | Init * | init | ) |
Resize the full screen view and its components.
| init | Pointer to the Init structure containing view settings. |
This function resizes the full screen view and its components, including the command line window, line number window, and main content pad. It also recalculates the dimensions for the full screen mode and updates the scroll regions accordingly.
Definition at line 140 of file init_view.c.
References View::cmdln_win, View::cols, View::lines, View::ln_win_cols, View::ln_win_lines, View::lnno_win, View::pad, View::scroll_lines, Init::view, and view_calc_full_screen_dimensions().
Referenced by view_cmd_processor().
| int win2_box_new | ( | int | wlines, |
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx, | ||
| char * | wtitle ) |
Create a new window with optional box and title, and a second window inside it.
win2_box_new
| wlines | Number of lines for the first window |
| wcols | Number of columns for the first window |
| wbegy | Beginning Y position for the first window |
| wbegx | Beginning X position for the first window |
| wtitle | Window title for the first window |
Definition at line 952 of file dwin.c.
References bare_box_new(), win2_new(), and win_new().
| int win2_new | ( | int | wlines, |
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx ) |
Create a new subwindow (win2) with specified dimensions and position.
win2_new
| wlines | Number of lines |
| wcols | Number of columns |
| wbegy | Beginning Y position relative to the parent window |
| wbegx | Beginning X position relative to the parent window |
Definition at line 1066 of file dwin.c.
References CC_NT, panel_win2, Perror(), win_box, win_ptr, and win_win2.
Referenced by box_hsplit_new(), and win2_box_new().
| void win_del | ( | ) |
Delete the current window and its associated box window.
win_del
This function deletes the current window and its associated box window, if they exist. It also refreshes the remaining windows to ensure the display is updated correctly. After calling this function, the global win_ptr variable is decremented to point to the previous window in the stack.
Definition at line 1179 of file dwin.c.
References panel_box, panel_win, panel_win2, Perror(), win_box, win_ptr, win_win, and win_win2.
Referenced by action_disposition(), answer_yn(), display_error(), init_form(), init_pick(), menu_engine(), Perror(), popup_ckeys(), wait_destroy(), and waitpid_with_timeout().
| void win_init_attrs | ( | ) |
| int win_new | ( | int | wlines, |
| int | wcols ) |
Create a new window with specified dimensions and position.
win_new
| wlines | Number of lines |
| wcols | Number of columns |
Definition at line 1037 of file dwin.c.
References CC_NT, panel_win, Perror(), win_box, win_ptr, and win_win.
Referenced by box_hsplit_new(), box_new(), and win2_box_new().
| void win_redraw | ( | WINDOW * | win | ) |
Redraw the specified window.
win_redraw
| win | Pointer to the window to redraw |
This function erases the contents of the specified window and then refreshes it to update the display. Use this function when you need to clear and redraw a window, such as after resizing or when updating its contents.
Definition at line 1168 of file dwin.c.
| void win_resize | ( | int | wlines, |
| int | wcols, | ||
| char * | title ) |
Resize the current window and its box, and update the title.
win_resize
| wlines | Number of lines |
| wcols | Number of columns |
| title | Window title |
This function resizes the current window and its associated box window to the specified number of lines and columns. It also updates the title of the box window if a title is provided. After resizing, it refreshes the windows to apply the changes.
Definition at line 1128 of file dwin.c.
References bl, br, bs, bw_lt, bw_rt, bw_sp, CC_BOX, CC_NT, ls, rs, tl, tr, ts, win_box, win_ptr, and win_win.
| int xwgetch | ( | WINDOW * | win, |
| Chyron * | chyron, | ||
| int | n ) |
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line, and accepts a sinigle character answer.
xwgetch
| win | Pointer to window |
| chyron | Pointer to chyron struct |
| n | Number of seconds to wait before timing out 0: Wait indefinitely for user input (raw mode)
accept a single character answer, and don't wait for Enter key
1: Wait for 1 decisecond
n > 1: Wait for n/10 seconds
|
Get mouse event and check if it's a left click or double click. If the click is outside the window, ignore it. If it's on the chyron line, get the corresponding key command. Otherwise, store the click coordinates as click_y and click_x for later use.
Definition at line 2094 of file dwin.c.
References click_x, click_y, curses_tioctl, display_error(), em0, em1, em2, get_chyron_key(), handle_signal(), mk_raw_tioctl(), restore_curses_tioctl(), and sig_received.
Referenced by action_disposition(), answer_yn(), display_error(), field_editor(), form_post(), form_process(), menu_cmd_processor(), Perror(), and wait_continue().