7
8
9
10
11
12
13
14
16#include "../include/ui_backend.h"
17#include <notcurses/notcurses.h>
20
21
22
26
27
28
#define min(x, y)
min macro evaluates two expressions, returning least result
int ui_border_draw(UiSurface *sfc)
int ui_surface_resize(UiSurface *s, ss_t w, uint lines, uint cols)
Resize a UiSurface to new dimensions.
int ui_surface_addwin(UiSurface *s, ss_t w, uint p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
const wchar_t * border_none
UiRuntime * ui_init(const UiConfig *config, SIO *sio)
Initialize the UI runtime with the given configuration and SIO.
void ui_render()
Render the UI by updating panels and refreshing the display.
void ui_getyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the current cursor position within a window of a UI surface.
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
int ui_wmove(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the maximum dimensions of a UiSurface.
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 within a UiSurface.
int ui_wscrl(UiSurface *s, ss_t w, int rows)
Scroll the contents of a UiSurface by a specified number of lines.
int ui_idcok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete character capabilities for a UiSurface.
int ui_surface_addpad(UiSurface *s, ss_t w, uint view_win, uint lines, uint cols, uint begy, uint begx)
Add a new pad to the specified UiSurface.
int ui_cursor_move(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
int ui_suspend()
Suspend the UI, saving the current program state and ending the window session.
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
int ui_border_title(UiSurface *sfc, const char *title)
Draw a box with a title around the specified window.
void ui_update_panels()
Update the panels in the UI.
int ui_bkgd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
int ui_idlok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete line capabilities for a UiSurface.
const wchar_t * border_double
int ui_surface_move(UiSurface *s, ss_t w, uint y, uint x)
Move a UiSurface to a new position on the screen.
int ui_getmaxy(UiSurface *s, ss_t w)
Get the maximum number of lines (rows) of a UiSurface.
UiSurface * ui_surface_box(UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x, const char *title)
Create a new UI surface with a border box and optional title.
const wchar_t * border_single
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
int ui_surface_show(UiSurface *s, ss_t w)
Show a UiSurface, making it visible on the screen.
int ui_erase()
Erase the entire screen.
void ui_shutdown()
Shutdown the UI runtime, cleaning up resources and freeing memory.
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.
void ui_initialize_sio(SIO *sio)
int ui_curs_set(int visibility)
Set the visibility of the cursor.
int ui_resume()
Resume the UI, restoring the previous program state and updating the display.
int ui_bkgrndset(UiSurface *s, ss_t w, const UiCell *cell)
Set the background for new content to be written to a specific window within a UiSurface.
int ui_top_surface(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
int ui_wclear(UiSurface *s, ss_t w)
Clear the contents of a UiSurface or all surfaces.
void ui_endwin()
End the UI application, cleaning up resources and shutting down the UI runtime.
int ui_cursor_enable(UiSurface *s, ss_t w, bool visible)
Enable or disable the cursor for a UiSurface.
int ui_clear()
Clear the entire screen.
int ui_getmaxx(UiSurface *s, ss_t w)
Get the maximum number of columns of a UiSurface.
const wchar_t * border_heavy
int ui_surface_hide(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
const wchar_t * border_rounded
int ui_bkgrnd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
void ui_get_caps(UiCaps *caps)
Get the UI backend capabilities.
int ui_bkgdset(UiSurface *s, ss_t w, const UiCell *cell)
Set the background for new content to be written to a specific window within a UiSurface.
int ui_werase(UiSurface *s, ss_t w)
Erase the contents of a UiSurface or all surfaces.
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
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_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_init_color_hex(char *s)
Initialize a color from a hexadecimal string representation.
struct notcurses * ui_notcurses_get_nc()
Get the pointer to the Notcurses context associated with the UI.
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.
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_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.
void ui_cursor_yx(int *y, int *x)
Get the current cursor position within a window of a UI surface.
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.
UiLogLevel ui_min_log_level
void ui_apply_gamma(RGB *rgb)
Apply gamma correction to RGB color.
int ui_pair_content(uint pair, uint *fg, uint *bg)
Get the foreground and background colors of a specified color pair.
int ui_init_color(uint color, uint r, uint g, uint b)
Initialize a color in the curses color table with specified RGB values.
int ui_init_pair(uint pair, uint fg, uint bg)
Initialize a color pair in the curses color table with specified foreground and background colors.
uint ui_add_pair(uint fg, uint bg)
Add a new color pair to the UI, or retrieve the index of an existing pair.
UiSurface * ui_surface[UI_SFC_MAX]
int ui_color_content(uint color, uint *r, uint *g, uint *b)
RGB ui_hex_to_rgb(char *s)
Convert a hexadecimal color string to an RGB structure.
UiCell ui_cell_from_ucp(const wchar_t *ucp, const uint32_t *fg, const uint32_t *bg)
Convert a Unicode code point to a curses UiCell with specified foreground and background colors.
int ui_color_from_rgb(RGB *rgb)
Convert RGB to curses color index, adding new color if necessary.
int ui_chg_color(uint16_t color_idx, uint32_t *color)
Change the RGB color value for a given color index.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
int ui_display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
UiBackend ui_get_backend()
Get the UI backend type.
UiBorderStyle border_style