ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.587 by sf-exg, Sat May 8 06:16:21 2021 UTC vs.
Revision 1.597 by root, Sun Jun 26 15:45:48 2022 UTC

25 * - extensive modifications 25 * - extensive modifications
26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> 26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org>
27 * Copyright (c) 2001 Marius Gedminas 27 * Copyright (c) 2001 Marius Gedminas
28 * - Ctrl/Mod4+Tab works like Meta+Tab (options) 28 * - Ctrl/Mod4+Tab works like Meta+Tab (options)
29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> 29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org>
30 * Copyright (c) 2003-2014 Marc Lehmann <schmorp@schmorp.de> 30 * Copyright (c) 2003-2021 Marc Lehmann <schmorp@schmorp.de>
31 * Copyright (c) 2007,2015 Emanuele Giaquinta <e.giaquinta@glauco.it> 31 * Copyright (c) 2007,2015 Emanuele Giaquinta <e.giaquinta@glauco.it>
32 * 32 *
33 * This program is free software; you can redistribute it and/or modify 33 * This program is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by 34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 3 of the License, or 35 * the Free Software Foundation; either version 3 of the License, or
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
2356wchar_t ecb_hot 2356wchar_t ecb_hot
2357rxvt_term::next_char () NOTHROW 2357rxvt_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
2392uint32_t ecb_hot 2392uint32_t ecb_hot
2393rxvt_term::next_octet () NOTHROW 2393rxvt_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
2400static class out_of_input out_of_input; 2400static class out_of_input out_of_input;
2401 2401
2402wchar_t ecb_hot 2402wchar_t ecb_hot
2403rxvt_term::cmd_getc () THROW ((class out_of_input)) 2403rxvt_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
2413uint32_t ecb_hot 2413uint32_t ecb_hot
2414rxvt_term::cmd_get8 () THROW ((class out_of_input)) 2414rxvt_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;
2866 } 2866 }
2867 break; 2867 break;
2868 2868
2869 case '?': 2869 case '?':
2870 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2870 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
2871 process_terminal_mode (ch, priv, nargs, arg);
2872 if (prev_ch == '$' && ch == 'p')
2871 process_terminal_mode (ch, priv, nargs, arg); 2873 process_terminal_mode (ch, priv, nargs, arg);
2872 break; 2874 break;
2873 2875
2874 case '!': 2876 case '!':
2875 if (ch == CSI_70) 2877 if (ch == CSI_70)
3017 case 7: /* unofficial extension */ 3019 case 7: /* unofficial extension */
3018 if (option (Opt_insecure)) 3020 if (option (Opt_insecure))
3019 tt_printf ("%-.250s\012", rs[Rs_display_name]); 3021 tt_printf ("%-.250s\012", rs[Rs_display_name]);
3020 break; 3022 break;
3021 case 8: /* unofficial extension */ 3023 case 8: /* unofficial extension */
3022 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); 3024 process_xterm_seq (XTerm_title, (char *)RESNAME "-" VERSION, CHAR_ST); // char * cast verified
3023 break; 3025 break;
3024 } 3026 }
3025 break; 3027 break;
3026 3028
3027 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 3029 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
3330 b &= 0xff; 3332 b &= 0xff;
3331 a &= 0xff; 3333 a &= 0xff;
3332 3334
3333 uint32_t color = (a << 24) | (r << 16) | (g << 8) | b; 3335 uint32_t color = (a << 24) | (r << 16) | (g << 8) | b;
3334 3336
3335 unsigned int idx_r = r * (Red_levels - 1) / 0xff;
3336 unsigned int idx_g = g * (Green_levels - 1) / 0xff;
3337 unsigned int idx_b = b * (Blue_levels - 1) / 0xff;
3338 unsigned int idx = colorcube_index (idx_r, idx_g, idx_b);
3339
3340 /* we allow one of the 6 directly neighbouring colours */ 3337 /* we allow one of the 6 closest neighbouring colours */
3341 /* to replace the current color, if they not used recently */ 3338 /* to replace the current color, if they not used recently */
3339 #if 0
3342 static const signed char dxyz[][3] = { 3340 static const unsigned char dxyz[][3] = {
3343 0, 0, 0, 3341 0, 0, 0,
3344 0, 0, +1, 3342 0, 0, 4,
3345 0, 0, -1, 3343 0, 4, 4,
3344 4, 4, 0,
3345 4, 0, 4,
3346 0, +1, 0, 3346 0, 4, 0,
3347 0, -1, 0,
3348 +1, 0, 0, 3347 4, 0, 0,
3349 -1, 0, 0,
3350 }; 3348 };
3349 #else
3350 // silly compressed verlapping triplets version of above
3351 static const unsigned char dxyz[] = {
3352 0, 0, 0, 4, 4, 0, 4, 0, 0,
3353 };
3354 #endif
3351 3355
3356 static const unsigned char color_level[8][32] = {
3357 // neighbour index
3358 {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},
3359 {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},
3360 {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},
3361 {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},
3362 // Red_levels/Green_levels/Blue_levels index
3363 {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},
3364 {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},
3365 {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},
3366 {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},
3367 };
3368
3369 unsigned int idx;
3370
3352 for (int n = 0; n < ecb_array_length (dxyz); ++n) 3371 for (int n = 0; n < ecb_array_length (dxyz) - 2; ++n)
3353 { 3372 {
3354 int r = idx_r + dxyz[n][0]; 3373 unsigned int idx_r = color_level[ Red_levels - dxyz[n + 0]][r / 8];
3355 int g = idx_g + dxyz[n][1]; 3374 unsigned int idx_g = color_level[Green_levels - dxyz[n + 1]][g / 8];
3356 int b = idx_b + dxyz[n][2]; 3375 unsigned int idx_b = color_level[ Blue_levels - dxyz[n + 2]][b / 8];
3357
3358 if (!IN_RANGE_EXC (r, 0, Red_levels )) continue;
3359 if (!IN_RANGE_EXC (g, 0, Green_levels)) continue;
3360 if (!IN_RANGE_EXC (b, 0, Blue_levels )) continue;
3361
3362 unsigned int index = colorcube_index (r, g, b); 3376 unsigned int index = colorcube_index (idx_r, idx_g, idx_b);
3377
3378 if (n == 0)
3379 idx = index;
3363 3380
3364 if (rgb24_color[index] == color) 3381 if (rgb24_color[index] == color)
3365 { 3382 {
3366 rgb24_seqno[index] = ++rgb24_sequence; 3383 rgb24_seqno[index] = ++rgb24_sequence;
3367 return index + minTermCOLOR24; 3384 return index + minTermCOLOR24;
3373 idx = index; 3390 idx = index;
3374 goto update; 3391 goto update;
3375 } 3392 }
3376 3393
3377 // like (rgb24_seqno[idx] > rgb24_seqno[index]) 3394 // like (rgb24_seqno[idx] > rgb24_seqno[index])
3378 // but also handles wrap around values good enough 3395 // but also handles wrap around values well enough
3379 if ((uint16_t)(rgb24_seqno[idx] - rgb24_seqno[index]) < 0x7fff) 3396 if ((uint16_t)(rgb24_seqno[idx] - rgb24_seqno[index]) < 0x8000)
3380 idx = index; 3397 idx = index;
3381 } 3398 }
3382 3399
3383update: 3400update:
3384 rgb24_color[idx] = color; 3401 rgb24_color[idx] = color;
3395void 3412void
3396rxvt_term::process_color_seq (int report, int color, const char *str, char resp) 3413rxvt_term::process_color_seq (int report, int color, const char *str, char resp)
3397{ 3414{
3398 if (str[0] == '?' && !str[1]) 3415 if (str[0] == '?' && !str[1])
3399 { 3416 {
3417 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3418 return;
3419
3400 rgba c; 3420 rgba c;
3401 pix_colors_focused[color].get (c); 3421 pix_colors_focused[color].get (c);
3422 color -= minCOLOR;
3402 3423
3403#if XFT 3424#if XFT
3404 if (c.a != rgba::MAX_CC) 3425 if (c.a != rgba::MAX_CC)
3405 tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.r, c.g, c.b, c.a, resp); 3426 tt_printf ("\033]%d;%d;rgba:%04x/%04x/%04x/%04x%c", report, color, c.r, c.g, c.b, c.a, resp);
3406 else 3427 else
3407#endif 3428#endif
3408 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); 3429 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", report, color, c.r, c.g, c.b, resp);
3409 } 3430 }
3410 else 3431 else
3411 set_window_color (color, str); 3432 set_window_color (color, str);
3412} 3433}
3413 3434
3585 rs[Rs_name], VERSION[0], VERSION[2], 3606 rs[Rs_name], VERSION[0], VERSION[2],
3586 resp); 3607 resp);
3587 break; 3608 break;
3588 3609
3589#if !ENABLE_MINIMAL 3610#if !ENABLE_MINIMAL
3611 case URxvt_cellinfo:
3612 if (query)
3613 tt_printf ("\33]%d;%d;%d;%d%c", saveop,
3614 fwidth, fheight, fbase,
3615 resp);
3616 break;
3617
3590 case URxvt_locale: 3618 case URxvt_locale:
3591 if (query) 3619 if (query)
3592 tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); 3620 tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp);
3593 else 3621 else
3594 { 3622 {
3717 // 1037 send DEL for keypad delete NYI 3745 // 1037 send DEL for keypad delete NYI
3718 { 1047, PrivMode_Screen }, 3746 { 1047, PrivMode_Screen },
3719 // 1048 save and restore cursor, implemented in code 3747 // 1048 save and restore cursor, implemented in code
3720 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ 3748 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
3721 // 1051, 1052, 1060, 1061 keyboard emulation NYI 3749 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3750#if ENABLE_FRILLS
3722 { 2004, PrivMode_BracketPaste }, 3751 { 2004, PrivMode_BracketPaste },
3752#endif
3723 }; 3753 };
3724 3754
3725 if (nargs == 0) 3755 if (nargs == 0)
3726 return; 3756 return;
3757
3758 // DECRQM
3759 if (mode == 'p')
3760 {
3761 int status = 0;
3762 if (nargs != 1)
3763 return;
3764
3765 for (j = 0; j < ecb_array_length (argtopriv); j++)
3766 if (argtopriv[j].argval == arg[0])
3767 {
3768 status = (priv_modes & argtopriv[j].bit) ? 1 : 2;
3769 break;
3770 }
3771
3772 tt_printf ("\33[?%d;%d$y", arg[0], status);
3773 return;
3774 }
3727 3775
3728 /* make lo/hi boolean */ 3776 /* make lo/hi boolean */
3729 if (mode == 'l') 3777 if (mode == 'l')
3730 mode = 0; /* reset */ 3778 mode = 0; /* reset */
3731 else if (mode == 'h') 3779 else if (mode == 'h')

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines