C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
ui_backend.h File Reference

Backend API for terminal UI library. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for ui_backend.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  border_wide
struct  GCluster
struct  STDRGB
struct  UiCaps
 Capability flags reported by the active UI backend. More...
struct  UiCchar64
struct  UiConfig
 Structure representing the configuration options for the UI runtime. More...
struct  UiEvent
struct  UiRect

Macros

#define _GNU_SOURCE
#define _XOPEN_SOURCE_EXTENDED   1
#define ALLWINS   (uint)1000
#define bw_bl   bw.bl
#define bw_br   bw.br
#define bw_bt   bw.bt
#define bw_cr   bw.cr
#define bw_ho   bw.ho
#define bw_lt   bw.lt
#define bw_rt   bw.rt
#define bw_tl   bw.tl
#define bw_tr   bw.tr
#define bw_tt   bw.tt
#define bw_ve   bw.ve
#define CCHARW_MAX   5
#define CELL_CHAR_INITIALIZER(c)
#define CELL_INITIALIZER(c, s, chan)
#define DEFAULT_INITIALIZER(c)
#define ERR   -1
#define NCURSES_WIDECHAR   1
#define SFC_MAX   30
#define UI_COLORS   512
#define UI_PAIRS   512
#define UI_SFC_MAX   30

Typedefs

typedef uint16_t attr_t
typedef union border_wide BorderWide
typedef struct ncplane NcPlane
typedef struct ncplane_options NcPlaneOptions
typedef struct notcurses NotCurses
typedef struct notcurses_options NotCursesOptions
typedef struct nccell UiCell
typedef union UiChannels UiChannels
typedef struct UiColor UiColor
typedef uint UiColorIdx
typedef struct UiMB UiMB
typedef struct UiPair UiPair
typedef uint16_t UiPairIdx
typedef struct UiRuntime UiRuntime
typedef struct UiSplitSurface UiSplitSurface
typedef uint16_t UiStyle
typedef struct UiSurface UiSurface

Enumerations

enum  UiBackend { UI_BACKEND_NCURSES = 0 , UI_BACKEND_NOTCURSES }
 Identifies which terminal library is powering the UI runtime. More...
enum  UiBorderKind { UI_BORDER_NONE = 0 , UI_BORDER_ASCII , UI_BORDER_LIGHT , UI_BORDER_ROUNDED }
enum  UiKey {
  UI_KEY_NONE = 0 , UI_KEY_CHAR , UI_KEY_ENTER , UI_KEY_ESCAPE ,
  UI_KEY_BACKSPACE , UI_KEY_TAB , UI_KEY_BTAB , UI_KEY_UP ,
  UI_KEY_DOWN , UI_KEY_LEFT , UI_KEY_RIGHT , UI_KEY_HOME ,
  UI_KEY_END , UI_KEY_PGUP , UI_KEY_PGDN , UI_KEY_INSERT ,
  UI_KEY_DELETE , UI_KEY_RESIZE , UI_KEY_MOUSE , UI_KEY_F1 ,
  UI_KEY_F2 , UI_KEY_F3 , UI_KEY_F4 , UI_KEY_F5 ,
  UI_KEY_F6 , UI_KEY_F7 , UI_KEY_F8 , UI_KEY_F9 ,
  UI_KEY_F10 , UI_KEY_F11 , UI_KEY_F12
}
enum  UiMouseAction {
  UI_MOUSE_NONE = 0 , UI_MOUSE_PRESS , UI_MOUSE_RELEASE , UI_MOUSE_DRAG ,
  UI_MOUSE_SCROLL_UP , UI_MOUSE_SCROLL_DOWN
}

Functions

void fast_exit (UiSurface *s)
uint mbstr_to_cellstr (UiCell *cmplx_buf, const char *str, const UiCell *cell_base, uint *pos, const uint atmost)
 Convert multibyte string to complex character array.
int ui_add_color (uint r, uint g, uint b)
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 *title)
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_chg_pair (uint pair, uint fg, uint bg)
int ui_clear ()
int ui_color_content (uint color, uint *r, uint *g, uint *b)
int ui_curs_set (int visibility)
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)
int ui_doupdate ()
int ui_draw_border (UiSurface *s, uint w, UiBorderKind kind, const UiStyle *style)
int ui_draw_box_title (UiSurface *s, uint w, uint x, const UiStyle *style, const char *title)
int ui_draw_ch (UiSurface *s, uint w, const char c)
int ui_draw_ch_yx (UiSurface *s, uint w, uint y, uint x, const char c)
int ui_draw_hline (UiSurface *s, uint w, uint y, uint x, uint len, const UiStyle *style)
int ui_draw_text (UiSurface *s, uint w, uint y, uint x, const char *text)
int ui_draw_text_fill (UiSurface *s, uint w, uint y, uint x, const char *text, int m)
int ui_draw_text_n (UiSurface *s, uint w, uint y, uint x, const char *text, int m)
int ui_draw_vline (UiSurface *s, uint w, uint y, uint x, uint len, const UiStyle *style)
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.
uint32_t ui_get_color (uint16_t color_idx)
int ui_get_event (UiSurface *s, uint w, UiEvent *ev, int timeout_ms)
 Wait for an input event on target (or stdscr if NULL).
int ui_get_event_multi (UiSurface *s, uint w, UiEvent *ev, int timeout_ms)
int ui_get_event_no_mouse (UiSurface *surface, uint w, UiEvent *ev)
int ui_get_pair (uint pair, uint *fg, uint *bg)
void ui_get_screen_size (uint *lines, uint *cols)
int ui_getcchar (const UiCell *uc, wchar_t *wstr, attr_t *attrs, ushort *pair, void *opts)
int ui_getch ()
int ui_getmaxx (UiSurface *s, uint w)
int ui_getmaxy (UiSurface *s, uint w)
void ui_getmaxyx (UiSurface *s, uint w, uint *lines, uint *cols)
void ui_getyx (UiSurface *s, uint w, uint *lines, uint *cols)
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 *config)
int ui_init_color (uint color, uint r, uint g, uint b)
int ui_init_pair (uint 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)
int ui_mvaddstr (UiSurface *s, uint w, uint y, uint x, const char *text)
int ui_mvwadd_wch (UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
int ui_mvwadd_wchnstr (UiSurface *s, uint w, uint y, uint x, const UiCell *cell, uint m)
int ui_mvwadd_wchstr (UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
int ui_mvwaddch (UiSurface *s, uint w, uint y, uint x, const char c)
int ui_mvwaddnstr (UiSurface *s, uint w, uint y, uint x, const char *text, int m)
int ui_mvwaddnwstr (UiSurface *s, uint w, uint y, uint x, const wchar_t *wstr, int m)
int ui_mvwaddstr (UiSurface *s, uint w, uint y, uint x, const char *text)
int ui_mvwaddstr_fill (UiSurface *s, uint w, uint y, uint x, const char *str, int m)
int ui_mvwaddwstr (UiSurface *s, uint w, uint y, uint x, const wchar_t *wstr)
SCREEN * ui_ncurses_get_screen ()
int ui_pair_content (uint pair, uint *fg, uint *bg)
void ui_render ()
void ui_restore_wins ()
int ui_resume ()
int ui_scrollok (UiSurface *s, uint w, bool enable)
int ui_setcchar (UiCell *wch, const wchar_t *wc, const attr_t attrs, short 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 view_win, 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_wadd_wch (UiSurface *s, uint w, const UiCell *cell)
int ui_wadd_wchnstr (UiSurface *s, uint w, const UiCell *cell, uint m)
int ui_wadd_wchstr (UiSurface *s, uint w, const UiCell *cell)
int ui_waddch (UiSurface *s, uint w, const char c)
int ui_waddnstr (UiSurface *s, uint w, const char *text, int m)
int ui_waddnwstr (UiSurface *s, uint w, const wchar_t *wstr, int m)
int ui_waddstr (UiSurface *s, uint w, const char *text)
int ui_waddwstr (UiSurface *s, uint w, const wchar_t *wstr)
int ui_wclear (UiSurface *s, uint w)
int ui_wclrtobot (UiSurface *s, uint w)
int ui_wclrtoeol (UiSurface *s, uint w)
int ui_werase (UiSurface *s, uint w)
int ui_whide (UiSurface *s, uint w)
int ui_wmove (UiSurface *s, uint w, uint y, uint x)
int ui_wnoutrefresh (UiSurface *s, uint w)
int ui_wresize (UiSurface *s, uint w, uint lines, uint cols)
int ui_wscrl (UiSurface *s, uint w, int rows)
int ui_wset_base (UiSurface *s, uint w, const UiStyle *style, uint32_t fill_ch)
int ui_wset_style (UiSurface *s, uint w, const UiStyle *style)
int ui_wshow (UiSurface *s, uint w)

Variables

wchar_t * border_double = L"═║╠╣╦╩╬╔╗╚╝"
wchar_t * border_heavy = L"━┃┣┫┳┻╋┏┓┗┛"
wchar_t * border_rounded = L"─│├┤┬┴┼╭╮╰╯"
wchar_t * border_square
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 []
NcPlanestdplane
UiSurfacestdsfc
UiRuntimeui = NULL
uint ui_color_cnt = 0
uint ui_pair_cnt = 0
UiSurfaceui_surface [UI_SFC_MAX]
int win_ptr = -1

Detailed Description

Backend API for terminal UI library.

Definition in file ui_backend.h.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 9 of file ui_backend.h.

◆ _XOPEN_SOURCE_EXTENDED

#define _XOPEN_SOURCE_EXTENDED   1

Definition at line 8 of file ui_backend.h.

◆ ALLWINS

#define ALLWINS   (uint)1000

Definition at line 92 of file ui_backend.h.

◆ bw_bl

#define bw_bl   bw.bl

Definition at line 222 of file ui_backend.h.

◆ bw_br

#define bw_br   bw.br

Definition at line 223 of file ui_backend.h.

◆ bw_bt

#define bw_bt   bw.bt

Definition at line 218 of file ui_backend.h.

◆ bw_cr

#define bw_cr   bw.cr

Definition at line 219 of file ui_backend.h.

◆ bw_ho

#define bw_ho   bw.ho

Definition at line 213 of file ui_backend.h.

◆ bw_lt

#define bw_lt   bw.lt

Definition at line 215 of file ui_backend.h.

◆ bw_rt

#define bw_rt   bw.rt

Definition at line 216 of file ui_backend.h.

◆ bw_tl

#define bw_tl   bw.tl

Definition at line 220 of file ui_backend.h.

◆ bw_tr

#define bw_tr   bw.tr

Definition at line 221 of file ui_backend.h.

◆ bw_tt

#define bw_tt   bw.tt

Definition at line 217 of file ui_backend.h.

◆ bw_ve

#define bw_ve   bw.ve

Definition at line 214 of file ui_backend.h.

◆ CCHARW_MAX

#define CCHARW_MAX   5

Definition at line 248 of file ui_backend.h.

◆ CELL_CHAR_INITIALIZER

#define CELL_CHAR_INITIALIZER ( c)
Value:
{ \
.gcluster = (c), \
.gcluster_backstop = 0, \
.stylemask = 0, \
.channels = 0, \
}
uint64_t channels
Definition nckeys.c:42

Definition at line 267 of file ui_backend.h.

267#define CELL_CHAR_INITIALIZER(c) { \
268 .gcluster = (c), \
269 .gcluster_backstop = 0, \
270 .stylemask = 0, \
271 .channels = 0, \
272}

◆ CELL_INITIALIZER

#define CELL_INITIALIZER ( c,
s,
chan )
Value:
{ \
.gcluster = (c), \
.gcluster_backstop = 0, \
.stylemask = (s), \
.channels = (chan), \
}

Definition at line 273 of file ui_backend.h.

273#define CELL_INITIALIZER(c, s, chan) { \
274 .gcluster = (c), \
275 .gcluster_backstop = 0, \
276 .stylemask = (s), \
277 .channels = (chan), \
278}

