C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
ui_notcurses.c File Reference

NotCurses UI backend — lifecycle, surface management, and capabilities. More...

#include "common.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>
Include dependency graph for ui_notcurses.c:

Go to the source code of this file.

Macros

#define _XOPEN_SOURCE_EXTENDED   1

Functions

int ui_add_color_rgb (RGB *rgb)
uint ui_add_pair (uint fg, uint bg)
int ui_bkgd (UiSurface *s, uint w, const UiCell *cell)
int ui_bkgdset (UiSurface *s, uint w, const UiCell *cell)
int ui_bkgrnd (UiSurface *s, uint w, const UiCell *cell)
int ui_bkgrndset (UiSurface *s, uint w, const UiCell *cell)
UiSurfaceui_box_surface_new (UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x, char *wtitle)
UiCell ui_cell_from_ucp (const wchar_t *ucp, const uint32_t *fg, const uint32_t *bg)
int ui_chg_color (uint16_t color_idx, uint32_t *color)
int ui_clear ()
int ui_color_content (uint16_t color, uint8_t *r, uint8_t *g, uint8_t *b)
int ui_curs_set (int visible)
int ui_cursor_enable (UiSurface *s, uint w, bool visible)
 Disable (visible = false) or enable (visibile = true) the cursor at its current position on the surface and plane specified.
int ui_cursor_enable_yx (UiSurface *s, uint w, uint y, uint x, bool visible)
 Disable (visible = false) or enable (visibile = true) the cursor at a specified position on the surface and plane specified. Include workaround for NotCurses cursor position bug.
int ui_cursor_move (UiSurface *s, uint w, uint y, uint x)
void ui_endwin ()
int ui_erase ()
UiBackend ui_get_backend ()
 Return which backend is powering this runtime.
void ui_get_caps (UiCaps *caps)
 Query the capabilities of the active backend.
uint64_t ui_get_channels_from_pair (uint16_t pair)
int ui_get_pair (uint16_t pair, uint *fg, uint *bg)
void ui_get_screen_size (uint *lines, uint *cols)
int ui_getcchar (const UiCell *uic, wchar_t *wc, UiStyle *style, UiPairIdx *pair, const void *opts)
uint ui_getmaxx (UiSurface *s, uint w)
uint ui_getmaxy (UiSurface *s, uint w)
void ui_getmaxyx (UiSurface *s, uint w, uint *y, uint *x)
void ui_getyx (UiSurface *s, uint w, uint *y, uint *x)
RGB ui_hex_to_rgb (char *s)
int ui_idcok (UiSurface *s, uint w, bool enable)
int ui_idlok (UiSurface *s, uint w, bool enable)
UiRuntimeui_init (const UiConfig *cfg)
int ui_init_color (uint16_t color, uint8_t r, uint8_t g, uint8_t b)
uint ui_init_color_hex (char *s)
int ui_init_pair (uint16_t pair, uint fg, uint bg)
int ui_keypad (UiSurface *s, uint w, bool enable)
int ui_mice_enable (int mask)
int ui_mousemask (int mask)
struct notcurses * ui_notcurses_get_nc ()
 Return the raw struct notcurses* for the NotCurses session.
NcPlaneui_notcurses_surface_get_plane (const UiSurface *s, uint w)
 Return the raw struct ncplane* underlying a surface.
int ui_pair_content (uint16_t pair, uint *fg, uint *bg)
void ui_render ()
int ui_resume ()
int ui_scrollok (UiSurface *s, uint w, bool enable)
int ui_setcchar (UiCell *cell, const wchar_t *wstr, const uint16_t style, ushort pair, const void *opts)
int ui_setscrreg (UiSurface *s, uint w, uint top, uint bottom)
void ui_shutdown ()
int ui_surface_addpad (UiSurface *s, uint w, uint p, uint lines, uint cols)
int ui_surface_addwin (UiSurface *s, uint w, uint p, uint lines, uint cols, uint y, uint x)
void ui_surface_destroy (UiSurface *s)
int ui_surface_hide (UiSurface *s, uint w)
int ui_surface_move (UiSurface *s, uint w, uint y, uint x)
UiSurfaceui_surface_new (uint w, UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x)
int ui_surface_resize (UiSurface *s, uint w, uint lines, uint cols)
int ui_surface_show (UiSurface *s, uint w)
int ui_suspend ()
int ui_top_panel (UiSurface *s, uint w)
void ui_update_panels ()
int ui_wclear (UiSurface *s, uint w)
int ui_werase (UiSurface *s, uint w)
int ui_wmove (UiSurface *s, uint w, uint y, uint x)
int ui_wnoutrefresh (UiSurface *s, uint w)
int ui_wscrl (UiSurface *s, uint w, int r)

Variables

UiCell bkgd_cell
wchar_t * border_double = L"═║╠╣╦╩╬╔╗╚╝"
wchar_t * border_heavy = L"━┃┣┫┳┻╋┏┓┗┛"
wchar_t * border_none = L" "
wchar_t * border_rounded = L"─│├┤┬┴┼╭╮╰╯"
wchar_t * border_single = L"─│├┤┬┴┼┌┐└┘"
BorderWide bw
const wchar_t * bw_chk = L"\x2611"
const wchar_t * bw_da = L"\x2193"
const wchar_t * bw_h09 = L"\x23BD"
const wchar_t * bw_la = L"\x2190"
const wchar_t * bw_lan = L"\x276E"
const wchar_t * bw_ra = L"\x2192"
const wchar_t * bw_ran = L"\x276F"
const wchar_t * bw_rbl = L"\x2570"
const wchar_t * bw_rbr = L"\x256f"
const wchar_t * bw_rtl = L"\x256d"
const wchar_t * bw_rtr = L"\x256e"
const wchar_t * bw_sp = L"\x20"
const wchar_t * bw_ua = L"\x2191"
uint COLS
uint LINES
int sfc_ptr = -1
STDRGB std_color [] = {{0, 0, 0}, {128, 0, 0}, {0, 128, 0}, {128, 128, 0}, {0, 0, 128}, {128, 0, 128}, {0, 128, 128}, {192, 192, 192}, {128, 128, 128}, {255, 0, 0}, {0, 255, 0}, {255, 255, 0}, {0, 0, 255}, {255, 0, 255}, {0, 255, 255}, {255, 255, 255}}
NcPlanestdplane
UiSurfacestdsfc
UiRuntimeui = NULL
UiColorui_color
uint ui_color_cnt = 0
UiConfigui_config
UiPairui_pair
uint ui_pair_cnt = 0
UiSurfaceui_surface [UI_SFC_MAX]
int win_ptr = -1

Detailed Description

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.

Macro Definition Documentation

◆ _XOPEN_SOURCE_EXTENDED

#define _XOPEN_SOURCE_EXTENDED   1

Definition at line 10 of file ui_notcurses.c.

Function Documentation

◆ ui_add_color_rgb()

int ui_add_color_rgb ( RGB * rgb)

Definition at line 726 of file ui_notcurses.c.

726 {
727 uint i;
728 RGB tmp;
729 apply_gamma(rgb);
730 for (i = 0; i < ui_color_cnt && i < UI_COLORS; i++) {
731 ui_color_content(i, &tmp.r, &tmp.g, &tmp.b);
732 if (rgb->r == tmp.r && rgb->g == tmp.g && rgb->b == tmp.b)
733 return i;
734 }
735 if (i < UI_COLORS) {
736 if (i < 16) {
737 std_color[i].r = rgb->r;
738 std_color[i].g = rgb->g;
739 std_color[i].b = rgb->b;
740 }
741 ui_init_color(i, rgb->r, rgb->g, rgb->b);
742 if (ui_color_cnt + 1 < UI_COLORS)
743 ui_color_cnt++;
744 return ui_color_cnt - 1;
745 }
746 return -1;
747}
STDRGB std_color[]
Definition ui_ncurses.c:62
uint ui_color_cnt
Definition ui_ncurses.c:33
#define UI_COLORS
Definition ui_backend.h:39
int ui_init_color(uint16_t color, uint8_t r, uint8_t g, uint8_t b)
int ui_color_content(uint16_t color, uint8_t *r, uint8_t *g, uint8_t *b)
void apply_gamma(RGB *rgb)
Apply gamma correction to RGB color.
Definition dwin.c:307

