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
UiSurface * ui_surface_box(UiSurface *parent, ss_t 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:293
int ui_surface_resize(UiSurface *s, ss_t w, uint lines, uint cols)
Resize a UiSurface to new dimensions.
Definition ui_ncurses.c:567
UiRuntime * ui_init(const UiConfig *config, SIO *sio)
Initialize the UI runtime with the given configuration and SIO.
Definition ui_ncurses.c:130
void ui_render()
Render the UI by updating panels and refreshing the display.
Definition ui_ncurses.c:931
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:707
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
Definition ui_ncurses.c:230
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
Definition ui_ncurses.c:861
int ui_plane_cpy(NcPlane *dst, NcPlane *src, int dst_y, int dst_x, int src_y, int src_x, int ylen, int xlen)
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:685
void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the maximum dimensions of a UiSurface.
Definition ui_ncurses.c:722
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:896
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:770
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:844
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:698
#define UI_SFC_MAX
Definition ui_backend.h:64
int ui_surface_addwin(UiSurface *s, ss_t w, ss_t p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
Definition ui_ncurses.c:423
#define UI_PAIRS
Definition ui_backend.h:62
int ui_suspend()
Suspend the UI, saving the current program state and ending the window session.
Definition ui_ncurses.c:525
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
Definition ui_ncurses.c:499
int ui_surface_addpad(UiSurface *s, ss_t w, ss_t view_win, uint lines, uint cols, uint y, uint x, bool hidden)
Add a new pad to the specified UiSurface.
Definition ui_ncurses.c:381
@ SUB_SFC_MAX
Definition ui_backend.h:86
void ui_update_panels()
Update the panels in the UI.
Definition ui_ncurses.c:937
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:974
#define ERR
Definition ui_backend.h:468
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:828
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:552
int ui_prefresh(UiSurface *s, ss_t w, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
Definition ui_ncurses.c:923
int ui_getmaxy(UiSurface *s, ss_t w)
Get the maximum number of lines (rows) of a UiSurface.
Definition ui_ncurses.c:733
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
Definition ui_ncurses.c:754
int ui_surface_show(UiSurface *s, ss_t w)
Show a UiSurface, making it visible on the screen.
Definition ui_ncurses.c:641
int ui_erase()
Erase the entire screen.
Definition ui_ncurses.c:623
void ui_shutdown()
Shutdown the UI runtime, cleaning up resources and freeing memory.
Definition ui_ncurses.c:449
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:881
int ui_resume()
Resume the UI, restoring the previous program state and updating the display.
Definition ui_ncurses.c:534
struct ncplane NcPlane
Definition ui_backend.h:189
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.
Definition ui_ncurses.c:655
int ui_wclear(UiSurface *s, ss_t w)
Clear the contents of a UiSurface or all surfaces.
Definition ui_ncurses.c:603
void ui_endwin()
End the UI application, cleaning up resources and shutting down the UI runtime.
Definition ui_ncurses.c:443
int ui_cursor_enable(UiSurface *s, ss_t w, bool visible)
Enable or disable the cursor for a UiSurface.
Definition ui_ncurses.c:911
int ui_clear()
Clear the entire screen.
Definition ui_ncurses.c:631
int ui_getmaxx(UiSurface *s, ss_t w)
Get the maximum number of columns of a UiSurface.
Definition ui_ncurses.c:744
int ui_surface_hide(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
Definition ui_ncurses.c:667
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.
Definition ui_ncurses.c:796
uint16_t UiStyle
Definition ui_backend.h:184
#define UI_COLORS
Definition ui_backend.h:61
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:988
int ui_werase(UiSurface *s, ss_t w)
Erase the contents of a UiSurface or all surfaces.
Definition ui_ncurses.c:582
@ UI_BACKEND_NOTCURSES
Definition ui_backend.h:494
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
Definition ui_ncurses.c:812
#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.
void ui_plane_get_abs_yx(UiSurface *s, ss_t w, int *absy, int *absx)
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.
const wchar_t * border_none
Definition ui_common.c:89
int ui_border_draw(UiSurface *sfc, ss_t w)
Definition ui_common.c:523
UiCell cell_nt
Definition ui_common.c:123
UiLogContext ui_log_ctx
Definition ui_common.c:53
BorderWide bw
Definition ui_common.c:27
STDRGB std_color[]
Definition ui_common.c:188
const wchar_t * border_double
Definition ui_common.c:86
const wchar_t * border_single
Definition ui_common.c:85
void ui_initialize_sio(SIO *sio)
Definition ui_common.c:211
int ui_border_title(UiSurface *sfc, ss_t w, const char *title)
Draw a box with a title around the specified window.
Definition ui_common.c:621
const wchar_t * border_heavy
Definition ui_common.c:88
bool f_notcurses_open
Definition ui_common.c:51
const wchar_t * border_rounded
Definition ui_common.c:87
void ui_apply_gamma(RGB *rgb)
Apply gamma correction to RGB color.
Definition ui_common.c:1002
UiCell cell_box
Definition ui_common.c:127
void ui_log_write(const UiLogLevel level, const char *file, const char *func, const int line, const char *fmt,...)
Definition ui_common.c:1476
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:102
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:867
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 lf.h:38
char em1[MAXLEN]
Definition lf.c:43
char em2[MAXLEN]
Definition lf.c:44
char em0[MAXLEN]
Definition lf.c:42
#define _(String)
Definition amort.c:23
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition lf.c:2299
size_t ssnprintf(char *, size_t, const char *,...)
Custom safe string formatting utility (Variadic version).
Definition futil.c:398
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:1261
UiBackend ui_get_backend()
Get the UI backend type.
Definition ui_ncurses.c:55
wchar_t w32
Definition ui_backend.h:148
uint32_t u32
Definition ui_backend.h:147
UiLogLevel min_level
Definition ui_backend.h:237
UiBorderStyle border_style
Definition ui_backend.h:486
UiLogLevel log_level
Definition ui_backend.h:488
bool palette256
Definition ui_backend.h:499
bool mouse
Definition ui_backend.h:500
bool pad_relative_yx
Definition ui_backend.h:504
int color_pairs
Definition ui_backend.h:503
bool truecolor
Definition ui_backend.h:498
bool unicode
Definition ui_backend.h:501
bool resize
Definition ui_backend.h:502
wchar_t str[11]
Definition ui_backend.h:609