◆ DEFAULT_INITIALIZER

#define DEFAULT_INITIALIZER ( c)
Value:
{ \
.gcluster = (c), \
.gcluster_backstop = 0, \
.stylemask = (bkgd_cell.stylemask), \
.channels = (bkgd_cell.channels), \
}
UiCell bkgd_cell

Definition at line 279 of file ui_backend.h.

279#define DEFAULT_INITIALIZER(c) { \
280 .gcluster = (c), \
281 .gcluster_backstop = 0, \
282 .stylemask = (bkgd_cell.stylemask), \
283 .channels = (bkgd_cell.channels), \
284}

◆ ERR

#define ERR   -1

Definition at line 249 of file ui_backend.h.

◆ NCURSES_WIDECHAR

#define NCURSES_WIDECHAR   1

Definition at line 10 of file ui_backend.h.

◆ SFC_MAX

#define SFC_MAX   30

Definition at line 25 of file ui_backend.h.

◆ UI_COLORS

#define UI_COLORS   512

Definition at line 39 of file ui_backend.h.

◆ UI_PAIRS

#define UI_PAIRS   512

Definition at line 40 of file ui_backend.h.

◆ UI_SFC_MAX

#define UI_SFC_MAX   30

Definition at line 24 of file ui_backend.h.

Typedef Documentation

◆ attr_t

typedef uint16_t attr_t

Definition at line 256 of file ui_backend.h.

◆ BorderWide

typedef union border_wide BorderWide

◆ NcPlane

typedef struct ncplane NcPlane

Definition at line 251 of file ui_backend.h.

◆ NcPlaneOptions

typedef struct ncplane_options NcPlaneOptions

Definition at line 254 of file ui_backend.h.

◆ NotCurses

typedef struct notcurses NotCurses

Definition at line 252 of file ui_backend.h.

◆ NotCursesOptions

typedef struct notcurses_options NotCursesOptions

Definition at line 253 of file ui_backend.h.

◆ UiCell

typedef struct nccell UiCell

Definition at line 250 of file ui_backend.h.

◆ UiChannels

typedef union UiChannels UiChannels

Definition at line 33 of file ui_backend.h.

◆ UiColor

typedef struct UiColor UiColor

Definition at line 258 of file ui_backend.h.

◆ UiColorIdx

typedef uint UiColorIdx

Definition at line 37 of file ui_backend.h.

◆ UiMB

typedef struct UiMB UiMB

Definition at line 34 of file ui_backend.h.

◆ UiPair

typedef struct UiPair UiPair

Definition at line 257 of file ui_backend.h.

◆ UiPairIdx

typedef uint16_t UiPairIdx

Definition at line 36 of file ui_backend.h.

◆ UiRuntime

typedef struct UiRuntime UiRuntime

Definition at line 30 of file ui_backend.h.

◆ UiSplitSurface

typedef struct UiSplitSurface UiSplitSurface

Definition at line 32 of file ui_backend.h.

◆ UiStyle

typedef uint16_t UiStyle

Definition at line 35 of file ui_backend.h.

◆ UiSurface

typedef struct UiSurface UiSurface

Definition at line 31 of file ui_backend.h.

Enumeration Type Documentation

◆ UiBackend

enum UiBackend

Identifies which terminal library is powering the UI runtime.

Enumerator
UI_BACKEND_NCURSES 

NCurses / NCursesW backend

UI_BACKEND_NOTCURSES 

NotCurses backend

Definition at line 155 of file ui_backend.h.

155 {
158} UiBackend;
UiBackend
Identifies which terminal library is powering the UI runtime.
Definition ui_backend.h:155
@ UI_BACKEND_NCURSES
Definition ui_backend.h:156
@ UI_BACKEND_NOTCURSES
Definition ui_backend.h:157

◆ UiBorderKind

Enumerator
UI_BORDER_NONE 
UI_BORDER_ASCII 
UI_BORDER_LIGHT 
UI_BORDER_ROUNDED 

Definition at line 85 of file ui_backend.h.