References apply_gamma(), STDRGB::b, STDRGB::g, STDRGB::r, std_color, ui_color_cnt, ui_color_content(), and ui_init_color().

Referenced by parse_ansi(), parse_ansi_str(), ui_cell_from_ucp(), ui_getcchar(), and ui_pair_from_hex().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_add_pair()

uint ui_add_pair ( uint fg,
uint bg )

Definition at line 749 of file ui_notcurses.c.

749 {
750 uint16_t i;
751 for (i = 1; i < ui_pair_cnt; i++) {
752 if (ui_pair[i].fg == fg && ui_pair[i].bg == bg)
753 return i;
754 }
755 if (i + 1 >= UI_PAIRS) {
756 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
757 ssnprintf(em1, MAXLEN - 1, "NotCurses COLOR_PAIRS (%d) exceeded (%d)",
758 UI_PAIRS, i);
759 strerror_r(errno, em2, MAXLEN);
760 display_error(em0, em1, em2, nullptr);
761 return (EXIT_FAILURE);
762 }
763 if (i < UI_PAIRS) {
764 ui_pair[i].fg = fg;
765 ui_pair[i].bg = bg;
766 ui_pair_cnt++;
767 }
768 return ui_pair_cnt - 1;
769}
#define UI_PAIRS
Definition ui_backend.h:40
uint ui_pair_cnt
Definition ui_ncurses.c:34
UiPair * ui_pair
#define MAXLEN
Definition curskeys.c:15
char em1[MAXLEN]
Definition dwin.c:143
char em2[MAXLEN]
Definition dwin.c:144
char em0[MAXLEN]
Definition dwin.c:142
int display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
Definition dwin.c:778
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
Definition futil.c:413

References UiPair::bg, display_error(), em0, em1, em2, UiPair::fg, ssnprintf(), ui_pair, ui_pair_cnt, and ui_pair_content().

Here is the call graph for this function:

◆ ui_bkgd()

int ui_bkgd ( UiSurface * s,
uint w,
const UiCell * cell )

Definition at line 882 of file ui_notcurses.c.

882 {
883 if (!s)
884 return -1;
885 ncplane_set_styles(s->mplane[w], cell->stylemask);
886 ncplane_set_channels(s->mplane[w], cell_box.channels);
887 ncplane_set_base(s->mplane[w], " ",
888 cell->stylemask, cell->channels);
889 return 0;
890}
UiCell cell_box
Definition dwin.c:98
struct ncplane * mplane[SUB_SFC_MAX]

References cell_box, nccell::channels, and nccell::stylemask.

Referenced by init_view_boxwin(), init_view_full_screen(), ui_surface_addpad(), and ui_surface_addwin().

Here is the caller graph for this function:

◆ ui_bkgdset()

int ui_bkgdset ( UiSurface * s,
uint w,
const UiCell * cell )

Definition at line 892 of file ui_notcurses.c.

892 {
893 if (!s)
894 return -1;
895 ncplane_set_styles(s->mplane[w], cell->stylemask);
896 ncplane_set_channels(s->mplane[w], cell->channels);
897 bkgd_cell = *cell;
898 return 0;
899}
UiCell bkgd_cell

References bkgd_cell, nccell::channels, and nccell::stylemask.

Referenced by border_title(), border_ysplit_text(), display_pick_page(), display_prompt(), get_cmd_arg(), init_view_boxwin(), menu_cmd_processor(), menu_engine(), popup_ckeys(), reverse_object(), ui_surface_addpad(), ui_surface_addwin(), and unreverse_object().

Here is the caller graph for this function:

◆ ui_bkgrnd()

int ui_bkgrnd ( UiSurface * s,
uint w,
const UiCell * cell )

Definition at line 900 of file ui_notcurses.c.

900 {
901 if (!s)
902 return -1;
903 ncplane_set_styles(s->mplane[w], cell->stylemask);
904 ncplane_set_channels(s->mplane[w], cell->channels);
905 ncplane_set_base(s->mplane[w], " ",
906 cell->stylemask, cell->channels);
907 return 0;
908}

References nccell::channels, and nccell::stylemask.

◆ ui_bkgrndset()

int ui_bkgrndset ( UiSurface * s,
uint w,
const UiCell * cell )

Definition at line 910 of file ui_notcurses.c.

910 {
911 if (!s)
912 return -1;
913 ncplane_set_styles(s->mplane[w], cell->stylemask);
914 ncplane_set_channels(s->mplane[w], cell->channels);
915 return 0;
916}

References nccell::channels, and nccell::stylemask.

◆ ui_box_surface_new()

UiSurface * ui_box_surface_new ( UiSurface * parent,
uint p,
uint lines,
uint cols,
uint y,
uint x,
char * wtitle )

Definition at line 271 of file ui_notcurses.c.

271 {
272 if (!ui)
273 return NULL;
274 UiSurface *s = calloc(1, sizeof(*s));
275 if (!s)
276 return NULL;
277 s->runtime = ui;
278 s->parent = parent;
279 ncplane_options plane_opts = {
280 .y = y,
281 .x = x,
282 .rows = lines + 2,
283 .cols = cols + 2,
284 .name = NULL};
285 s->meta[BOX].y = y;
286 s->meta[BOX].x = x;
287 s->meta[BOX].lines = lines + 2;
288 s->meta[BOX].cols = cols + 2;
289 s->meta[BOX].hidden = false;
290 strnz__cpy(s->meta[BOX].name, "BOX", XLEN - 1);
291 if (parent && parent->mplane[p]) {
292 s->mplane[BOX] = ncplane_create(parent->mplane[p], &plane_opts);
293 } else {
294 stdplane = notcurses_stdplane(ui->nc);
295 s->mplane[BOX] = ncplane_create(stdplane, &plane_opts);
296 }
297 if (!s->mplane[BOX]) {
298 free(s);
299 return NULL;
300 }
301 ncplane_set_base(s->mplane[BOX],
302 " ",
303 0,
304 cell_box.channels);
305 ncplane_set_channels(s->mplane[BOX], cell_box.channels);
306 border_draw(s);
307 border_title(s, wtitle);
308 return s;
309}
NcPlane * stdplane
UiRuntime * ui
#define XLEN
int border_draw(UiSurface *sfc)
Definition dwin.c:581
int border_title(UiSurface *sfc, char *title)
Draw a box with a title around the specified window.
Definition dwin.c:676
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:537
A drawable surface in the NotCurses backend.
struct UiSurface * parent
struct UiRuntime * runtime
struct UiSurfaceMeta meta[SUB_SFC_MAX]

References border_draw(), border_title(), BOX, cell_box, nccell::channels, UiSurfaceMeta::cols, UiSurfaceMeta::hidden, UiSurfaceMeta::lines, UiSurface::meta, UiSurfaceMeta::name, UiRuntime::nc, UiSurface::parent, UiSurface::runtime, stdplane, strnz__cpy(), ui, ui_scrollok(), UiSurfaceMeta::x, and UiSurfaceMeta::y.

Referenced by init_view_boxwin(), surface_box_win_new(), and surface_split_box_win_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_cell_from_ucp()

