2
3
4
5
6
7
8
9
10
11
12
13
16
17
19#include "include/ui_backend.h"
20#include "ui/ui_ncurses_internal.h"
60int win2_new(
int wlines,
int wcols,
int wbegy,
int wbegx);
64int box_new(
int,
int,
int,
int,
char *);
77void abend(
int,
char *);
103int mb_to_cc(cchar_t *,
char *, attr_t,
int,
int *,
int);
108int xwgetch(WINDOW *, Chyron *,
int);
109cchar_t
mkcc(
int, attr_t,
const char *);
122cchar_t
ls,
rs,
ts,
bs,
tl,
tr,
bl,
br,
lt,
rt,
sp,
ra,
la,
ua,
da,
ran,
chk;
125
126
128 {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}};
130
131
132
134 "black",
"red",
"green",
"yellow",
"blue",
"magenta",
"cyan",
135 "white",
"orange",
"bg",
"abg",
"bblack",
"bred",
"bgreen",
136 "byellow",
"bblue",
"bcyan",
"bmagenta",
"bwhite",
"borange",
""};
222
223
224
225
231
232
233
234
235
236
237
238
239
240
241
242
243
253 strerror_r(errno, tmp_str,
MAXLEN - 1);
256 fprintf(stderr,
"%s\n", tmp_str);
262 strerror_r(errno, tmp_str,
MAXLEN - 1);
265 fprintf(stderr,
"%s\n", tmp_str);
272 strerror_r(errno, tmp_str,
MAXLEN - 1);
275 fprintf(stderr,
"%s\n", tmp_str);
282 abend(-1
, "Terminal color support required");
285 if (!can_change_color()) {
287 fprintf(stderr,
"Terminal cannot change colors\n");
288 fprintf(stderr,
"Check TERM environment variable\n");
289 fprintf(stderr,
"Check terminfo for missing \"ccc\"\n");
294 keypad(stdscr,
true);
295 idlok(stdscr,
false);
296 idcok(stdscr,
false);
311
312
313
314
315
316
317
318
319
392
393
394
396
397
398
399
400
404 extended_pair_content(i, &pfg, &pbg);
405 if (pfg == fg && pbg == bg)
408 if (i >= COLOR_PAIRS) {
412 strerror_r(errno, em2,
MAXLEN);
414 return (EXIT_FAILURE);
416 if (i < COLOR_PAIRS) {
417 rc = init_extended_pair(i, fg, bg);
426
427
428
429
430
431
436 rgb
->r = (rgb
->r * 1000) / 255;
437 rgb
->g = (rgb
->g * 1000) / 255;
438 rgb
->b = (rgb
->b * 1000) / 255;
439 for (i = 0; i <
clr_cnt; i++) {
440 extended_color_content(i, &r, &g, &b);
441 if (rgb
->r == r && rgb
->g == g && rgb
->b == b) {
446 init_extended_color(i, rgb
->r, rgb
->g, rgb
->b);
453
454
455
456
457
458
459
460
467 return ((rgb
->r - 8) / 10) + 231;
469 int r_index = (rgb
->r < 45) ? 0 : (rgb
->r - 60) / 40 + 1;
470 int g_index = (rgb
->g < 45) ? 0 : (rgb
->g - 60) / 40 + 1;
471 int b_index = (rgb
->b < 45) ? 0 : (rgb
->b - 60) / 40 + 1;
472 return 16 + (36 * r_index) + (6 * g_index) + b_index;
476
477
478
479
480
481
482
485
486
492 rgb
.r = rgb
.g = rgb
.b = 0;
497 }
else if (idx >= 16 && idx <= 231) {
499 rgb
.r = (idx / 36) % 6 * 51;
500 rgb
.g = (idx / 6) % 6 * 51;
501 rgb
.b = (idx % 6) * 51;
502 }
else if (idx >= 232 && idx <= 255) {
503 int gray = (idx - 232) * 11;
504 rgb
.r = rgb
.g = rgb
.b = gray;
510
511
512
513
514
515
516
517
535
536
537
538
539
540
541
542
543
544
545
629
630
631
632
633
634
635
636
637
647 rgb
.r = (rgb
.r * 1000) / 255;
648 rgb
.g = (rgb
.g * 1000) / 255;
649 rgb
.b = (rgb
.b * 1000) / 255;
650 init_extended_color(idx, rgb
.r, rgb
.g, rgb
.b);
653
654
655
658 sscanf(s,
"#%02x%02x%02x", &rgb
.r, &rgb
.g, &rgb
.b);
662
663
664
665
666
667
668
669
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705int mb_to_cc(cchar_t *cmplx_buf,
char *str, attr_t attr,
int cpx,
int *pos,
710 wchar_t wstr[2] = {L'\0', L'\0'};
712 memset(&mbstate, 0,
sizeof(mbstate));
714 if (*pos >= maxlen - 1)
716 while (str[i] !=
'\0') {
718 len = mbrtowc(wstr, s, MB_CUR_MAX, &mbstate);
725 if (*pos >= maxlen - 1)
727 if (setcchar(&cc, wstr, attr, cpx,
nullptr) != ERR) {
728 if (len > 0 && (*pos + len) <
MAXLEN - 1)
729 cmplx_buf[(*pos)++] = cc;
735 setcchar(&cc, wstr, attr, cpx,
nullptr);
736 cmplx_buf[*pos] = cc;
740
741
742
743
744
745
746
747
748cchar_t
mkcc(
int cp, attr_t attr,
const char *s) {
750 memset(&mbstate, 0,
sizeof(mbstate));
754 wchar_t wstr[2] = {L'\0', L'\0'};
757 n = mbrtowc(wstr, s, MB_CUR_MAX, &mbstate);
768 setcchar(&cc, wstr, attr, cp,
nullptr);
772
773
774
775
776
777
778
779
780
781
782
783
784
786str_to_cc(cchar_t *cmplx_buf,
const char *s, attr_t attr,
int cp, size_t maxlen) {
790 wchar_t wstr[2] = {L'\0', L'\0'};
792 memset(&mbstate, 0,
sizeof(mbstate));
793 while (s[i] !=
'\0') {
794 if (s[i] ==
'\033') {
799 len = mbrtowc(wstr, &s[i], MB_CUR_MAX, &mbstate);
805 if (setcchar(&cc, wstr, attr, cp,
nullptr) != ERR) {
807 if ((j + len) < (
int)maxlen + 1)
814 setcchar(&cc, wstr, WA_NORMAL, cp,
nullptr);
819
820
821
822
823
824
825
826
830 wchar_t wstr[2] = {L'\0', L'\0'};
832 memset(&mbstate, 0,
sizeof(mbstate));
833 size_t len = strlen(s);
836 mbrtowc(wstr, s, MB_CUR_MAX, &mbstate);
837 setcchar(&cc, wstr, attr, cp,
nullptr);
839 s += mbrlen(s, MB_CUR_MAX, &mbstate);
843 setcchar(&cc, wstr, attr, cp,
nullptr);
848
849
850
851
852
853
854
855
856
861 wadd_wchstr(win, cmplx_buf);
862 wmove(win, line, col);
866
867
868
869
870
874 buffer[0] = (uint8_t)cp;
876 }
else if (cp <= 0x7FF) {
878 buffer[0] = (uint8_t)(0xC0 | ((cp >> 6) & 0x1F));
879 buffer[1] = (uint8_t)(0x80 | (cp & 0x3F));
881 }
else if (cp <= 0xFFFF) {
883 buffer[0] = (uint8_t)(0xE0 | ((cp >> 12) & 0x0F));
884 buffer[1] = (uint8_t)(0x80 | ((cp >> 6) & 0x3F));
885 buffer[2] = (uint8_t)(0x80 | (cp & 0x3F));
887 }
else if (cp <= 0x10FFFF) {
889 buffer[0] = (uint8_t)(0xF0 | ((cp >> 18) & 0x07));
890 buffer[1] = (uint8_t)(0x80 | ((cp >> 12) & 0x3F));
891 buffer[2] = (uint8_t)(0x80 | ((cp >> 6) & 0x3F));
892 buffer[3] = (uint8_t)(0x80 | (cp & 0x3F));
898
899
900
901
902
903
904
905
906
907
915
916
917
918
919
920
921
922
923
924
925int box_hsplit_new(
int wlines,
int split_win_lines,
int wcols,
int wbegy,
int wbegx,
char *wtitle) {
927 Perror("Maximum number of windows (%d) exceeded");
930 wlines =
min(wlines, LINES - 2);
931 wcols =
min(wcols, COLS - 2);
943
944
945
946
947
948
949
950
951
952int win2_box_new(
int wlines,
int wcols,
int wbegy,
int wbegx,
char *wtitle) {
959
960
961
962
963
964
965
966
967int box_new(
int wlines,
int wcols,
int wbegy,
int wbegx,
char *wtitle) {
973
974
975
976
977
978
979
980
981int bare_box_new(
int wlines,
int wcols,
int wbegy,
int wbegx,
char *wtitle) {
984 Perror("Maximum number of windows (%d) exceeded");
988 getmaxyx(stdscr, maxy, maxx);
992 wlines =
min(wlines, maxy - 2);
993 wcols =
min(wcols, maxx - 2);
997 ui_rect_set(&ui_rect, wbegy, wbegx, wlines + 2, wcols + 2);
998 ui_box[win_ptr] = ui_surface_new(ui_runtime, NULL, ui_rect);
999 win_box[win_ptr] = ui_box[win_ptr]->win;
1000 panel_box[win_ptr] = ui_box[win_ptr]->pan;
1002 UiStyle *ui_style = ui_style_from_cch(&CC_BOX);
1003 ui_bkgrnd(ui_box[win_ptr], ui_style,
" ");
1004 ui_bkgrnd_set(ui_box[win_ptr], ui_style,
" ");
1005 wborder_set(win_box[win_ptr], &ls, &rs, &ts, &bs, &tl, &tr, &bl, &br);
1006 border_title(win_box[win_ptr], wtitle);
1008 ui_rect_set(&ui_rect, 1, 1, wlines, wcols);
1009 ui_win[win_ptr] = ui_surface_new(ui_runtime, ui_box[win_ptr], ui_rect);
1010 ui_style = ui_style_from_cch(&CC_NT);
1011 ui_bkgrnd(ui_win[win_ptr], ui_style,
" ");
1012 ui_bkgrnd_set(ui_win[win_ptr], ui_style,
" ");
1013 win_win[win_ptr] = ui_win[win_ptr]->win;
1014 panel_win[win_ptr] = ui_win[win_ptr]->pan;
1015 mvwaddstr(win_win[win_ptr], 10, 1,
"Hello!");
1020 Perror("win_box[win_ptr] = newwin() failed");
1032
1033
1034
1035
1036
1041 Perror("win_win[win_ptr] = derwin() failed");
1056
1059
1060
1061
1062
1063
1064
1065
1066int win2_new(
int wlines,
int wcols,
int wbegy,
int wbegx) {
1071 Perror("win_win2[win_ptr] = derwin() failed");
1082
1083
1084
1085
1086
1087
1088
1089
1096 mvwaddstr(
win_box[i], 5, 2, tmp_str);
1104 mvwaddstr(
win_win[i], 6, 2, tmp_str);
1112 mvwaddstr(
win_win2[i], 0, 0, tmp_str);
1119
1120
1121
1122
1123
1124
1125
1126
1127
1135 if (title !=
nullptr && *title !=
'\0') {
1144 int s = strlen(title);
1162
1163
1164
1165
1166
1167
1173
1174
1175
1176
1177
1178
1218
1219
1220
1221
1222
1223
1224
1227 for (
int i = 0; i <=
win_ptr; i++) {
1237 int maxy = getmaxy(box);
1238 int maxx = getmaxx(box);
1241 mvwadd_wchnstr(box, y, x++, &
tl, 1);
1242 for (x = 1; x < maxx - 1; x++)
1243 mvwadd_wchnstr(box, y, x, &
ts, 1);
1244 mvwadd_wchnstr(box, y, maxx - 1, &
tr, 1);
1246 for (y = 1; y < maxy - 1; y++) {
1247 mvwadd_wchnstr(box, y, 0, &
ls, 1);
1248 mvwadd_wchnstr(box, y, maxx - 1, &
rs, 1);
1251 mvwadd_wchnstr(box, y, 0, &
bl, 1);
1252 for (x = 1; x < maxx - 1; x++)
1253 mvwadd_wchnstr(box, y, x, &
bs, 1);
1254 mvwadd_wchnstr(box, y, maxx - 1, &
br, 1);
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1270 int maxx = getmaxx(box);
1271 mvwaddnwstr(box, y, 0, &
bw_lt, 1);
1272 for (
int x = 1; x < maxx - 1; x++)
1273 waddnwstr(box, &
bw_ho, 1);
1274 mvwaddnwstr(box, y, maxx - 1, &
bw_rt, 1);
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1291 int maxx = getmaxx(box);
1293 int y = separator_line;
1300 mvwadd_wchnstr(box, y, x++, &
lt, 1);
1301 mvwadd_wchnstr(box, y, x++, &
ts, 1);
1302 mvwadd_wchnstr(box, y, x++, &
rt, 1);
1303 mvwadd_wchnstr(box, y, x++, &
sp, 1);
1305 cchar_t text_cc[
MAXLEN] = {0};
1307 mvwadd_wchnstr(box, y, x, text_cc, l);
1309 mvwadd_wchnstr(box, y, x++, &
sp, 1);
1310 mvwadd_wchnstr(box, y, x++, &
lt, 1);
1312 while (x < maxx - 1)
1313 mvwadd_wchnstr(box, y, x++, &
ts, 1);
1314 mvwadd_wchnstr(box, y, x++, &
rt, 1);
1318
1319
1320
1321
1322
1323
1324
1325
1326
1329 int maxx = getmaxx(box);
1333 mvwadd_wchnstr(box, y, x++, &
tl, 1);
1334 mvwadd_wchnstr(box, y, x++, &
rt, 1);
1335 mvwadd_wchnstr(box, y, x++, &
sp, 1);
1336 cchar_t title_cc[
MAXLEN] = {0};
1338 l =
min(l, maxx - 7);
1339 mvwadd_wchnstr(box, y, x, title_cc, l);
1341 mvwadd_wchnstr(box, y, x++, &
sp, 1);
1342 mvwadd_wchnstr(box, y, x++, &
lt, 1);
1343 while (x < maxx - 1)
1344 mvwadd_wchnstr(box, y, x++, &
ts, 1);
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1369
1370
1373
1374
1375
1379 fprintf(stderr,
"\n\n%s\n\n", msg);
1382 if (LINES < 4 || COLS < 42)
1384 int wlines = 3, wcols = 40;
1386 int wbegx = COLS - wcols - 2;
1387 WINDOW *win = subwin(stdscr, wlines, wcols, wbegy, wbegx);
1390 wbkgrndset(win, &
CC_BOX);
1393 mvwaddstr(win, 0, 1, msg);
1399
1400
1401
1402
1403
1404
1405
1406int answer_yn(
char *msg0,
char *msg1,
char *msg2,
char *msg3) {
1408 int line, pos, msg_l, msg0_l, msg1_l, msg2_l, msg3_l;
1412 fprintf(stderr,
"\n\n%s\n%s\n%s\n%s\n\n", msg0, msg1, msg2, msg3);
1426 msg_l =
max(msg0_l, msg1_l);
1427 msg_l =
max(msg_l, msg2_l);
1428 msg_l =
max(msg_l, msg3_l);
1429 msg_l =
max(msg_l, chyron
->l);
1430 msg_l =
min(msg_l, COLS - 4);
1432 pos = ((COLS - msg_l) - 4) / 2;
1433 line = (LINES - 6) / 2;
1437 msg_l + 2
, line
, pos
, title
);
1442 mvwaddstr(error_win, 0, 1, msg0);
1443 mvwaddstr(error_win, 1, 1, msg1);
1444 mvwaddstr(error_win, 2, 1, msg2);
1445 mvwaddstr(error_win, 3, 1, msg3);
1460
1461
1462
1463
1464
1465
1466
1469 int line, pos, msg_l, msg0_l, msg1_l, msg2_l, msg3_l;
1473 fprintf(stderr,
"\n\n%s\n", msg0);
1474 fprintf(stderr,
"%s\n", msg1);
1475 fprintf(stderr,
"%s\n", msg2);
1476 fprintf(stderr,
"%s\n\n", msg3);
1490 msg_l =
max(msg0_l, msg1_l);
1491 msg_l =
max(msg_l, msg2_l);
1492 msg_l =
max(msg_l, msg3_l);
1493 msg_l =
max(msg_l, chyron
->l);
1494 msg_l =
min(msg_l, COLS - 4);
1496 pos = ((COLS - msg_l) - 4) / 2;
1497 line = (LINES - 6) / 2;
1501 msg_l + 2
, line
, pos
, title
);
1506 mvwaddstr(error_win, 0, 1, msg0);
1507 mvwaddstr(error_win, 1, 1, msg1);
1508 mvwaddstr(error_win, 2, 1, msg2);
1509 mvwaddstr(error_win, 3, 1, msg3);
1522
1523
1524
1525
1532 bool f_xwgetch =
true;
1533 if (emsg_str[0] ==
'␛' && emsg_str[1] ==
'w') {
1539 fprintf(stderr,
"\n%s\n", emsg);
1548 pos = (COLS - len - 4) / 2;
1549 line = (LINES - 4) / 2;
1553 4
, line
, line
, pos
, title
);
1558 mvwaddstr(error_win, 0, 1, emsg);
1572
1573
1574
1583
1584
1585
1586
1587
1590 char wm1[] =
"Seconds remaining:";
1596 fprintf(stderr,
"\n%s\n", title);
1597 fprintf(stderr,
"%s\n", wm1);
1600 len =
max(strlen(title), strlen(wm1));
1601 len =
max(len, chyron
->l);
1603 col = (COLS - len - 4) / 2;
1604 line = (LINES - 4) / 2;
1607 line
, line
, col
, title
);
1611 mvwaddstr(wait_win, 0, 1, wm1);
1613 wmove(wait_win, 1, chyron
->l);
1617
1618
1619
1620
1629
1630
1631
1632
1633
1634
1635
1639 mvwaddstr(wait_win, 0, 21, time_str);
1641 wmove(wait_win, 1, chyron
->l);
1646
1647
1648
1649
1650
1654 WINDOW *action_disposition_win;
1657 fprintf(stderr,
"\n%s\n", title);
1658 fprintf(stderr,
"%s\n", action_str);
1664 len =
max(strlen(title), strlen(action_str));
1665 col = (COLS - len - 4) / 2;
1666 line = (LINES - 4) / 2;
1669 line
, line
, col
, title
);
1673 mvwaddstr(action_disposition_win, 0, 1, action_str);
1675 wmove(action_disposition_win, 1, chyron
->l);
1682
1683
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1702 Chyron *chyron = (Chyron *)calloc(1,
sizeof(Chyron));
1708 chyron
->key[i] = (ChyronKey *)calloc(1,
sizeof(ChyronKey));
1709 if (!chyron
->key[i]) {
1710 abend(-1
, "calloc chyron->key[i] failed");
1717
1718
1719
1720
1721
1728 if (chyron
->key[i]) {
1729 free(chyron
->key[i]);
1730 chyron
->key[i] =
nullptr;
1738
1739
1740
1741
1742
1750
1751
1752
1753
1754
1755
1756
1757
1758
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1793
1794
1795
1796
1797
1802
1803
1804
1805
1806
1811
1812
1813
1814
1815
1821
1822
1823
1824
1825
1830
1831
1832
1833
1839
1840
1841
1842
1843
1844
1845
1846
1847
1872 chyron
->l = end_pos;
1879 chyron
->l = end_pos;
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1893 wmove(win, line, 0);
1895 wmove(win, line, 0);
1897 wmove(win, line, col);
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1934
1935
1936
1937
1938
1939
1940
1945 getmaxyx(w, maxy, maxx);
1952 if (*s ==
'\0' || *s ==
'\n')
1958 l = strlen(tmp_str);
1959 mvwaddstr(w, y, x, tmp_str);
1962
1963
1964
1965
1981
1982
1983
1984
1988 for (i = 0, col = 0; i < 16; i++, col++) {
1990 fprintf(stderr,
" ");
1994 fprintf(stderr,
"\n");
1996 fprintf(stderr,
" ");
1999 fprintf(stderr,
"\n");
2002
2003
2004
2005
2007 fprintf(stderr,
"ERROR: %s code: %d\n", s, ec);
2008 fprintf(stderr,
"Press a key to continue");
2010 fprintf(stderr,
"\n");
2014
2015
2016
2017
2022 fprintf(stderr,
"\n\nABEND: %s (code: %d)\n", s, ec);
2026
2027
2028
2029
2030
2031
2032
2035 Chyron *wait_chyron;
2037 int remaining = timeout;
2040 waitpid(pid, &status, WNOHANG);
2041 if (WIFEXITED(status) || WIFSIGNALED(status)) {
2043 waitpid(pid, &status, 0);
2051 while (remaining > 0 &&
cmd_key != KEY_F(9)) {
2056 remaining = timeout;
2060 waitpid(pid, &status, WNOHANG);
2061 if (WIFEXITED(status) || WIFSIGNALED(status)) {
2067 waitpid(pid, &status, 0);
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2097 mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON4_PRESSED | BUTTON5_PRESSED,
2103 struct termios raw_tioctl;
2109 halfdelay(
min(255,
max(0, n * 10)));
2110 tcflush(2, TCIFLUSH);
2118 if (c ==
'q' || c ==
'Q' || c == KEY_F(9))
2121 if (n > 0 && c == ERR) {
2127 if (c == KEY_MOUSE) {
2128 if (getmouse(&event) != OK) {
2132 if (event.bstate & BUTTON4_PRESSED) {
2134 }
else if (event.bstate & BUTTON5_PRESSED) {
2137 if (event.bstate & BUTTON1_CLICKED || event.bstate & BUTTON1_DOUBLE_CLICKED) {
2138 if (wenclose(win, event.y, event.x)) {
2139 wmouse_trafo(win, &event.y, &event.x,
false);
2142 if (chyron && event.y == getmaxy(win) - 1) {
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180int dxwgetch(WINDOW *win_0, WINDOW *win_1, WINDOW *win_2, WINDOW *win_3, WINDOW *win_c, Chyron *chyron,
int n) {
2183 mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON4_PRESSED | BUTTON5_PRESSED,
2189 struct termios raw_tioctl;
2195 halfdelay(
min(255,
max(0, n * 10)));
2196 tcflush(2, TCIFLUSH);
2204 if (c ==
'q' || c ==
'Q' || c == KEY_F(9))
2207 if (n > 0 && c == ERR) {
2213 if (c == KEY_MOUSE) {
2214 if (getmouse(&event) != OK) {
2218 if (event.bstate & BUTTON4_PRESSED) {
2220 }
else if (event.bstate & BUTTON5_PRESSED) {
2223 if (event.bstate & BUTTON1_CLICKED || event.bstate & BUTTON1_DOUBLE_CLICKED) {
2229 if (win_1 !=
nullptr && wenclose(win_1, event.y, event.x) && wmouse_trafo(win_1, &event.y, &event.x,
false))
2231 else if (win_2 !=
nullptr && wenclose(win_2, event.y, event.x) && wmouse_trafo(win_2, &event.y, &event.x,
false))
2233 else if (win_3 !=
nullptr && wenclose(win_3, event.y, event.x) && wmouse_trafo(win_3, &event.y, &event.x,
false))
2251
2252
2253
2254
2255
2256
2257
2260 mousemask(0,
nullptr);
2264 struct termios raw_tioctl;
2270 halfdelay(
min(255,
max(0, n * 10)));
2273 if (n > 0 && c == ERR) {
volatile sig_atomic_t sig_received
bool handle_signal(sig_atomic_t)
PANEL * panel_win2[MAXWIN]
WINDOW * win_win2[MAXWIN]
struct termios shell_tioctl curses_tioctl
int border_draw(WINDOW *)
#define CHYRON_KEY_MAXLEN
PANEL * panel_win[MAXWIN]
#define min(x, y)
min macro evaluates two expressions, returning least result
PANEL * panel_box[MAXWIN]
char const colors_text[][10]
Color names for .minitrc overrides.
#define max(a, b)
max macro evaluates two expressions, returning greatest result.
UiSurface * ui_box[MAXWIN]
UiSurface * ui_win2[MAXWIN]
UiSurface * ui_win[MAXWIN]
bool open_curses(SIO *)
Initialize NCurses and color settings.
int border_title(WINDOW *, char *)
Draw a box with a title around the specified window.
int dxwgetch(WINDOW *, WINDOW *, WINDOW *, WINDOW *, WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
void restore_wins()
Restore all windows after a screen resize.
void win_del()
Delete the current window and its associated box window.
void check_panels(int)
Check and display the panels for a given window index.
int border_hsplit_text(WINDOW *, char *, int)
Draw a box with a separator line and text around the specified window.
int bare_box_new(int, int, int, int, char *)
Create a new window with optional box and title.
int win_new(int, int)
Create a new window with specified dimensions and position.
int border_hsplit(WINDOW *, int)
Draw a box with a separator line around the specified window.
void win_init_attrs()
Initialize window attributes.
void mvwaddstr_fill(WINDOW *, int, int, char *, int)
For lines shorter than their display area, fill the rest with spaces.
int box_new(int, int, int, int, char *)
Create a new window with optional box and title.
int box_hsplit_new(int, int, int, int, int, char *)
Create a new window with optional box and title, and a second window inside it, split horizontally.
int win2_new(int, int, int, int)
Create a new subwindow (win2) with specified dimensions and position.
int vgetch(WINDOW *, int)
Wrapper for wgetch that handles signals and mouse events, and accepts a single character answer.
void win_resize(int, int, char *)
Resize the current window and its box, and update the title.
void destroy_curses()
Gracefully shut down NCurses and restore terminal settings.
void win_redraw(WINDOW *)
Redraw the specified window.
int win2_box_new(int, int, int, int, char *)
Create a new window with optional box and title, and a second window inside it.
void initialize_local_colors(SIO *)
Initialize local color variables and color pairs based on SIO settings.
void display_cmplx_str(WINDOW *, cchar_t *, int, int)
Display a complex character string on a window.
RGB xterm256_idx_to_rgb(int)
Convert XTerm 256 color index to RGB.
size_t str_to_cc(cchar_t *, const char *, attr_t, int, size_t)
Convert a multibyte string to an array of cchar_t complex characters.
int clr_name_to_idx(char *)
Get color index from color name.
void list_colors()
list colors to stderr
int rgb_to_curses_clr(RGB *)
Get color index for RGB color.
size_t mk_cmplx_str(cchar_t *, char *, attr_t, int)
Convert a multibyte string to an array of cchar_t complex characters.
void init_hex_clr(int, char *)
Initialize extended ncurses color from HTML style hex string.
bool init_clr_palette(SIO *)
Initialize color palette based on SIO settings.
RGB hex_clr_str_to_rgb(char *)
Convert six-digit HTML style hex color code to RGB struct.
void apply_gamma(RGB *)
Apply gamma correction to RGB color.
int rgb_to_xterm256_idx(RGB *)
Convert RGB color to XTerm 256 color index.
cchar_t mkcc(int, attr_t, const char *)
Create a cchar_t with the specified color pair index.
int get_clr_pair(int, int)
Get color pair index for foreground and background colors.
WINDOW * message_win(char *)
Display a message in a window or print to stderr if curses is not available.
bool wait_destroy(Chyron *)
Destroy the waiting message window and chyron.
bool waitpid_with_timeout(pid_t, int)
Wait for a process to finish with a timeout and optional user cancellation.
bool action_disposition(char *eitle, char *action_str)
Display a simple action disposition message window or print to stderr.
int nf_error(int, char *)
Display error message and wait for key press.
int answer_yn(char *, char *, char *, char *)
Accept a single letter answer.
int wait_continue(WINDOW *, Chyron *, int)
Update the waiting message with remaining time and check for user input.
WINDOW * wait_mk_win(Chyron *, char *)
Display a popup waiting message.
int Perror(char *)
Display a simple error message window or print to stderr.
void abend(int, char *)
Abnormal program termination.
Chyron * wait_mk_chyron()
Create a Chyron struct for the waiting message.
int display_error(char *, char *, char *, char *)
Display an error message window or print to stderr.
bool is_set_chyron_key(Chyron *, int)
Check if function key label is set.
void set_chyron_key(Chyron *, int, char *, int)
Set chyron key with default color pair (cp_nt_rev).
void display_chyron(WINDOW *, Chyron *, int, int)
Display chyron on window.
Chyron * destroy_chyron(Chyron *chyron)
Destroy Chyron structure.
void activate_chyron_key(Chyron *, int)
Activate chyron key.
int get_chyron_key(Chyron *, int)
Get keycode from chyron.
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key with color pair (cp).
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
void activate_all_chyron_keys(Chyron *)
Deactivate chyron key.
void unset_chyron_key(Chyron *, int)
Unset chyron key.
int mb_to_cc(cchar_t *, char *, attr_t, int, int *, int)
Convert multibyte string to complex character array.
void deactivate_all_chyron_keys(Chyron *)
Deactivate all chyron keys.
void deactivate_chyron_key(Chyron *, int)
Deactivate chyron key.
Chyron * new_chyron()
Create and initialize Chyron structure.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
bool str_to_lower(char *)
Converts a string to lowercase.
void ui_rect_set(UiRect *, int, int, int, int)
Set the properties of a UiRect structure.
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
size_t ssnprintf(char *, size_t, const char *,...)
ssnprintf was designed to be a safer alternative to snprintf.
int wccp_to_str(wchar_t, uint8_t *)
Converts a Unicode code point to a UTF-8 encoded string.
size_t strnz__cat(char *, const char *, size_t)
safer alternative to strncat
char di_getch()
get single character from terminal in raw mode
bool restore_curses_tioctl()
restore_curses_tioctl() - restore curses terminal settings
bool mk_raw_tioctl(struct termios *)
mk_raw_tioctl() - set terminal to raw mode
bool restore_shell_tioctl()
restore_shell_tioctl() - restore shell terminal settings
void sig_dfl_mode()
Set signal handlers to default behavior.
void ui_get_screen_size(UiRuntime *ui, int *rows, int *cols)
Get the current screen size.
char text[CHYRON_KEY_MAXLEN]
cchar_t cmplx_buf[MAXLEN]
ChyronKey * key[CHYRON_KEYS]
char nt_hl_rev_bg[COLOR_LEN]
char nt_rev_bg[COLOR_LEN]
char nt_rev_fg[COLOR_LEN]
char brackets_fg[COLOR_LEN]
char fill_char_fg[COLOR_LEN]
char brackets_bg[COLOR_LEN]
char fill_char_bg[COLOR_LEN]
char nt_hl_rev_fg[COLOR_LEN]