|
C-Menu 0.2.9
A User Interface Toolkit
|
NotCurses UI backend — lifecycle, surface management, and capabilities. More...
#include <iso646.h>#include "cm.h"#include "ui_backend.h"#include "ui_notcurses_compat.h"#include "ui_notcurses_internal.h"#include <errno.h>#include <inttypes.h>#include <locale.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <unistd.h>Go to the source code of this file.
Macros | |
| #define | _XOPEN_SOURCE_EXTENDED 1 |
Functions | |
| void | ui_abs_yx (UiSurface *s, ss_t w, int *y, int *x) |
| Get the absolute cursor position within a window of a UI surface. | |
| uint | ui_add_pair (uint fg, uint bg) |
| Add a new color pair to the UI color pair palette. | |
| int | ui_bkgd (UiSurface *s, ss_t w, const UiCell *cell) |
| Set the background cell for the specified window within a UI surface. | |
| int | ui_bkgdset (UiSurface *s, ss_t w, const UiCell *cell) |
| Set the background cell for the specified window within a UI surface without changing the base character. | |
| int | ui_bkgrnd (UiSurface *s, ss_t w, const UiCell *cell) |
| Set the background cell for the specified window within a UI surface without changing the base character. | |
| int | ui_bkgrndset (UiSurface *s, ss_t w, const UiCell *cell) |
| Set the background cell for the specified window within a UI surface without changing the base character. | |
| UiCell | ui_cell_from_ucp (const wchar_t *ucp, const uint32_t *fg, const uint32_t *bg) |
| Create a UiCell from a Unicode codepoint and specified foreground and background colors. | |
| int | ui_chg_color (uint16_t color_idx, uint32_t *color) |
| Change the color at a specified index in the UI color palette. | |
| int | ui_clear () |
| Clear the contents of the standard plane. | |
| int | ui_color_content (uint16_t color, uint8_t *r, uint8_t *g, uint8_t *b) |
| Get the RGB components of a color from the UI color palette. | |
| uint | ui_color_from_rgb (RGB *rgb) |
| Convert an RGB color to a color index in the UI color palette. | |
| int | ui_curs_set (int visible) |
| Enable or disable the cursor visibility. | |
| int | ui_cursor_enable (UiSurface *s, ss_t w, bool visible) |
| Enable or disable the cursor at the current position on the surface and plane specified. | |
| int | ui_cursor_enable_yx (UiSurface *s, ss_t w, uint y, uint x, bool visible) |
| Enable or disable the cursor at a specific position on the surface and plane specified. | |
| int | ui_cursor_move (UiSurface *s, ss_t w, uint y, uint x) |
| Move the cursor to the specified position within a window of a UI surface. | |
| void | ui_cursor_yx (int *y, int *x) |
| Get the current cursor position within a window of a UI surface. | |
| void | ui_def_prog_mode () |
| void | ui_endwin () |
| Destroy a UI surface and free its resources. | |
| int | ui_erase () |
| Clear the contents of the specified window within a UI surface. | |
| UiBackend | ui_get_backend () |
| Get the current UI backend in use. | |
| void | ui_get_caps (UiCaps *caps) |
| Get the capabilities of the current UI backend. | |
| uint64_t | ui_get_channels_from_pair (uint16_t pair) |
| Get the combined foreground and background color channels for a given color pair index. | |
| int | ui_get_nccell (UiSurface *sfc, ss_t w, const UiCell *cell, wchar_t *wstr, UiStyle *style, short *pair) |
| Get the properties of a cell at the current cursor position in a window of a UI surface. | |
| int | ui_get_pair (uint16_t pair, uint *fg, uint *bg) |
| Get the foreground and background color indices for a given color pair index. | |
| void | ui_get_screen_size (uint *lines, uint *cols) |
| Get the current screen size in lines and columns. | |
| int | ui_getmaxx (UiSurface *s, ss_t w) |
| Get the maximum number of columns of a window within a UI surface. | |
| int | ui_getmaxy (UiSurface *s, ss_t w) |
| Get the maximum number of lines (rows) of a window within a UI surface. | |
| void | ui_getmaxyx (UiSurface *s, ss_t w, uint *y, uint *x) |
| Get the maximum dimensions of a window within a UI surface. | |
| void | ui_getyx (UiSurface *s, ss_t w, uint *y, uint *x) |
| Get the current cursor position within a window of a UI surface. | |
| RGB | ui_hex_to_rgb (char *s) |
| Convert a hexadecimal color string to an RGB structure. | |
| int | ui_idcok (UiSurface *s, ss_t w, bool enable) |
| Enable or disable the keypad for the specified window within a UI surface. | |
| int | ui_idlok (UiSurface *s, ss_t w, bool enable) |
| Enable or disable the use of the keypad for the specified window within a UI surface. | |
| UiRuntime * | ui_init (const UiConfig *cfg, SIO *sio) |
| Initialize the UI runtime with the specified configuration and SIO. | |
| int | ui_init_color (uint16_t color, uint8_t r, uint8_t g, uint8_t b) |
| Initialize a color in the UI color palette with specified RGB components. | |
| uint | ui_init_color_hex (char *s) |
| Initialize a color from a hexadecimal string representation. | |
| int | ui_init_pair (uint16_t pair, uint fg, uint bg) |
| Initialize a color pair in the UI color pair palette with specified foreground and background colors. | |
| int | ui_keypad (UiSurface *s, ss_t w, bool enable) |
| Enable or disable the keypad for the specified window within a UI surface. | |
| uint | ui_mbstr_to_cellstr (UiSurface *sfc, ss_t w, UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *p, const uint atmost) |
| Convert multibyte string to complex character array (Notcurses version). | |
| struct notcurses * | ui_notcurses_get_nc () |
| Get the pointer to the Notcurses context associated with the UI. | |
| NcPlane * | ui_notcurses_surface_get_plane (const UiSurface *s, ss_t w) |
| Get the pointer to the NcPlane associated with a specific window in a UI surface. | |
| int | ui_pair_content (uint16_t pair, uint *fg, uint *bg) |
| Get the foreground and background color indices for a given color pair index. | |
| void | ui_render () |
| Render the UI. | |
| int | ui_resume () |
| Resume the UI and enter the alternate screen. | |
| int | ui_scrollok (UiSurface *s, ss_t w, bool enable) |
| Enable or disable scrolling for the specified window within a UI surface. | |
| int | ui_set_nccell (UiSurface *sfc, ss_t w, UiCell *cell, const wchar_t *wstr, const UiStyle style, short pair) |
| Set the properties of a cell at the current cursor position in a window of a UI surface. | |
| int | ui_setscrreg (UiSurface *s, ss_t w, uint top, uint bottom) |
| Set the scrolling region for the specified window within a UI surface. | |
| void | ui_shutdown () |
| Shutdown the UI runtime and free all associated resources. | |
| int | ui_surface_addpad (UiSurface *s, ss_t w, uint p, uint lines, uint cols, uint y, uint x) |
| Add padding to an existing UI surface. | |
| int | ui_surface_addwin (UiSurface *s, ss_t w, uint p, uint lines, uint cols, uint y, uint x) |
| Add a new window to an existing UI surface. | |
| UiSurface * | ui_surface_box (UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x, const char *wtitle) |
| Create a new UI surface with a border box and optional title. | |
| void | ui_surface_destroy (UiSurface *s) |
| Destroy a UI surface and free its resources. | |
| int | ui_surface_hide (UiSurface *s, ss_t w) |
| Hide the specified window within a UI surface. | |
| int | ui_surface_move (UiSurface *s, ss_t w, uint y, uint x) |
| Move a UI surface to a new position on the screen. | |
| UiSurface * | ui_surface_new (ss_t w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x) |
| Create a new UI surface with the specified parameters. | |
| int | ui_surface_resize (UiSurface *s, ss_t w, uint lines, uint cols) |
| Resize a UI surface to new dimensions. | |
| int | ui_surface_show (UiSurface *s, ss_t w) |
| Show the specified window within a UI surface. | |
| int | ui_suspend () |
| Suspend the UI and leave the alternate screen. | |
| int | ui_top_surface (UiSurface *s, ss_t w) |
| Move the specified window within a UI surface to the top of the z-order. | |
| void | ui_update_panels () |
| Update the panels and render the UI. | |
| int | ui_wclear (UiSurface *s, ss_t w) |
| Clear the contents of the specified window within a UI surface. | |
| int | ui_werase (UiSurface *s, ss_t w) |
| Clear the contents of the specified window within a UI surface. | |
| int | ui_wmove (UiSurface *s, ss_t w, uint y, uint x) |
| Move the cursor to the specified position within a window of a UI surface. | |
| int | ui_wscrl (UiSurface *s, ss_t w, int r) |
| Scroll the contents of the specified window up or down by the specified number of lines. | |
Variables | |
| UiCell | bkgd_cell |
| uint | COLS |
| uint | LINES |
| int | sfc_ptr = -1 |
| NcPlane * | stdplane |
| UiSurface * | stdsfc |
| UiRuntime * | ui = NULL |
| UiColor * | ui_color |
| uint | ui_color_cnt = 0 |
| UiConfig * | ui_config |
| UiPair * | ui_pair |
| uint | ui_pair_cnt = 0 |
| UiSurface * | ui_surface [UI_SFC_MAX] |
NotCurses UI backend — lifecycle, surface management, and capabilities.
Implements all UiRuntime and UiSurface operations declared in ui_backend.h using the NotCurses library.
Definition in file ui_notcurses.c.
| #define _XOPEN_SOURCE_EXTENDED 1 |
Definition at line 10 of file ui_notcurses.c.
Get the absolute cursor position within a window of a UI surface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| y | Pointer to an integer to store the absolute y-coordinate of the cursor. |
| x | Pointer to an integer to store the absolute x-coordinate of the cursor. |
This function retrieves the absolute cursor position within a window of a UI surface. If the surface or window is not initialized, it does nothing.
Definition at line 709 of file ui_notcurses.c.
| uint ui_add_pair | ( | uint | fg, |
| uint | bg ) |
Add a new color pair to the UI color pair palette.
| fg | The foreground color index for the new color pair. |
| bg | The background color index for the new color pair. |
This function adds a new color pair to the UI color pair palette. It checks if the specified foreground and background colors already exist in the palette. If they do, it returns the existing index. If not, it adds the new color pair and returns its index. If the maximum number of pairs is exceeded, it displays an error message and returns EXIT_FAILURE.
Definition at line 1302 of file ui_notcurses.c.
References em0, em1, em2, ssnprintf(), ui_display_error(), ui_pair, and ui_pair_cnt.
Set the background cell for the specified window within a UI surface.
Set the background of a specific window within a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| cell | Pointer to the UiCell representing the background cell. |
This function sets the background cell for the specified window within a UI surface. It updates the styles and channels of the ncplane associated with the window and stores the background cell in the metadata. If the surface is not initialized, it returns -1.
Definition at line 1069 of file ui_notcurses.c.
Referenced by init_view_boxwin(), init_view_full_screen(), ui_surface_addpad(), and ui_surface_addwin().
Set the background cell for the specified window within a UI surface without changing the base character.
Set the background for new content to be written to a specific window within a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| cell | Pointer to the UiCell representing the background cell. |
This function sets the background cell for the specified window within a UI surface without changing the base character. It updates the styles and channels of the ncplane associated with the window and stores the background cell in the metadata. If the surface is not initialized, it returns -1.
Definition at line 1090 of file ui_notcurses.c.
Referenced by display_pick_page(), display_prompt(), get_cmd_arg(), init_view_boxwin(), init_view_full_screen(), menu_cmd_processor(), menu_engine(), popup_ckeys(), reverse_object(), ui_border_title(), ui_border_ysplit_text(), ui_surface_addpad(), ui_surface_addwin(), and unreverse_object().
Set the background cell for the specified window within a UI surface without changing the base character.
Set the background of a specific window within a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| cell | Pointer to the UiCell representing the background cell. |
This function sets the background cell for the specified window within a UI surface without changing the base character. It updates the styles and channels of the ncplane associated with the window and stores the background cell in the metadata. If the surface is not initialized, it returns -1.
Definition at line 1111 of file ui_notcurses.c.
Set the background cell for the specified window within a UI surface without changing the base character.
Set the background for new content to be written to a specific window within a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| cell | Pointer to the UiCell representing the background cell. |
This function sets the background cell for the specified window within a UI surface without changing the base character. It updates the styles and channels of the ncplane associated with the window and stores the background cell in the metadata. If the surface is not initialized, it returns -1.
Definition at line 1131 of file ui_notcurses.c.
| UiCell ui_cell_from_ucp | ( | const wchar_t * | ucp, |
| const uint32_t * | fg, | ||
| const uint32_t * | bg ) |
Create a UiCell from a Unicode codepoint and specified foreground and background colors.
| ucp | Pointer to a wide character string representing the Unicode codepoint. |
| fg | Pointer to a 32-bit unsigned integer representing the foreground color. |
| bg | Pointer to a 32-bit unsigned integer representing the background color. |
This function creates a UiCell from a Unicode codepoint and specified foreground and background colors. It initializes the cell, sets its width based on the Unicode codepoint, converts the codepoint to UTF-8, and sets the styles and channels for the cell. The resulting UiCell can be used for rendering text in a UI surface.
Definition at line 1239 of file ui_notcurses.c.
| int ui_chg_color | ( | uint16_t | color_idx, |
| uint32_t * | color ) |
Change the color at a specified index in the UI color palette.
| color_idx | The index of the color to change in the UI color palette. |
| color | Pointer to a 32-bit unsigned integer representing the new color value. |
This function changes the color at a specified index in the UI color palette. It applies gamma correction to the new color value and updates both the standard and UI color arrays with the new RGB components. If the color index is out of bounds, it returns -1.
Definition at line 1498 of file ui_notcurses.c.
References std_color, ui_apply_gamma(), and ui_color.
| int ui_clear | ( | ) |
Clear the contents of the standard plane.
Clear the entire screen.
This function clears the contents of the standard plane by erasing its contents. If the standard plane is not initialized, it returns -1.
Definition at line 548 of file ui_notcurses.c.
| int ui_color_content | ( | uint16_t | color, |
| uint8_t * | r, | ||
| uint8_t * | g, | ||
| uint8_t * | b ) |
Get the RGB components of a color from the UI color palette.
| color | The index of the color in the UI color palette. |
| r | Pointer to store the red component of the color. |
| g | Pointer to store the green component of the color. |
| b | Pointer to store the blue component of the color. |
This function retrieves the RGB components of a color from the UI color palette. It checks if the specified color index is valid and then fills in the provided pointers with the corresponding RGB values. If the color index is out of bounds, it returns -1.
Definition at line 1423 of file ui_notcurses.c.
| uint ui_color_from_rgb | ( | RGB * | rgb | ) |
Convert an RGB color to a color index in the UI color palette.
| rgb | Pointer to an RGB structure representing the color to convert. |
This function converts an RGB color to a color index in the UI color palette. It applies gamma correction to the RGB values and checks if the color already exists in the palette. If it does, it returns the existing index. If not, it adds the new color to the palette and returns its index. If the palette is full, it returns -1.
Definition at line 1268 of file ui_notcurses.c.
References std_color, ui_apply_gamma(), ui_color_cnt, ui_color_content(), and ui_init_color().
| int ui_curs_set | ( | int | visible | ) |
Enable or disable the cursor visibility.
Set the visibility of the cursor.
| visible | True to enable the cursor, false to disable it. |
This function enables or disables the cursor visibility. If the UI is not initialized, it returns -1. When enabling the cursor, it retrieves the current cursor position and enables the cursor at that position.
Definition at line 985 of file ui_notcurses.c.
References ui.
Referenced by cf_accept(), field_editor(), fork_exec(), ui_answer_yn(), and ui_tracked_sfc_split_box().
Enable or disable the cursor at the current position on the surface and plane specified.
Enable or disable the cursor for a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| visible | True to enable the cursor, false to disable it. |
This function enables or disables the cursor at the current position on the surface and plane specified. If the UI is not initialized, it returns -1.
Definition at line 1037 of file ui_notcurses.c.
References ui.
Enable or disable the cursor at a specific position on the surface and plane specified.
Enable or disable the cursor at a specific position within a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| y | The y-coordinate for the cursor position. |
| x | The x-coordinate for the cursor position. |
| visible | True to enable the cursor, false to disable it. |
This function enables or disables the cursor at a specific position on the surface and plane specified. If the UI is not initialized, it returns -1.
Definition at line 1011 of file ui_notcurses.c.
References ui.
Referenced by field_editor(), get_cmd_arg(), get_cmd_char(), and picker().
Move the cursor to the specified position within a window of a UI surface.
Move the cursor to a specified position within a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| y | The y-coordinate for the new cursor position. |
| x | The x-coordinate for the new cursor position. |
This function moves the cursor to the specified position within a window of a UI surface. If the surface or window is not initialized, it returns -1.
Definition at line 681 of file ui_notcurses.c.
Referenced by cf_accept(), display_line(), display_line_eod(), display_prompt(), display_split_line(), form_post(), form_process(), get_cmd_arg(), get_cmd_char(), picker(), remove_right_angle(), scroll_next(), scroll_prev(), search(), unreverse_object(), and view_display_page().
| void ui_cursor_yx | ( | int * | y, |
| int * | x ) |
Get the current cursor position within a window of a UI surface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| y | Pointer to an unsigned integer to store the y-coordinate of the cursor. |
| x | Pointer to an unsigned integer to store the x-coordinate of the cursor. |
This function retrieves the current cursor position within a window of a UI surface. If the surface or window is not initialized, it does nothing.
Definition at line 697 of file ui_notcurses.c.
References ui.
| void ui_def_prog_mode | ( | ) |
Definition at line 971 of file ui_notcurses.c.
| void ui_endwin | ( | ) |
Destroy a UI surface and free its resources.
End the UI application, cleaning up resources and shutting down the UI runtime.
| s | Pointer to the UiSurface to be destroyed. |
This function destroys a UI surface by freeing its associated ncplanes and metadata. It also frees the memory allocated for the UiSurface structure. If the provided pointer is NULL, the function does nothing.
Definition at line 410 of file ui_notcurses.c.
References ui_shutdown().
Referenced by exec_objects(), fork_exec(), and form_exec_receiver().
| int ui_erase | ( | ) |
Clear the contents of the specified window within a UI surface.
Erase the entire screen.
| s | Pointer to the UiSurface containing the window to clear. |
| w | The index of the window to clear. |
This function clears the contents of the specified window within a UI surface by erasing its contents. If the surface or window is not initialized, it returns -1.
Definition at line 563 of file ui_notcurses.c.
Referenced by view_full_screen_resize().
| void ui_get_caps | ( | UiCaps * | caps | ) |
Get the capabilities of the current UI backend.
Get the UI backend capabilities.
| caps | Pointer to a UiCaps structure to be filled with the capabilities. |
This function populates the provided UiCaps structure with information about the capabilities of the current UI backend. It sets various fields in the structure, such as truecolor support, palette size, mouse support, Unicode support, and resize capability. If the provided pointer is NULL or if the UI runtime is not initialized, the function does nothing.
Definition at line 61 of file ui_notcurses.c.
References UiCaps::color_pairs, UiCaps::mouse, UiCaps::palette256, UiCaps::resize, UiCaps::truecolor, ui, and UiCaps::unicode.
| uint64_t ui_get_channels_from_pair | ( | uint16_t | pair | ) |
Get the combined foreground and background color channels for a given color pair index.
| pair | The color pair index. |
This function retrieves the combined foreground and background color channels for a given color pair index. It uses the ui_get_pair function to obtain the foreground and background color indices, then retrieves their RGB values and constructs a UiChannels structure. The resulting combined channels are returned as a 64-bit unsigned integer.
Definition at line 1344 of file ui_notcurses.c.
References ui_color_content(), and ui_get_pair().
| int ui_get_nccell | ( | UiSurface * | sfc, |
| ss_t | w, | ||
| const UiCell * | cell, | ||
| wchar_t * | wstr, | ||
| UiStyle * | style, | ||
| short * | pair ) |
Get the properties of a cell at the current cursor position in a window of a UI surface.
| sfc | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| cell | Pointer to a UiCell structure to store the cell properties. |
| wstr | Pointer to a wide character string to store the cell's character(s). |
| style | Pointer to a UiStyle variable to store the cell's style attributes. |
| pair | Pointer to a short variable to store the color pair index of the cell. |
This function retrieves the properties of a cell at the current cursor position in a window of a UI surface. It fills in the provided UiCell structure with the cell's properties, including its character(s), style attributes, and color pair index. If any of the input pointers are NULL, it returns -1.
Definition at line 1157 of file ui_notcurses.c.
References GCluster::u32, ui_add_pair(), ui_color_from_rgb(), and GCluster::w32.
| int ui_get_pair | ( | uint16_t | pair, |
| uint * | fg, | ||
| uint * | bg ) |
Get the foreground and background color indices for a given color pair index.
| pair | The color pair index. |
| fg | Pointer to store the foreground color index. |
| bg | Pointer to store the background color index. |
Definition at line 1329 of file ui_notcurses.c.
Referenced by ui_get_channels_from_pair(), and ui_set_nccell().
| void ui_get_screen_size | ( | uint * | lines, |
| uint * | cols ) |
Get the current screen size in lines and columns.
Get the current screen size (number of lines and columns).
| lines | Pointer to an unsigned integer to store the number of lines (rows). |
| cols | Pointer to an unsigned integer to store the number of columns. |
This function retrieves the current screen size in lines and columns.
Definition at line 910 of file ui_notcurses.c.
References ui.
Referenced by open_pick_win(), popup_ckeys(), ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), ui_surface_box(), ui_surface_new(), ui_timeout_prompt(), ui_tracked_sfc_box(), ui_tracked_sfc_split_box(), view_calc_boxwin_dimensions(), view_calc_full_screen_dimensions(), and view_cmd_processor().
Get the maximum number of columns of a window within a UI surface.
Get the maximum number of columns of a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
This function retrieves the maximum number of columns of a window within a UI surface. If the surface or window is not initialized, it returns -1.
Definition at line 766 of file ui_notcurses.c.
Referenced by ui_border_draw(), ui_border_title(), ui_border_ysplit(), and ui_border_ysplit_text().
Get the maximum number of lines (rows) of a window within a UI surface.
Get the maximum number of lines (rows) of a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
This function retrieves the maximum number of lines (rows) of a window within a UI surface. If the surface or window is not initialized, it returns -1.
Definition at line 751 of file ui_notcurses.c.
Referenced by field_editor(), ui_assign_chyron_win(), and ui_border_draw().
Get the maximum dimensions of a window within a UI surface.
Get the maximum dimensions of a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| y | Pointer to an unsigned integer to store the maximum number of lines (rows). |
| x | Pointer to an unsigned integer to store the maximum number of columns. |
This function retrieves the maximum dimensions of a window within a UI surface. If the surface or window is not initialized, it does nothing.
Definition at line 737 of file ui_notcurses.c.
Referenced by form_post(), form_process(), and picker().
Get the current cursor position within a window of a UI surface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| y | Pointer to an unsigned integer to store the y-coordinate of the cursor. |
| x | Pointer to an unsigned integer to store the x-coordinate of the cursor. |
This function retrieves the current cursor position within a window of a UI surface. If the surface or window is not initialized, it does nothing.
Definition at line 723 of file ui_notcurses.c.
Referenced by display_prompt(), and get_cmd_char().
| RGB ui_hex_to_rgb | ( | char * | s | ) |
Convert a hexadecimal color string to an RGB structure.
| s | A string representing the color in hexadecimal format (e.g., "#RRGGBB"). |
This function converts a hexadecimal color string to an RGB structure. It uses sscanf to parse the hex string and extract the red, green, and blue components. The resulting RGB structure is returned.
Definition at line 1406 of file ui_notcurses.c.
Enable or disable the keypad for the specified window within a UI surface.
Enable or disable the use of the insert/delete character capabilities for a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| enable | True to enable the keypad, false to disable the keypad. |
This function does nothing.
Definition at line 851 of file ui_notcurses.c.
Referenced by init_view_boxwin(), and init_view_full_screen().
Enable or disable the use of the keypad for the specified window within a UI surface.
Enable or disable the use of the insert/delete line capabilities for a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| enable | True to enable the use of the keypad, false to disable it. |
This function does nothing.
Definition at line 865 of file ui_notcurses.c.
Referenced by init_view_boxwin(), and init_view_full_screen().
Initialize the UI runtime with the specified configuration and SIO.
Initialize the UI runtime with the given configuration and SIO.
| cfg | Pointer to a UiConfig structure containing configuration options. |
| sio | Pointer to a SIO structure for input/output operations. |
This function initializes the UI runtime using the NotCurses library. It sets up the terminal, creates the standard plane, and initializes various UI components based on the provided configuration. If any step fails, it cleans up and returns NULL.
Definition at line 88 of file ui_notcurses.c.
References border_double, border_heavy, border_none, border_rounded, border_single, UiConfig::border_style, bw, f_ncurses_open, f_notcurses_open, UiConfig::log_level, sfc_ptr, stdplane, stdsfc, border_wide::str, SUB_SFC_MAX, ui, ui_color, ui_color_cnt, ui_initialize_sio(), ui_min_log_level, ui_pair, ui_pair_cnt, and ui_shutdown().
Referenced by main().
| int ui_init_color | ( | uint16_t | color, |
| uint8_t | r, | ||
| uint8_t | g, | ||
| uint8_t | b ) |
Initialize a color in the UI color palette with specified RGB components.
| color | The index of the color to initialize in the UI color palette. |
| r | The red component of the color (0-255). |
| g | The green component of the color (0-255). |
| b | The blue component of the color (0-255). |
This function initializes a color in the UI color palette with specified RGB components. It checks if the specified color index is valid and then sets the corresponding RGB values in the ui_color array. If the color index is out of bounds, it returns -1.
Definition at line 1443 of file ui_notcurses.c.
References ui_color.
| uint ui_init_color_hex | ( | char * | s | ) |
Initialize a color from a hexadecimal string representation.
| s | A string representing the color in hexadecimal format (e.g., "#RRGGBB"). |
This function initializes a color from a hexadecimal string representation. It converts the hex string to an RGB structure, applies gamma correction, and checks if the color already exists in the UI color palette. If it does, it returns the existing index. If not, it adds the new color to the palette and returns its index. If the palette is full, it returns 0.
Definition at line 1374 of file ui_notcurses.c.
References std_color, ui_apply_gamma(), ui_color, ui_color_cnt, and ui_hex_to_rgb().
| int ui_init_pair | ( | uint16_t | pair, |
| uint | fg, | ||
| uint | bg ) |
Initialize a color pair in the UI color pair palette with specified foreground and background colors.
| pair | The index of the color pair to initialize in the UI color pair palette. |
| fg | The foreground color index for the color pair. |
| bg | The background color index for the color pair. |
This function initializes a color pair in the UI color pair palette with specified foreground and background colors. It checks if the specified pair index is valid and then sets the corresponding foreground and background color indices in the ui_pair array. If the pair index is out of bounds, it returns -1.
Definition at line 1481 of file ui_notcurses.c.
References ui_pair.
Enable or disable the keypad for the specified window within a UI surface.
Enable or disable the keypad for a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| enable | True to enable the keypad, false to disable it. |
This function does nothing.
Definition at line 895 of file ui_notcurses.c.
Referenced by fork_exec(), init_view_boxwin(), init_view_full_screen(), menu_cmd_processor(), open_pick_win(), picker(), and popup_ckeys().
| uint ui_mbstr_to_cellstr | ( | UiSurface * | sfc, |
| ss_t | w, | ||
| UiCell * | cmplx_buf, | ||
| const char * | str, | ||
| const UiCell * | cell_base, | ||
| uint * | p, | ||
| const uint | atmost ) |
Convert multibyte string to complex character array (Notcurses version).
ui__mbstr_to_cellstr
| cmplx_buf | Output buffer for complex characters |
| str | Input multibyte string |
| cell_base | Base cell for attributes and color pair |
| p | Pointer to current position in the output buffer, updated as characters are added |
| atmost | Maximum length of the output buffer |
This function is a specialized version of ui_mbstr_to_cellstr for use with NCurses. It converts a multibyte string to an array of complex characters (cchar_t) that can be used with NCurses functions. It handles multibyte characters and applies the attributes and color pair from the base cell to each character. The p parameter is updated to reflect the current position in the output buffer, and the function ensures that it does not exceed the maximum length specified by atmost.
Definition at line 1562 of file ui_notcurses.c.
| struct notcurses * ui_notcurses_get_nc | ( | ) |
Get the pointer to the Notcurses context associated with the UI.
Return the raw struct notcurses* for the NotCurses session.
This function retrieves the pointer to the Notcurses context associated with the UI. If the UI is not initialized, it returns NULL.
Definition at line 1523 of file ui_notcurses.c.
References ui.
Get the pointer to the NcPlane associated with a specific window in a UI surface.
Return the raw struct ncplane* underlying a surface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
This function retrieves the pointer to the NcPlane associated with a specific window in a UI surface. If the surface is not initialized, it returns NULL.
Definition at line 1536 of file ui_notcurses.c.
| int ui_pair_content | ( | uint16_t | pair, |
| uint * | fg, | ||
| uint * | bg ) |
Get the foreground and background color indices for a given color pair index.
| pair | The color pair index. |
| fg | Pointer to store the foreground color index. |
| bg | Pointer to store the background color index. |
This function retrieves the foreground and background color indices for a given color pair index. It checks if the specified pair index is valid and then fills in the provided pointers with the corresponding foreground and background color indices. If the pair index is out of bounds, it returns -1.
Definition at line 1462 of file ui_notcurses.c.
| void ui_render | ( | ) |
Render the UI.
Render the UI by updating panels and refreshing the display.
This function renders the UI.
Definition at line 935 of file ui_notcurses.c.
References ui.
Referenced by cf_accept(), display_form(), display_line(), display_pick_page(), field_editor(), form_display_accept_field(), form_display_field(), form_display_fields(), get_cmd_arg(), get_cmd_char(), init_pick(), main(), menu_cmd_processor(), menu_engine(), pad_refresh(), picker(), read_theme(), ui_draw_text_fill(), ui_get_event(), ui_restore_wins(), ui_surface_destroy(), ui_timeout_prompt(), ui_tracked_sfc_box(), ui_update_timeout_prompt(), view_boxwin_resize(), view_display_page(), and view_full_screen_resize().
| int ui_resume | ( | ) |
Resume the UI and enter the alternate screen.
Resume the UI, restoring the previous program state and updating the display.
This function resumes the UI and enters the alternate screen. It is typically used after a suspension of the UI, allowing the application to return to its previous state and continue rendering the UI.
Definition at line 964 of file ui_notcurses.c.
References ui.
Referenced by fork_exec().
Enable or disable scrolling for the specified window within a UI surface.
Enable or disable scrolling for a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| enable | True to enable scrolling, false to disable scrolling. |
This function enables or disables scrolling for the specified window within a UI surface. If the surface or window is not initialized, it returns -1.
Definition at line 837 of file ui_notcurses.c.
Referenced by init_view_boxwin(), init_view_full_screen(), menu_cmd_processor(), open_pick_win(), ui_surface_addpad(), and ui_surface_box().
| int ui_set_nccell | ( | UiSurface * | sfc, |
| ss_t | w, | ||
| UiCell * | cell, | ||
| const wchar_t * | wstr, | ||
| const UiStyle | style, | ||
| short | pair ) |
Set the properties of a cell at the current cursor position in a window of a UI surface.
| sfc | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| cell | Pointer to a UiCell structure representing the cell properties to set. |
| wstr | Pointer to a wide character string representing the character(s) to set in the cell. |
| style | The style attributes to set for the cell. |
| pair | The color pair index to set for the cell. |
This function sets the properties of a cell at the current cursor position in a window of a UI surface. It updates the specified UiCell structure with the provided character(s), style attributes, and color pair index. If any of the input pointers are NULL, it returns -1.
Definition at line 1204 of file ui_notcurses.c.
References GCluster::u32, ui_color_content(), and ui_get_pair().
Set the scrolling region for the specified window within a UI surface.
Set the scrolling region for a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| top | The top line of the scrolling region. |
| bottom | The bottom line of the scrolling region. |
This function does nothing.
Definition at line 880 of file ui_notcurses.c.
Referenced by init_view_boxwin(), init_view_full_screen(), and open_pick_win().
| void ui_shutdown | ( | ) |
Shutdown the UI runtime and free all associated resources.
Shutdown the UI runtime, cleaning up resources and freeing memory.
This function shuts down the UI runtime by destroying all surfaces, freeing memory, and stopping the NotCurses library. It also closes the terminal file pointer if it was opened. If the UI runtime is not initialized, the function does nothing.
Definition at line 420 of file ui_notcurses.c.
References f_ncurses_open, f_notcurses_open, sfc_ptr, stdsfc, ui, ui_color, ui_pair, ui_surface, and ui_surface_destroy().
Referenced by cmenu_shutdown(), main(), ui_abend(), ui_destroy_curses(), ui_endwin(), and ui_init().
Add padding to an existing UI surface.
Add a new pad to the specified UiSurface.
| s | Pointer to the UiSurface to which padding will be added. |
| w | The index of the new padded surface. |
| p | The index of the parent plane to attach to. |
| lines | The number of lines (rows) for the padded surface. |
| cols | The number of columns for the padded surface. |
| y | The y-coordinate for the padded surface's position. |
| x | The x-coordinate for the padded surface's position. |
This function adds padding to an existing UI surface by creating a new ncplane with the specified dimensions and position. It updates the metadata for the new padded surface and sets its background and scrolling properties. If any step fails, it cleans up and returns -1.
Definition at line 333 of file ui_notcurses.c.
References cell_nt, f_notcurses_open, ui, ui_bkgd(), ui_bkgdset(), and ui_scrollok().
Referenced by init_view_boxwin(), and init_view_full_screen().
Add a new window to an existing UI surface.
Add a new window to the specified UiSurface.
| s | Pointer to the UiSurface to which the window will be added. |
| w | The index of the new window. |
| p | The index of the parent plane to attach to. |
| lines | The number of lines (rows) for the new window. |
| cols | The number of columns for the new window. |
| y | The y-coordinate for the new window's position. |
| x | The x-coordinate for the new window's position. |
This function adds a new window to an existing UI surface by creating a new ncplane with the specified dimensions and position. It updates the metadata for the new window and sets its background properties. If any step fails, it cleans up and returns -1.
Definition at line 378 of file ui_notcurses.c.
References cell_nt, f_notcurses_open, ui, ui_bkgd(), and ui_bkgdset().
Referenced by init_view_boxwin(), init_view_full_screen(), ui_display_image(), ui_tracked_sfc_box(), and ui_tracked_sfc_split_box().
| UiSurface * ui_surface_box | ( | UiSurface * | parent, |
| uint | p, | ||
| uint | lines, | ||
| uint | cols, | ||
| uint | y, | ||
| uint | x, | ||
| const char * | wtitle ) |
Create a new UI surface with a border box and optional title.
| parent | Pointer to the parent UiSurface, or NULL for no parent. |
| p | The index of the parent plane to attach to. |
| lines | The number of lines (rows) for the new surface. |
| cols | The number of columns for the new surface. |
| y | The y-coordinate for the new surface's position. |
| x | The x-coordinate for the new surface's position. |
| wtitle | The title to display on the border box, or NULL for no title. |
This function creates a new UI surface with a border box and an optional title. It allocates memory for the surface, sets up its metadata, and creates a new ncplane for rendering. If any step fails, it cleans up and returns NULL.
Definition at line 279 of file ui_notcurses.c.
References cell_box, em0, em1, em2, ssnprintf(), stdplane, strnz__cpy(), ui, ui_border_draw(), ui_border_title(), ui_display_error(), ui_get_screen_size(), and ui_scrollok().
Referenced by init_view_boxwin(), ui_display_image(), ui_tracked_sfc_box(), and ui_tracked_sfc_split_box().
| void ui_surface_destroy | ( | UiSurface * | s | ) |
Destroy a UI surface and free its resources.
Destroy a UiSurface, cleaning up its windows and panels.
| s | Pointer to the UiSurface to be destroyed. |
This function destroys a UI surface by freeing its associated ncplanes and metadata. It also frees the memory allocated for the UiSurface structure. If the provided pointer is NULL, the function does nothing.
Definition at line 479 of file ui_notcurses.c.
References SUB_SFC_MAX, and ui_render().
Referenced by destroy_pick_view(), main(), ui_cm_surface_destroy(), ui_framed_surface_destroy(), ui_framed_surface_new(), ui_shutdown(), view_boxwin_resize(), view_file(), and view_full_screen_resize().
Hide the specified window within a UI surface.
Hide a UiSurface, making it invisible on the screen.
| s | Pointer to the UiSurface containing the window to hide. |
| w | The index of the window to hide. |
This function hides the specified window within a UI surface by updating its metadata and moving it far off-screen. If the surface or window is not initialized, it returns -1.
Definition at line 641 of file ui_notcurses.c.
Move a UI surface to a new position on the screen.
Move a UiSurface to a new position on the screen.
| s | Pointer to the UiSurface to be moved. |
| w | The index of the window within the surface to move. |
| y | The new y-coordinate for the surface's position. |
| x | The new x-coordinate for the surface's position. |
This function moves a UI surface to a new position on the screen by updating its metadata and moving the associated ncplane. If the surface is hidden, it only updates the metadata without moving the ncplane. If any step fails, it returns -1.
Definition at line 515 of file ui_notcurses.c.
| UiSurface * ui_surface_new | ( | ss_t | w, |
| UiSurface * | parent, | ||
| uint | p, | ||
| uint | lines, | ||
| uint | cols, | ||
| uint | y, | ||
| uint | x ) |
Create a new UI surface with the specified parameters.
| w | The index of the surface to create. |
| parent | Pointer to the parent UiSurface, or NULL for no parent. |
| p | The index of the parent plane to attach to. |
| lines | The number of lines (rows) for the new surface. |
| cols | The number of columns for the new surface. |
| y | The y-coordinate for the new surface's position. |
| x | The x-coordinate for the new surface's position. |
This function creates a new UI surface and initializes its properties based on the provided parameters. It allocates memory for the surface, sets up its metadata, and creates a new ncplane for rendering. If any step fails, it cleans up and returns NULL.
Definition at line 224 of file ui_notcurses.c.
References em0, em1, em2, f_notcurses_open, ssnprintf(), stdplane, SUB_SFC_MAX, ui, ui_display_error(), and ui_get_screen_size().
Referenced by init_view_full_screen(), and ui_framed_surface_new().
Resize a UI surface to new dimensions.
Resize a UiSurface to new dimensions.
| s | Pointer to the UiSurface to be resized. |
| w | The index of the window within the surface to resize. |
| lines | The new number of lines (rows) for the surface. |
| cols | The new number of columns for the surface. |
This function resizes a UI surface to new dimensions by updating its metadata and resizing the associated ncplane. If any step fails, it returns -1.
Definition at line 534 of file ui_notcurses.c.
Show the specified window within a UI surface.
Show a UiSurface, making it visible on the screen.
| s | Pointer to the UiSurface containing the window to show. |
| w | The index of the window to show. |
This function shows the specified window within a UI surface by updating its metadata and moving it to its designated position. If the surface or window is not initialized, it returns -1.
Definition at line 623 of file ui_notcurses.c.
| int ui_suspend | ( | ) |
Suspend the UI and leave the alternate screen.
Suspend the UI, saving the current program state and ending the window session.
This function suspends the UI and leaves the alternate screen. It is typically used when the application needs to temporarily exit the UI mode, such as when executing a shell command or displaying a message outside of the UI context.
Definition at line 949 of file ui_notcurses.c.
References ui.
Move the specified window within a UI surface to the top of the z-order.
Hide a UiSurface, making it invisible on the screen.
| s | Pointer to the UiSurface containing the window to move. |
| w | The index of the window to move to the top. |
This function moves the specified window within a UI surface to the top of the z-order, making it the foremost window. If the surface or window is not initialized, it returns -1.
Definition at line 608 of file ui_notcurses.c.
Referenced by get_cmd_char(), and picker().
| void ui_update_panels | ( | ) |
Update the panels and render the UI.
Update the panels in the UI.
This function updates the panels and renders the UI.
Definition at line 926 of file ui_notcurses.c.
References ui.
Clear the contents of the specified window within a UI surface.
Clear the contents of a UiSurface or all surfaces.
| s | Pointer to the UiSurface containing the window to clear. |
| w | The index of the window to clear. |
This function clears the contents of the specified window within a UI surface by erasing its contents. If the surface or window is not initialized, it returns -1.
Definition at line 593 of file ui_notcurses.c.
References SUB_SFC_MAX.
Clear the contents of the specified window within a UI surface.
Erase the contents of a UiSurface or all surfaces.
| s | Pointer to the UiSurface containing the window to clear. |
| w | The index of the window to clear. |
This function clears the contents of the specified window within a UI surface by erasing its contents. If the surface or window is not initialized, it returns -1.
Definition at line 578 of file ui_notcurses.c.
References SUB_SFC_MAX.
Referenced by exec_objects(), and full_screen_shell().
Move the cursor to the specified position within a window of a UI surface.
Move the cursor to a specified position within a UiSurface.
| s | Pointer to the UiSurface containing the window. |
| w | The index of the window within the surface. |
| y | The y-coordinate for the new cursor position. |
| x | The x-coordinate for the new cursor position. |
This function moves the cursor to the specified position within a window of a UI surface. If the surface or window is not initialized, it returns -1.
Definition at line 664 of file ui_notcurses.c.
Referenced by full_screen_shell(), menu_cmd_processor(), ui_display_chyron(), ui_mvwadd_wchnstr(), and ui_mvwadd_wchstr().
Scroll the contents of the specified window up or down by the specified number of lines.
Scroll the contents of a UiSurface by a specified number of lines.
| s | The surface containing the window to scroll. |
| w | The index of the window to scroll. |
| r | The number of lines to scroll. Positive values scroll up, negative values scroll down. |
If r is positive, the contents of the plane are moved up, leaving blank lines at the bottom. In the view application, the view scope is moved toward end of file (eof). - scope_toward_eof()
Definition at line 789 of file ui_notcurses.c.
Referenced by display_pick_page(), scroll_next(), and scroll_prev().
| UiCell bkgd_cell |
Definition at line 34 of file ui_notcurses.c.
| uint COLS |
Definition at line 30 of file ui_notcurses.c.
| uint LINES |
Definition at line 30 of file ui_notcurses.c.
| int sfc_ptr = -1 |
Definition at line 36 of file ui_notcurses.c.
Referenced by display_field(), display_form(), field_editor(), form_display_accept_field(), form_display_field(), form_display_fields(), form_engine(), form_post(), form_process(), init_form(), main(), menu_cmd_processor(), menu_engine(), open_pick_win(), popup_ckeys(), ui_action_disposition(), ui_answer_yn(), ui_cm_surface_destroy(), ui_display_error(), ui_init(), ui_perror(), ui_restore_wins(), ui_shutdown(), ui_timeout_prompt(), ui_tracked_sfc_box(), and ui_tracked_sfc_split_box().
| NcPlane* stdplane |
Definition at line 37 of file ui_notcurses.c.
Referenced by ui_init(), ui_surface_box(), and ui_surface_new().
| UiSurface* stdsfc |
Definition at line 29 of file ui_notcurses.c.
Referenced by exec_objects(), fork_exec(), full_screen_shell(), ui_display_image(), ui_init(), ui_init(), and ui_shutdown().
| UiRuntime* ui = NULL |
Definition at line 24 of file ui_notcurses.c.
| UiColor * ui_color |
Definition at line 28 of file ui_notcurses.c.
Referenced by ui_chg_color(), ui_init(), ui_init_color(), ui_init_color_hex(), and ui_shutdown().
| uint ui_color_cnt = 0 |
Definition at line 25 of file ui_notcurses.c.
| UiConfig * ui_config |
Definition at line 32 of file ui_notcurses.c.
| UiPair * ui_pair |
Definition at line 27 of file ui_notcurses.c.
Referenced by ui_add_pair(), ui_init(), ui_init_pair(), and ui_shutdown().
| uint ui_pair_cnt = 0 |
Definition at line 26 of file ui_notcurses.c.
| UiSurface* ui_surface[UI_SFC_MAX] |
Definition at line 33 of file ui_notcurses.c.