UiCell ui_cell_from_ucp ( const wchar_t * ucp,
const uint32_t * fg,
const uint32_t * bg )

Definition at line 705 of file ui_notcurses.c.

705 {
706 nccell cell;
707 nccell_init(&cell);
708 GCluster *gc = (GCluster *)&cell.gcluster;
709 wchar_t wstr[2] = {ucp[0], L'\0'};
710 // wcwidth expects Unicode codepoints, not UTF-8 encoded bytes
711 cell.width = wcwidth(wstr[0]);
712 // unicode_to_utf8_gcluster converts Unicode codepoints to UTF-8
713 unicode_to_utf8_gcluster(wstr[0], gc);
714 nccell_set_styles(&cell, WA_NORMAL);
715 UiChannels *chan = (UiChannels *)&cell.channels;
716 chan->bargb = *bg;
717 chan->fargb = *fg;
718 chan->b_a = chan->f_a = 0x40;
719 return cell;
720}
#define WA_NORMAL
Definition nccell.h:3
uint32_t gcluster
Definition nccell.h:4

References nccell::channels, nccell::gcluster, ui_add_color_rgb(), ui_add_pair(), and nccell::width.

Referenced by initialize_cells().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_chg_color()

int ui_chg_color ( uint16_t color_idx,
uint32_t * color )

Definition at line 862 of file ui_notcurses.c.

862 {
863 RGB rgb;
864 rgb.color = *color;
865 if (color_idx + 1 >= UI_COLORS)
866 return -1;
867 apply_gamma(&rgb);
868 if (color_idx < 16) {
869 std_color[color_idx].r = rgb.r;
870 std_color[color_idx].g = rgb.g;
871 std_color[color_idx].b = rgb.b;
872 }
873 ui_color[color_idx].r = rgb.r;
874 ui_color[color_idx].g = rgb.g;
875 ui_color[color_idx].b = rgb.b;
876 return 0;
877}
UiColor * ui_color
uint32_t color

References apply_gamma(), STDRGB::b, RGB::color, STDRGB::g, STDRGB::r, std_color, and ui_color.

Referenced by init_clr_palette().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_clear()

int ui_clear ( )

Definition at line 552 of file ui_notcurses.c.

552 {
553 if (!stdplane)
554 return -1;
555 ncplane_erase_region(stdplane, 0, 0, 0, 0);
556 return 0;
557}

References stdplane.

◆ ui_color_content()

int ui_color_content ( uint16_t color,
uint8_t * r,
uint8_t * g,
uint8_t * b )

Definition at line 828 of file ui_notcurses.c.

828 {
829 if (color + 1 >= UI_COLORS)
830 return -1;
831 *r = ui_color[color].r;
832 *g = ui_color[color].g;
833 *b = ui_color[color].b;
834 return 0;
835}

References ui_color.

◆ ui_curs_set()

int ui_curs_set ( int visible)

Definition at line 473 of file ui_notcurses.c.

473 {
474 if (!ui)
475 return -1;
476 if (visible == 0) {
477 ui->cursor_visible = false;
478 notcurses_cursor_disable(ui->nc);
479 } else {
480 ui->cursor_visible = true;
481 int y, x;
482 notcurses_cursor_yx(ui->nc, &y, &x);
483 int rc = notcurses_cursor_enable(ui->nc, y, x);
484 return rc;
485 }
486 return 0;
487}

References UiRuntime::cursor_visible, UiRuntime::nc, and ui.

Referenced by answer_yn(), cf_accept(), field_editor(), fork_exec(), get_cmd_arg(), picker(), and surface_split_box_win_new().

Here is the caller graph for this function:

◆ ui_cursor_enable()

int ui_cursor_enable ( UiSurface * s,
uint w,
bool visible )

Disable (visible = false) or enable (visibile = true) the cursor at its current position on the surface and plane specified.

Definition at line 512 of file ui_notcurses.c.

512 {
513 if (!s)
514 return -1;
515 if (!visible) {
516 ui->cursor_visible = false;
517 notcurses_cursor_disable(ui->nc);
518 } else {
519 uint y, x;
520 ncplane_cursor_yx(s->mplane[w], &y, &x);
521 int yy, xx;
522 ncplane_abs_yx(s->mplane[w], &yy, &xx);
523 y += yy;
524 x += xx;
525 ui->cursor_visible = true;
526 return notcurses_cursor_enable(ui->nc, y, x) == 0 ? 0 : -1;
527 }
528 return 0;
529}

References UiRuntime::cursor_visible, UiRuntime::nc, and ui.

◆ ui_cursor_enable_yx()

int ui_cursor_enable_yx ( UiSurface * s,
uint w,
uint y,
uint x,
bool visible )

Disable (visible = false) or enable (visibile = true) the cursor at a specified position on the surface and plane specified. Include workaround for NotCurses cursor position bug.

Definition at line 492 of file ui_notcurses.c.

492 {
493 if (!s)
494 return -1;
495 if (!visible) {
496 ui->cursor_visible = false;
497 notcurses_cursor_disable(ui->nc);
498 } else {
499 int yy, xx;
500 ncplane_abs_yx(s->mplane[w], &yy, &xx);
501 y += yy;
502 x += xx;
503 ui->cursor_visible = true;
504 int rc = notcurses_cursor_enable(ui->nc, y, x);
505 return rc;
506 }
507 return 0;
508}

References UiRuntime::cursor_visible, UiRuntime::nc, and ui.

Referenced by get_cmd_char().

Here is the caller graph for this function:

◆ ui_cursor_move()

int ui_cursor_move ( UiSurface * s,
uint w,
uint y,
uint x )

Definition at line 605 of file ui_notcurses.c.

605 {
606 if (!s)
607 return -1;
608 if (ncplane_cursor_move_yx(s->mplane[w], y, x) != 0)
609 return -1;
610 return 0;
611}

Referenced by cf_accept(), display_line(), display_line_eod(), display_prompt(), display_split_line(), field_editor(), form_post(), form_process(), get_cmd_arg(), get_cmd_char(), notcurses_input(), picker(), remove_right_angle(), scroll_down(), scroll_up(), search(), unreverse_object(), and view_display_page().

Here is the caller graph for this function:

◆ ui_endwin()

void ui_endwin ( )

Definition at line 210 of file ui_notcurses.c.

210 {
211 // if (ui == NULL)
212 // return;
213 // if (ui->nc) {
214 // if (ui->mouse_enabled)
215 // notcurses_mice_disable(ui->nc);
216 // notcurses_stop(ui->nc);
217 // }
218 // free(ui);
219 // ui = NULL;
220}

References ui_shutdown().

Referenced by exec_objects(), fork_exec(), and form_exec_receiver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_erase()

int ui_erase ( )

Definition at line 558 of file ui_notcurses.c.

558 {
559 if (!stdplane)
560 return -1;
561 ncplane_erase_region(stdplane, 0, 0, 0, 0);
562 return 0;
563}

References stdplane.

Referenced by view_full_screen_resize().

Here is the caller graph for this function:

◆ ui_get_backend()

UiBackend ui_get_backend ( )

Return which backend is powering this runtime.

Parameters
uiThe UiRuntime returned by ui_init().
Returns
The UiBackend enum value for the compiled-in backend.

Definition at line 71 of file ui_notcurses.c.

71 {
73}
@ UI_BACKEND_NOTCURSES
Definition ui_backend.h:157

References UI_BACKEND_NCURSES, and UI_BACKEND_NOTCURSES.

◆ ui_get_caps()

void ui_get_caps ( UiCaps * caps)

Query the capabilities of the active backend.

Parameters
uiThe UiRuntime returned by ui_init().
capsOutput structure filled with capability flags.

Definition at line 75 of file ui_notcurses.c.