85 {
UiBorderKind
Definition ui_backend.h:85
@ UI_BORDER_ROUNDED
Definition ui_backend.h:89
@ UI_BORDER_ASCII
Definition ui_backend.h:87
@ UI_BORDER_LIGHT
Definition ui_backend.h:88
@ UI_BORDER_NONE
Definition ui_backend.h:86

◆ UiKey

enum UiKey
Enumerator
UI_KEY_NONE 
UI_KEY_CHAR 
UI_KEY_ENTER 
UI_KEY_ESCAPE 
UI_KEY_BACKSPACE 
UI_KEY_TAB 
UI_KEY_BTAB 
UI_KEY_UP 
UI_KEY_DOWN 
UI_KEY_LEFT 
UI_KEY_RIGHT 
UI_KEY_HOME 
UI_KEY_END 
UI_KEY_PGUP 
UI_KEY_PGDN 
UI_KEY_INSERT 
UI_KEY_DELETE 
UI_KEY_RESIZE 
UI_KEY_MOUSE 
UI_KEY_F1 
UI_KEY_F2 
UI_KEY_F3 
UI_KEY_F4 
UI_KEY_F5 
UI_KEY_F6 
UI_KEY_F7 
UI_KEY_F8 
UI_KEY_F9 
UI_KEY_F10 
UI_KEY_F11 
UI_KEY_F12 

Definition at line 42 of file ui_backend.h.

42 {
43 UI_KEY_NONE = 0,
74} UiKey;
UiKey
Definition ui_backend.h:42
@ UI_KEY_F8
Definition ui_backend.h:69
@ UI_KEY_BACKSPACE
Definition ui_backend.h:47
@ UI_KEY_F9
Definition ui_backend.h:70
@ UI_KEY_TAB
Definition ui_backend.h:48
@ UI_KEY_F2
Definition ui_backend.h:63
@ UI_KEY_F7
Definition ui_backend.h:68
@ UI_KEY_DELETE
Definition ui_backend.h:59
@ UI_KEY_CHAR
Definition ui_backend.h:44
@ UI_KEY_MOUSE
Definition ui_backend.h:61
@ UI_KEY_F11
Definition ui_backend.h:72
@ UI_KEY_DOWN
Definition ui_backend.h:51
@ UI_KEY_F4
Definition ui_backend.h:65
@ UI_KEY_F3
Definition ui_backend.h:64
@ UI_KEY_HOME
Definition ui_backend.h:54
@ UI_KEY_F6
Definition ui_backend.h:67
@ UI_KEY_PGDN
Definition ui_backend.h:57
@ UI_KEY_PGUP
Definition ui_backend.h:56
@ UI_KEY_NONE
Definition ui_backend.h:43
@ UI_KEY_BTAB
Definition ui_backend.h:49
@ UI_KEY_END
Definition ui_backend.h:55
@ UI_KEY_F5
Definition ui_backend.h:66
@ UI_KEY_ESCAPE
Definition ui_backend.h:46
@ UI_KEY_LEFT
Definition ui_backend.h:52
@ UI_KEY_F1
Definition ui_backend.h:62
@ UI_KEY_ENTER
Definition ui_backend.h:45
@ UI_KEY_UP
Definition ui_backend.h:50
@ UI_KEY_F12
Definition ui_backend.h:73
@ UI_KEY_RESIZE
Definition ui_backend.h:60
@ UI_KEY_INSERT
Definition ui_backend.h:58
@ UI_KEY_RIGHT
Definition ui_backend.h:53
@ UI_KEY_F10
Definition ui_backend.h:71

◆ UiMouseAction

Enumerator
UI_MOUSE_NONE 
UI_MOUSE_PRESS 
UI_MOUSE_RELEASE 
UI_MOUSE_DRAG 
UI_MOUSE_SCROLL_UP 
UI_MOUSE_SCROLL_DOWN 

Definition at line 76 of file ui_backend.h.

76 {
77 UI_MOUSE_NONE = 0,
UiMouseAction
Definition ui_backend.h:76
@ UI_MOUSE_SCROLL_DOWN
Definition ui_backend.h:82
@ UI_MOUSE_PRESS
Definition ui_backend.h:78
@ UI_MOUSE_SCROLL_UP
Definition ui_backend.h:81
@ UI_MOUSE_NONE
Definition ui_backend.h:77
@ UI_MOUSE_DRAG
Definition ui_backend.h:80
@ UI_MOUSE_RELEASE
Definition ui_backend.h:79

Function Documentation

◆ fast_exit()

void fast_exit ( UiSurface * s)

Definition at line 490 of file ui_ncurses.c.

490 {
491 update_panels();
492 doupdate();
493 for (int i = SUB_SFC_MAX; i >= 0; i--) {
494 if (s->mpan[i]) {
495 hide_panel(s->mpan[i]);
496 del_panel(s->mpan[i]);
497 s->mpan[i] = NULL;
498 }
499 }
500 for (int i = SUB_SFC_MAX; i >= 0; i--) {
501 if (s->mwin[i]) {
502 delwin(s->mwin[i]);
503 s->mwin[i] = NULL;
504 }
505 }
506 endwin();
507 exit(EXIT_SUCCESS);
508}
PANEL * mpan[SUB_SFC_MAX]
WINDOW * mwin[SUB_SFC_MAX]

References SUB_SFC_MAX.

◆ ui_add_color()

int ui_add_color ( uint r,
uint g,
uint b )

◆ ui_add_color_rgb()

int ui_add_color_rgb ( RGB * rgb)

Definition at line 138 of file ui_ncurses.c.

138 {
139 uint i;
140 RGB tmp;
141 apply_gamma(rgb);
142 rgb->r = (rgb->r * 1000) / 255;
143 rgb->g = (rgb->g * 1000) / 255;
144 rgb->b = (rgb->b * 1000) / 255;
145 rgb->a = 0;
146 for (i = 0; i < ui_color_cnt && i < UI_COLORS; i++) {
147 extended_color_content(i, &tmp.r, &tmp.g, &tmp.b);
148 if (rgb->r == tmp.r && rgb->g == tmp.g && rgb->b == tmp.b)
149 return i;
150 }
151 if (i < UI_COLORS) {
152 if (i < 16) {
153 std_color[i].r = rgb->r;
154 std_color[i].g = rgb->g;
155 std_color[i].b = rgb->b;
156 }
157 init_extended_color(i, rgb->r, rgb->g, rgb->b);
158 if (ui_color_cnt + 1 < UI_COLORS)
159 ui_color_cnt++;
160 return ui_color_cnt - 1;
161 }
162 return 0;
163}
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
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 105 of file ui_ncurses.c.

105 {
106 int rc;
107 uint i;
108 uint pfg, pbg;
109 for (i = 1; i < ui_pair_cnt; i++) {
110 ui_pair_content(i, &pfg, &pbg);
111 if (pfg == fg && pbg == bg)
112 return i;
113 }
114 if (i + 1 >= UI_PAIRS) {
115 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
116 ssnprintf(em1, MAXLEN - 1, "ui_add_pair failed for pair: %d", i);
117 strerror_r(errno, em2, MAXLEN);
118 display_error(em0, em1, em2, nullptr);
119 return (EXIT_FAILURE);
120 }
121 rc = init_extended_pair(i, fg, bg);
122 if (rc == ERR) {
123 ssnprintf(em0, MAXLEN - 1, "%s, line: %d", __FILE__, __LINE__ - 1);
124 ssnprintf(em1, MAXLEN - 1, "init_extended_pair failed for pair: %d", i);
125 ssnprintf(em2, MAXLEN - 1, "fg: %d, bg: %d, ui_pair_cnt: %d", fg, bg, ui_pair_cnt);
126 display_error(em0, em1, em2, nullptr);
127 return (EXIT_FAILURE);
128 }
129 ui_pair_cnt++;
130 return (int)(ui_pair_cnt - 1);
131}
#define UI_PAIRS
Definition ui_backend.h:40
#define ERR
Definition ui_backend.h:249
uint ui_pair_cnt
Definition ui_ncurses.c:34
int ui_pair_content(uint pair, uint *fg, uint *bg)
Definition ui_ncurses.c:194
#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().

Referenced by initialize_cells(), 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_bkgd()

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

Definition at line 753 of file ui_ncurses.c.

753 {
754 if (!s)
755 return -1;
756 wbkgrnd(s->mwin[w], cell);
757 return 0;
758}

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 760 of file ui_ncurses.c.

760 {
761 if (!s)
762 return -1;
763 wbkgrndset(s->mwin[w], cell);
764 return 0;
765}

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 767 of file ui_ncurses.c.

767 {
768 if (!s->mwin[w])
769 return -1;
770 wbkgrnd(s->mwin[w], cell);
771 return 0;
772}

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

◆ ui_bkgrndset()

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

Definition at line 774 of file ui_ncurses.c.

774 {
775 if (!s->mwin[w])
776 return -1;
777 wbkgrndset(s->mwin[w], cell);
778 return 0;
779}

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 * title )

Definition at line 453 of file ui_ncurses.c.

453 {
454 UiSurface *s = calloc(1, sizeof(*s));
455 if (!s)
456 return NULL;
457 s->runtime = ui;
458 s->parent = parent;
459 s->meta[BOX].y = y;
460 s->meta[BOX].x = x;
461 s->meta[BOX].lines = lines;
462 s->meta[BOX].cols = cols;
463 if (parent && parent->mwin[p]) {
464 s->mwin[BOX] = derwin(parent->mwin[p], lines + 2, cols + 2, y, x);
465 if (!s->mwin[BOX]) {
466 free(s);
467 return NULL;
468 }
469 } else {
470 s->mwin[BOX] = newwin(lines + 2, cols + 2, y, x);
471 if (!s->mwin[BOX]) {
472 free(s);
473 return NULL;
474 }
475 s->mpan[BOX] = new_panel(s->mwin[BOX]);
476 if (!s->mpan[BOX]) {
477 delwin(s->mwin[BOX]);
478 return NULL;
479 }
480 }
481 ui_scrollok(s, BOX, false);
482 border_draw(s);
483 border_title(s, wtitle);
484#ifdef DEBUG_UI
485 immedok(s->mwin[BOX], true);
486#endif
487 return s;
488}
UiRuntime * ui
int ui_scrollok(UiSurface *s, uint w, bool enable)
Definition ui_ncurses.c:626
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
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 239 of file ui_ncurses.c.

239 {
240 UiCell cc = {0};
241 RGB rgb;
242 rgb.r = (*fg >> 16) & 0xff;
243 rgb.g = (*fg >> 8) & 0xff;
244 rgb.b = *fg & 0xff;
245 int f_idx = ui_add_color_rgb(&rgb);
246 rgb.r = (*bg >> 16) & 0xff;
247 rgb.g = (*bg >> 8) & 0xff;
248 rgb.b = *bg & 0xff;
249 int b_idx = ui_add_color_rgb(&rgb);
250 short cp = ui_add_pair(f_idx, b_idx);
251 wchar_t wstr[2] = {L'\0', L'\0'};
252 wstr[0] = *ucp;
253 wstr[1] = L'\0';
254 setcchar(&cc, wstr, WA_NORMAL, cp, nullptr);
255 return cc;
256}
#define WA_NORMAL
int ui_add_color_rgb(RGB *rgb)
Definition ui_ncurses.c:138
uint ui_add_pair(uint fg, uint bg)
Definition ui_ncurses.c:105

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 206 of file ui_ncurses.c.

206 {
207 if (color_idx + 1 >= UI_COLORS)
208 return -1;
209 RGB rgb;
210 rgb.r = (*color >> 16) & 0xff;
211 rgb.g = (*color >> 8) & 0xff;
212 rgb.b = *color & 0xff;
213 apply_gamma(&rgb);
214 rgb.r = (rgb.r * 1000) / 255;
215 rgb.g = (rgb.g * 1000) / 255;
216 rgb.b = (rgb.b * 1000) / 255;
217 if (color_idx < 16) {
218 std_color[color_idx].r = rgb.r;
219 std_color[color_idx].g = rgb.g;
220 std_color[color_idx].b = rgb.b;
221 }
222 init_extended_color(color_idx, rgb.r, rgb.g, rgb.b);
223 return 0;
224}

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_chg_pair()

int ui_chg_pair ( uint pair,
uint fg,
uint bg )

Definition at line 132 of file ui_ncurses.c.

132 {
133 if (pair + 1 >= UI_PAIRS)
134 return -1;
135 init_extended_pair(pair, fg, bg);
136 return 0;
137}

◆ ui_clear()

int ui_clear ( )

Definition at line 594 of file ui_ncurses.c.

594 {
595 clear();
596 return 0;
597}

References stdplane.

◆ ui_color_content()

int ui_color_content ( uint color,
uint * r,
uint * g,
uint * b )

Definition at line 179 of file ui_ncurses.c.

179 {
180 int _color = (int)color;
181 int _r, _g, _b;
182 extended_color_content(_color, &_r, &_g, &_b);
183 *r = (uint)_r;
184 *g = (uint)_g;
185 *b = (uint)_b;
186 return 0;
187}

Referenced by ui_add_color_rgb(), ui_get_channels_from_pair(), and ui_setcchar().

Here is the caller graph for this function:

◆ ui_curs_set()

int ui_curs_set ( int visibility)

Definition at line 737 of file ui_ncurses.c.

737 {
738 curs_set(visibility);
739 return 0;
740}

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 713 of file ui_ncurses.c.

713 {
714 (void)s;
715 (void)w;
716 if (!ui)
717 return -1;
718 ui->cursor_visible = visible;
719 curs_set(visible ? 1 : 0);
720 return 0;
721}

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 703 of file ui_ncurses.c.

703 {
704 (void)s;
705 (void)w;
706 if (!ui)
707 return -1;
708 wmove(s->mwin[w], y, x);
709 ui->cursor_visible = visible;
710 curs_set(visible ? 1 : 0);
711 return 0;
712}

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 727 of file ui_ncurses.c.

727 {
728 if (!s || !s->mwin[w])
729 return -1;
730 return wmove(s->mwin[w], y, x);
731}

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_doupdate()

int ui_doupdate ( )

Definition at line 807 of file ui_ncurses.c.

807 {
808 doupdate();
809 return 0;
810}

◆ ui_draw_border()

int ui_draw_border ( UiSurface * s,
uint w,
UiBorderKind kind,
const UiStyle * style )

◆ ui_draw_box_title()

int ui_draw_box_title ( UiSurface * s,
uint w,
uint x,
const UiStyle * style,
const char * title )

◆ ui_draw_ch()

int ui_draw_ch ( UiSurface * s,
uint w,
const char c )

Definition at line 59 of file ui_notcurses_draw.c.

59 {
60 if (!s || !c)
61 return -1;
63 ncplane_putc_yx(s->mplane[w], -1, -1, &cell);
64 return 0;
65}
#define DEFAULT_INITIALIZER(c)
Definition ui_backend.h:279
struct ncplane * mplane[SUB_SFC_MAX]
Definition nccell.h:3

◆ ui_draw_ch_yx()

int ui_draw_ch_yx ( UiSurface * s,
uint w,
uint y,
uint x,
const char c )

Definition at line 40 of file ui_ncurses_draw.c.

40 {
41 if (!s)
42 return -1;
43 mvwaddch(s->mwin[w], y, x, c);
44 return 0;
45}

Referenced by menu_cmd_processor().

Here is the caller graph for this function:

◆ ui_draw_hline()

int ui_draw_hline ( UiSurface * s,
uint w,
uint y,
uint x,
uint len,
const UiStyle * style )

◆ ui_draw_text()

int ui_draw_text ( UiSurface * s,
uint w,
uint y,
uint x,
const char * text )

Definition at line 47 of file ui_ncurses_draw.c.

47 {
48 if (!s || !text)
49 return -1;
50 mvwaddstr(s->mwin[w], y, x, text);
51 return 0;
52}

Referenced by action_disposition(), answer_yn(), display_error(), and Perror().

Here is the caller graph for this function:

◆ ui_draw_text_fill()

int ui_draw_text_fill ( UiSurface * s,
uint w,
uint y,
uint x,
const char * text,
int m )

Definition at line 61 of file ui_ncurses_draw.c.

61 {
62 if (!s || !text)
63 return -1;
64 uint l = strlen(text);
65 if (l < (uint)n) {
66 char *tmp_str = (char *)malloc(n + 1);
67 if (!tmp_str)
68 return -1;
69 strcpy(tmp_str, text);
70 for (int i = l; i < (int)n; i++) {
71 tmp_str[i] = ' ';
72 }
73 tmp_str[n] = '\0';
74 mvwaddstr(s->mwin[w], y, x, tmp_str);
75 free(tmp_str);
76 } else {
77 mvwaddnstr(s->mwin[w], y, x, text, (int)n);
78 }
79 return 0;
80}

References ui_render().

Referenced by menu_cmd_processor(), and menu_engine().

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

◆ ui_draw_text_n()

int ui_draw_text_n ( UiSurface * s,
uint w,
uint y,
uint x,
const char * text,
int m )

Definition at line 54 of file ui_ncurses_draw.c.

54 {
55 if (!s || !text)
56 return -1;
57 mvwaddnstr(s->mwin[w], y, x, text, (int)n);
58 return 0;
59}

◆ ui_draw_vline()

int ui_draw_vline ( UiSurface * s,
uint w,
uint y,
uint x,
uint len,
const UiStyle * style )

◆ ui_endwin()

void ui_endwin ( )

Definition at line 341 of file ui_ncurses.c.

341 {
342 ui_shutdown();
343}
void ui_shutdown()
Definition ui_ncurses.c:344

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 590 of file ui_ncurses.c.

590 {
591 erase();
592 return 0;
593}

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 84 of file ui_ncurses.c.

84 {
85 return UI_BACKEND_NCURSES;
86}

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 88 of file ui_ncurses.c.

88 {
89 if (!caps)
90 return;
91 memset(caps, 0, sizeof(*caps));
92 if (!ui)
93 return;
94 // Will add code to actually check later. For now, just lie.
95 caps->truecolor = true;
96 caps->palette256 = true;
97 caps->mouse = ui->mouse_enabled;
98 caps->unicode = true;
99 caps->resize = true;
100 caps->color_pairs = 0;
101}
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_color()

uint32_t ui_get_color ( uint16_t color_idx)

Definition at line 164 of file ui_ncurses.c.

164 {
165 if (color_idx + 1 >= UI_COLORS)
166 return -1;
167 RGB rgb;
168 extended_color_content(color_idx, &rgb.r, &rgb.g, &rgb.b);
169 rgb.r = (rgb.r * 255) / 1000;
170 rgb.g = (rgb.g * 255) / 1000;
171 rgb.b = (rgb.b * 255) / 1000;
172 return 0;
173}

◆ ui_get_event()

int ui_get_event ( UiSurface * s,
uint w,
UiEvent * ev,
int timeout_ms )

Wait for an input event on target (or stdscr if NULL).

Wait for an input event from the NotCurses context.

Parameters
uiUI runtime context (unused — event comes from the window).
targetSurface to read from, or NULL for stdscr.
evOutput UiEvent structure.
timeout_msMilliseconds to wait; -1 = block indefinitely.
Returns
0 on success, -1 if ev is NULL.
Parameters
uiUI runtime context.
targetUnused for NotCurses (events are global to the context).
evOutput UiEvent structure.
timeout_msMilliseconds to wait; -1 = block indefinitely.
Returns
0 on success, -1 if ui or ev is NULL.

Wait for an input event on target (or stdscr if NULL).

Parameters
uiUI runtime context.
targetUnused for NotCurses (events are global to the context).
evOutput UiEvent structure.
timeout_msMilliseconds to wait; -1 = block indefinitely.
Returns
0 on success, -1 if ui or ev is NULL.

Definition at line 103 of file ui_ncurses_input.c.

103 {
104 if (!ev)
105 return -1;
106 memset(ev, 0, sizeof(*ev));
107 tcflush(2, TCIFLUSH);
108 if (timeout_ms <= 0) {
109 timeout_ms = -1;
110 } else
111 wtimeout(s->mwin[w], timeout_ms);
112 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION | BUTTON_SHIFT | BUTTON_CTRL | BUTTON_ALT, NULL);
113 curs_set(2);
114 int ch = wgetch(s->mwin[w]);
115 curs_set(0);
116 ev->key = translate_key(ch);
117 if (ev->key == UI_KEY_CHAR) {
118 ev->ch = (uint32_t)ch;
119 } else if (ev->key == UI_KEY_MOUSE) {
120 MEVENT me;
121 if (getmouse(&me) == OK) {
122 ev->y = me.y;
123 ev->x = me.x;
124 if (me.bstate & BUTTON4_PRESSED)
126 else if (me.bstate & BUTTON5_PRESSED)
128 else if (me.bstate & BUTTON1_PRESSED)
130 else if (me.bstate & BUTTON1_RELEASED)
132 if (wenclose(s->mwin[w], me.y, me.x) &&
133 wmouse_trafo(s->mwin[w], &me.y, &me.x, false)) {
134 ev->bstate = me.bstate;
135 ev->mouse_inside = true;
136 ev->y = me.y;
137 ev->x = me.x;
138 } else {
139 ev->mouse_inside = false;
140 }
141 }
142 }
143 return ch;
144}
uint32_t ch
Definition ui_backend.h:102
UiMouseAction mouse_action
Definition ui_backend.h:112
int bstate
Definition ui_backend.h:111
UiKey key
Definition ui_backend.h:101
bool mouse_inside
Definition ui_backend.h:113

References UiEvent::alt, UiEvent::bstate, UiEvent::ch, UiEvent::ctrl, UiEvent::key, UiEvent::mouse_action, UiEvent::mouse_inside, UiRuntime::nc, UiEvent::shift, ui, UI_KEY_CHAR, UI_KEY_MOUSE, UI_MOUSE_PRESS, UI_MOUSE_RELEASE, UI_MOUSE_SCROLL_DOWN, UI_MOUSE_SCROLL_UP, UiEvent::x, and UiEvent::y.

Referenced by action_disposition(), answer_yn(), cf_accept(), display_error(), menu_cmd_processor(), notcurses_input(), and Perror().

Here is the caller graph for this function:

◆ ui_get_event_multi()

int ui_get_event_multi ( UiSurface * s,
uint w,
UiEvent * ev,
int timeout_ms )

Definition at line 146 of file ui_ncurses_input.c.

146 {
147 int i;
148 if (!ev)
149 return -1;
150 memset(ev, 0, sizeof(*ev));
151 keypad(s->mwin[w], true);
152 if (timeout_ms <= 0) {
153 timeout_ms = -1;
154 } else
155 wtimeout(s->mwin[w], timeout_ms);
156 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION | BUTTON_SHIFT | BUTTON_CTRL | BUTTON_ALT, NULL);
157 ev->chyron = -1;
158 qiflush();
159 tcflush(2, TCIFLUSH);
160 cbreak();
161 curs_set(2);
162 int ch = wgetch(s->mwin[w]);
163 curs_set(0);
165 ev->key = translate_key(ch);
166 if (ev->key == UI_KEY_CHAR) {
167 ev->ch = (uint32_t)ch;
168 } else if (ev->key == UI_KEY_MOUSE) {
169 MEVENT me;
170 if (getmouse(&me) == OK) {
171 ev->y = me.y;
172 ev->x = me.x;
173 if (me.bstate & BUTTON4_PRESSED)
175 else if (me.bstate & BUTTON5_PRESSED)
177 else if (me.bstate & BUTTON1_CLICKED ||
178 me.bstate & BUTTON1_PRESSED ||
179 me.bstate & BUTTON1_DOUBLE_CLICKED) {
181 ev->in_win = -1;
182 for (i = WIN; i < SUB_SFC_MAX; i++) {
183 if (s->mwin[i] != NULL &&
184 wenclose(s->mwin[i], me.y, me.x) &&
185 wmouse_trafo(s->mwin[i], &me.y, &me.x, false)) {
186 ev->in_win = i;
187 ev->key = 0;
188 break;
189 }
190 }
191 ev->bstate = me.bstate;
192 ev->y = me.y;
193 ev->x = me.x;
194 ev->key = 0;
195 return 0;
196 }
197 }
198 }
199 curs_set(0);
200 return ch;
201}
uint in_win
Definition ui_backend.h:110
int chyron
Definition ui_backend.h:109

References UiEvent::alt, UiEvent::bstate, UiEvent::ch, UiEvent::chyron, UiEvent::ctrl, get_plane_idx(), UiEvent::in_win, UiEvent::key, UiEvent::mouse_action, UiRuntime::nc, ncplane_clicked(), UiEvent::shift, SUB_SFC_MAX, ui, UI_KEY_CHAR, UI_KEY_MOUSE, UI_MOUSE_NONE, UI_MOUSE_PRESS, UI_MOUSE_RELEASE, UI_MOUSE_SCROLL_DOWN, UI_MOUSE_SCROLL_UP, WIN, UiEvent::x, and UiEvent::y.

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

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

◆ ui_get_event_no_mouse()

int ui_get_event_no_mouse ( UiSurface * surface,
uint w,
UiEvent * ev )

Definition at line 203 of file ui_ncurses_input.c.

203 {
204 int ch;
205 mousemask(0, NULL);
206
207 qiflush();
208 tcflush(2, TCIFLUSH);
209 cbreak();
210 do {
211 curs_set(2);
212 ch = wgetch(s->mwin[w]);
213 curs_set(0);
214 ev->key = translate_key(ch);
215 if (ev->key == UI_KEY_CHAR) {
216 ev->ch = (uint32_t)ch;
217 break;
218 }
219 } while (ch == ERR);
220 return ch;
221}

References UiEvent::alt, UiEvent::ch, UiEvent::ctrl, UiEvent::key, UiRuntime::nc, UiEvent::shift, ui, and UI_KEY_CHAR.

Referenced by get_cmd_char().

Here is the caller graph for this function:

◆ ui_get_pair()

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

◆ ui_get_screen_size()

void ui_get_screen_size ( uint * lines,
uint * cols )

Definition at line 692 of file ui_ncurses.c.

692 {
693 if (!ui)
694 return;
695 getmaxyx(stdscr, ui->lines, ui->cols);
696 if (lines)
697 *lines = ui->lines;
698 if (cols)
699 *cols = ui->cols;
700}

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 * uc,
wchar_t * wstr,
attr_t * attrs,
ushort * pair,
void * opts )

◆ ui_getch()

int ui_getch ( )

Definition at line 255 of file nckeys.c.

255 {
256 ncinput ni;
257 notcurses_get_blocking(nc, &ni);
258 return ni.id;
259}
NotCurses * nc
Definition nckeys.c:45

References nc, UiRuntime::nc, and ui.

Referenced by ui_notcurses_init().

Here is the caller graph for this function:

◆ ui_getmaxx()

uint ui_getmaxx ( UiSurface * s,
uint w )

Definition at line 686 of file ui_ncurses.c.

686 {
687
688 if (!s->mwin[w])
689 return -1;
690 return (int)(getmaxx(s->mwin[w]));
691}

Referenced by border_draw(), border_title(), border_ysplit(), and border_ysplit_text().

Here is the caller graph for this function:

◆ ui_getmaxy()

uint ui_getmaxy ( UiSurface * s,
uint w )

Definition at line 681 of file ui_ncurses.c.

681 {
682 if (!s->mwin[w])
683 return -1;
684 return (int)(getmaxy(s->mwin[w]));
685}

Referenced by assign_chyron_win(), and border_draw().

Here is the caller graph for this function:

◆ ui_getmaxyx()

void ui_getmaxyx ( UiSurface * s,
uint w,
uint * lines,
uint * cols )

Definition at line 676 of file ui_ncurses.c.

676 {
677 if (!s->mwin[w])
678 return;
679 getmaxyx(s->mwin[w], *lines, *cols);
680}

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 * lines,
uint * cols )

Definition at line 668 of file ui_ncurses.c.

668 {
669 if (!s->mwin[w])
670 return;
671 int _lines, _cols;
672 getyx(s->mwin[w], _lines, _cols);
673 *lines = (uint)(_lines);
674 *cols = (uint)(_cols);
675}

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 174 of file ui_ncurses.c.

174 {
175 RGB rgb;
176 sscanf(s, "#%02x%02x%02x", &rgb.r, &rgb.g, &rgb.b);
177 return rgb;
178}

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 653 of file ui_ncurses.c.

653 {
654 if (!s->mwin[w])
655 return -1;
656 if (enable)
657 idcok(s->mwin[w], true);
658 else
659 idcok(s->mwin[w], false);
660 return 0;
661}

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 644 of file ui_ncurses.c.

644 {
645 if (!s->mwin[w])
646 return -1;
647 if (enable)
648 idlok(s->mwin[w], true);
649 else
650 idlok(s->mwin[w], false);
651 return 0;
652}

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 * config)

Definition at line 261 of file ui_ncurses.c.

