… | |
… | |
168 | int len; |
168 | int len; |
169 | |
169 | |
170 | # if ENABLE_COMBINING |
170 | # if ENABLE_COMBINING |
171 | if (IS_COMPOSE (ch)) |
171 | if (IS_COMPOSE (ch)) |
172 | { |
172 | { |
173 | len = rxvt_composite.expand (ch, 0); |
173 | len = rxvt_composite.expand (ch); |
174 | alloc = chr = new wchar_t[len]; |
174 | alloc = chr = new wchar_t[len]; |
175 | rxvt_composite.expand (ch, chr); |
175 | rxvt_composite.expand (ch, chr); |
176 | } |
176 | } |
177 | else |
177 | else |
178 | # endif |
178 | # endif |
… | |
… | |
2352 | } |
2352 | } |
2353 | } |
2353 | } |
2354 | |
2354 | |
2355 | // read the next character |
2355 | // read the next character |
2356 | wchar_t ecb_hot |
2356 | wchar_t ecb_hot |
2357 | rxvt_term::next_char () NOTHROW |
2357 | rxvt_term::next_char () noexcept |
2358 | { |
2358 | { |
2359 | while (cmdbuf_ptr < cmdbuf_endp) |
2359 | while (cmdbuf_ptr < cmdbuf_endp) |
2360 | { |
2360 | { |
2361 | // assume 7-bit to be ascii ALWAYS (always true in POSIX) |
2361 | // assume 7-bit to be ascii ALWAYS (always true in POSIX) |
2362 | if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f)) |
2362 | if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f)) |
… | |
… | |
2388 | return NOCHAR; |
2388 | return NOCHAR; |
2389 | } |
2389 | } |
2390 | |
2390 | |
2391 | // read the next octet |
2391 | // read the next octet |
2392 | uint32_t ecb_hot |
2392 | uint32_t ecb_hot |
2393 | rxvt_term::next_octet () NOTHROW |
2393 | rxvt_term::next_octet () noexcept |
2394 | { |
2394 | { |
2395 | return cmdbuf_ptr < cmdbuf_endp |
2395 | return cmdbuf_ptr < cmdbuf_endp |
2396 | ? (unsigned char)*cmdbuf_ptr++ |
2396 | ? (unsigned char)*cmdbuf_ptr++ |
2397 | : NOCHAR; |
2397 | : NOCHAR; |
2398 | } |
2398 | } |
2399 | |
2399 | |
2400 | static class out_of_input out_of_input; |
2400 | static class out_of_input out_of_input; |
2401 | |
2401 | |
2402 | wchar_t ecb_hot |
2402 | wchar_t ecb_hot |
2403 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2403 | rxvt_term::cmd_getc () |
2404 | { |
2404 | { |
2405 | wchar_t c = next_char (); |
2405 | wchar_t c = next_char (); |
2406 | |
2406 | |
2407 | if (c == NOCHAR) |
2407 | if (c == NOCHAR) |
2408 | throw out_of_input; |
2408 | throw out_of_input; |
2409 | |
2409 | |
2410 | return c; |
2410 | return c; |
2411 | } |
2411 | } |
2412 | |
2412 | |
2413 | uint32_t ecb_hot |
2413 | uint32_t ecb_hot |
2414 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2414 | rxvt_term::cmd_get8 () |
2415 | { |
2415 | { |
2416 | uint32_t c = next_octet (); |
2416 | uint32_t c = next_octet (); |
2417 | |
2417 | |
2418 | if (c == NOCHAR) |
2418 | if (c == NOCHAR) |
2419 | throw out_of_input; |
2419 | throw out_of_input; |
… | |
… | |
3019 | case 7: /* unofficial extension */ |
3019 | case 7: /* unofficial extension */ |
3020 | if (option (Opt_insecure)) |
3020 | if (option (Opt_insecure)) |
3021 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3021 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3022 | break; |
3022 | break; |
3023 | case 8: /* unofficial extension */ |
3023 | case 8: /* unofficial extension */ |
3024 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3024 | process_xterm_seq (XTerm_title, (char *)RESNAME "-" VERSION, CHAR_ST); // char * cast verified |
3025 | break; |
3025 | break; |
3026 | } |
3026 | } |
3027 | break; |
3027 | break; |
3028 | |
3028 | |
3029 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
3029 | case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ |
… | |
… | |
3332 | b &= 0xff; |
3332 | b &= 0xff; |
3333 | a &= 0xff; |
3333 | a &= 0xff; |
3334 | |
3334 | |
3335 | uint32_t color = (a << 24) | (r << 16) | (g << 8) | b; |
3335 | uint32_t color = (a << 24) | (r << 16) | (g << 8) | b; |
3336 | |
3336 | |
3337 | unsigned int idx_r = r * (Red_levels - 1) / 0xff; |
|
|
3338 | unsigned int idx_g = g * (Green_levels - 1) / 0xff; |
|
|
3339 | unsigned int idx_b = b * (Blue_levels - 1) / 0xff; |
|
|
3340 | unsigned int idx = colorcube_index (idx_r, idx_g, idx_b); |
|
|
3341 | |
|
|
3342 | /* we allow one of the 6 directly neighbouring colours */ |
3337 | /* we allow one of the 6 closest neighbouring colours */ |
3343 | /* to replace the current color, if they not used recently */ |
3338 | /* to replace the current color, if they not used recently */ |
3344 | static const signed char dxyz[][3] = { |
3339 | static const signed char dxyz[][3] = { |
3345 | 0, 0, 0, |
3340 | 0, 0, 0, |
3346 | 0, 0, +1, |
3341 | 0, 0, 4, |
3347 | 0, 0, -1, |
|
|
3348 | 0, +1, 0, |
3342 | 0, 4, 0, |
3349 | 0, -1, 0, |
|
|
3350 | +1, 0, 0, |
3343 | 4, 0, 0, |
3351 | -1, 0, 0, |
3344 | 0, 4, 4, |
|
|
3345 | 4, 4, 0, |
|
|
3346 | 4, 0, 4, |
3352 | }; |
3347 | }; |
3353 | |
3348 | |
|
|
3349 | static const unsigned char color_level[8][32] = { |
|
|
3350 | // neighbour index |
|
|
3351 | {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}, |
|
|
3352 | {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}, |
|
|
3353 | {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}, |
|
|
3354 | {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}, |
|
|
3355 | // Red_levels/Green_levels/Blue_levels index |
|
|
3356 | {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}, |
|
|
3357 | {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}, |
|
|
3358 | {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}, |
|
|
3359 | {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}, |
|
|
3360 | }; |
|
|
3361 | |
|
|
3362 | unsigned int idx; |
|
|
3363 | |
3354 | for (int n = 0; n < ecb_array_length (dxyz); ++n) |
3364 | for (int n = 0; n < ecb_array_length (dxyz); ++n) |
3355 | { |
3365 | { |
3356 | int r = idx_r + dxyz[n][0]; |
3366 | unsigned int idx_r = color_level[ Red_levels - dxyz[n][0]][r / 8]; |
3357 | int g = idx_g + dxyz[n][1]; |
3367 | unsigned int idx_g = color_level[Green_levels - dxyz[n][1]][g / 8]; |
3358 | int b = idx_b + dxyz[n][2]; |
3368 | unsigned int idx_b = color_level[ Blue_levels - dxyz[n][2]][b / 8]; |
3359 | |
|
|
3360 | if (!IN_RANGE_EXC (r, 0, Red_levels )) continue; |
|
|
3361 | if (!IN_RANGE_EXC (g, 0, Green_levels)) continue; |
|
|
3362 | if (!IN_RANGE_EXC (b, 0, Blue_levels )) continue; |
|
|
3363 | |
|
|
3364 | unsigned int index = colorcube_index (r, g, b); |
3369 | unsigned int index = colorcube_index (idx_r, idx_g, idx_b); |
|
|
3370 | |
|
|
3371 | if (n == 0) |
|
|
3372 | idx = index; |
3365 | |
3373 | |
3366 | if (rgb24_color[index] == color) |
3374 | if (rgb24_color[index] == color) |
3367 | { |
3375 | { |
3368 | rgb24_seqno[index] = ++rgb24_sequence; |
3376 | rgb24_seqno[index] = ++rgb24_sequence; |
3369 | return index + minTermCOLOR24; |
3377 | return index + minTermCOLOR24; |