75 {
76 if (!caps)
77 return;
78 memset(caps, 0, sizeof(*caps));
79 if (!ui)
80 return;
81 // I don't know that it isn't truecolor
82 caps->truecolor = true;
83 caps->palette256 = true;
84 caps->mouse = ui->mouse_enabled;
85 caps->unicode = true;
86 caps->resize = true;
87 caps->color_pairs = 0;
88}
bool palette256
Definition ui_backend.h:170
bool mouse
Definition ui_backend.h:171
int color_pairs
Definition ui_backend.h:174
bool truecolor
Definition ui_backend.h:169
bool unicode
Definition ui_backend.h:172
bool resize
Definition ui_backend.h:173

References UiCaps::color_pairs, UiCaps::mouse, UiRuntime::mouse_enabled, UiCaps::palette256, UiCaps::resize, UiCaps::truecolor, ui, and UiCaps::unicode.

◆ ui_get_channels_from_pair()

uint64_t ui_get_channels_from_pair ( uint16_t pair)

Definition at line 776 of file ui_notcurses.c.

776 {
777 uint fg, bg;
778 // ui_channels is a struct that holds the foreground and background color
779 // channels
780 // use channels.fb to get the combined foreground and background color channels
781 UiChannels ui_channels = {0};
782 ui_get_pair(pair, &fg, &bg);
783 ui_color_content(fg, &ui_channels.f_r, &ui_channels.f_g, &ui_channels.f_b);
784 ui_channels.f_a = 0x40;
785 ui_channels.f_r = ui_color[fg].r;
786 ui_channels.f_g = ui_color[fg].g;
787 ui_channels.f_b = ui_color[fg].b;
788 bg = ui_pair[pair].bg;
789 ui_color_content(bg, &ui_channels.b_r, &ui_channels.b_g, &ui_channels.b_b);
790 ui_channels.b_a = 0x40;
791 ui_channels.b_r = ui_color[bg].r;
792 ui_channels.b_g = ui_color[bg].g;
793 ui_channels.b_b = ui_color[bg].b;
794 return ui_channels.fb;
795}
int ui_get_pair(uint16_t pair, uint *fg, uint *bg)

References UiPair::bg, UiChannels::fb, ui_color, ui_color_content(), ui_get_pair(), and ui_pair.

Here is the call graph for this function:

◆ ui_get_pair()

int ui_get_pair ( uint16_t pair,
uint * fg,
uint * bg )

Definition at line 770 of file ui_notcurses.c.

770 {
771 *fg = ui_pair[pair].fg;
772 *bg = ui_pair[pair].bg;
773 return 0;
774}

References UiPair::bg, UiPair::fg, and ui_pair.

Referenced by ui_get_channels_from_pair(), and ui_setcchar().

Here is the caller graph for this function:

◆ ui_get_screen_size()

void ui_get_screen_size ( uint * lines,
uint * cols )

Definition at line 434 of file ui_notcurses.c.

434 {
435 if (!ui)
436 return;
437 unsigned int r = 0, c = 0;
438 notcurses_stddim_yx(ui->nc, &r, &c);
439 ui->lines = (int)r;
440 ui->cols = (int)c;
441 if (lines)
442 *lines = ui->lines;
443 if (cols)
444 *cols = ui->cols;
445}

References UiRuntime::cols, UiRuntime::lines, UiRuntime::nc, and ui.

Referenced by action_disposition(), answer_yn(), display_error(), Perror(), pick_engine(), popup_ckeys(), surface_box_win_new(), surface_split_box_win_new(), view_calc_boxwin_dimensions(), view_calc_full_screen_dimensions(), and view_cmd_processor().

Here is the caller graph for this function:

◆ ui_getcchar()

int ui_getcchar ( const UiCell * uic,
wchar_t * wc,
UiStyle * style,
UiPairIdx * pair,
const void * opts )

Definition at line 659 of file ui_notcurses.c.

659 {
660 (void)opts;
661 if (!uic || !wc || !style || !pair)
662 return -1;
663 GCluster gcluster;
664 gcluster.u32 = uic->gcluster;
665 wc = gcluster.u16;
666 *style = uic->stylemask;
667 // Convert the channels to a color pair index
669 channels.fb = uic->channels;
670 RGB rgb;
671 rgb.r = channels.f_r;
672 rgb.g = channels.f_g;
673 rgb.b = channels.f_b;
674 // If the color index does not exist, create a new one
675 int fg = ui_add_color_rgb(&rgb);
676 rgb.r = channels.b_r;
677 rgb.g = channels.b_g;
678 rgb.b = channels.b_b;
679 // If the color index does not exist, create a new one
680 int bg = ui_add_color_rgb(&rgb);
681 // If the color pair does not exist, create a new one
682 *pair = ui_add_pair(fg, bg);
683 return 0;
684}
int ui_add_color_rgb(RGB *rgb)
uint ui_add_pair(uint fg, uint bg)
uint64_t channels
Definition nckeys.c:42
uint32_t u32
Definition ui_backend.h:288
wchar_t u16[2]
Definition ui_backend.h:289

References nccell::channels, UiChannels::fb, nccell::gcluster, nccell::stylemask, GCluster::u16, GCluster::u32, ui_add_color_rgb(), and ui_add_pair().

Here is the call graph for this function:

◆ ui_getmaxx()

uint ui_getmaxx ( UiSurface * s,
uint w )

Definition at line 629 of file ui_notcurses.c.

629 {
630 if (!s)
631 return -1;
632 uint y, x;
633 ncplane_dim_yx(s->mplane[w], &y, &x);
634 return x;
635}

◆ ui_getmaxy()

uint ui_getmaxy ( UiSurface * s,
uint w )

Definition at line 622 of file ui_notcurses.c.

622 {
623 if (!s)
624 return -1;
625 uint y, x;
626 ncplane_dim_yx(s->mplane[w], &y, &x);
627 return y;
628}

◆ ui_getmaxyx()

void ui_getmaxyx ( UiSurface * s,
uint w,
uint * y,
uint * x )

Definition at line 617 of file ui_notcurses.c.

617 {
618 if (!s)
619 return;
620 ncplane_dim_yx(s->mplane[w], y, x);
621}

Referenced by field_editor(), form_post(), form_process(), and picker().

Here is the caller graph for this function:

◆ ui_getyx()

void ui_getyx ( UiSurface * s,
uint w,
uint * y,
uint * x )

Definition at line 612 of file ui_notcurses.c.

612 {
613 if (!s)
614 return;
615 ncplane_cursor_yx(s->mplane[w], y, x);
616}

Referenced by display_prompt(), and get_cmd_char().

Here is the caller graph for this function:

◆ ui_hex_to_rgb()

RGB ui_hex_to_rgb ( char * s)

Definition at line 822 of file ui_notcurses.c.

822 {
823 RGB rgb;
824 sscanf(s, "#%02hhX%02hhX%02hhX", &rgb.r, &rgb.g, &rgb.b);
825 return rgb;
826}

Referenced by ui_init_color_hex().

Here is the caller graph for this function:

◆ ui_idcok()

int ui_idcok ( UiSurface * s,
uint w,
bool enable )

Definition at line 387 of file ui_notcurses.c.

387 {
388 (void)s;
389 (void)w;
390 (void)enable;
391 return 0;
392}

Referenced by init_view_boxwin(), and init_view_full_screen().

Here is the caller graph for this function:

◆ ui_idlok()

int ui_idlok ( UiSurface * s,
uint w,
bool enable )

Definition at line 393 of file ui_notcurses.c.

393 {
394 (void)s;
395 (void)w;
396 (void)enable;
397 return 0;
398}

Referenced by init_view_boxwin(), and init_view_full_screen().

Here is the caller graph for this function:

◆ ui_init()

UiRuntime * ui_init ( const UiConfig * cfg)

Definition at line 92 of file ui_notcurses.c.

92 {
93 setlocale(LC_ALL, "");
94 ui = calloc(1, sizeof(*ui));
95 if (!ui)
96 return NULL;
97 char tty_name[MAXLEN];
98 if (cfg && cfg->tty_path) {
99 strncpy(tty_name, cfg->tty_path, sizeof(tty_name) - 1);
100 tty_name[sizeof(tty_name) - 1] = '\0';
101 } else {
102 if (ttyname_r(STDIN_FILENO, tty_name,
103 sizeof(tty_name)) != 0) {
104 free(ui);
105 ui = NULL;
106 return NULL;
107 }
108 }
109 ui->tty_fp = fopen(tty_name, "r+");
110 if (ui->tty_fp == NULL) {
111 ui = NULL;
112 free(ui);
113 return NULL;
114 }
115 NotCursesOptions nc_opts = {
116 .flags = NCOPTION_SUPPRESS_BANNERS |
117 NCOPTION_NO_QUIT_SIGHANDLERS
118 // NCOPTION_PRESERVE_CURSOR,
119 // .loglevel = NCLOGLEVEL_SILENT,
120 };
121 ui->nc = notcurses_init(&nc_opts, ui->tty_fp);
122 if (ui->nc == NULL) {
123 free(ui);
124 ui = NULL;
125 return NULL;
126 }
127 f_curses_open = true;
128 stdplane = notcurses_stdplane(ui->nc);
129 notcurses_render(ui->nc);
130
131 if (ui->nc == NULL) {
132 fclose(ui->tty_fp);
133 ui->tty_fp = NULL;
134 free(ui);
135 ui = NULL;
136 return NULL;
137 }
138 if (cfg) {
139 ui->mouse_enabled = cfg->enable_mouse;
140 ui->alt_screen = cfg->enable_alt_screen;
141 ui->cursor_visible = cfg->cursor_visible;
142 ui->border_style = cfg->border_style;
143 } else {
144 ui->cursor_visible = false;
145 ui->alt_screen = false;
146 }
147 if (ui->mouse_enabled)
148 notcurses_mice_enable(ui->nc, NCMICE_ALL_EVENTS);
149 if (!ui->cursor_visible)
150 notcurses_cursor_disable(ui->nc);
151 notcurses_stddim_yx(ui->nc, &ui->lines, &ui->cols);
152 stdsfc = calloc(1, sizeof(*stdsfc));
153 if (!stdsfc)
154 return NULL;
155 for (int i = 0; i < SUB_SFC_MAX; i++) {
156 stdsfc->mplane[i] = NULL;
157 stdsfc->meta[i].lines = 0;
158 stdsfc->meta[i].cols = 0;
159 stdsfc->meta[i].y = 0;
160 stdsfc->meta[i].x = 0;
161 stdsfc->meta[i].hidden = false;
162 }
163 stdsfc->runtime = ui;
164 stdsfc->parent = NULL;
165 stdsfc->meta[BOX].lines = ui->lines;
166 stdsfc->meta[BOX].cols = ui->cols;
167 stdsfc->meta[BOX].y = 0;
168 stdsfc->meta[BOX].x = 0;
169 stdsfc->mplane[BOX] = stdplane;
170 if (!stdsfc->mplane[BOX]) {
171 notcurses_stop(ui->nc);
172 return NULL;
173 }
174 sfc_ptr = -1;
175 LINES = ui->lines;
176 COLS = ui->cols;
177 ui_pair = calloc(UI_PAIRS, sizeof(UiPair));
178 if (!ui_pair) {
179 free(ui_pair);
180 notcurses_stop(ui->nc);
181 free(ui);
182 return NULL;
183 }
184 ui_color = calloc(UI_COLORS, sizeof(UiColor));
185 if (!ui_color) {
186 free(ui_pair);
187 notcurses_stop(ui->nc);
188 free(ui);
189 return NULL;
190 }
191 if (cfg) {
192 if (ui->border_style == 'r' || ui->border_style == 'R') {
193 memcpy(bw.str, border_rounded, sizeof(bw.str));
194 } else if (ui->border_style == 's' || ui->border_style == 'S') {
195 memcpy(bw.str, border_single, sizeof(bw.str));
196 } else if (ui->border_style == 'd' || ui->border_style == 'D') {
197 memcpy(bw.str, border_double, sizeof(bw.str));
198 } else if (ui->border_style == 'h' || ui->border_style == 'H') {
199 memcpy(bw.str, border_heavy, sizeof(bw.str));
200 } else if (ui->border_style == 'n' || ui->border_style == 'N') {
201 memcpy(bw.str, border_none, sizeof(bw.str));
202 }
203 }
204 stdsfc = calloc(1, sizeof(*stdsfc));
205 ui_color_cnt = 0;
206 ui_pair_cnt = 0;
207 return ui;
208}
bool f_curses_open
Definition sig.c:33
wchar_t * border_rounded
Definition ui_ncurses.c:41
uint COLS
Definition ui_backend.h:266
BorderWide bw
Definition ui_ncurses.c:46
struct notcurses_options NotCursesOptions
Definition ui_backend.h:253
uint LINES
UiSurface * stdsfc
Definition ui_ncurses.c:36
int sfc_ptr
Definition nckeys.c:47
wchar_t * border_heavy
Definition ui_ncurses.c:43
wchar_t * border_double
Definition ui_ncurses.c:42
wchar_t * border_single
Definition ui_ncurses.c:40
wchar_t * border_none
Definition ui_ncurses.c:44
bool cursor_visible
Definition ui_backend.h:145
const char * tty_path
Definition ui_backend.h:147
bool enable_mouse
Definition ui_backend.h:143
char border_style
Definition ui_backend.h:146
bool enable_alt_screen
Definition ui_backend.h:144

References UiRuntime::alt_screen, border_double, border_heavy, border_none, border_rounded, border_single, UiConfig::border_style, UiRuntime::border_style, BOX, bw, COLS, UiRuntime::cols, UiSurfaceMeta::cols, UiConfig::cursor_visible, UiRuntime::cursor_visible, UiConfig::enable_alt_screen, UiConfig::enable_mouse, f_curses_open, UiSurfaceMeta::hidden, LINES, UiRuntime::lines, UiSurfaceMeta::lines, UiSurface::meta, UiRuntime::mouse_enabled, UiRuntime::nc, UiSurface::parent, Perror(), UiSurface::runtime, sfc_ptr, stdplane, stdsfc, border_wide::str, SUB_SFC_MAX, UiRuntime::tty_fp, UiConfig::tty_path, ui, ui_color, ui_color_cnt, ui_pair, ui_pair_cnt, ui_shutdown(), UiSurfaceMeta::x, and UiSurfaceMeta::y.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_init_color()

int ui_init_color ( uint16_t color,
uint8_t r,
uint8_t g,
uint8_t b )

Definition at line 837 of file ui_notcurses.c.

837 {
838 if (color + 1 >= UI_COLORS)
839 return -1;
840 ui_color[color].r = r;
841 ui_color[color].g = g;
842 ui_color[color].b = b;
843 return 0;
844}

References ui_color.

◆ ui_init_color_hex()

uint ui_init_color_hex ( char * s)

Definition at line 797 of file ui_notcurses.c.

797 {
798 RGB rgb;
799 rgb = ui_hex_to_rgb(s);
800 apply_gamma(&rgb);
801 uint i;
802 for (i = 0; i < ui_color_cnt && i < UI_COLORS; i++) {
803 if (rgb.r == ui_color[i].r && rgb.g == ui_color[i].g && rgb.b == ui_color[i].b)
804 return i;
805 }
806 if (i < UI_COLORS) {
807 if (i < 16) {
808 std_color[i].r = rgb.r;
809 std_color[i].g = rgb.g;
810 std_color[i].b = rgb.b;
811 }
812 ui_color[i].r = rgb.r;
813 ui_color[i].g = rgb.g;
814 ui_color[i].b = rgb.b;
815 if (ui_color_cnt + 1 < UI_COLORS)
816 ui_color_cnt++;
817 return ui_color_cnt - 1;
818 }
819 return 0;
820}
RGB ui_hex_to_rgb(char *s)

References apply_gamma(), STDRGB::b, STDRGB::g, STDRGB::r, std_color, ui_color, ui_color_cnt, and ui_hex_to_rgb().

Here is the call graph for this function:

◆ ui_init_pair()

int ui_init_pair ( uint16_t pair,
uint fg,
uint bg )

Definition at line 854 of file ui_notcurses.c.

854 {
855 if (pair + 1 >= UI_PAIRS)
856 return -1;
857 ui_pair[pair].fg = fg;
858 ui_pair[pair].bg = bg;
859 return 0;
860}

References UiPair::bg, UiPair::fg, and ui_pair.

◆ ui_keypad()

int ui_keypad ( UiSurface * s,
uint w,
bool enable )

Definition at line 406 of file ui_notcurses.c.

406 {
407 (void)s;
408 (void)w;
409 (void)enable;
410 return 0;
411}

Referenced by fork_exec(), init_view_boxwin(), init_view_full_screen(), menu_cmd_processor(), open_pick_win(), picker(), and popup_ckeys().

Here is the caller graph for this function:

◆ ui_mice_enable()

int ui_mice_enable ( int mask)

Definition at line 426 of file ui_notcurses.c.

426 {
427 if (mask)
428 notcurses_mice_enable(ui->nc, mask);
429 else
430 notcurses_mice_enable(ui->nc, NCMICE_ALL_EVENTS);
431 return 0;
432}

References UiRuntime::nc, and ui.

Referenced by menu_cmd_processor(), and picker().

Here is the caller graph for this function:

◆ ui_mousemask()

int ui_mousemask ( int mask)

Definition at line 416 of file ui_notcurses.c.

416 {
417 if (!ui)
418 return 0;
419 if (mask)
420 notcurses_mice_enable(ui->nc, mask);
421 else
422 notcurses_mice_enable(ui->nc, NCMICE_ALL_EVENTS);
423 return 0;
424}

References UiRuntime::nc, and ui.

◆ ui_notcurses_get_nc()

struct notcurses * ui_notcurses_get_nc ( )

Return the raw struct notcurses* for the NotCurses session.

Parameters
uiThe UiRuntime returned by ui_init().
Returns
The NotCurses context pointer, or NULL if ui is NULL.

Definition at line 921 of file ui_notcurses.c.

921 {
922 if (!ui)
923 return NULL;
924 return ui->nc;
925}

References UiRuntime::nc, and ui.

◆ ui_notcurses_surface_get_plane()

NcPlane * ui_notcurses_surface_get_plane ( const UiSurface * s,
uint w )

Return the raw struct ncplane* underlying a surface.

Parameters
sThe UiSurface to inspect.
Returns
The ncplane pointer, or NULL if s is NULL.

Definition at line 927 of file ui_notcurses.c.

927 {
928 (void)w;
929 if (!s)
930 return NULL;
931 return s->mplane[w];
932}

◆ ui_pair_content()

int ui_pair_content ( uint16_t pair,
uint * fg,
uint * bg )

Definition at line 846 of file ui_notcurses.c.

846 {
847 if (pair + 1 >= UI_PAIRS)
848 return -1;
849 *fg = ui_pair[pair].fg;
850 *bg = ui_pair[pair].bg;
851 return 0;
852}

References UiPair::bg, UiPair::fg, and ui_pair.

◆ ui_render()

void ui_render ( )

◆ ui_resume()

int ui_resume ( )

Definition at line 465 of file ui_notcurses.c.

465 {
466 if (!ui)
467 return -1;
468 notcurses_enter_alternate_screen(ui->nc);
469 notcurses_render(ui->nc);
470 return 0;
471}

References UiRuntime::nc, and ui.

Referenced by fork_exec().

Here is the caller graph for this function:

◆ ui_scrollok()

int ui_scrollok ( UiSurface * s,
uint w,
bool enable )

Definition at line 381 of file ui_notcurses.c.

381 {
382 if (!s)
383 return -1;
384 ncplane_set_scrolling(s->mplane[w], enable);
385 return 0;
386}

Referenced by init_view_boxwin(), init_view_full_screen(), menu_cmd_processor(), open_pick_win(), and ui_box_surface_new().

Here is the caller graph for this function:

◆ ui_setcchar()

int ui_setcchar ( UiCell * cell,
const wchar_t * wstr,
const uint16_t style,
ushort pair,
const void * opts )

Definition at line 686 of file ui_notcurses.c.

686 {
687 (void)opts;
688 if (!cell)
689 return -1;
690 uint32_t fg, bg;
691 GCluster *gc = (GCluster *)&cell->gcluster;
692 gc->u16[0] = wstr[0];
693 gc->u16[1] = wstr[1];
694 cell->width = wcwidth((wchar_t)*wstr);
695 nccell_set_styles(cell, style);
696 UiChannels *chan = (UiChannels *)&cell->channels;
697 ui_get_pair(pair, &fg, &bg);
698 ui_color_content(fg, &chan->f_r, &chan->f_g, &chan->f_b);
699 chan->f_a = 0x40;
700 ui_color_content(bg, &chan->b_r, &chan->b_g, &chan->b_b);
701 chan->b_a = 0x40;
702 return 0;
703}

References nccell::channels, nccell::gcluster, GCluster::u16, ui_color_content(), ui_get_pair(), and nccell::width.

Here is the call graph for this function:

◆ ui_setscrreg()

int ui_setscrreg ( UiSurface * s,
uint w,
uint top,
uint bottom )

Definition at line 399 of file ui_notcurses.c.

399 {
400 (void)s;
401 (void)w;
402 (void)top;
403 (void)bottom;
404 return 0;
405}

Referenced by init_view_boxwin(), init_view_full_screen(), and open_pick_win().

Here is the caller graph for this function:

◆ ui_shutdown()

void ui_shutdown ( )

Definition at line 222 of file ui_notcurses.c.

222 {
223 if (ui == NULL || f_curses_open == false)
224 return;
225 if (ui->nc) {
226 if (ui->mouse_enabled)
227 notcurses_mice_disable(ui->nc);
228 notcurses_stop(ui->nc);
229 f_curses_open = false;
230 }
231 free(ui);
232 ui = NULL;
233}

References f_curses_open, UiRuntime::mouse_enabled, UiRuntime::nc, sfc_ptr, stdsfc, UiRuntime::tty_fp, ui, ui_surface, and ui_surface_destroy().

Referenced by destroy_curses(), ui_endwin(), and ui_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_surface_addpad()

int ui_surface_addpad ( UiSurface * s,
uint w,
uint p,
uint lines,
uint cols )

Definition at line 311 of file ui_notcurses.c.