261 {
262 setlocale(LC_ALL, "");
263 ui = calloc(1, sizeof(*ui));
264 if (!ui)
265 return NULL;
266 char tty_name[MAXLEN];
267 if (cfg && cfg->tty_path) {
268 strncpy(tty_name, cfg->tty_path, sizeof(tty_name) - 1);
269 tty_name[sizeof(tty_name) - 1] = '\0';
270 } else {
271 if (ttyname_r(STDERR_FILENO, tty_name, sizeof(tty_name)) != 0) {
272 free(ui);
273 return NULL;
274 }
275 }
276 ui->tty_fp = fopen(tty_name, "r+");
277 if (!ui->tty_fp) {
278 free(ui);
279 return NULL;
280 }
281 ui->screen = newterm(NULL, ui->tty_fp, ui->tty_fp);
282 if (!ui->screen) {
283 fclose(ui->tty_fp);
284 free(ui);
285 return NULL;
286 }
287 set_term(ui->screen);
288 f_curses_open = true;
289 if (!has_colors() || !can_change_color()) {
290 ui_shutdown();
291 return NULL;
292 }
293 start_color();
294 use_default_colors();
295 cbreak();
296 noecho();
297 keypad(stdscr, TRUE);
298 if (cfg) {
299 ui->mouse_enabled = cfg->enable_mouse;
300 ui->alt_screen = cfg->enable_alt_screen;
301 ui->cursor_visible = cfg->cursor_visible;
302 ui->border_style = cfg->border_style;
303 } else {
304 ui->cursor_visible = false;
305 ui->alt_screen = false;
306 }
307 if (ui->mouse_enabled)
308 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
309 getmaxyx(stdscr, ui->lines, ui->cols);
310 if (cfg) {
311 if (ui->border_style == 'r' || ui->border_style == 'R') {
312 memcpy(bw.str, border_rounded, sizeof(bw.str));
313 } else if (ui->border_style == 's' || ui->border_style == 'S') {
314 memcpy(bw.str, border_single, sizeof(bw.str));
315 } else if (ui->border_style == 'd' || ui->border_style == 'D') {
316 memcpy(bw.str, border_double, sizeof(bw.str));
317 } else if (ui->border_style == 'h' || ui->border_style == 'H') {
318 memcpy(bw.str, border_heavy, sizeof(bw.str));
319 } else if (ui->border_style == 'n' || ui->border_style == 'N') {
320 memcpy(bw.str, border_none, sizeof(bw.str));
321 }
322 }
323 stdsfc = calloc(1, sizeof(*stdsfc));
324 if (!stdsfc)
325 return NULL;
326 stdsfc->runtime = ui;
327 stdsfc->parent = NULL;
328 stdsfc->meta[BOX].lines = (int)ui->lines;
329 stdsfc->meta[BOX].cols = (int)ui->cols;
330 stdsfc->meta[BOX].y = 0;
331 stdsfc->meta[BOX].x = 0;
332 stdsfc->mwin[BOX] = stdscr;
333 stdsfc->mpan[BOX] = new_panel(stdsfc->mwin[BOX]);
334 if (!stdsfc->mpan[BOX]) {
335 free(stdsfc);
336 Perror("new_panel failed for stdsfc->mpan[BOX]");
337 exit(EXIT_FAILURE);
338 }
339 return ui;
340}
bool f_curses_open
Definition sig.c:33
wchar_t * border_rounded
Definition ui_ncurses.c:41
BorderWide bw
Definition ui_ncurses.c:46
UiSurface * stdsfc
Definition ui_ncurses.c:36
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
#define TRUE
Definition iloan.c:19
int Perror(char *emsg_str)
Display a simple error message window or print to stderr.
Definition dwin.c:841

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 ( uint color,
uint r,
uint g,
uint b )

Definition at line 189 of file ui_ncurses.c.

189 {
190 init_extended_color(color, r, g, b);
191 return 0;
192}

Referenced by ui_add_color_rgb().

Here is the caller graph for this function:

◆ ui_init_pair()

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

Definition at line 202 of file ui_ncurses.c.

202 {
203 init_extended_pair(pair, fg, bg);
204 return 0;
205}

◆ ui_keypad()

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

Definition at line 635 of file ui_ncurses.c.

635 {
636 if (!s->mwin[w])
637 return -1;
638 if (enable)
639 keypad(s->mwin[w], true);
640 else
641 keypad(s->mwin[w], false);
642 return 0;
643}

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 234 of file ui_ncurses_input.c.

234 {
235 if (!ui)
236 return -1;
237 if (mask)
238 mousemask(mask, nullptr);
239 else
240 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr);
241 return 0;
242}

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 225 of file ui_ncurses_input.c.

225 {
226 if (!ui)
227 return -1;
228 if (mask)
229 mousemask(mask, nullptr);
230 else
231 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, nullptr);
232 return 0;
233}

References UiRuntime::nc, and ui.

◆ ui_mvaddstr()

int ui_mvaddstr ( UiSurface * s,
uint w,
uint y,
uint x,
const char * text )

Definition at line 118 of file ui_ncurses_draw.c.

118 {
119 if (!s || !text)
120 return -1;
121 mvwaddstr(s->mwin[w], y, x, text);
122 return 0;
123}

◆ ui_mvwadd_wch()

int ui_mvwadd_wch ( UiSurface * s,
uint w,
uint y,
uint x,
const UiCell * cell )

Definition at line 175 of file ui_ncurses_draw.c.

175 {
176 if (!s)
177 return -1;
178 mvwadd_wch(s->mwin[w], y, x, cell);
179 return 0;
180}

Referenced by display_form(), and get_cmd_char().

Here is the caller graph for this function:

◆ ui_mvwadd_wchnstr()

int ui_mvwadd_wchnstr ( UiSurface * s,
uint w,
uint y,
uint x,
const UiCell * cell,
uint m )

Definition at line 201 of file ui_ncurses_draw.c.

201 {
202 if (!s || !cmplx_buf)
203 return -1;
204 mvwadd_wchnstr(s->mwin[w], y, x, cmplx_buf, n);
205 return 0;
206}

References nccell::gcluster, ui_wmove(), and nccell::width.

Referenced by border_draw(), border_title(), border_ysplit(), border_ysplit_text(), deselect_object(), form_display_accept_field(), form_display_field(), form_display_fields(), get_cmd_arg(), get_cmd_char(), picker(), remove_right_angle(), reverse_object(), toggle_object(), unreverse_object(), and view_cmd_processor().

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

◆ ui_mvwadd_wchstr()

int ui_mvwadd_wchstr ( UiSurface * s,
uint w,
uint y,
uint x,
const UiCell * cell )

Definition at line 188 of file ui_ncurses_draw.c.

188 {
189 if (!s || !cmplx_buf)
190 return -1;
191 mvwadd_wchstr(s->mwin[w], y, x, cmplx_buf);
192 return 0;
193}

References nccell::gcluster, and ui_wmove().

Referenced by display_chyron(), display_field(), display_line(), and form_display_fields().

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

◆ ui_mvwaddch()

int ui_mvwaddch ( UiSurface * s,
uint w,
uint y,
uint x,
const char c )

Definition at line 125 of file ui_ncurses_draw.c.

125 {
126 if (!s || !c)
127 return -1;
128 mvwaddch(s->mwin[w], y, x, c);
129 return 0;
130}

References ui_wmove().

Referenced by get_cmd_char(), and menu_engine().

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

◆ ui_mvwaddnstr()

int ui_mvwaddnstr ( UiSurface * s,
uint w,
uint y,
uint x,
const char * text,
int m )

Definition at line 138 of file ui_ncurses_draw.c.

138 {
139 if (!s || !text)
140 return -1;
141 mvwaddnstr(s->mwin[w], y, x, text, m);
142 return 0;
143}

◆ ui_mvwaddnwstr()

int ui_mvwaddnwstr ( UiSurface * s,
uint w,
uint y,
uint x,
const wchar_t * wstr,
int m )

Definition at line 102 of file ui_ncurses_draw.c.

102 {
103 if (!s || !wstr)
104 return -1;
105 mvwaddnwstr(s->mwin[w], y, x, wstr, m);
106 return 0;
107}

Referenced by border_title(), and border_ysplit_text().

Here is the caller graph for this function:

◆ ui_mvwaddstr()

int ui_mvwaddstr ( UiSurface * s,
uint w,
uint y,
uint x,
const char * text )

Definition at line 132 of file ui_ncurses_draw.c.

132 {
133 if (!s || !text)
134 return -1;
135 mvwaddstr(s->mwin[w], y, x, text);
136 return 0;
137}

Referenced by cf_accept(), display_form(), display_line(), display_pick_page(), display_prompt(), display_split_line(), notcurses_input(), pick_engine(), picker(), and popup_ckeys().

Here is the caller graph for this function:

◆ ui_mvwaddstr_fill()

int ui_mvwaddstr_fill ( UiSurface * s,
uint w,
uint y,
uint x,
const char * str,
int m )

Definition at line 145 of file ui_ncurses_draw.c.

145 {
146 char *d, *e;
147 uint maxy, maxx;
148 char tmp_str[MAXLEN];
149 getmaxyx(s->mwin[w], maxy, maxx);
150 y = min(y, maxy);
151 m = min(m, maxx);
152 m = min(m, (uint)MAXLEN - 1);
153 e = d = tmp_str;
154 e += m;
155 while (d < e) {
156 if (*str == '\0' || *str == '\n')
157 *d++ = ' ';
158 else
159 *d++ = *str++;
160 }
161 *d = '\0';
162 m = strlen(tmp_str);
163 mvwaddnstr(s->mwin[w], y, x, tmp_str, m);
164 return 0;
165}
#define min(x, y)
min macro evaluates two expressions, returning least result
Definition cm.h:91

Referenced by display_pick_page(), picker(), reverse_object(), and unreverse_object().

Here is the caller graph for this function:

◆ ui_mvwaddwstr()

