From 1eaa24be68b432fd54f587c6ef365562abaac99f Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Sun, 2 Apr 2023 18:10:10 -0400 Subject: [PATCH] restore `TB_DEFAULT==0` in all modes (#51) this removes `TB_TRUECOLOR_DEFAULT` added in 846bba4b and goes back to `TB_DEFAULT==0` in all modes. instead, hi-bit macros `TB_256_BLACK` and `TB_TRUECOLOR_BLACK` are added which provide a way to emit black in those modes. turns out there were some subtle bugs associated with `TB_DEFAULT!=0` (in addition to the bug identified in #51). the bugs were fixable but required uglying up some code. zero as default in all modes is more intuitive and easier to reason about (e.g., `memset(..., 0, ...)`). --- termbox2.h | 105 +++++++++++++++------------- tests/test_color_8bit/expected.ansi | 16 ++--- tests/test_color_8bit/test.php | 18 +++-- tests/test_color_true/expected.ansi | 4 +- tests/test_color_true/test.php | 13 ++-- 5 files changed, 90 insertions(+), 66 deletions(-) diff --git a/termbox2.h b/termbox2.h index 2606712..5db3f9e 100644 --- a/termbox2.h +++ b/termbox2.h @@ -196,6 +196,7 @@ extern "C" { #define TB_HARDCAP_EXIT_MOUSE "\x1b[?1006l\x1b[?1015l\x1b[?1002l\x1b[?1000l" /* Colors (numeric) and attributes (bitwise) (tb_cell.fg, tb_cell.bg) */ +#define TB_DEFAULT 0x0000 #define TB_BLACK 0x0001 #define TB_RED 0x0002 #define TB_GREEN 0x0003 @@ -209,14 +210,14 @@ extern "C" { #define TB_REVERSE 0x0400 #define TB_ITALIC 0x0800 #define TB_BLINK 0x1000 -#define TB_DEFAULT 0x2000 +#define TB_256_BLACK 0x2000 #ifdef TB_OPT_TRUECOLOR #define TB_TRUECOLOR_BOLD 0x01000000 #define TB_TRUECOLOR_UNDERLINE 0x02000000 #define TB_TRUECOLOR_REVERSE 0x04000000 #define TB_TRUECOLOR_ITALIC 0x08000000 #define TB_TRUECOLOR_BLINK 0x10000000 -#define TB_TRUECOLOR_DEFAULT 0x20000000 +#define TB_TRUECOLOR_BLACK 0x20000000 #endif /* Event types (tb_event.type) */ @@ -461,7 +462,8 @@ int tb_set_input_mode(int mode); * Colors (including TB_DEFAULT) may be bitwise OR'd with attributes: * TB_BOLD, TB_UNDERLINE, TB_REVERSE, TB_ITALIC, TB_BLINK * - * The value 0 is interpreted as TB_DEFAULT. + * As in all modes, the value 0 is interpreted as TB_DEFAULT for + * convenience. * * Some notes: TB_REVERSE can be applied as either fg or bg attributes for * the same effect. TB_BOLD, TB_UNDERLINE, TB_ITALIC, TB_BLINK apply as fg @@ -470,49 +472,56 @@ int tb_set_input_mode(int mode); * Example usage: * tb_set_cell(x, y, '@', TB_BLACK | TB_BOLD, TB_RED); * - * 2. TB_OUTPUT_256 => [0..255] + * 2. TB_OUTPUT_256 => [0..255] + TB_256_BLACK * - * In this mode you get 256 distinct colors: - * 0x00 - 0x07: the 8 colors as in TB_OUTPUT_NORMAL - * 0x08 - 0x0f: bright versions of the above - * 0x10 - 0xe7: 216 different colors - * 0xe8 - 0xff: 24 different shades of grey + * In this mode you get 256 distinct colors (plus default): + * 0x00 (1): TB_DEFAULT + * TB_256_BLACK (1): TB_BLACK in TB_OUTPUT_NORMAL + * 0x01..0x07 (7): the next 7 colors as in TB_OUTPUT_NORMAL + * 0x08..0x0f (8): bright versions of the above + * 0x10..0xe7 (216): 216 different colors + * 0xe8..0xff (24): 24 different shades of gray * * Attributes may be bitwise OR'd as in TB_OUTPUT_NORMAL. * - * In this mode 0x00 represents TB_BLACK, so TB_DEFAULT must be used for - * default colors. + * Note TB_256_BLACK must be used for black, as 0x00 represents default. * * 3. TB_OUTPUT_216 => [0..216] * - * This mode supports the 3rd range of TB_OUTPUT_256 only, but you don't - * need to provide an offset. - * - * The value 0 is interpreted as TB_DEFAULT. + * This mode supports the 216-color range of TB_OUTPUT_256 only, but you + * don't need to provide an offset: + * 0x00 (1): TB_DEFAULT + * 0x01..0xd8 (216): 216 different colors * * 4. TB_OUTPUT_GRAYSCALE => [0..24] * - * This mode supports the 4th range of TB_OUTPUT_256 only, but you don't - * need to provide an offset. - * - * The value 0 is interpreted as TB_DEFAULT. + * This mode supports the 24-color range of TB_OUTPUT_256 only, but you + * don't need to provide an offset: + * 0x00 (1): TB_DEFAULT + * 0x01..0x18 (24): 24 different shades of gray * - * 5. TB_OUTPUT_TRUECOLOR => [0x000000..0xffffff] + * 5. TB_OUTPUT_TRUECOLOR => [0x000000..0xffffff] + TB_TRUECOLOR_BLACK * * This mode provides 24-bit color on supported terminals. The format is - * 0xRRGGBB. Colors may be bitwise OR'd with `TB_TRUECOLOR_*` attributes. + * 0xRRGGBB. Colors may be bitwise OR'd with TB_TRUECOLOR_* attributes. * - * In this mode 0x000000 represents black, so TB_TRUECOLOR_DEFAULT must be - * used for default colors. + * Note TB_TRUECOLOR_BLACK must be used for black, as 0x000000 represents + * default. * * If mode is TB_OUTPUT_CURRENT, the function returns the current output mode. * * The default output mode is TB_OUTPUT_NORMAL. * * To use the terminal default color (i.e., to not send an escape code), pass - * TB_DEFAULT (or TB_TRUECOLOR_DEFAULT in TB_OUTPUT_TRUECOLOR mode). For - * convenience, the value 0 is interpreted as TB_DEFAULT in TB_OUTPUT_NORMAL, - * TB_OUTPUT_216, and TB_OUTPUT_GRAYSCALE. + * TB_DEFAULT. For convenience, the value 0 is interpreted as TB_DEFAULT in + * all modes. + * + * Note, attributes persist after changing the output mode. This means if you, + * for example, start in TB_OUTPUT_NORMAL with some cells colored TB_CYAN (7) + * and then switch to TB_OUTPUT_GRAYSCALE, those cells will now render as a + * shade of gray. As such, it is recommended to avoid switching output modes + * at runtime unless your program can sensibly re-assign all attributes of all + * cells in the new output mode. * * Note, not all terminals support all output modes, especially beyond * TB_OUTPUT_NORMAL. There is also no very reliable way to determine color @@ -1389,8 +1398,8 @@ static int extract_esc_mouse(struct tb_event *event); static int resize_cellbufs(void); static void handle_resize(int sig); static int send_attr(uintattr_t fg, uintattr_t bg); -static int send_sgr(uintattr_t fg, uintattr_t bg, uintattr_t fg_is_default, - uintattr_t bg_is_default); +static int send_sgr(uintattr_t fg, uintattr_t bg, int fg_is_default, + int bg_is_default); static int send_cursor_if(int x, int y); static int send_char(int x, int y, uint32_t ch); static int send_cluster(int x, int y, uint32_t *ch, size_t nch); @@ -2846,6 +2855,8 @@ static int send_attr(uintattr_t fg, uintattr_t bg) { case TB_OUTPUT_256: cfg = fg & 0xff; cbg = bg & 0xff; + if (fg & TB_256_BLACK) cfg = 0; + if (bg & TB_256_BLACK) cbg = 0; break; case TB_OUTPUT_216: @@ -2874,12 +2885,13 @@ static int send_attr(uintattr_t fg, uintattr_t bg) { case TB_OUTPUT_TRUECOLOR: cfg = fg & 0xffffff; cbg = bg & 0xffffff; + if (fg & TB_TRUECOLOR_BLACK) cfg = 0; + if (bg & TB_TRUECOLOR_BLACK) cbg = 0; break; #endif } - uintattr_t attr_bold, attr_blink, attr_italic, attr_underline, attr_reverse, - attr_default; + uintattr_t attr_bold, attr_blink, attr_italic, attr_underline, attr_reverse; #ifdef TB_OPT_TRUECOLOR if (global.output_mode == TB_OUTPUT_TRUECOLOR) { attr_bold = TB_TRUECOLOR_BOLD; @@ -2887,7 +2899,6 @@ static int send_attr(uintattr_t fg, uintattr_t bg) { attr_italic = TB_TRUECOLOR_ITALIC; attr_underline = TB_TRUECOLOR_UNDERLINE; attr_reverse = TB_TRUECOLOR_REVERSE; - attr_default = TB_TRUECOLOR_DEFAULT; } else #endif { @@ -2896,19 +2907,6 @@ static int send_attr(uintattr_t fg, uintattr_t bg) { attr_italic = TB_ITALIC; attr_underline = TB_UNDERLINE; attr_reverse = TB_REVERSE; - attr_default = TB_DEFAULT; - } - - /* For convenience (and some back compat), interpret 0 as default in some - * modes */ - if (global.output_mode == TB_OUTPUT_NORMAL || - global.output_mode == TB_OUTPUT_216 || - global.output_mode == TB_OUTPUT_GRAYSCALE) - { - if ((fg & 0xff) == 0) - fg |= attr_default; - if ((bg & 0xff) == 0) - bg |= attr_default; } if (fg & attr_bold) @@ -2929,7 +2927,20 @@ static int send_attr(uintattr_t fg, uintattr_t bg) { if_err_return(rv, bytebuf_puts(&global.out, global.caps[TB_CAP_REVERSE])); - if_err_return(rv, send_sgr(cfg, cbg, fg & attr_default, bg & attr_default)); + int fg_is_default = (fg & 0xff) == 0; + int bg_is_default = (bg & 0xff) == 0; + if (global.output_mode == TB_OUTPUT_256) { + if (fg & TB_256_BLACK) fg_is_default = 0; + if (bg & TB_256_BLACK) bg_is_default = 0; + } +#ifdef TB_OPT_TRUECOLOR + if (global.output_mode == TB_OUTPUT_TRUECOLOR) { + fg_is_default = ((fg & 0xffffff) == 0) && ((fg & TB_TRUECOLOR_BLACK) == 0); + bg_is_default = ((bg & 0xffffff) == 0) && ((bg & TB_TRUECOLOR_BLACK) == 0); + } +#endif + + if_err_return(rv, send_sgr(cfg, cbg, fg_is_default, bg_is_default)); global.last_fg = fg; global.last_bg = bg; @@ -2937,8 +2948,8 @@ static int send_attr(uintattr_t fg, uintattr_t bg) { return TB_OK; } -static int send_sgr(uintattr_t cfg, uintattr_t cbg, uintattr_t fg_is_default, - uintattr_t bg_is_default) { +static int send_sgr(uintattr_t cfg, uintattr_t cbg, int fg_is_default, + int bg_is_default) { int rv; char nbuf[32]; diff --git a/tests/test_color_8bit/expected.ansi b/tests/test_color_8bit/expected.ansi index 2867c4a..ebd0df7 100644 --- a/tests/test_color_8bit/expected.ansi +++ b/tests/test_color_8bit/expected.ansi @@ -1,24 +1,24 @@ #5TB_OUTPUT_NORMAL #5▀▀▀▀▀▀▀▀▀ #5fg=def|ital bg=6 -#5fg=0|ital   bg=6 +#5fg=0x0|ital bg=6 #5TB_OUTPUT_256 -#5▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀[0;38:5:16m▀[0;38:5:17m▀[0;38:5:18m▀[0;38:5:19m▀[0;38:5:20m▀[0;38:5:21m▀[0;38:5:22m▀[0;38:5:23m▀[0;38:5:24m▀[0;38:5:25m▀[0;38:5:26m▀[0;38:5:27m▀[0;38:5:28m▀[0;38:5:29m▀[0;38:5:30m▀[0;38:5:31m▀[0;38:5:32m▀[0;38:5:33m▀[0;38:5:34m▀[0;38:5:35m▀[0;38:5:36m▀[0;38:5:37m▀[0;38:5:38m▀[0;38:5:39m▀[0;38:5:40m▀[0;38:5:41m▀[0;38:5:42m▀[0;38:5:43m▀[0;38:5:44m▀[0;38:5:45m▀[0;38:5:46m▀[0;38:5:47m▀[0;38:5:48m▀[0;38:5:49m▀[0;38:5:50m▀[0;38:5:51m▀[0;38:5:52m▀[0;38:5:53m▀[0;38:5:54m▀[0;38:5:55m▀[0;38:5:56m▀[0;38:5:57m▀[0;38:5:58m▀[0;38:5:59m▀[0;38:5:60m▀[0;38:5:61m▀[0;38:5:62m▀[0;38:5:63m▀[0;38:5:64m▀[0;38:5:65m▀[0;38:5:66m▀[0;38:5:67m▀[0;38:5:68m▀[0;38:5:69m▀[0;38:5:70m▀[0;38:5:71m▀[0;38:5:72m▀[0;38:5:73m▀[0;38:5:74m▀[0;38:5:75m▀[0;38:5:76m▀[0;38:5:77m▀[0;38:5:78m▀[0;38:5:79m▀ -#5[0;38:5:80m▀[0;38:5:81m▀[0;38:5:82m▀[0;38:5:83m▀[0;38:5:84m▀[0;38:5:85m▀[0;38:5:86m▀[0;38:5:87m▀[0;38:5:88m▀[0;38:5:89m▀[0;38:5:90m▀[0;38:5:91m▀[0;38:5:92m▀[0;38:5:93m▀[0;38:5:94m▀[0;38:5:95m▀[0;38:5:96m▀[0;38:5:97m▀[0;38:5:98m▀[0;38:5:99m▀[0;38:5:100m▀[0;38:5:101m▀[0;38:5:102m▀[0;38:5:103m▀[0;38:5:104m▀[0;38:5:105m▀[0;38:5:106m▀[0;38:5:107m▀[0;38:5:108m▀[0;38:5:109m▀[0;38:5:110m▀[0;38:5:111m▀[0;38:5:112m▀[0;38:5:113m▀[0;38:5:114m▀[0;38:5:115m▀[0;38:5:116m▀[0;38:5:117m▀[0;38:5:118m▀[0;38:5:119m▀[0;38:5:120m▀[0;38:5:121m▀[0;38:5:122m▀[0;38:5:123m▀[0;38:5:124m▀[0;38:5:125m▀[0;38:5:126m▀[0;38:5:127m▀[0;38:5:128m▀[0;38:5:129m▀[0;38:5:130m▀[0;38:5:131m▀[0;38:5:132m▀[0;38:5:133m▀[0;38:5:134m▀[0;38:5:135m▀[0;38:5:136m▀[0;38:5:137m▀[0;38:5:138m▀[0;38:5:139m▀[0;38:5:140m▀[0;38:5:141m▀[0;38:5:142m▀[0;38:5:143m▀[0;38:5:144m▀[0;38:5:145m▀[0;38:5:146m▀[0;38:5:147m▀[0;38:5:148m▀[0;38:5:149m▀[0;38:5:150m▀[0;38:5:151m▀[0;38:5:152m▀[0;38:5:153m▀[0;38:5:154m▀[0;38:5:155m▀[0;38:5:156m▀[0;38:5:157m▀[0;38:5:158m▀[0;38:5:159m▀ -#5[0;38:5:160m▀[0;38:5:161m▀[0;38:5:162m▀[0;38:5:163m▀[0;38:5:164m▀[0;38:5:165m▀[0;38:5:166m▀[0;38:5:167m▀[0;38:5:168m▀[0;38:5:169m▀[0;38:5:170m▀[0;38:5:171m▀[0;38:5:172m▀[0;38:5:173m▀[0;38:5:174m▀[0;38:5:175m▀[0;38:5:176m▀[0;38:5:177m▀[0;38:5:178m▀[0;38:5:179m▀[0;38:5:180m▀[0;38:5:181m▀[0;38:5:182m▀[0;38:5:183m▀[0;38:5:184m▀[0;38:5:185m▀[0;38:5:186m▀[0;38:5:187m▀[0;38:5:188m▀[0;38:5:189m▀[0;38:5:190m▀[0;38:5:191m▀[0;38:5:192m▀[0;38:5:193m▀[0;38:5:194m▀[0;38:5:195m▀[0;38:5:196m▀[0;38:5:197m▀[0;38:5:198m▀[0;38:5:199m▀[0;38:5:200m▀[0;38:5:201m▀[0;38:5:202m▀[0;38:5:203m▀[0;38:5:204m▀[0;38:5:205m▀[0;38:5:206m▀[0;38:5:207m▀[0;38:5:208m▀[0;38:5:209m▀[0;38:5:210m▀[0;38:5:211m▀[0;38:5:212m▀[0;38:5:213m▀[0;38:5:214m▀[0;38:5:215m▀[0;38:5:216m▀[0;38:5:217m▀[0;38:5:218m▀[0;38:5:219m▀[0;38:5:220m▀[0;38:5:221m▀[0;38:5:222m▀[0;38:5:223m▀[0;38:5:224m▀[0;38:5:225m▀[0;38:5:226m▀[0;38:5:227m▀[0;38:5:228m▀[0;38:5:229m▀[0;38:5:230m▀[0;38:5:231m▀[0;38:5:232m▀[0;38:5:233m▀[0;38:5:234m▀[0;38:5:235m▀[0;38:5:236m▀[0;38:5:237m▀[0;38:5:238m▀[0;38:5:239m▀ -#5[0;38:5:240m▀[0;38:5:241m▀[0;38:5:242m▀[0;38:5:243m▀[0;38:5:244m▀[0;38:5:245m▀[0;38:5:246m▀[0;38:5:247m▀[0;38:5:248m▀[0;38:5:249m▀[0;38:5:250m▀[0;38:5:251m▀[0;38:5:252m▀[0;38:5:253m▀[0;38:5:254m▀[0;38:5:255m▀ +#5▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀[0;38:5:16m▀[0;38:5:17m▀[0;38:5:18m▀[0;38:5:19m▀[0;38:5:20m▀[0;38:5:21m▀[0;38:5:22m▀[0;38:5:23m▀[0;38:5:24m▀[0;38:5:25m▀[0;38:5:26m▀[0;38:5:27m▀[0;38:5:28m▀[0;38:5:29m▀[0;38:5:30m▀[0;38:5:31m▀[0;38:5:32m▀[0;38:5:33m▀[0;38:5:34m▀[0;38:5:35m▀[0;38:5:36m▀[0;38:5:37m▀[0;38:5:38m▀[0;38:5:39m▀[0;38:5:40m▀[0;38:5:41m▀[0;38:5:42m▀[0;38:5:43m▀[0;38:5:44m▀[0;38:5:45m▀[0;38:5:46m▀[0;38:5:47m▀[0;38:5:48m▀[0;38:5:49m▀[0;38:5:50m▀[0;38:5:51m▀[0;38:5:52m▀[0;38:5:53m▀[0;38:5:54m▀[0;38:5:55m▀[0;38:5:56m▀[0;38:5:57m▀[0;38:5:58m▀[0;38:5:59m▀[0;38:5:60m▀[0;38:5:61m▀[0;38:5:62m▀[0;38:5:63m▀[0;38:5:64m▀[0;38:5:65m▀[0;38:5:66m▀[0;38:5:67m▀[0;38:5:68m▀[0;38:5:69m▀[0;38:5:70m▀[0;38:5:71m▀[0;38:5:72m▀[0;38:5:73m▀[0;38:5:74m▀[0;38:5:75m▀[0;38:5:76m▀[0;38:5:77m▀[0;38:5:78m▀ +#5[0;38:5:79m▀[0;38:5:80m▀[0;38:5:81m▀[0;38:5:82m▀[0;38:5:83m▀[0;38:5:84m▀[0;38:5:85m▀[0;38:5:86m▀[0;38:5:87m▀[0;38:5:88m▀[0;38:5:89m▀[0;38:5:90m▀[0;38:5:91m▀[0;38:5:92m▀[0;38:5:93m▀[0;38:5:94m▀[0;38:5:95m▀[0;38:5:96m▀[0;38:5:97m▀[0;38:5:98m▀[0;38:5:99m▀[0;38:5:100m▀[0;38:5:101m▀[0;38:5:102m▀[0;38:5:103m▀[0;38:5:104m▀[0;38:5:105m▀[0;38:5:106m▀[0;38:5:107m▀[0;38:5:108m▀[0;38:5:109m▀[0;38:5:110m▀[0;38:5:111m▀[0;38:5:112m▀[0;38:5:113m▀[0;38:5:114m▀[0;38:5:115m▀[0;38:5:116m▀[0;38:5:117m▀[0;38:5:118m▀[0;38:5:119m▀[0;38:5:120m▀[0;38:5:121m▀[0;38:5:122m▀[0;38:5:123m▀[0;38:5:124m▀[0;38:5:125m▀[0;38:5:126m▀[0;38:5:127m▀[0;38:5:128m▀[0;38:5:129m▀[0;38:5:130m▀[0;38:5:131m▀[0;38:5:132m▀[0;38:5:133m▀[0;38:5:134m▀[0;38:5:135m▀[0;38:5:136m▀[0;38:5:137m▀[0;38:5:138m▀[0;38:5:139m▀[0;38:5:140m▀[0;38:5:141m▀[0;38:5:142m▀[0;38:5:143m▀[0;38:5:144m▀[0;38:5:145m▀[0;38:5:146m▀[0;38:5:147m▀[0;38:5:148m▀[0;38:5:149m▀[0;38:5:150m▀[0;38:5:151m▀[0;38:5:152m▀[0;38:5:153m▀[0;38:5:154m▀[0;38:5:155m▀[0;38:5:156m▀[0;38:5:157m▀[0;38:5:158m▀ +#5[0;38:5:159m▀[0;38:5:160m▀[0;38:5:161m▀[0;38:5:162m▀[0;38:5:163m▀[0;38:5:164m▀[0;38:5:165m▀[0;38:5:166m▀[0;38:5:167m▀[0;38:5:168m▀[0;38:5:169m▀[0;38:5:170m▀[0;38:5:171m▀[0;38:5:172m▀[0;38:5:173m▀[0;38:5:174m▀[0;38:5:175m▀[0;38:5:176m▀[0;38:5:177m▀[0;38:5:178m▀[0;38:5:179m▀[0;38:5:180m▀[0;38:5:181m▀[0;38:5:182m▀[0;38:5:183m▀[0;38:5:184m▀[0;38:5:185m▀[0;38:5:186m▀[0;38:5:187m▀[0;38:5:188m▀[0;38:5:189m▀[0;38:5:190m▀[0;38:5:191m▀[0;38:5:192m▀[0;38:5:193m▀[0;38:5:194m▀[0;38:5:195m▀[0;38:5:196m▀[0;38:5:197m▀[0;38:5:198m▀[0;38:5:199m▀[0;38:5:200m▀[0;38:5:201m▀[0;38:5:202m▀[0;38:5:203m▀[0;38:5:204m▀[0;38:5:205m▀[0;38:5:206m▀[0;38:5:207m▀[0;38:5:208m▀[0;38:5:209m▀[0;38:5:210m▀[0;38:5:211m▀[0;38:5:212m▀[0;38:5:213m▀[0;38:5:214m▀[0;38:5:215m▀[0;38:5:216m▀[0;38:5:217m▀[0;38:5:218m▀[0;38:5:219m▀[0;38:5:220m▀[0;38:5:221m▀[0;38:5:222m▀[0;38:5:223m▀[0;38:5:224m▀[0;38:5:225m▀[0;38:5:226m▀[0;38:5:227m▀[0;38:5:228m▀[0;38:5:229m▀[0;38:5:230m▀[0;38:5:231m▀[0;38:5:232m▀[0;38:5:233m▀[0;38:5:234m▀[0;38:5:235m▀[0;38:5:236m▀[0;38:5:237m▀[0;38:5:238m▀ +#5[0;38:5:239m▀[0;38:5:240m▀[0;38:5:241m▀[0;38:5:242m▀[0;38:5:243m▀[0;38:5:244m▀[0;38:5:245m▀[0;38:5:246m▀[0;38:5:247m▀[0;38:5:248m▀[0;38:5:249m▀[0;38:5:250m▀[0;38:5:251m▀[0;38:5:252m▀[0;38:5:253m▀[0;38:5:254m▀[0;38:5:255m▀ #5fg=def|ital bg=6 -#5fg=0|ital   bg=6 +#5fg=0x0|ital bg=6 #5TB_OUTPUT_216 #5▀[0;38:5:16m▀[0;38:5:17m▀[0;38:5:18m▀[0;38:5:19m▀[0;38:5:20m▀[0;38:5:21m▀[0;38:5:22m▀[0;38:5:23m▀[0;38:5:24m▀[0;38:5:25m▀[0;38:5:26m▀[0;38:5:27m▀[0;38:5:28m▀[0;38:5:29m▀[0;38:5:30m▀[0;38:5:31m▀[0;38:5:32m▀[0;38:5:33m▀[0;38:5:34m▀[0;38:5:35m▀[0;38:5:36m▀[0;38:5:37m▀[0;38:5:38m▀[0;38:5:39m▀[0;38:5:40m▀[0;38:5:41m▀[0;38:5:42m▀[0;38:5:43m▀[0;38:5:44m▀[0;38:5:45m▀[0;38:5:46m▀[0;38:5:47m▀[0;38:5:48m▀[0;38:5:49m▀[0;38:5:50m▀[0;38:5:51m▀[0;38:5:52m▀[0;38:5:53m▀[0;38:5:54m▀[0;38:5:55m▀[0;38:5:56m▀[0;38:5:57m▀[0;38:5:58m▀[0;38:5:59m▀[0;38:5:60m▀[0;38:5:61m▀[0;38:5:62m▀[0;38:5:63m▀[0;38:5:64m▀[0;38:5:65m▀[0;38:5:66m▀[0;38:5:67m▀[0;38:5:68m▀[0;38:5:69m▀[0;38:5:70m▀[0;38:5:71m▀[0;38:5:72m▀[0;38:5:73m▀[0;38:5:74m▀[0;38:5:75m▀[0;38:5:76m▀[0;38:5:77m▀[0;38:5:78m▀[0;38:5:79m▀[0;38:5:80m▀[0;38:5:81m▀[0;38:5:82m▀[0;38:5:83m▀[0;38:5:84m▀[0;38:5:85m▀[0;38:5:86m▀[0;38:5:87m▀[0;38:5:88m▀[0;38:5:89m▀[0;38:5:90m▀[0;38:5:91m▀[0;38:5:92m▀[0;38:5:93m▀[0;38:5:94m▀ #5[0;38:5:95m▀[0;38:5:96m▀[0;38:5:97m▀[0;38:5:98m▀[0;38:5:99m▀[0;38:5:100m▀[0;38:5:101m▀[0;38:5:102m▀[0;38:5:103m▀[0;38:5:104m▀[0;38:5:105m▀[0;38:5:106m▀[0;38:5:107m▀[0;38:5:108m▀[0;38:5:109m▀[0;38:5:110m▀[0;38:5:111m▀[0;38:5:112m▀[0;38:5:113m▀[0;38:5:114m▀[0;38:5:115m▀[0;38:5:116m▀[0;38:5:117m▀[0;38:5:118m▀[0;38:5:119m▀[0;38:5:120m▀[0;38:5:121m▀[0;38:5:122m▀[0;38:5:123m▀[0;38:5:124m▀[0;38:5:125m▀[0;38:5:126m▀[0;38:5:127m▀[0;38:5:128m▀[0;38:5:129m▀[0;38:5:130m▀[0;38:5:131m▀[0;38:5:132m▀[0;38:5:133m▀[0;38:5:134m▀[0;38:5:135m▀[0;38:5:136m▀[0;38:5:137m▀[0;38:5:138m▀[0;38:5:139m▀[0;38:5:140m▀[0;38:5:141m▀[0;38:5:142m▀[0;38:5:143m▀[0;38:5:144m▀[0;38:5:145m▀[0;38:5:146m▀[0;38:5:147m▀[0;38:5:148m▀[0;38:5:149m▀[0;38:5:150m▀[0;38:5:151m▀[0;38:5:152m▀[0;38:5:153m▀[0;38:5:154m▀[0;38:5:155m▀[0;38:5:156m▀[0;38:5:157m▀[0;38:5:158m▀[0;38:5:159m▀[0;38:5:160m▀[0;38:5:161m▀[0;38:5:162m▀[0;38:5:163m▀[0;38:5:164m▀[0;38:5:165m▀[0;38:5:166m▀[0;38:5:167m▀[0;38:5:168m▀[0;38:5:169m▀[0;38:5:170m▀[0;38:5:171m▀[0;38:5:172m▀[0;38:5:173m▀[0;38:5:174m▀ #5[0;38:5:175m▀[0;38:5:176m▀[0;38:5:177m▀[0;38:5:178m▀[0;38:5:179m▀[0;38:5:180m▀[0;38:5:181m▀[0;38:5:182m▀[0;38:5:183m▀[0;38:5:184m▀[0;38:5:185m▀[0;38:5:186m▀[0;38:5:187m▀[0;38:5:188m▀[0;38:5:189m▀[0;38:5:190m▀[0;38:5:191m▀[0;38:5:192m▀[0;38:5:193m▀[0;38:5:194m▀[0;38:5:195m▀[0;38:5:196m▀[0;38:5:197m▀[0;38:5:198m▀[0;38:5:199m▀[0;38:5:200m▀[0;38:5:201m▀[0;38:5:202m▀[0;38:5:203m▀[0;38:5:204m▀[0;38:5:205m▀[0;38:5:206m▀[0;38:5:207m▀[0;38:5:208m▀[0;38:5:209m▀[0;38:5:210m▀[0;38:5:211m▀[0;38:5:212m▀[0;38:5:213m▀[0;38:5:214m▀[0;38:5:215m▀[0;38:5:216m▀[0;38:5:217m▀[0;38:5:218m▀[0;38:5:219m▀[0;38:5:220m▀[0;38:5:221m▀[0;38:5:222m▀[0;38:5:223m▀[0;38:5:224m▀[0;38:5:225m▀[0;38:5:226m▀[0;38:5:227m▀[0;38:5:228m▀[0;38:5:229m▀[0;38:5:230m▀[0;38:5:231m▀ #5[0;3;48:5:21mf[0;3;48:5:21mg[0;3;48:5:21m=[0;3;48:5:21md[0;3;48:5:21me[0;3;48:5:21mf[0;3;48:5:21m|[0;3;48:5:21mi[0;3;48:5:21mt[0;3;48:5:21ma[0;3;48:5:21ml[0;3;48:5:21m [0;3;48:5:21mb[0;3;48:5:21mg[0;3;48:5:21m=[0;3;48:5:21m6 -#5[0;3;48:5:21mf[0;3;48:5:21mg[0;3;48:5:21m=[0;3;48:5:21m0[0;3;48:5:21m|[0;3;48:5:21mi[0;3;48:5:21mt[0;3;48:5:21ma[0;3;48:5:21ml[0;3;48:5:21m [0;3;48:5:21m [0;3;48:5:21m [0;3;48:5:21mb[0;3;48:5:21mg[0;3;48:5:21m=[0;3;48:5:21m6 +#5[0;3;48:5:21mf[0;3;48:5:21mg[0;3;48:5:21m=[0;3;48:5:21m0[0;3;48:5:21mx[0;3;48:5:21m0[0;3;48:5:21m|[0;3;48:5:21mi[0;3;48:5:21mt[0;3;48:5:21ma[0;3;48:5:21ml[0;3;48:5:21m [0;3;48:5:21mb[0;3;48:5:21mg[0;3;48:5:21m=[0;3;48:5:21m6 #5TB_OUTPUT_GRAYSCALE #5▀[0;38:5:232m▀[0;38:5:233m▀[0;38:5:234m▀[0;38:5:235m▀[0;38:5:236m▀[0;38:5:237m▀[0;38:5:238m▀[0;38:5:239m▀[0;38:5:240m▀[0;38:5:241m▀[0;38:5:242m▀[0;38:5:243m▀[0;38:5:244m▀[0;38:5:245m▀[0;38:5:246m▀[0;38:5:247m▀[0;38:5:248m▀[0;38:5:249m▀[0;38:5:250m▀[0;38:5:251m▀[0;38:5:252m▀[0;38:5:253m▀[0;38:5:254m▀[0;38:5:255m▀ #5[0;3;48:5:237mf[0;3;48:5:237mg[0;3;48:5:237m=[0;3;48:5:237md[0;3;48:5:237me[0;3;48:5:237mf[0;3;48:5:237m|[0;3;48:5:237mi[0;3;48:5:237mt[0;3;48:5:237ma[0;3;48:5:237ml[0;3;48:5:237m [0;3;48:5:237mb[0;3;48:5:237mg[0;3;48:5:237m=[0;3;48:5:237m6 -#5[0;3;48:5:237mf[0;3;48:5:237mg[0;3;48:5:237m=[0;3;48:5:237m0[0;3;48:5:237m|[0;3;48:5:237mi[0;3;48:5:237mt[0;3;48:5:237ma[0;3;48:5:237ml[0;3;48:5:237m [0;3;48:5:237m [0;3;48:5:237m [0;3;48:5:237mb[0;3;48:5:237mg[0;3;48:5:237m=[0;3;48:5:237m6 +#5[0;3;48:5:237mf[0;3;48:5:237mg[0;3;48:5:237m=[0;3;48:5:237m0[0;3;48:5:237mx[0;3;48:5:237m0[0;3;48:5:237m|[0;3;48:5:237mi[0;3;48:5:237mt[0;3;48:5:237ma[0;3;48:5:237ml[0;3;48:5:237m [0;3;48:5:237mb[0;3;48:5:237mg[0;3;48:5:237m=[0;3;48:5:237m6 diff --git a/tests/test_color_8bit/test.php b/tests/test_color_8bit/test.php index 5dd78f8..4768236 100755 --- a/tests/test_color_8bit/test.php +++ b/tests/test_color_8bit/test.php @@ -25,22 +25,32 @@ function test_mode($test, string $mode, int $n, int $w, int &$x, int &$y): void $x = 0; $y++; } - $test->ffi->tb_print($x, $y, $fg, $attr_default, $s); + if ($mode === 'TB_OUTPUT_256') { + if ($fg === 0) { + $cfg = $attr_default; + } else if ($fg === 1) { + $cfg = $test->defines['TB_256_BLACK']; + } else { + $cfg = $fg - 1; + } + } else { + $cfg = $fg; + } + $test->ffi->tb_print($x, $y, $cfg, $attr_default, $s); $x += $slen; } $y++; $test->ffi->tb_print($x = 0, $y++, $attr_default | $attr_italic, 6, "fg=def|ital bg=6"); - $test->ffi->tb_print($x = 0, $y++, 0 | $attr_italic, 6, "fg=0|ital bg=6"); + $test->ffi->tb_print($x = 0, $y++, 0 | $attr_italic, 6, "fg=0x0|ital bg=6"); $test->ffi->tb_present(); } // TB_OUTPUT_NORMAL test_mode($test, 'TB_OUTPUT_NORMAL', 8, $w, $x, $y); -test_mode($test, 'TB_OUTPUT_256', 255, $w, $x, $y); +test_mode($test, 'TB_OUTPUT_256', 256, $w, $x, $y); test_mode($test, 'TB_OUTPUT_216', 216, $w, $x, $y); test_mode($test, 'TB_OUTPUT_GRAYSCALE', 24, $w, $x, $y); - $test->screencap(); diff --git a/tests/test_color_true/expected.ansi b/tests/test_color_true/expected.ansi index df26615..27d14dc 100644 --- a/tests/test_color_true/expected.ansi +++ b/tests/test_color_true/expected.ansi @@ -9,8 +9,8 @@ #5[0;38:2::128:128:0mo[0;38:2::128:128:0ml[0;38:2::128:128:0mi[0;38:2::128:128:0mv[0;38:2::128:128:0me[0;38:2::128:128:0m,[0;38:2::128:128:0m [0;38:2::255:165:0mo[0;38:2::255:165:0mr[0;38:2::255:165:0ma[0;38:2::255:165:0mn[0;38:2::255:165:0mg[0;38:2::255:165:0me[0;38:2::255:165:0m,[0;38:2::255:165:0m [0;38:2::218:112:214mo[0;38:2::218:112:214mr[0;38:2::218:112:214mc[0;38:2::218:112:214mh[0;38:2::218:112:214mi[0;38:2::218:112:214md[0;38:2::218:112:214m,[0;38:2::218:112:214m [0;38:2::152:251:152mp[0;38:2::152:251:152ma[0;38:2::152:251:152ml[0;38:2::152:251:152me[0;38:2::152:251:152mg[0;38:2::152:251:152mr[0;38:2::152:251:152me[0;38:2::152:251:152me[0;38:2::152:251:152mn[0;38:2::152:251:152m,[0;38:2::152:251:152m [0;38:2::219:112:147mp[0;38:2::219:112:147ma[0;38:2::219:112:147ml[0;38:2::219:112:147me[0;38:2::219:112:147mv[0;38:2::219:112:147mi[0;38:2::219:112:147mo[0;38:2::219:112:147ml[0;38:2::219:112:147me[0;38:2::219:112:147mt[0;38:2::219:112:147mr[0;38:2::219:112:147me[0;38:2::219:112:147md[0;38:2::219:112:147m,[0;38:2::219:112:147m [0;38:2::255:218:185mp[0;38:2::255:218:185me[0;38:2::255:218:185ma[0;38:2::255:218:185mc[0;38:2::255:218:185mh[0;38:2::255:218:185mp[0;38:2::255:218:185mu[0;38:2::255:218:185mf[0;38:2::255:218:185mf[0;38:2::255:218:185m,[0;38:2::255:218:185m [0;38:2::255:192:203mp[0;38:2::255:192:203mi[0;38:2::255:192:203mn[0;38:2::255:192:203mk[0;38:2::255:192:203m,[0;38:2::255:192:203m [0;38:2::176:224:230mp[0;38:2::176:224:230mo[0;38:2::176:224:230mw[0;38:2::176:224:230md[0;38:2::176:224:230me[0;38:2::176:224:230mr[0;38:2::176:224:230mb[0;38:2::176:224:230ml[0;38:2::176:224:230mu[0;38:2::176:224:230me[0;38:2::176:224:230m,[0;38:2::176:224:230m  #5[0;38:2::255:0:0mr[0;38:2::255:0:0me[0;38:2::255:0:0md[0;38:2::255:0:0m,[0;38:2::255:0:0m [0;38:2::65:105:225mr[0;38:2::65:105:225mo[0;38:2::65:105:225my[0;38:2::65:105:225ma[0;38:2::65:105:225ml[0;38:2::65:105:225mb[0;38:2::65:105:225ml[0;38:2::65:105:225mu[0;38:2::65:105:225me[0;38:2::65:105:225m,[0;38:2::65:105:225m [0;38:2::250:128:114ms[0;38:2::250:128:114ma[0;38:2::250:128:114ml[0;38:2::250:128:114mm[0;38:2::250:128:114mo[0;38:2::250:128:114mn[0;38:2::250:128:114m,[0;38:2::250:128:114m [0;38:2::46:139:87ms[0;38:2::46:139:87me[0;38:2::46:139:87ma[0;38:2::46:139:87mg[0;38:2::46:139:87mr[0;38:2::46:139:87me[0;38:2::46:139:87me[0;38:2::46:139:87mn[0;38:2::46:139:87m,[0;38:2::46:139:87m [0;38:2::160:82:45ms[0;38:2::160:82:45mi[0;38:2::160:82:45me[0;38:2::160:82:45mn[0;38:2::160:82:45mn[0;38:2::160:82:45ma[0;38:2::160:82:45m,[0;38:2::160:82:45m [0;38:2::135:206:235ms[0;38:2::135:206:235mk[0;38:2::135:206:235my[0;38:2::135:206:235mb[0;38:2::135:206:235ml[0;38:2::135:206:235mu[0;38:2::135:206:235me[0;38:2::135:206:235m,[0;38:2::135:206:235m [0;38:2::112:128:144ms[0;38:2::112:128:144ml[0;38:2::112:128:144ma[0;38:2::112:128:144mt[0;38:2::112:128:144me[0;38:2::112:128:144mg[0;38:2::112:128:144mr[0;38:2::112:128:144me[0;38:2::112:128:144my[0;38:2::112:128:144m,[0;38:2::112:128:144m [0;38:2::0:255:127ms[0;38:2::0:255:127mp[0;38:2::0:255:127mr[0;38:2::0:255:127mi[0;38:2::0:255:127mn[0;38:2::0:255:127mg[0;38:2::0:255:127mg[0;38:2::0:255:127mr[0;38:2::0:255:127me[0;38:2::0:255:127me[0;38:2::0:255:127mn[0;38:2::0:255:127m,[0;38:2::0:255:127m [0;38:2::210:180:140mt[0;38:2::210:180:140ma[0;38:2::210:180:140mn[0;38:2::210:180:140m,[0;38:2::210:180:140m  #5[0;38:2::216:191:216mt[0;38:2::216:191:216mh[0;38:2::216:191:216mi[0;38:2::216:191:216ms[0;38:2::216:191:216mt[0;38:2::216:191:216ml[0;38:2::216:191:216me[0;38:2::216:191:216m,[0;38:2::216:191:216m [0;38:2::64:224:208mt[0;38:2::64:224:208mu[0;38:2::64:224:208mr[0;38:2::64:224:208mq[0;38:2::64:224:208mu[0;38:2::64:224:208mo[0;38:2::64:224:208mi[0;38:2::64:224:208ms[0;38:2::64:224:208me[0;38:2::64:224:208m,[0;38:2::64:224:208m [0;38:2::245:222:179mw[0;38:2::245:222:179mh[0;38:2::245:222:179me[0;38:2::245:222:179ma[0;38:2::245:222:179mt[0;38:2::245:222:179m,[0;38:2::245:222:179m [0;38:2::245:245:245mw[0;38:2::245:245:245mh[0;38:2::245:245:245mi[0;38:2::245:245:245mt[0;38:2::245:245:245me[0;38:2::245:245:245ms[0;38:2::245:245:245mm[0;38:2::245:245:245mo[0;38:2::245:245:245mk[0;38:2::245:245:245me[0;38:2::245:245:245m,[0;38:2::245:245:245m [0;38:2::154:205:50my[0;38:2::154:205:50me[0;38:2::154:205:50ml[0;38:2::154:205:50ml[0;38:2::154:205:50mo[0;38:2::154:205:50mw[0;38:2::154:205:50mg[0;38:2::154:205:50mr[0;38:2::154:205:50me[0;38:2::154:205:50me[0;38:2::154:205:50mn[0;38:2::154:205:50m,[0;38:2::154:205:50m [0;38:2::0:255:0mg[0;38:2::0:255:0mr[0;38:2::0:255:0me[0;38:2::0:255:0me[0;38:2::0:255:0mn[0;38:2::0:255:0m [0;38:2::0:255:0mo[0;38:2::0:255:0mn[0;38:2::0:255:0m [0;38:2::0:255:0md[0;38:2::0:255:0me[0;38:2::0:255:0mf[0;38:2::0:255:0ma[0;38:2::0:255:0mu[0;38:2::0:255:0ml[0;38:2::0:255:0mt[0;38:2::0:255:0m,[0;38:2::0:255:0m  -#5[0;38:2::0:0:0mb[0;38:2::0:0:0ml[0;38:2::0:0:0ma[0;38:2::0:0:0mc[0;38:2::0:0:0mk[0;38:2::0:0:0m [0;38:2::0:0:0mo[0;38:2::0:0:0mn[0;38:2::0:0:0m [0;38:2::0:0:0md[0;38:2::0:0:0me[0;38:2::0:0:0mf[0;38:2::0:0:0ma[0;38:2::0:0:0mu[0;38:2::0:0:0ml[0;38:2::0:0:0mt[0;38:2::0:0:0m,[0;38:2::0:0:0m [0;48:2::0:255:0md[0;48:2::0:255:0me[0;48:2::0:255:0mf[0;48:2::0:255:0ma[0;48:2::0:255:0mu[0;48:2::0:255:0ml[0;48:2::0:255:0mt[0;48:2::0:255:0m [0;48:2::0:255:0mo[0;48:2::0:255:0mn[0;48:2::0:255:0m [0;48:2::0:255:0mg[0;48:2::0:255:0mr[0;48:2::0:255:0me[0;48:2::0:255:0me[0;48:2::0:255:0mn[0;48:2::0:255:0m,[0;48:2::0:255:0m [0;48:2::0:0:0md[0;48:2::0:0:0me[0;48:2::0:0:0mf[0;48:2::0:0:0ma[0;48:2::0:0:0mu[0;48:2::0:0:0ml[0;48:2::0:0:0mt[0;48:2::0:0:0m [0;48:2::0:0:0mo[0;48:2::0:0:0mn[0;48:2::0:0:0m [0;48:2::0:0:0mb[0;48:2::0:0:0ml[0;48:2::0:0:0ma[0;48:2::0:0:0mc[0;48:2::0:0:0mk[0;48:2::0:0:0m,[0;48:2::0:0:0m default on default,  -#5default w/ ignored bits, italic on default,  +#5[0;38:2::0:0:0mb[0;38:2::0:0:0ml[0;38:2::0:0:0ma[0;38:2::0:0:0mc[0;38:2::0:0:0mk[0;38:2::0:0:0m [0;38:2::0:0:0mo[0;38:2::0:0:0mn[0;38:2::0:0:0m [0;38:2::0:0:0md[0;38:2::0:0:0me[0;38:2::0:0:0mf[0;38:2::0:0:0ma[0;38:2::0:0:0mu[0;38:2::0:0:0ml[0;38:2::0:0:0mt[0;38:2::0:0:0m,[0;38:2::0:0:0m [0;48:2::0:255:0md[0;48:2::0:255:0me[0;48:2::0:255:0mf[0;48:2::0:255:0ma[0;48:2::0:255:0mu[0;48:2::0:255:0ml[0;48:2::0:255:0mt[0;48:2::0:255:0m [0;48:2::0:255:0mo[0;48:2::0:255:0mn[0;48:2::0:255:0m [0;48:2::0:255:0mg[0;48:2::0:255:0mr[0;48:2::0:255:0me[0;48:2::0:255:0me[0;48:2::0:255:0mn[0;48:2::0:255:0m,[0;48:2::0:255:0m [0;48:2::0:0:0md[0;48:2::0:0:0me[0;48:2::0:0:0mf[0;48:2::0:0:0ma[0;48:2::0:0:0mu[0;48:2::0:0:0ml[0;48:2::0:0:0mt[0;48:2::0:0:0m [0;48:2::0:0:0mo[0;48:2::0:0:0mn[0;48:2::0:0:0m [0;48:2::0:0:0mb[0;48:2::0:0:0ml[0;48:2::0:0:0ma[0;48:2::0:0:0mc[0;48:2::0:0:0mk[0;48:2::0:0:0m,[0;48:2::0:0:0m default on default, +#5[0;38:2::0:0:0;48:2::0:0:0mb[0;38:2::0:0:0;48:2::0:0:0ml[0;38:2::0:0:0;48:2::0:0:0ma[0;38:2::0:0:0;48:2::0:0:0mc[0;38:2::0:0:0;48:2::0:0:0mk[0;38:2::0:0:0;48:2::0:0:0m [0;38:2::0:0:0;48:2::0:0:0mo[0;38:2::0:0:0;48:2::0:0:0mn[0;38:2::0:0:0;48:2::0:0:0m [0;38:2::0:0:0;48:2::0:0:0mb[0;38:2::0:0:0;48:2::0:0:0ml[0;38:2::0:0:0;48:2::0:0:0ma[0;38:2::0:0:0;48:2::0:0:0mc[0;38:2::0:0:0;48:2::0:0:0mk[0;38:2::0:0:0;48:2::0:0:0m [0;38:2::0:0:0;48:2::0:0:0mw[0;38:2::0:0:0;48:2::0:0:0m/[0;38:2::0:0:0;48:2::0:0:0m [0;38:2::0:0:0;48:2::0:0:0mi[0;38:2::0:0:0;48:2::0:0:0mg[0;38:2::0:0:0;48:2::0:0:0mn[0;38:2::0:0:0;48:2::0:0:0mo[0;38:2::0:0:0;48:2::0:0:0mr[0;38:2::0:0:0;48:2::0:0:0me[0;38:2::0:0:0;48:2::0:0:0md[0;38:2::0:0:0;48:2::0:0:0m [0;38:2::0:0:0;48:2::0:0:0mb[0;38:2::0:0:0;48:2::0:0:0mi[0;38:2::0:0:0;48:2::0:0:0mt[0;38:2::0:0:0;48:2::0:0:0ms[0;38:2::0:0:0;48:2::0:0:0m,[0;38:2::0:0:0;48:2::0:0:0m italic on default,  #5[0;1;38:2::128:128:120my[0;1;38:2::128:128:120me[0;1;38:2::128:128:120ms[0;1;38:2::128:128:120m [0;1;38:2::128:128:120mb[0;1;38:2::128:128:120mo[0;1;38:2::128:128:120ml[0;1;38:2::128:128:120md[0;1;38:2::128:128:120m [0;1;38:2::128:128:120m([0;1;38:2::128:128:120m#[0;1;38:2::128:128:120m1[0;1;38:2::128:128:120m8[0;1;38:2::128:128:120m0[0;1;38:2::128:128:120m8[0;1;38:2::128:128:120m0[0;1;38:2::128:128:120m8[0;1;38:2::128:128:120m0[0;1;38:2::128:128:120m) #5[0;4;38:2::128:128:128my[0;4;38:2::128:128:128me[0;4;38:2::128:128:128ms[0;4;38:2::128:128:128m [0;4;38:2::128:128:128mu[0;4;38:2::128:128:128mn[0;4;38:2::128:128:128md[0;4;38:2::128:128:128me[0;4;38:2::128:128:128mr[0;4;38:2::128:128:128ml[0;4;38:2::128:128:128mi[0;4;38:2::128:128:128mn[0;4;38:2::128:128:128me[0;4;38:2::128:128:128m [0;4;38:2::128:128:128m([0;4;38:2::128:128:128m#[0;4;38:2::128:128:128m2[0;4;38:2::128:128:128m8[0;4;38:2::128:128:128m0[0;4;38:2::128:128:128m8[0;4;38:2::128:128:128m0[0;4;38:2::128:128:128m8[0;4;38:2::128:128:128m0[0;4;38:2::128:128:128m) #5[0;3;38:2::128:128:128my[0;3;38:2::128:128:128me[0;3;38:2::128:128:128ms[0;3;38:2::128:128:128m [0;3;38:2::128:128:128mi[0;3;38:2::128:128:128mt[0;3;38:2::128:128:128ma[0;3;38:2::128:128:128ml[0;3;38:2::128:128:128mi[0;3;38:2::128:128:128mc[0;3;38:2::128:128:128m [0;3;38:2::128:128:128m([0;3;38:2::128:128:128m#[0;3;38:2::128:128:128m8[0;3;38:2::128:128:128m8[0;3;38:2::128:128:128m0[0;3;38:2::128:128:128m8[0;3;38:2::128:128:128m0[0;3;38:2::128:128:128m8[0;3;38:2::128:128:128m0[0;3;38:2::128:128:128m) diff --git a/tests/test_color_true/test.php b/tests/test_color_true/test.php index 1d290bb..83ec8e7 100755 --- a/tests/test_color_true/test.php +++ b/tests/test_color_true/test.php @@ -9,13 +9,14 @@ if (!$test->ffi->tb_has_truecolor()) { $attr_bold = $test->defines['TB_TRUECOLOR_BOLD']; $attr_underline = $test->defines['TB_TRUECOLOR_UNDERLINE']; $attr_italic = $test->defines['TB_TRUECOLOR_ITALIC']; -$attr_default = $test->defines['TB_TRUECOLOR_DEFAULT']; +$attr_default = $test->defines['TB_DEFAULT']; +$true_black = $test->defines['TB_TRUECOLOR_BLACK']; $css_colors = [ 'antiquewhite' => [ 0xfaebd7, $attr_default ], 'aquamarine' => [ 0x7fffd4, $attr_default ], 'beige' => [ 0xf5f5dc, $attr_default ], - 'black' => [ 0x000000, $attr_default ], + 'black' => [ $true_black, $attr_default ], 'blue' => [ 0x0000ff, $attr_default ], 'brown' => [ 0xa52a2a, $attr_default ], 'cadetblue' => [ 0x5f9ea0, $attr_default ], @@ -85,11 +86,11 @@ $css_colors = [ 'whitesmoke' => [ 0xf5f5f5, $attr_default ], 'yellowgreen' => [ 0x9acd32, $attr_default ], 'green on default' => [ 0x00ff00, $attr_default ], - 'black on default' => [ 0x000000, $attr_default ], + 'black on default' => [ $true_black, $attr_default ], 'default on green' => [ $attr_default, 0x00ff00 ], - 'default on black' => [ $attr_default, 0x000000 ], + 'default on black' => [ $attr_default, $true_black ], 'default on default' => [ $attr_default, $attr_default ], - 'default w/ ignored bits' => [ 0x123456 | $attr_default, 0x789abc | $attr_default ], + 'black on black w/ ignored bits' => [ 0x123456 | $true_black, 0x789abc | $true_black ], 'italic on default' => [ $attr_default | $attr_italic, $attr_default ], ]; @@ -137,6 +138,8 @@ for ($r = 0x00; $r <= 0xff; $r += 0xff) { $x = 0; $y++; } + if ($fg == 0) $fg = $true_black; + if ($bg == 0) $bg = $true_black; $test->ffi->tb_print($x, $y, $fg, $bg, $str); $x += $slen; } -- 2.39.5