311 {
312 uint plines, pcols;
313 ncplane_dim_yx(s->mplane[p], &plines, &pcols);
314 pcols = min(pcols, cols);
315 plines = min(plines, lines);
316 ncplane_options plane_opts = {
317 .y = 0,
318 .x = 0,
319 .rows = plines,
320 .cols = pcols,
321 .name = NULL};
322 s->meta[w].y = 0;
323 s->meta[w].x = 0;
324 s->meta[w].lines = plines;
325 s->meta[w].cols = pcols;
326 s->meta[w].hidden = false;
327 s->mplane[w] = ncplane_create(s->mplane[p], &plane_opts);
328 if (!s->mplane[w]) {
329 notcurses_stop(ui->nc);
330 return -1;
331 }
332 ncplane_set_base(s->mplane[w], " ", 0, cell_nt.channels);
333 ncplane_set_channels(s->mplane[w], cell_nt.channels);
334 ui_bkgd(s, w, &cell_nt);
335 ui_bkgdset(s, w, &cell_nt);
336 return 0;
337}
#define min(x, y)
min macro evaluates two expressions, returning least result
Definition cm.h:91
int ui_bkgdset(UiSurface *s, uint w, const UiCell *cell)
int ui_bkgd(UiSurface *s, uint w, const UiCell *cell)
UiCell cell_nt
Definition dwin.c:94

References cell_nt, nccell::channels, UiSurfaceMeta::cols, UiSurfaceMeta::hidden, UiSurfaceMeta::lines, UiSurface::meta, UiRuntime::nc, PAD, ui, ui_bkgd(), ui_bkgdset(), UiSurfaceMeta::x, and UiSurfaceMeta::y.

Referenced by init_view_boxwin(), and init_view_full_screen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_surface_addwin()

int ui_surface_addwin ( UiSurface * s,
uint w,
uint p,
uint lines,
uint cols,
uint y,
uint x )

Definition at line 339 of file ui_notcurses.c.

339 {
340 ncplane_options plane_opts = {
341 .y = y,
342 .x = x,
343 .rows = lines,
344 .cols = cols,
345 .name = NULL};
346 s->meta[w].y = y;
347 s->meta[w].x = x;
348 s->meta[w].lines = lines;
349 s->meta[w].cols = cols;
350 s->meta[w].hidden = false;
351 s->mplane[w] = ncplane_create(s->mplane[p], &plane_opts);
352 if (!s->mplane[w]) {
353 notcurses_stop(ui->nc);
354 return -1;
355 }
356 ncplane_set_base(s->mplane[w], " ", 0, cell_nt.channels);
357 ncplane_set_channels(s->mplane[w], cell_nt.channels);
358 ui_bkgd(s, w, &cell_nt);
359 ui_bkgdset(s, w, &cell_nt);
360 return 0;
361}

References cell_nt, nccell::channels, UiSurfaceMeta::cols, UiSurfaceMeta::hidden, UiSurfaceMeta::lines, UiSurface::meta, UiRuntime::nc, ui, ui_bkgd(), ui_bkgdset(), UiSurfaceMeta::x, and UiSurfaceMeta::y.

Referenced by init_view_boxwin(), init_view_full_screen(), surface_box_win_new(), and surface_split_box_win_new().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_surface_destroy()

void ui_surface_destroy ( UiSurface * s)

Definition at line 363 of file ui_notcurses.c.

363 {
364 if (!s)
365 return;
366 for (int w = SUB_SFC_MAX; w >= 0; w--)
367 if (s->mplane[w] != NULL) {
368 ncplane_erase(s->mplane[w]);
369 ncplane_destroy(s->mplane[w]);
370 s->mplane[w] = NULL;
371 }
372 if (s != NULL) {
373 free(s);
374 s = NULL;
375 }
376}

References SUB_SFC_MAX.

Referenced by cm_surface_destroy(), destroy_pick_view(), popup_ckeys(), ui_framed_surface_destroy(), ui_framed_surface_new(), ui_shutdown(), view_boxwin_resize(), view_file(), and view_full_screen_resize().

Here is the caller graph for this function:

◆ ui_surface_hide()

int ui_surface_hide ( UiSurface * s,
uint w )

Definition at line 587 of file ui_notcurses.c.

587 {
588 if (!s)
589 return -1;
590 if (!s->meta[w].hidden) {
591 s->meta[w].hidden = true;
592 /* Move far off-screen so the plane does not obscure anything. */
593 ncplane_move_yx(s->mplane[w], -s->meta[w].lines - 1, 0);
594 }
595 return 0;
596}

References UiSurfaceMeta::hidden, UiSurfaceMeta::lines, and UiSurface::meta.

◆ ui_surface_move()

int ui_surface_move ( UiSurface * s,
uint w,
uint y,
uint x )

Definition at line 533 of file ui_notcurses.c.

533 {
534 if (!s)
535 return -1;
536 s->meta[w].y = y;
537 s->meta[w].x = x;
538 if (!s->meta[w].hidden)
539 return ncplane_move_yx(s->mplane[w], y, x) == 0 ? 0 : -1;
540 return 0;
541}

References UiSurfaceMeta::hidden, UiSurface::meta, UiSurfaceMeta::x, and UiSurfaceMeta::y.

◆ ui_surface_new()

UiSurface * ui_surface_new ( uint w,
UiSurface * parent,
uint p,
uint lines,
uint cols,
uint y,
uint x )

Definition at line 239 of file ui_notcurses.c.

239 {
240 if (!ui)
241 return NULL;
242 UiSurface *s = calloc(1, sizeof(*s));
243 if (!s)
244 return NULL;
245 s->runtime = ui;
246 s->parent = parent;
247 ncplane_options plane_opts = {
248 .y = y,
249 .x = x,
250 .rows = lines,
251 .cols = cols};
252 s->meta[w].y = y;
253 s->meta[w].x = x;
254 s->meta[w].lines = lines;
255 s->meta[w].cols = cols;
256 s->meta[w].hidden = false;
257 if (parent && parent->mplane[p]) {
258 s->mplane[w] = ncplane_create(parent->mplane[p], &plane_opts);
259 } else {
260 stdplane = notcurses_stdplane(ui->nc);
261 s->mplane[w] = ncplane_create(stdplane, &plane_opts);
262 }
263 if (!s->mplane[w]) {
264 notcurses_stop(ui->nc);
265 return NULL;
266 }
267 free(stdsfc);
268 return s;
269}

References UiSurfaceMeta::cols, UiSurfaceMeta::hidden, UiSurfaceMeta::lines, UiSurface::meta, UiRuntime::nc, UiSurface::parent, UiSurface::runtime, stdplane, stdsfc, SUB_SFC_MAX, ui, UiSurfaceMeta::x, and UiSurfaceMeta::y.

Referenced by init_view_full_screen(), and ui_framed_surface_new().

Here is the caller graph for this function:

◆ ui_surface_resize()

int ui_surface_resize ( UiSurface * s,
uint w,
uint lines,
uint cols )

Definition at line 543 of file ui_notcurses.c.

543 {
544 if (!s)
545 return -1;
546 return ncplane_resize_simple(s->mplane[w], (unsigned int)lines,
547 (unsigned int)cols) == 0
548 ? 0
549 : -1;
550}

References UiSurfaceMeta::cols, UiSurfaceMeta::lines, and UiSurface::meta.

◆ ui_surface_show()

int ui_surface_show ( UiSurface * s,
uint w )

Definition at line 577 of file ui_notcurses.c.

577 {
578 if (!s)
579 return -1;
580 if (s->meta[w].hidden) {
581 s->meta[w].hidden = false;
582 ncplane_move_yx(s->mplane[w], s->meta[w].y, s->meta[w].x);
583 }
584 return 0;
585}

References UiSurfaceMeta::hidden, UiSurface::meta, UiSurfaceMeta::x, and UiSurfaceMeta::y.

◆ ui_suspend()

int ui_suspend ( )

Definition at line 458 of file ui_notcurses.c.

458 {
459 if (!ui)
460 return -1;
461 notcurses_leave_alternate_screen(ui->nc);
462 return 0;
463}

References UiRuntime::nc, and ui.

◆ ui_top_panel()

int ui_top_panel ( UiSurface * s,
uint w )

Definition at line 643 of file ui_notcurses.c.

643 {
644 (void)w;
645 if (!s)
646 return -1;
647 return 0;
648}