int ui_mvwaddwstr ( UiSurface * s,
uint w,
uint y,
uint x,
const wchar_t * wstr )

Definition at line 90 of file ui_ncurses_draw.c.

90 {
91 if (!s || !wstr)
92 return -1;
93 mvwaddwstr(s->mwin[w], y, x, wstr);
94 return 0;
95}

◆ ui_ncurses_get_screen()

SCREEN * ui_ncurses_get_screen ( )

Definition at line 821 of file ui_ncurses.c.

821 {
822 if (!ui)
823 return NULL;
824 return ui->screen;
825}

References ui.

◆ ui_pair_content()

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

Definition at line 194 of file ui_ncurses.c.

194 {
195 int _pair = (int)pair;
196 int _fg, _bg;
197 extended_pair_content(_pair, &_fg, &_bg);
198 *fg = (uint)_fg;
199 *bg = (uint)_bg;
200 return 0;
201}

Referenced by parse_ansi_str(), and ui_add_pair().

Here is the caller graph for this function:

◆ ui_render()

void ui_render ( )

◆ ui_restore_wins()

void ui_restore_wins ( )

Definition at line 210 of file ui_ncurses_draw.c.

210 {
211 touchwin(stdscr);
212 for (int s = 0; s <= sfc_ptr; s++) {
213 for (uint w = 0; w < SUB_SFC_MAX; w++)
214 if (ui_surface[s]->mwin[w] != nullptr)
215 touchwin(ui_surface[s]->mwin[w]);
216 }
217 ui_render();
218}
void ui_render()
Definition ui_ncurses.c:800
UiSurface * ui_surface[UI_SFC_MAX]
Definition ui_ncurses.c:28
int sfc_ptr
Definition nckeys.c:47

References sfc_ptr, SUB_SFC_MAX, ui_render(), and ui_surface.

Referenced by enter_file_spec(), exec_objects(), fork_exec(), form_exec_receiver(), full_screen_shell(), menu_cmd_processor(), menu_engine(), view_cmd_processor(), view_init_input(), and write_view_buffer().

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

◆ ui_resume()

int ui_resume ( )

Definition at line 403 of file ui_ncurses.c.

403 {
404 reset_prog_mode();
405 update_panels();
406 doupdate();
407 return 0;
408}

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 626 of file ui_ncurses.c.

626 {
627 if (!s->mwin[w])
628 return -1;
629 if (enable)
630 scrollok(s->mwin[w], true);
631 else
632 scrollok(s->mwin[w], false);
633 return 0;
634}

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 * wch,
const wchar_t * wc,
const attr_t attrs,
short pair,
const void * opts )

◆ ui_setscrreg()

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

Definition at line 662 of file ui_ncurses.c.

662 {
663 if (!s->mwin[w])
664 return -1;
665 wsetscrreg(s->mwin[w], top, bottom);
666 return 0;
667}

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 344 of file ui_ncurses.c.

344 {
345 if (ui == NULL)
346 return;
347 for (int i = sfc_ptr; i >= 0; i--) {
348 if (ui_surface[i] != NULL) {
350 ui_surface[i] = NULL;
351 }
352 }
353 if (stdsfc->mpan[0] != NULL) {
354 hide_panel(stdsfc->mpan[0]);
355 del_panel(stdsfc->mpan[0]);
356 stdsfc->mpan[0] = NULL;
357 }
358 f_curses_open = false;
359 endwin();
360 if (ui->screen != NULL) {
361 delscreen(ui->screen);
362 ui->screen = NULL;
363 }
364 if (ui->tty_fp != NULL) {
365 fclose(ui->tty_fp);
366 ui->tty_fp = NULL;
367 }
368 if (stdsfc != NULL) {
369 free(stdsfc);
370 stdsfc = NULL;
371 }
372 if (ui != NULL) {
373 free(ui);
374 ui = NULL;
375 }
376}
void ui_surface_destroy(UiSurface *s)
Definition ui_ncurses.c:377

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 view_win,
uint lines,
uint cols )

Definition at line 509 of file ui_ncurses.c.

509 {
510 s->mwin[w] = newpad(lines, cols);
511 if (s->mwin[w] == nullptr)
512 return -1;
513 s->mwin[view_win] = subpad(s->mwin[PAD], lines, cols, 0, 0);
514 if (s->mwin[view_win] == nullptr)
515 return -1;
516 s->mpan[w] = new_panel(s->mwin[view_win]);
517 immedok(s->mwin[w], true);
518#ifdef DEBUG_UI
519#endif
520 return 0;
521}

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 523 of file ui_ncurses.c.

523 {
524 s->mwin[w] = derwin(s->mwin[p], lines, cols, y, x);
525 if (!s->mwin[w]) {
526 free(s);
527 return -1;
528 }
529 s->mpan[w] = new_panel(s->mwin[w]);
530 keypad(s->mwin[w], true);
531 ui_bkgd(s, w, &cell_nt);
532 ui_bkgdset(s, w, &cell_nt);
533 immedok(s->mwin[w], true);
534#ifdef DEBUG_UI
535#endif
536 return 0;
537}
int ui_bkgdset(UiSurface *s, uint w, const UiCell *cell)
Definition ui_ncurses.c:760
int ui_bkgd(UiSurface *s, uint w, const UiCell *cell)
Definition ui_ncurses.c:753
UiCell cell_nt
Definition dwin.c:94

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 377 of file ui_ncurses.c.

377 {
378 if (!s)
379 return;
380 for (int i = SUB_SFC_MAX; i >= 0; i--) {
381 if (s->mpan[i] != NULL) {
382 hide_panel(s->mpan[i]);
383 del_panel(s->mpan[i]);
384 s->mpan[i] = NULL;
385 }
386 }
387 for (int i = SUB_SFC_MAX; i >= 0; i--) {
388 if (s->mwin[i] != NULL) {
389 delwin(s->mwin[i]);
390 s->mwin[i] = NULL;
391 }
392 }
393 if (s != NULL) {
394 free(s);
395 s = NULL;
396 }
397}

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 614 of file ui_ncurses.c.

614 {
615 if (!s)
616 return -1;
617 hide_panel(s->mpan[w]);
618 s->meta[w].hidden = true;
619 return 0;
620}

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 542 of file ui_ncurses.c.

542 {
543 if (!s)
544 return -1;
545 s->meta[w].y = y;
546 s->meta[w].x = x;
547 return move_panel(s->mpan[w], y, x);
548}

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 414 of file ui_ncurses.c.

414 {
415 if (!ui)
416 return NULL;
417 UiSurface *s = calloc(1, sizeof(*s));
418 if (!s)
419 return NULL;
420 for (int i = 0; i < SUB_SFC_MAX; i++) {
421 s->mwin[i] = NULL;
422 s->mpan[i] = NULL;
423 }
424 s->runtime = ui;
425 s->parent = parent;
426 s->meta[w].lines = lines;
427 s->meta[w].cols = cols;
428 s->meta[w].y = y;
429 s->meta[w].x = x;
430
431 if (parent && parent->mwin[p]) {
432 s->mwin[w] = derwin(parent->mwin[p], lines, cols, y, x);
433 if (!s->mwin[w]) {
434 free(s);
435 return NULL;
436 }
437 } else {
438 s->mwin[w] = newwin(lines, cols, y, x);
439 if (!s->mwin[w]) {
440 free(s);
441 return NULL;
442 }
443 s->mpan[w] = new_panel(s->mwin[w]);
444 if (!s->mpan[w]) {
445 delwin(s->mwin[w]);
446 free(s);
447 return NULL;
448 }
449 }
450 return s;
451}

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 550 of file ui_ncurses.c.

550 {
551 if (!s)
552 return -1;
553 s->meta[w].lines = lines;
554 s->meta[w].cols = cols;
555 wresize(s->mwin[w], lines + 2, cols + 2);
556 wresize(s->mwin[w + 1], lines, cols);
557 return 0;
558}

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

◆ ui_surface_show()

int ui_surface_show ( UiSurface * s,
uint w )

Definition at line 598 of file ui_ncurses.c.

598 {
599 if (!s)
600 return -1;
601 show_panel(s->mpan[w]);
602 s->meta[w].hidden = false;
603 return 0;
604 return 0;
605}

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

◆ ui_suspend()

int ui_suspend ( )

Definition at line 398 of file ui_ncurses.c.

398 {
399 def_prog_mode();
400 endwin();
401 return 0;
402}

References UiRuntime::nc, and ui.

◆ ui_top_panel()

int ui_top_panel ( UiSurface * s,
uint w )

Definition at line 607 of file ui_ncurses.c.

607 {
608 if (!s)
609 return -1;
610 top_panel(s->mpan[w]);
611 return 0;
612}

Referenced by picker().

Here is the caller graph for this function:

◆ ui_update_panels()

void ui_update_panels ( )

Definition at line 804 of file ui_ncurses.c.

804 {
805 update_panels();
806}

References UiRuntime::nc, and ui.

◆ ui_wadd_wch()

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

Definition at line 169 of file ui_ncurses_draw.c.

169 {
170 if (!s)
171 return -1;
172 wadd_wchnstr(s->mwin[w], cell, 1);
173 return 0;
174}

