--- rxvt-unicode/src/command.C 2021/05/09 15:48:26 1.589 +++ rxvt-unicode/src/command.C 2021/11/21 23:36:36 1.596 @@ -27,7 +27,7 @@ * Copyright (c) 2001 Marius Gedminas * - Ctrl/Mod4+Tab works like Meta+Tab (options) * Copyright (c) 2003 Rob McMullen - * Copyright (c) 2003-2014 Marc Lehmann + * Copyright (c) 2003-2021 Marc Lehmann * Copyright (c) 2007,2015 Emanuele Giaquinta * * This program is free software; you can redistribute it and/or modify @@ -170,7 +170,7 @@ # if ENABLE_COMBINING if (IS_COMPOSE (ch)) { - len = rxvt_composite.expand (ch, 0); + len = rxvt_composite.expand (ch); alloc = chr = new wchar_t[len]; rxvt_composite.expand (ch, chr); } @@ -2354,7 +2354,7 @@ // read the next character wchar_t ecb_hot -rxvt_term::next_char () NOTHROW +rxvt_term::next_char () noexcept { while (cmdbuf_ptr < cmdbuf_endp) { @@ -2390,7 +2390,7 @@ // read the next octet uint32_t ecb_hot -rxvt_term::next_octet () NOTHROW +rxvt_term::next_octet () noexcept { return cmdbuf_ptr < cmdbuf_endp ? (unsigned char)*cmdbuf_ptr++ @@ -2400,7 +2400,7 @@ static class out_of_input out_of_input; wchar_t ecb_hot -rxvt_term::cmd_getc () THROW ((class out_of_input)) +rxvt_term::cmd_getc () { wchar_t c = next_char (); @@ -2411,7 +2411,7 @@ } uint32_t ecb_hot -rxvt_term::cmd_get8 () THROW ((class out_of_input)) +rxvt_term::cmd_get8 () { uint32_t c = next_octet (); @@ -3021,7 +3021,7 @@ tt_printf ("%-.250s\012", rs[Rs_display_name]); break; case 8: /* unofficial extension */ - process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); + process_xterm_seq (XTerm_title, (char *)RESNAME "-" VERSION, CHAR_ST); // char * cast verified break; } break; @@ -3334,34 +3334,42 @@ uint32_t color = (a << 24) | (r << 16) | (g << 8) | b; - unsigned int idx_r = r * (Red_levels - 1) / 0xff; - unsigned int idx_g = g * (Green_levels - 1) / 0xff; - unsigned int idx_b = b * (Blue_levels - 1) / 0xff; - unsigned int idx = colorcube_index (idx_r, idx_g, idx_b); - - /* we allow one of the 6 directly neighbouring colours */ + /* we allow one of the 6 closest neighbouring colours */ /* to replace the current color, if they not used recently */ static const signed char dxyz[][3] = { - 0, 0, 0, - 0, 0, +1, - 0, 0, -1, - 0, +1, 0, - 0, -1, 0, - +1, 0, 0, - -1, 0, 0, + 0, 0, 0, + 0, 0, 4, + 0, 4, 0, + 4, 0, 0, + 0, 4, 4, + 4, 4, 0, + 4, 0, 4, + }; + + static const unsigned char color_level[8][32] = { + // neighbour index + {0, 0, 1, 0, 0, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}, + {0, 1, 0, 1, 1, 2, 1, 1, 2, 2, 3, 3, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4}, + {0, 0, 1, 2, 1, 1, 2, 3, 3, 2, 2, 3, 3, 4, 4, 3, 3, 3, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 5, 5, 5, 5}, + {0, 0, 2, 1, 2, 3, 2, 2, 3, 4, 4, 3, 3, 4, 4, 5, 5, 4, 4, 5, 5, 5, 6, 6, 5, 5, 5, 6, 6, 6, 6, 6}, + // Red_levels/Green_levels/Blue_levels index + {0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, + {0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, + {0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5}, + {0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6}, }; + unsigned int idx; + for (int n = 0; n < ecb_array_length (dxyz); ++n) { - int r = idx_r + dxyz[n][0]; - int g = idx_g + dxyz[n][1]; - int b = idx_b + dxyz[n][2]; - - if (!IN_RANGE_EXC (r, 0, Red_levels )) continue; - if (!IN_RANGE_EXC (g, 0, Green_levels)) continue; - if (!IN_RANGE_EXC (b, 0, Blue_levels )) continue; + unsigned int idx_r = color_level[ Red_levels - dxyz[n][0]][r / 8]; + unsigned int idx_g = color_level[Green_levels - dxyz[n][1]][g / 8]; + unsigned int idx_b = color_level[ Blue_levels - dxyz[n][2]][b / 8]; + unsigned int index = colorcube_index (idx_r, idx_g, idx_b); - unsigned int index = colorcube_index (r, g, b); + if (n == 0) + idx = index; if (rgb24_color[index] == color) { @@ -3593,6 +3601,13 @@ break; #if !ENABLE_MINIMAL + case URxvt_cellinfo: + if (query) + tt_printf ("\33]%d;%d;%d;%d%c", saveop, + fwidth, fheight, fbase, + resp); + break; + case URxvt_locale: if (query) tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); @@ -3725,7 +3740,9 @@ // 1048 save and restore cursor, implemented in code { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ // 1051, 1052, 1060, 1061 keyboard emulation NYI +#if ENABLE_FRILLS { 2004, PrivMode_BracketPaste }, +#endif }; if (nargs == 0)