2
3
4
5
6
7
10#define _XOPEN_SOURCE_EXTENDED 1
42
43
45
46
47
48
49
50
55
56
57
58
59
60
61
62
66 memset(caps, 0,
sizeof(*caps));
78
79
81
82
83
84
85
86
87
88
89
90UiRuntime *
ui_init(
const UiConfig *cfg, SIO *sio) {
91 setlocale(LC_ALL,
"en_US.UTF-8");
92 ui = calloc(1,
sizeof(*
ui));
96 if (ttyname_r(STDIN_FILENO, tty_name,
sizeof(tty_name)) != 0) {
101 ui->tty_fp = fopen(tty_name,
"r+");
102 if (
ui->tty_fp == NULL) {
108 NotCursesOptions nc_opts = {
109 .flags = NCOPTION_SUPPRESS_BANNERS |
110 NCOPTION_NO_QUIT_SIGHANDLERS,
112 ui->nc = notcurses_init(&nc_opts,
ui->tty_fp);
113 if (
ui->nc == NULL) {
120 notcurses_render(
ui->nc);
122 if (
ui->nc == NULL) {
129 notcurses_mice_enable(
ui->nc, NCMICE_BUTTON_EVENT);
130 notcurses_cursor_disable(
ui->nc);
131 notcurses_stddim_yx(
ui->nc, &
ui->lines, &
ui->cols);
137 stdsfc->meta[i].lines = 0;
141 stdsfc->meta[i].hidden =
false;
145 stdsfc->meta[BOX].lines =
ui->lines;
150 if (!
stdsfc->mplane[BOX]) {
151 notcurses_stop(
ui->nc);
161 notcurses_stop(
ui->nc);
170 notcurses_stop(
ui->nc);
178 if (!
ui->border_style)
179 ui->border_style = UI_BORDER_ROUNDED;
181 switch (
ui->border_style) {
182 case UI_BORDER_SINGLE:
185 case UI_BORDER_DOUBLE:
188 case UI_BORDER_ROUNDED:
191 case UI_BORDER_HEAVY:
202 ui->tty_fd = notcurses_inputready_fd(
ui->nc);
209
210
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226UiSurface *
ui_surface_new(ss_t w, UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x) {
229 UiSurface *s = calloc(1,
sizeof(*s));
231 ui_log(ERROR,
"Failed to allocate memory for UiSurface\n");
234 ui_log(INFO,
_(
"Memory allocated for new surface"));
237 UiLogLevel level = INFO;
238 ncplane_options plane_opts = {
245 s->meta[w].lines = lines;
246 s->meta[w].cols = cols;
247 s->meta[w].hidden =
false;
248 if (parent && parent->mplane[p]) {
249 s->mplane[w] = ncplane_create(parent->mplane[p], &plane_opts);
252 ui_log(level,
"%s = ncplane_create(parent=%s, lines=%d, cols=%d, begy=%d, begx=%d) failed", ss_n[w]
, ss_n[p]
, lines
, cols
, y
, x);
253 notcurses_stop(
ui->nc);
257 ui_log(level,
"%s = ncplane_create(parent=%s, lines=%d, cols=%d, begy=%d, begx=%d) success", ss_n[w]
, ss_n[p]
, lines
, cols
, y
, x);
258 ncplane_set_base(s->mplane[PAD],
" ", 0,
cell_nt.channels);
259 ncplane_set_channels(s->mplane[PAD],
cell_nt.channels);
265 s->mplane[w] = ncplane_create(
stdplane, &plane_opts);
268 ui_log(level,
"%s = ncplane_create(parent=%s, lines=%d, cols=%d, begy=%d, begx=%d) failed", ss_n[w]
, "stdplane", lines
, cols
, y
, x);
271 ui_log(level,
"%s = ncplane_create(parent=%s, lines=%d, cols=%d, begy=%d, begx=%d) success", ss_n[w]
, ss_n[p]
, lines
, cols
, y
, x);
274 notcurses_stop(
ui->nc);
281
282
283
284
285
286
287
288
289
290
291
292
293
294UiSurface *
ui_surface_box(UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x,
const char *wtitle) {
297 UiSurface *s = calloc(1,
sizeof(*s));
302 UiLogLevel level = INFO;
303 ncplane_options plane_opts = {
311 s->meta[BOX].lines = lines + 2;
312 s->meta[BOX].cols = cols + 2;
313 s->meta[BOX].hidden =
false;
317 if (parent && parent->mplane[p]) {
318 s->mplane[w] = ncplane_create(parent->mplane[p], &plane_opts);
321 s->mplane[w] = ncplane_create(
stdplane, &plane_opts);
325 ui_log(level,
"ss_n[%s] = ncplane_create(%s, lines=%d, cols=%d, begy=%d, begx=%d) failed", ss_n[w]
, ss_n[p]
, lines
, cols
, y
, x);
329 ui_log(level,
"ss_n[%s] = ncplane_create(%s, lines=%d, cols=%d, begy=%d, begx=%d) success", ss_n[w]
, ss_n[p]
, lines
, cols
, y
, x);
330 ncplane_set_channels(s->mplane[w],
cell_box.channels);
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351int ui_surface_addpad(UiSurface *s, ss_t pad, ss_t win, uint lines, uint cols, uint y, uint x,
bool hidden) {
356 ncplane_dim_yx(
stdplane, &plines, &pcols);
358 s->meta[pad].hidden =
true;
361 offset = absy + s->meta[VIEWPORT].lines + 1;
362 ncplane_move_yx(s->mplane[pad], -offset, 0);
364 ui_log(INFO,
"ncplane_move(%s, begy=%d, begx=%d) success", ss_n[pad]
, -offset - 1
, 0);
365 ncplane_move_above(s->mplane[VIEWPORT], s->mplane[win]);
367 ncplane_move_above(s->mplane[pad], s->mplane[VIEWPORT]);
368 ui_log(INFO,
"ncplane_move_above(s->mplane[%s], s->mplane[%s]) success", ss_n[pad]
, ss_n[VIEWPORT]);
370 ncplane_move_above(s->mplane[LNNO], s->mplane[pad]);
372 ncplane_move_above(s->mplane[CMDLN], s->mplane[pad]);
375 ncplane_move_above(s->mplane[BOX], s->mplane[pad]);
381
382
383
384
385
386
387
388
389
390
391
392
393
394
396 ncplane_options plane_opts = {
404 s->meta[w].lines = lines;
405 s->meta[w].cols = cols;
406 s->meta[w].hidden =
false;
407 s->mplane[w] = ncplane_create(s->mplane[p], &plane_opts);
408 UiLogLevel level = INFO;
410 ui_log(level,
"%s = ncplane_create(parent=%s, lines=%d, cols=%d, begy=%d, begx=%d) failed", ss_n[w]
, ss_n[p]
, lines
, cols
, y
, x);
411 notcurses_stop(
ui->nc);
415 ui_log(level,
"%s = ncplane_create(parent=%s, lines=%d, cols=%d, begy=%d, begx=%d) success", ss_n[w]
, ss_n[p]
, lines
, cols
, y
, x);
419
420
421
422
423
424
429
430
431
432
433
434
440 ui_log(INFO,
_(
"Destroying surface: %d"),
sfc_ptr);
446 if (
stdsfc->mplane[BOX]) {
447 ui_log(INFO,
_(
"Destroying mplane[%d]"), BOX);
448 ncplane_erase(
stdsfc->mplane[BOX]);
449 ncplane_destroy(
stdsfc->mplane[BOX]);
450 stdsfc->mplane[BOX] = NULL;
457 ui_log(INFO,
_(
"Destroying stdsfc"));
461 ui_log(INFO,
_(
"Calling notcurses_stop"));
462 notcurses_stop(
ui->nc);
465 if (ui_pair != NULL) {
466 ui_log(INFO,
_(
"Destroying ui_pair"));
470 if (ui_color != NULL) {
471 ui_log(INFO,
_(
"Destroying ui_color"));
476 ui_log(INFO,
_(
"Destroying ui->sio"));
481 ui_log(INFO,
_(
"Destroying ui"));
488
489
490
491
492
493
499 if (s->mplane[w] != NULL) {
500 ui_log(INFO,
_(
"Destroying mplane[%d]"), w);
501 ncplane_erase(s->mplane[w]);
502 ncplane_destroy(s->mplane[w]);
510 ui_log(INFO,
_(
"Destroying surface: s"));
516
517
519
520
521
522
523
524
525
526
527
528
529
535 if (!s->meta[w].hidden)
536 return ncplane_move_yx(s->mplane[w], y, x) == 0 ? 0 : -1;
540
541
542
543
544
545
546
547
548
552 return ncplane_resize_simple(s->mplane[w], (
unsigned int)lines,
553 (
unsigned int)cols) == 0
558
559
560
561
562
566 ncplane_erase_region(
stdplane, 0, 0, 0, 0);
570
571
572
573
574
575
576
577
581 ncplane_erase_region(
stdplane, 0, 0, 0, 0);
585
586
587
588
589
590
591
592
596 ncplane_erase_region(s->mplane[w], 0, 0, 0, 0);
600
601
602
603
604
605
606
607
611 ncplane_erase_region(s->mplane[w], 0, 0, 0, 0);
615
616
617
618
619
620
621
622
626 ncplane_move_top(s->mplane[w]);
630
631
632
633
634
635
636
637
641 if (s->meta[w].hidden) {
642 s->meta[w].hidden =
false;
643 ncplane_move_yx(s->mplane[w], s->meta[w].y, s->meta[w].x);
648
649
650
651
652
653
654
655
659 if (!s->meta[w].hidden) {
660 s->meta[w].hidden =
true;
662 ncplane_move_yx(s->mplane[w], -s->meta[w].lines - 1, 0);
670
671
672
673
674
675
676
677
678
679int ui_wmove(UiSurface *s, ss_t w, uint y, uint x) {
682 if (ncplane_cursor_move_yx(s->mplane[w], y, x) != 0)
687
688
689
690
691
692
693
694
695
699 if (ncplane_cursor_move_yx(s->mplane[w], y, x) != 0)
704
705
706
707
708
709
710
711
713 notcurses_cursor_yx(
ui->nc, y, x);
716
717
718
719
720
721
722
723
727 ncplane_abs_yx(s->mplane[w], y, x);
730 ncplane_translate(s->mplane[w], NULL, absy, absx);
734
735
736
737
738
739
740
741
742void ui_getyx(UiSurface *s, ss_t w, uint *y, uint *x) {
745 ncplane_cursor_yx(s->mplane[w], y, x);
748
749
750
751
752
753
754
755
759 ncplane_dim_yx(s->mplane[w], y, x);
762
763
764
765
766
767
768
769
774 ncplane_dim_yx(s->mplane[w], &y, &x);
778
779
780
781
782
783
784
789 ncplane_dim_yx(s->mplane[w], &y, &x);
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
810 ncplane_dim_yx(s->mplane[w], &rows, &cols);
814 ncplane_scrollup(s->mplane[w], r);
820 if ((uint)r >= rows) {
821 ncplane_erase(s->mplane[w]);
826 for (
int src_row = (
int)(rows - r) - 1; src_row >= 0; src_row--) {
827 int dst_row = src_row + r;
828 for (uint col = 0; col < cols; col++) {
829 nccell c = NCCELL_TRIVIAL_INITIALIZER;
830 ncplane_at_yx_cell(s->mplane[w], src_row, col, &c);
831 ncplane_putc_yx(s->mplane[w], dst_row, col, &c);
832 nccell_release(s->mplane[w], &c);
836 for (
int row = 0; row < r; row++) {
837 for (uint col = 0; col < cols; col++) {
838 ncplane_putchar_yx(s->mplane[w], row, col,
' ');
845
846
848
849
850
851
852
853
854
855
859 ncplane_set_scrolling(s->mplane[w], enable);
863
864
865
866
867
868
869
877
878
879
880
881
882
883
891
892
893
894
895
896
897
898
907
908
909
910
911
912
913
921
922
924
925
926
927
928
932 unsigned int r = 0, c = 0;
933 notcurses_stddim_yx(
ui->nc, &r, &c);
940 ui_log(INFO,
"ui_get_screen_size(lines=%u, cols=%u)", *lines
, *cols);
943
944
945
949 notcurses_render(
ui->nc);
950 ui_log(INFO,
"notcurses_render(ui->nc)");
956 for (
int y = 0; y < ylen; y++) {
957 for (
int x = 0; x < xlen; x++) {
958 nccell c = NCCELL_TRIVIAL_INITIALIZER;
959 ncplane_at_yx_cell(src, src_y + y, src_x + x, &c);
960 ncplane_putc_yx(dst, dst_y + y, dst_x + x, &c);
961 nccell_release(src, &c);
968
969
970
974 notcurses_render(
ui->nc);
975 ui_log(INFO,
"notcurses_render(ui->nc)");
977int ui_prefresh(UiSurface *s, ss_t w,
int pminrow,
int pmincol,
int sminrow,
int smincol,
int smaxrow,
int smaxcol) {
980 if (s->meta[PAD].hidden ==
false)
981 ncplane_move_yx(s->mplane[w], -pminrow, -pmincol);
987 int ylen = smaxrow - sminrow;
988 int xlen = smaxcol - smincol;
990 ui_log(INFO,
"ui_plane_cpy(dst: %s, src: %s, dst_y=%d, dst_x=%d, src_y=%d, src_x=%d, ylen=%d, xlen=%d success)", ss_n[VIEWPORT]
, ss_n[PAD]
, pminrow
, pmincol
, sminrow
, smincol
, smaxrow
, smaxcol);
992 notcurses_render(
ui->nc);
993 ui_log(INFO,
"notcurses_render(ui->nc)");
997
998
999
1000
1001
1002
1003
1004
1008 notcurses_leave_alternate_screen(
ui->nc);
1012
1013
1014
1015
1016
1017
1018
1019
1023 notcurses_enter_alternate_screen(
ui->nc);
1024 notcurses_render(
ui->nc);
1034
1035
1036
1037
1038
1039
1040
1045 ui->cursor_visible =
false;
1046 notcurses_cursor_disable(
ui->nc);
1048 ui->cursor_visible =
true;
1050 notcurses_cursor_yx(
ui->nc, &y, &x);
1051 int rc = notcurses_cursor_enable(
ui->nc, y, x);
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1071 ui->cursor_visible =
false;
1072 notcurses_cursor_disable(
ui->nc);
1075 ncplane_abs_yx(s->mplane[w], &yy, &xx);
1078 ui->cursor_visible =
true;
1079 int rc = notcurses_cursor_enable(
ui->nc, y, x);
1085
1086
1087
1088
1089
1090
1091
1092
1097 ui->cursor_visible =
false;
1098 notcurses_cursor_disable(
ui->nc);
1101 ncplane_cursor_yx(s->mplane[w], &y, &x);
1103 ncplane_abs_yx(s->mplane[w], &yy, &xx);
1106 ui->cursor_visible =
true;
1107 return notcurses_cursor_enable(
ui->nc, y, x) == 0 ? 0 : -1;
1112
1113
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125int ui_bkgd(UiSurface *s, ss_t w,
const UiCell *cell) {
1128 ncplane_set_styles(s->mplane[w], cell->stylemask);
1129 ncplane_set_channels(s->mplane[w], cell->channels);
1130 ncplane_set_base(s->mplane[w],
" ",
1131 cell->stylemask, cell->channels);
1132 s->meta[w].bkgd_cell = *cell;
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1149 ncplane_set_styles(s->mplane[w], cell->stylemask);
1150 ncplane_set_channels(s->mplane[w], cell->channels);
1151 s->meta[w].bkgd_cell = *cell;
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1170 ncplane_set_styles(s->mplane[w], cell->stylemask);
1171 ncplane_set_channels(s->mplane[w], cell->channels);
1172 ncplane_set_base(s->mplane[w],
" ",
1173 cell->stylemask, cell->channels);
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1190 ncplane_set_styles(s->mplane[w], cell->stylemask);
1191 ncplane_set_channels(s->mplane[w], cell->channels);
1192 ncplane_set_base(s->mplane[w],
" ",
1193 cell->stylemask, cell->channels);
1197
1198
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1222 if (!cell || !wstr || !style || !pair)
1225 gc
.u32 = cell->gcluster;
1227 *style = cell->stylemask;
1229 UiChannels channels;
1230 channels.fb = cell->channels;
1232 rgb.r = channels.f_r;
1233 rgb.g = channels.f_g;
1234 rgb.b = channels.f_b;
1237 rgb.r = channels.b_r;
1238 rgb.g = channels.b_g;
1239 rgb.b = channels.b_b;
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1264 const wchar_t *wstr,
1272 unicode_to_utf8_gcluster(*wstr, &gc);
1273 nccell_set_styles(cell, style);
1274 UiChannels *chan = (UiChannels *)&cell->channels;
1280 nccell_load_egc32(sfc->mplane[w], cell, gc
.u32);
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1298 GCluster *gc = (GCluster *)&cell.gcluster;
1299 wchar_t wstr[2] = {ucp[0], L'\0'};
1301 cell.width = wcwidth(wstr[0]);
1303 unicode_to_utf8_gcluster(wstr[0], gc);
1305 UiChannels *chan = (UiChannels *)&cell.channels;
1308 chan->b_a = chan->f_a = 0x40;
1312
1313
1315
1316
1317
1318
1319
1320
1321
1322
1323
1330 if (rgb->r == tmp.r && rgb->g == tmp.g && rgb->b == tmp.b)
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1361 if (ui_pair[i].fg == fg && ui_pair[i].bg == bg)
1370 return (EXIT_FAILURE);
1380
1381
1382
1383
1384
1386 *fg = ui_pair[pair].fg;
1387 *bg = ui_pair[pair].bg;
1391
1392
1393
1394
1395
1396
1397
1398
1399
1405 UiChannels ui_channels = {};
1408 ui_channels.f_a = 0x40;
1409 ui_channels.f_r = ui_color[fg].r;
1410 ui_channels.f_g = ui_color[fg].g;
1411 ui_channels.f_b = ui_color[fg].b;
1412 bg = ui_pair[pair].bg;
1414 ui_channels.b_a = 0x40;
1415 ui_channels.b_r = ui_color[bg].r;
1416 ui_channels.b_g = ui_color[bg].g;
1417 ui_channels.b_b = ui_color[bg].b;
1418 return ui_channels.fb;
1421
1422
1423
1424
1425
1426
1427
1428
1429
1436 if (rgb.r == ui_color[i].r && rgb.g == ui_color[i].g && rgb.b == ui_color[i].b)
1455
1456
1457
1458
1459
1460
1461
1464 sscanf(s,
"#%02hhX%02hhX%02hhX", &rgb.r, &rgb.g, &rgb.b);
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1482 *r = ui_color[color].r;
1483 *g = ui_color[color].g;
1484 *b = ui_color[color].b;
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1521 *fg = ui_pair[pair].fg;
1522 *bg = ui_pair[pair].bg;
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1545
1546
1547
1548
1549
1550
1551
1552
1553
1560 if (color_idx < 16) {
1571
1572
1574
1575
1576
1577
1578
1585
1586
1587
1588
1589
1590
1591
1596 return s->mplane[w];
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618uint ui_mbstr_to_cellstr(UiSurface *sfc, ss_t w, UiCell *cmplx_buf,
const char *str,
const UiCell *cell_base, uint *p,
const uint atmost) {
1624 uint i = 0, len = 0;
1629 ui_get_nccell(sfc, w, cell_base, &wstr[0], &style, &cp);
1631 memset(&mbstate, 0,
sizeof(mbstate));
1632 if (pos && *pos >= atmost - 1)
1634 while (str[i] !=
'\0') {
1636 len = mbrtowc(wstr, s, MB_CUR_MAX, &mbstate);
1645 if (ui_set_nccell(sfc, w, &cc, wstr, style, cp) !=
ERR) {
1646 if (len > 0 && (*pos + len) < atmost)
1647 cmplx_buf[(*pos)++] = cc;
1653 ui_set_nccell(sfc, w, &cc, wstr, style, cp);
1654 cmplx_buf[*pos] = cc;
UiSurface * ui_surface_box(UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x, const char *title)
Create a new UI surface with a border box and optional title.
int ui_surface_resize(UiSurface *s, ss_t w, uint lines, uint cols)
Resize a UiSurface to new dimensions.
UiRuntime * ui_init(const UiConfig *config, SIO *sio)
Initialize the UI runtime with the given configuration and SIO.
void ui_render()
Render the UI by updating panels and refreshing the display.
void ui_getyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the current cursor position within a window of a UI surface.
UiSurface * ui_surface_new(ss_t w, UiSurface *parent, ss_t p, uint lines, uint cols, uint y, uint x)
Create a new UI surface with the specified parameters.
int ui_setscrreg(UiSurface *s, ss_t w, uint top, uint bottom)
Set the scrolling region for a UiSurface.
int ui_plane_cpy(NcPlane *dst, NcPlane *src, int dst_y, int dst_x, int src_y, int src_x, int ylen, int xlen)
int ui_wmove(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
void ui_getmaxyx(UiSurface *s, ss_t w, uint *lines, uint *cols)
Get the maximum dimensions of a UiSurface.
int ui_cursor_enable_yx(UiSurface *s, ss_t w, uint y, uint x, bool visible)
Enable or disable the cursor at a specific position within a UiSurface.
int ui_wscrl(UiSurface *s, ss_t w, int rows)
Scroll the contents of a UiSurface by a specified number of lines.
int ui_idcok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete character capabilities for a UiSurface.
int ui_cursor_move(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
int ui_surface_addwin(UiSurface *s, ss_t w, ss_t p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
int ui_suspend()
Suspend the UI, saving the current program state and ending the window session.
void ui_surface_destroy(UiSurface *s)
Destroy a UiSurface, cleaning up its windows and panels.
int ui_surface_addpad(UiSurface *s, ss_t w, ss_t view_win, uint lines, uint cols, uint y, uint x, bool hidden)
Add a new pad to the specified UiSurface.
void ui_update_panels()
Update the panels in the UI.
int ui_bkgd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
int ui_idlok(UiSurface *s, ss_t w, bool enable)
Enable or disable the use of the insert/delete line capabilities for a UiSurface.
int ui_surface_move(UiSurface *s, ss_t w, uint y, uint x)
Move a UiSurface to a new position on the screen.
int ui_prefresh(UiSurface *s, ss_t w, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
int ui_getmaxy(UiSurface *s, ss_t w)
Get the maximum number of lines (rows) of a UiSurface.
void ui_get_screen_size(uint *lines, uint *cols)
Get the current screen size (number of lines and columns).
int ui_surface_show(UiSurface *s, ss_t w)
Show a UiSurface, making it visible on the screen.
int ui_erase()
Erase the entire screen.
void ui_shutdown()
Shutdown the UI runtime, cleaning up resources and freeing memory.
int ui_curs_set(int visibility)
Set the visibility of the cursor.
int ui_resume()
Resume the UI, restoring the previous program state and updating the display.
int ui_bkgrndset(UiSurface *s, ss_t w, const UiCell *cell)
Set the background for new content to be written to a specific window within a UiSurface.
int ui_top_surface(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
int ui_wclear(UiSurface *s, ss_t w)
Clear the contents of a UiSurface or all surfaces.
void ui_endwin()
End the UI application, cleaning up resources and shutting down the UI runtime.
int ui_cursor_enable(UiSurface *s, ss_t w, bool visible)
Enable or disable the cursor for a UiSurface.
int ui_clear()
Clear the entire screen.
int ui_getmaxx(UiSurface *s, ss_t w)
Get the maximum number of columns of a UiSurface.
int ui_surface_hide(UiSurface *s, ss_t w)
Hide a UiSurface, making it invisible on the screen.
int ui_bkgrnd(UiSurface *s, ss_t w, const UiCell *cell)
Set the background of a specific window within a UiSurface.
int ui_scrollok(UiSurface *s, ss_t w, bool enable)
Enable or disable scrolling for a UiSurface.
void ui_get_caps(UiCaps *caps)
Get the UI backend capabilities.
int ui_bkgdset(UiSurface *s, ss_t w, const UiCell *cell)
Set the background for new content to be written to a specific window within a UiSurface.
int ui_werase(UiSurface *s, ss_t w)
Erase the contents of a UiSurface or all surfaces.
int ui_keypad(UiSurface *s, ss_t w, bool enable)
Enable or disable the keypad for a UiSurface.
int ui_get_pair(uint16_t pair, uint *fg, uint *bg)
Get the foreground and background color indices for a given color pair index.
void ui_abs_yx(UiSurface *s, ss_t w, int *y, int *x)
Get the absolute cursor position within a window of a UI surface.
uint ui_init_color_hex(char *s)
Initialize a color from a hexadecimal string representation.
struct notcurses * ui_notcurses_get_nc()
Get the pointer to the Notcurses context associated with the UI.
int ui_get_nccell(UiSurface *sfc, ss_t w, const UiCell *cell, wchar_t *wstr, UiStyle *style, short *pair)
Get the properties of a cell at the current cursor position in a window of a UI surface.
void ui_plane_get_abs_yx(UiSurface *s, ss_t w, int *absy, int *absx)
uint64_t ui_get_channels_from_pair(uint16_t pair)
Get the combined foreground and background color channels for a given color pair index.
int ui_set_nccell(UiSurface *sfc, ss_t w, UiCell *cell, const wchar_t *wstr, const UiStyle style, short pair)
Set the properties of a cell at the current cursor position in a window of a UI surface.
void ui_cursor_yx(int *y, int *x)
Get the current cursor position within a window of a UI surface.
NcPlane * ui_notcurses_surface_get_plane(const UiSurface *s, ss_t w)
Get the pointer to the NcPlane associated with a specific window in a UI surface.
const wchar_t * border_none
int ui_border_draw(UiSurface *sfc, ss_t w)
const wchar_t * border_double
const wchar_t * border_single
void ui_initialize_sio(SIO *sio)
int ui_border_title(UiSurface *sfc, ss_t w, const char *title)
Draw a box with a title around the specified window.
const wchar_t * border_heavy
const wchar_t * border_rounded
void ui_apply_gamma(RGB *rgb)
Apply gamma correction to RGB color.
void ui_log_write(const UiLogLevel level, const char *file, const char *func, const int line, const char *fmt,...)
int ui_pair_content(uint pair, uint *fg, uint *bg)
Get the foreground and background colors of a specified color pair.
int ui_init_color(uint color, uint r, uint g, uint b)
Initialize a color in the curses color table with specified RGB values.
int ui_init_pair(uint pair, uint fg, uint bg)
Initialize a color pair in the curses color table with specified foreground and background colors.
uint ui_add_pair(uint fg, uint bg)
Add a new color pair to the UI, or retrieve the index of an existing pair.
UiSurface * ui_surface[UI_SFC_MAX]
int ui_color_content(uint color, uint *r, uint *g, uint *b)
RGB ui_hex_to_rgb(char *s)
Convert a hexadecimal color string to an RGB structure.
UiCell ui_cell_from_ucp(const wchar_t *ucp, const uint32_t *fg, const uint32_t *bg)
Convert a Unicode code point to a curses UiCell with specified foreground and background colors.
int ui_color_from_rgb(RGB *rgb)
Convert RGB to curses color index, adding new color if necessary.
int ui_chg_color(uint16_t color_idx, uint32_t *color)
Change the RGB color value for a given color index.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t ssnprintf(char *, size_t, const char *,...)
Custom safe string formatting utility (Variadic version).
int ui_display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
UiBackend ui_get_backend()
Get the UI backend type.
UiBorderStyle border_style