◆ ui_wadd_wchnstr()

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

Definition at line 195 of file ui_ncurses_draw.c.

195 {
196 if (!s || !cmplx_buf)
197 return -1;
198 wadd_wchnstr(s->mwin[w], cmplx_buf, n);
199 return 0;
200}

References nccell::gcluster, and nccell::width.

Referenced by display_split_line().

Here is the caller graph for this function:

◆ ui_wadd_wchstr()

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

Definition at line 181 of file ui_ncurses_draw.c.

181 {
182 if (!s || !cmplx_buf)
183 return -1;
184 wadd_wchstr(s->mwin[w], cmplx_buf);
185 return 0;
186}

References nccell::gcluster.

◆ ui_waddch()

int ui_waddch ( UiSurface * s,
uint w,
const char c )

◆ ui_waddnstr()

int ui_waddnstr ( UiSurface * s,
uint w,
const char * text,
int m )

Definition at line 114 of file ui_notcurses_draw.c.

114 {
115 if (!s || !text)
116 return -1;
117 ncplane_putnstr(s->mplane[w], m, text);
118 return 0;
119}

◆ ui_waddnwstr()

int ui_waddnwstr ( UiSurface * s,
uint w,
const wchar_t * wstr,
int m )

Definition at line 96 of file ui_ncurses_draw.c.

96 {
97 if (!s || !wstr)
98 return -1;
99 waddnwstr(s->mwin[w], wstr, m);
100 return 0;
101}

◆ ui_waddstr()

int ui_waddstr ( UiSurface * s,
uint w,
const char * text )

Definition at line 111 of file ui_ncurses_draw.c.

111 {
112 if (!s || !text)
113 return -1;
114 waddstr(s->mwin[w], text);
115 return 0;
116}

Referenced by display_prompt(), and get_cmd_arg().

Here is the caller graph for this function:

◆ ui_waddwstr()

int ui_waddwstr ( UiSurface * s,
uint w,
const wchar_t * wstr )

Definition at line 84 of file ui_ncurses_draw.c.

84 {
85 if (!s || !wstr)
86 return -1;
87 waddwstr(s->mwin[w], wstr);
88 return 0;
89}

◆ ui_wclear()

int ui_wclear ( UiSurface * s,
uint w )

Definition at line 574 of file ui_ncurses.c.

574 {
575 if (!s)
576 return -1;
577 if (w == ALLWINS) {
578 for (int i = 1; i < SUB_SFC_MAX; i++) {
579 if (s->mwin[i]) {
580 wclear(s->mwin[i]);
581 }
582 }
583 } else {
584 if (s->mwin[w]) {
585 wclear(s->mwin[w]);
586 }
587 }
588 return 0;
589}
#define ALLWINS
Definition ui_backend.h:92

References SUB_SFC_MAX.

◆ ui_wclrtobot()

int ui_wclrtobot ( UiSurface * s,
uint w )

Definition at line 25 of file ui_ncurses_draw.c.

25 {
26 if (!s)
27 return -1;
28 wclrtobot(s->mwin[w]);
29 return 0;
30}

Referenced by display_line_eod(), scroll_down(), scroll_up(), and search().

Here is the caller graph for this function:

◆ ui_wclrtoeol()

int ui_wclrtoeol ( UiSurface * s,
uint w )

Definition at line 31 of file ui_ncurses_draw.c.

31 {
32 if (!s)
33 return -1;
34 wclrtoeol(s->mwin[w]);
35 return 0;
36}

Referenced by cf_accept(), display_chyron(), display_line(), display_prompt(), display_split_line(), form_post(), get_cmd_arg(), get_cmd_char(), notcurses_input(), pick_engine(), and picker().

Here is the caller graph for this function:

◆ ui_werase()

int ui_werase ( UiSurface * s,
uint w )

Definition at line 560 of file ui_ncurses.c.

560 {
561 if (w == ALLWINS) {
562 for (int i = 1; i < SUB_SFC_MAX; i++) {
563 if (s->mwin[i]) {
564 werase(s->mwin[i]);
565 }
566 }
567 } else {
568 if (s->mwin[w]) {
569 werase(s->mwin[w]);
570 }
571 }
572 return 0;
573}

References SUB_SFC_MAX.

Referenced by exec_objects(), and full_screen_shell().

Here is the caller graph for this function:

◆ ui_whide()

int ui_whide ( UiSurface * s,
uint w )

◆ ui_wmove()

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

Definition at line 732 of file ui_ncurses.c.

732 {
733 if (!s || !s->mwin[w])
734 return -1;
735 return wmove(s->mwin[w], y, x);
736}

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 811 of file ui_ncurses.c.

811 {
812 if (!s)
813 return -1;
814 wnoutrefresh(s->mwin[w]);
815 return 0;
816}

Referenced by picker().

Here is the caller graph for this function:

◆ ui_wresize()

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

◆ ui_wscrl()

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

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:

◆ ui_wset_base()

int ui_wset_base ( UiSurface * s,
uint w,
const UiStyle * style,
uint32_t fill_ch )

◆ ui_wset_style()

int ui_wset_style ( UiSurface * s,
uint w,
const UiStyle * style )

◆ ui_wshow()

int ui_wshow ( UiSurface * s,
uint w )

Variable Documentation

◆ border_double

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

Definition at line 42 of file ui_ncurses.c.

Referenced by ui_init(), and ui_init().

◆ border_heavy

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

Definition at line 43 of file ui_ncurses.c.

Referenced by ui_init(), and ui_init().

◆ border_rounded

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

BOX WIDE UNICODE CODEPOINTS

Definition at line 41 of file ui_ncurses.c.

Referenced by ui_init(), and ui_init().

◆ border_square

wchar_t* border_square
extern

◆ bw

BorderWide bw
extern

Definition at line 46 of file ui_ncurses.c.

Referenced by ui_init(), and ui_init().

◆ bw_chk

const wchar_t * bw_chk = L"\x2611"
extern

left_angle

Definition at line 59 of file ui_ncurses.c.

Referenced by initialize_cells().

◆ bw_da

const wchar_t * bw_da = L"\x2193"
extern

large down arrow

Definition at line 56 of file ui_ncurses.c.

◆ bw_h09

const wchar_t * bw_h09 = L"\x23BD"
extern

horizontal line 9

Definition at line 60 of file ui_ncurses.c.

◆ bw_la

const wchar_t * bw_la = L"\x2190"
extern

large left arrow

Definition at line 54 of file ui_ncurses.c.

◆ bw_lan

const wchar_t * bw_lan = L"\x276E"
extern

left_angle

Definition at line 58 of file ui_ncurses.c.

◆ bw_ra

const wchar_t * bw_ra = L"\x2192"
extern

large right arrow

Definition at line 53 of file ui_ncurses.c.

◆ bw_ran

const wchar_t * bw_ran = L"\x276F"
extern

right_angle

Definition at line 57 of file ui_ncurses.c.

Referenced by initialize_cells().

◆ bw_rbl

const wchar_t * bw_rbl = L"\x2570"
extern

rounded bottom left

Definition at line 50 of file ui_ncurses.c.

◆ bw_rbr

const wchar_t * bw_rbr = L"\x256f"
extern

rounded bottom right

Definition at line 51 of file ui_ncurses.c.

◆ bw_rtl

const wchar_t * bw_rtl = L"\x256d"
extern

rounded top left

Definition at line 48 of file ui_ncurses.c.

◆ bw_rtr

const wchar_t * bw_rtr = L"\x256e"
extern

rounded top right

Definition at line 49 of file ui_ncurses.c.

◆ bw_sp

const wchar_t * bw_sp = L"\x20"
extern

space

Definition at line 52 of file ui_ncurses.c.

Referenced by initialize_cells().

◆ bw_ua

const wchar_t * bw_ua = L"\x2191"
extern

large up arrow

Definition at line 55 of file ui_ncurses.c.

◆ COLS

uint COLS

Definition at line 266 of file ui_backend.h.

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

◆ LINES

uint LINES
extern

Definition at line 30 of file ui_notcurses.c.

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

◆ sfc_ptr

◆ std_color

STDRGB std_color
extern
Initial value:
= {
{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 62 of file ui_ncurses.c.

62 {
63 {0, 0, 0},
64 {128, 0, 0},
65 {0, 128, 0},
66 {128, 128, 0},
67 {0, 0, 128},
68 {128, 0, 128},
69 {0, 128, 128},
70 {192, 192, 192},
71 {128, 128, 128},
72 {255, 0, 0},
73 {0, 255, 0},
74 {255, 255, 0},
75 {0, 0, 255},
76 {255, 0, 255},
77 {0, 255, 255},
78 {255, 255, 255}};

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

◆ stdplane

NcPlane * stdplane
extern

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

UiSurface * stdsfc
extern

◆ ui

◆ ui_color_cnt

uint ui_color_cnt = 0
extern

Definition at line 33 of file ui_ncurses.c.

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

◆ ui_pair_cnt

uint ui_pair_cnt = 0
extern

Definition at line 34 of file ui_ncurses.c.

Referenced by ui_add_pair(), and ui_init().

◆ ui_surface

◆ win_ptr

int win_ptr = -1
extern

Definition at line 30 of file ui_ncurses.c.