|
C-Menu 0.2.9
A User Interface Toolkit
|
Manage NCurses windows and color settings. More...
Functions | |
| int | box2_new (int wlines, int wcols, int wbegy, int wbegx, char *wtitle, bool win_pair) |
| Create a new window with optional box and title. | |
| int | box_new (int wlines, int wcols, int wbegy, int wbegx, char *wtitle, bool win_pair) |
| Create a new window with optional box and title. | |
| void | cbox (WINDOW *box) |
| Draw a box around the specified window. | |
| void | cbox2 (WINDOW *box) |
| Draw a box with a separator line around the specified window. | |
| void | destroy_curses () |
| Gracefully shut down NCurses and restore terminal settings. | |
| 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. | |
| void | view_full_screen_resize (Init *init) |
| Resize the full screen view and its components. | |
| void | view_win_resize (Init *init, char *title) |
| Resize the current window and its box, and update the title. | |
| int | win2_new (int wlines, int wcols, int wbegy, int wbegx) |
| Create a new window with specified dimensions and position. | |
| WINDOW * | 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, int wbegy, int wbegx) |
| 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 box2_new | ( | int | wlines, |
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx, | ||
| char * | wtitle, | ||
| bool | win_pair ) |
Create a new window with optional box and title.
box2_new
| wlines | Number of lines |
| wcols | Number of columns |
| wbegy | Beginning Y position |
| wbegx | Beginning X position |
| wtitle | Window title |
| win_pair | If true, creates a pair of windows (box and inner window) |
Definition at line 697 of file dwin.c.
References abend(), bw_lt, bw_rt, bw_sp, cbox2(), CCC_BOX, em0, ssnprintf(), win2_new(), win_box, win_new(), win_ptr, win_win, and win_win2.
Referenced by open_pick_win().
| int box_new | ( | int | wlines, |
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx, | ||
| char * | wtitle, | ||
| bool | win_pair ) |
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 |
| win_pair | If true, creates a pair of windows (box and inner window) |
Definition at line 745 of file dwin.c.
References abend(), bw_lt, bw_rt, bw_sp, cbox(), CCC_BOX, em0, ssnprintf(), win_box, win_new(), win_ptr, and win_win.
Referenced by action_disposition(), answer_yn(), display_error(), display_form(), init_view_boxwin(), menu_engine(), Perror(), popup_ckeys(), and wait_mk_win().
| void cbox | ( | WINDOW * | box | ) |
Draw a box around the specified window.
cbox
| box | Pointer to the window to draw the box around |
This function uses NCurses functions to draw a box around the specified window. It adds the appropriate characters for the corners and edges of the box based on the current character set. Use this function when you want to visually separate a window from the rest of the screen with a border.
Definition at line 957 of file dwin.c.
References bw_bl, bw_br, bw_ho, bw_tl, bw_tr, and bw_ve.
Referenced by box_new(), view_win_resize(), and win_resize().
| void cbox2 | ( | WINDOW * | box | ) |
Draw a box with a separator line around the specified window.
cbox2
| box | Pointer to the window to draw the box around |
This function draws a box around the specified window, similar to cbox(), 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 989 of file dwin.c.
References bw_bl, bw_br, bw_ho, bw_lt, bw_rt, bw_tl, bw_tr, and bw_ve.
Referenced by box2_new().
| 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, refreshes it, 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 540 of file dwin.c.
References f_curses_open, ncurses_fp, restore_shell_tioctl(), screen, sig_dfl_mode(), win_box, win_ptr, win_win, and win_win2.
Referenced by abend(), and open_curses().
| 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 1515 of file dwin.c.
Referenced by display_page(), menu_cmd_processor(), 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
open the terminal device for reading and writing
We use SCREEN and newterm because this allows us to
specify the terminal FILE
Set gamma correction values
These are read from ~/.minitrc
We need these values when initializing colors
Definition at line 192 of file dwin.c.
References abend(), BLUE_GAMMA, SIO::blue_gamma, CCC_BOX, CCC_LN, CCC_NORM, CCC_NT, CCC_NT_HL, CCC_NT_HL_REV, CCC_NT_REV, CCC_WIN, CLR_BG, CLR_BLACK, CLR_BO, CLR_FG, CLR_LN, CLR_LN_BG, CLR_NT_BG, CLR_NT_FG, CLR_NT_HL_BG, CLR_NT_HL_FG, CLR_NT_HL_REV_BG, CLR_NT_HL_REV_FG, CLR_NT_REV_BG, CLR_NT_REV_FG, CLR_WHITE, cp_box, cp_ln, cp_norm, cp_nt, cp_nt_hl, cp_nt_hl_rev, cp_nt_rev, cp_win, destroy_curses(), f_curses_open, get_clr_pair(), GRAY_GAMMA, SIO::gray_gamma, GREEN_GAMMA, SIO::green_gamma, init_clr_palette(), mkccc(), ncurses_fp, RED_GAMMA, SIO::red_gamma, screen, strnz__cat(), strnz__cpy(), SIO::tty_name, and win_ptr.
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 and refreshing 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 933 of file dwin.c.
References win_box, win_ptr, and win_win.
Referenced by dmon(), enter_file_spec(), exec_objects(), fork_exec(), form_exec_receiver(), full_screen_shell(), menu_cmd_processor(), menu_engine(), view_cmd_processor(), and write_view_buffer().
| 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 115 of file init_view.c.
References View::cmdln_win, View::cols, View::lines, View::ln_win, View::ln_win_cols, View::ln_win_lines, View::pad, View::scroll_lines, view, and view_calc_full_screen_dimensions().
Referenced by view_cmd_processor().
| void view_win_resize | ( | Init * | init, |
| char * | title ) |
Resize the current window and its box, and update the title.
| init | Pointer to the Init structure containing view settings. |
| 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 265 of file init_view.c.
References View::begx, View::begy, View::box, bw_lt, bw_rt, bw_sp, cbox(), CCC_BOX, CCC_LN, View::cmdln_win, View::cols, View::f_ln, View::lines, View::ln_win, View::ln_win_cols, View::ln_win_lines, View::pad, View::scroll_lines, View::smaxcol, View::smaxrow, View::smincol, View::sminrow, view, and view_calc_win_dimensions().
Referenced by view_cmd_processor().
| int win2_new | ( | int | wlines, |
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx ) |
Create a new window with specified dimensions and position.
win2_new
| wlines | Number of lines |
| wcols | Number of columns |
| wbegy | Beginning Y position |
| wbegx | Beginning X position |
Definition at line 814 of file dwin.c.
References CCC_NT, win_box, win_ptr, and win_win2.
Referenced by box2_new().
| WINDOW * 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 893 of file dwin.c.
References CCC_NT, win_box, win_ptr, and win_win.
Referenced by action_disposition(), answer_yn(), display_error(), init_form(), init_pick(), menu_engine(), Perror(), popup_ckeys(), popup_view(), and wait_destroy().
| void win_init_attrs | ( | ) |
| int win_new | ( | int | wlines, |
| int | wcols, | ||
| int | wbegy, | ||
| int | wbegx ) |
Create a new window with specified dimensions and position.
win_new
| wlines | Number of lines |
| wcols | Number of columns |
| wbegy | Beginning Y position |
| wbegx | Beginning X position |
Definition at line 788 of file dwin.c.
References CCC_NT, win_box, win_ptr, and win_win.
Referenced by box2_new(), and 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.
| 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 841 of file dwin.c.
References bw_lt, bw_rt, bw_sp, cbox(), CCC_BOX, CCC_NT, 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 1651 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(), get_cmd_arg(), get_cmd_char(), menu_cmd_processor(), Perror(), remove_file(), and wait_continue().