Referenced by picker().

Here is the caller graph for this function:

◆ ui_update_panels()

void ui_update_panels ( )

Definition at line 446 of file ui_notcurses.c.

446 {
447 if (!ui)
448 return;
449 notcurses_render(ui->nc);
450}

References UiRuntime::nc, and ui.

◆ ui_wclear()

int ui_wclear ( UiSurface * s,
uint w )

Definition at line 570 of file ui_notcurses.c.

570 {
571 if (!s)
572 return -1;
573 ncplane_erase_region(s->mplane[w], 0, 0, 0, 0);
574 return 0;
575}

References SUB_SFC_MAX.

◆ ui_werase()

int ui_werase ( UiSurface * s,
uint w )

Definition at line 564 of file ui_notcurses.c.

564 {
565 if (!s)
566 return -1;
567 ncplane_erase_region(s->mplane[w], 0, 0, 0, 0);
568 return 0;
569}

References SUB_SFC_MAX.

Referenced by exec_objects(), and full_screen_shell().

Here is the caller graph for this function:

◆ ui_wmove()

int ui_wmove ( UiSurface * s,
uint w,
uint y,
uint x )

Definition at line 598 of file ui_notcurses.c.

598 {
599 if (!s)
600 return -1;
601 if (ncplane_cursor_move_yx(s->mplane[w], y, x) != 0)
602 return -1;
603 return 0;
604}

Referenced by display_chyron(), full_screen_shell(), menu_cmd_processor(), ui_mvwadd_wchnstr(), ui_mvwadd_wchstr(), and ui_mvwaddch().

Here is the caller graph for this function:

◆ ui_wnoutrefresh()

int ui_wnoutrefresh ( UiSurface * s,
uint w )

Definition at line 649 of file ui_notcurses.c.

649 {
650 (void)w;
651 if (!s)
652 return -1;
653 return 0;
654}

Referenced by picker().

Here is the caller graph for this function:

◆ ui_wscrl()

int ui_wscrl ( UiSurface * s,
uint w,
int r )

Definition at line 636 of file ui_notcurses.c.

636 {
637 if (!r)
638 return -1;
639 ncplane_scrollup(s->mplane[w], r);
640 ui_render();
641 return 0;
642}
void ui_render()

References ui_render().

Referenced by display_pick_page(), scroll_down(), and scroll_up().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ bkgd_cell

UiCell bkgd_cell

Definition at line 34 of file ui_notcurses.c.

Referenced by mk_chimera(), and ui_bkgdset().

◆ border_double

wchar_t* border_double = L"═║╠╣╦╩╬╔╗╚╝"

Definition at line 45 of file ui_notcurses.c.

Referenced by ui_init(), and ui_init().

◆ border_heavy

wchar_t* border_heavy = L"━┃┣┫┳┻╋┏┓┗┛"

Definition at line 46 of file ui_notcurses.c.

Referenced by ui_init(), and ui_init().

◆ border_none

wchar_t* border_none = L" "

Definition at line 47 of file ui_notcurses.c.

◆ border_rounded

wchar_t* border_rounded = L"─│├┤┬┴┼╭╮╰╯"

BOX WIDE UNICODE CODEPOINTS

Definition at line 44 of file ui_notcurses.c.

Referenced by ui_init(), and ui_init().

◆ border_single

wchar_t* border_single = L"─│├┤┬┴┼┌┐└┘"

BOX WIDE UNICODE CODEPOINTS

Definition at line 43 of file ui_notcurses.c.

◆ bw

Definition at line 49 of file ui_notcurses.c.

Referenced by ui_init(), and ui_init().

◆ bw_chk

const wchar_t* bw_chk = L"\x2611"

left_angle

Definition at line 62 of file ui_notcurses.c.

Referenced by initialize_cells().

◆ bw_da

const wchar_t* bw_da = L"\x2193"

large down arrow

Definition at line 59 of file ui_notcurses.c.

◆ bw_h09

const wchar_t* bw_h09 = L"\x23BD"

horizontal line 9

Definition at line 63 of file ui_notcurses.c.

◆ bw_la

const wchar_t* bw_la = L"\x2190"

large left arrow

Definition at line 57 of file ui_notcurses.c.

◆ bw_lan

const wchar_t* bw_lan = L"\x276E"

left_angle

Definition at line 61 of file ui_notcurses.c.

◆ bw_ra

const wchar_t* bw_ra = L"\x2192"

large right arrow

Definition at line 56 of file ui_notcurses.c.

◆ bw_ran

const wchar_t* bw_ran = L"\x276F"

right_angle

Definition at line 60 of file ui_notcurses.c.

Referenced by initialize_cells().

◆ bw_rbl

const wchar_t* bw_rbl = L"\x2570"

rounded bottom left

Definition at line 53 of file ui_notcurses.c.

◆ bw_rbr

const wchar_t* bw_rbr = L"\x256f"

rounded bottom right

Definition at line 54 of file ui_notcurses.c.

◆ bw_rtl

const wchar_t* bw_rtl = L"\x256d"

rounded top left

Definition at line 51 of file ui_notcurses.c.

◆ bw_rtr

const wchar_t* bw_rtr = L"\x256e"

rounded top right

Definition at line 52 of file ui_notcurses.c.

◆ bw_sp

const wchar_t* bw_sp = L"\x20"

space

Definition at line 55 of file ui_notcurses.c.

Referenced by initialize_cells().

◆ bw_ua

const wchar_t* bw_ua = L"\x2191"

large up arrow

Definition at line 58 of file ui_notcurses.c.

◆ COLS

uint COLS

Definition at line 30 of file ui_notcurses.c.

◆ LINES

uint LINES

Definition at line 30 of file ui_notcurses.c.

Referenced by display_form(), main(), and ui_init().

◆ sfc_ptr

◆ std_color

STDRGB std_color[] = {{0, 0, 0}, {128, 0, 0}, {0, 128, 0}, {128, 128, 0}, {0, 0, 128}, {128, 0, 128}, {0, 128, 128}, {192, 192, 192}, {128, 128, 128}, {255, 0, 0}, {0, 255, 0}, {255, 255, 0}, {0, 0, 255}, {255, 0, 255}, {0, 255, 255}, {255, 255, 255}}

Definition at line 65 of file ui_notcurses.c.

65{{0, 0, 0}, {128, 0, 0}, {0, 128, 0}, {128, 128, 0}, {0, 0, 128}, {128, 0, 128}, {0, 128, 128}, {192, 192, 192}, {128, 128, 128}, {255, 0, 0}, {0, 255, 0}, {255, 255, 0}, {0, 0, 255}, {255, 0, 255}, {0, 255, 255}, {255, 255, 255}};

Referenced by ui_add_color_rgb(), ui_chg_color(), ui_init_color_hex(), and xterm256_idx_to_rgb().

◆ stdplane

NcPlane* stdplane

Definition at line 39 of file ui_notcurses.c.

Referenced by ui_box_surface_new(), ui_clear(), ui_erase(), ui_init(), and ui_surface_new().

◆ stdsfc

◆ ui

◆ ui_color

◆ ui_color_cnt

uint ui_color_cnt = 0

Definition at line 25 of file ui_notcurses.c.

Referenced by init_clr_palette(), ui_add_color_rgb(), ui_init(), and ui_init_color_hex().

◆ ui_config

UiConfig * ui_config

Definition at line 32 of file ui_notcurses.c.

◆ ui_pair

◆ ui_pair_cnt

uint ui_pair_cnt = 0

Definition at line 26 of file ui_notcurses.c.

Referenced by ui_add_pair(), and ui_init().

◆ ui_surface

◆ win_ptr

int win_ptr = -1

Definition at line 37 of file ui_notcurses.c.