C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
ui_notcurses_compat.h
Go to the documentation of this file.
1#pragma once
2#ifdef __cplusplus
3extern "C" {
4#endif
5
6/** @file ui_notcurses_compat.h
7 @ingroup ui_notcurses
8 @brief Non-portable escape hatch for the NotCurses backend.
9
10 @warning Including this header couples application code to the NotCurses
11 backend. Use only when NotCurses-specific functionality is required and
12 portability to other backends (e.g., NCurses) is not needed. These
13 functions are intentionally not declared in ui_backend.h.
14*/
15
16#include "../include/ui_backend.h"
17#include <notcurses/notcurses.h>
18
19/** @brief Return the raw @c struct notcurses* for the NotCurses session.
20 @param ui The UiRuntime returned by ui_init().
21 @return The NotCurses context pointer, or NULL if @p ui is NULL.
22*/
23struct notcurses *ui_notcurses_get_nc();
24
25/** @brief Return the raw @c struct ncplane* underlying a surface.
26 @param s The UiSurface to inspect.
27 @return The ncplane pointer, or NULL if @p s is NULL.
28*/
29struct ncplane *ui_notcurses_surface_get_plane(const UiSurface *s, ss_t w);
30
31#ifdef __cplusplus
32}
33#endif
#define min(x, y)
min macro evaluates two expressions, returning least result
Definition cm.h:104
int ui_border_draw(UiSurface *sfc)
Definition ui_common.c:474
int ui_surface_resize(UiSurface *s, ss_t w, uint lines, uint cols)
Resize a UiSurface to new dimensions.
Definition ui_ncurses.c:536
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.
Definition ui_ncurses.c:395
const wchar_t * border_none
Definition ui_common.c:72
UiRuntime * ui_init(const UiConfig *config, SIO *sio)
Initialize the UI runtime with the given configuration and SIO.
Definition ui_ncurses.c:129
void ui_render()
Render the UI by updating panels and refreshing the display.
Definition ui_ncurses.c:884
void ui_getyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the current cursor position within a window of a UI surface.
Definition ui_ncurses.c:675
UiCell cell_nt
Definition ui_common.c:106
char em1[MAXLEN]
Definition ui_common.c:47
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
Definition ui_ncurses.c:820
int ui_wmove(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
Definition ui_ncurses.c:653
void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the maximum dimensions of a UiSurface.
Definition ui_ncurses.c:690
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.
Definition ui_ncurses.c:855
char em2[MAXLEN]
Definition ui_common.c:48
int ui_wscrl(UiSurface *s, ss_t w, int rows)
Scroll the contents of a UiSurface by a specified number of lines.
Definition ui_ncurses.c:738
int ui_idcok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete character capabilities for a UiSurface.
Definition ui_ncurses.c:803
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.
Definition ui_ncurses.c:369
BorderWide bw
Definition ui_common.c:27
int ui_cursor_move(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
Definition ui_ncurses.c:666
#define UI_SFC_MAX
Definition ui_backend.h:196
#define UI_PAIRS
Definition ui_backend.h:194
int ui_suspend()
Suspend the UI, saving the current program state and ending the window session.
Definition ui_ncurses.c:494
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
Definition ui_ncurses.c:468
@ SUB_SFC_MAX
Definition ui_backend.h:47
int ui_border_title(UiSurface *sfc, const char *title)
Draw a box with a title around the specified window.
Definition ui_common.c:563
void ui_update_panels()
Update the panels in the UI.
Definition ui_ncurses.c:890
int ui_bkgd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
Definition ui_ncurses.c:927
#define ERR
Definition ui_backend.h:427
int ui_idlok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete line capabilities for a UiSurface.
Definition ui_ncurses.c:787
const wchar_t * border_double
Definition ui_common.c:69
int ui_surface_move(UiSurface *s, ss_t w, uint y, uint x)
Move a UiSurface to a new position on the screen.
Definition ui_ncurses.c:521
int ui_getmaxy(UiSurface *s, ss_t w)
Get the maximum number of lines (rows) of a UiSurface.
Definition ui_ncurses.c:701
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.
Definition ui_ncurses.c:288
const wchar_t * border_single
Definition ui_common.c:68
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
Definition ui_ncurses.c:722
int ui_surface_show(UiSurface *s, ss_t w)
Show a UiSurface, making it visible on the screen.
Definition ui_ncurses.c:609
int ui_erase()
Erase the entire screen.
Definition ui_ncurses.c:591
void ui_shutdown()
Shutdown the UI runtime, cleaning up resources and freeing memory.
Definition ui_ncurses.c:418
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.
Definition ui_ncurses.c:229
void ui_initialize_sio(SIO *sio)
Definition ui_common.c:182
UiSurface * stdsfc
Definition ui_ncurses.c:46
int sfc_ptr
Definition ui_ncurses.c:42
int ui_curs_set(int visibility)
Set the visibility of the cursor.
Definition ui_ncurses.c:840
int ui_resume()
Resume the UI, restoring the previous program state and updating the display.
Definition ui_ncurses.c:503
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.
Definition ui_ncurses.c:969
int ui_top_surface(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
Definition ui_ncurses.c:623
int ui_wclear(UiSurface *s, ss_t w)
Clear the contents of a UiSurface or all surfaces.
Definition ui_ncurses.c:571
char em0[MAXLEN]
Definition ui_common.c:46
void ui_endwin()
End the UI application, cleaning up resources and shutting down the UI runtime.
Definition ui_ncurses.c:412
int ui_cursor_enable(UiSurface *s, ss_t w, bool visible)
Enable or disable the cursor for a UiSurface.
Definition ui_ncurses.c:870
int ui_clear()
Clear the entire screen.
Definition ui_ncurses.c:599
int ui_getmaxx(UiSurface *s, ss_t w)
Get the maximum number of columns of a UiSurface.
Definition ui_ncurses.c:712
const wchar_t * border_heavy
Definition ui_common.c:71
int ui_surface_hide(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
Definition ui_ncurses.c:635
bool f_notcurses_open
Definition ui_common.c:51
const wchar_t * border_rounded
Definition ui_common.c:70
int ui_bkgrnd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
Definition ui_ncurses.c:955
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
Definition ui_ncurses.c:755
uint16_t UiStyle
Definition ui_backend.h:158
#define UI_COLORS
Definition ui_backend.h:193
void ui_get_caps(UiCaps *caps)
Get the UI backend capabilities.
Definition ui_ncurses.c:62
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.
Definition ui_ncurses.c:941
int ui_werase(UiSurface *s, ss_t w)
Erase the contents of a UiSurface or all surfaces.
Definition ui_ncurses.c:551
@ UI_BACKEND_NOTCURSES
Definition ui_backend.h:453
UiCell cell_box
Definition ui_common.c:110
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
Definition ui_ncurses.c:771
#define WA_NORMAL
#define XLEN
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.
UiPair * ui_pair
UiConfig * ui_config
UiCell bkgd_cell
uint ui_init_color_hex(char *s)
Initialize a color from a hexadecimal string representation.
UiColor * ui_color
struct notcurses * ui_notcurses_get_nc()
Get the pointer to the Notcurses context associated with the UI.
NcPlane * stdplane
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.
STDRGB std_color[]
Definition ui_common.c:159
UiLogLevel ui_min_log_level
Definition ui_common.c:1390
void ui_apply_gamma(RGB *rgb)
Apply gamma correction to RGB color.
Definition ui_common.c:941
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]
Definition ui_ncurses.c:40
int ui_color_content(uint color, uint *r, uint *g, uint *b)
UiRuntime * ui
Definition ui_ncurses.c:39
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.
Definition ui_ncurses.c:101
uint ui_pair_cnt
Definition ui_ncurses.c:44
uint ui_color_cnt
Definition ui_ncurses.c:43
void ui_def_prog_mode()
Definition ui_ncurses.c:826
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.
#define MAXLEN
Definition curskeys.c:15
#define _(String)
Definition amort.c:23
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition whence.c:291
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:390
int ui_display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
Definition ui_common.c:1200
UiBackend ui_get_backend()
Get the UI backend type.
Definition ui_ncurses.c:55
wchar_t w32
Definition ui_backend.h:122
uint32_t u32
Definition ui_backend.h:121
UiBorderStyle border_style
Definition ui_backend.h:445
UiLogLevel log_level
Definition ui_backend.h:447
bool palette256
Definition ui_backend.h:458
bool mouse
Definition ui_backend.h:459
int color_pairs
Definition ui_backend.h:462
bool truecolor
Definition ui_backend.h:457
bool unicode
Definition ui_backend.h:460
bool resize
Definition ui_backend.h:461
wchar_t str[11]
Definition ui_backend.h:563