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.599 by root, Fri Dec 23 21:46:46 2022 UTC vs.
Revision 1.600 by sf-exg, Sun Feb 19 08:48:42 2023 UTC

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 {
3025 string_term st;
3026 st.v[0] = CHAR_ST;
3027 st.v[1] = '\0';
3024 process_xterm_seq (XTerm_title, (char *)RESNAME "-" VERSION, CHAR_ST); // char * cast verified 3028 process_xterm_seq (XTerm_title, (char *)RESNAME "-" VERSION, st); // char * cast verified
3025 break; 3029 break;
3030 }
3026 } 3031 }
3027 break; 3032 break;
3028 3033
3029 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 3034 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
3030 switch (arg[0]) 3035 switch (arg[0])
3215/* 3220/*
3216 * get input up until STRING TERMINATOR (or BEL) 3221 * get input up until STRING TERMINATOR (or BEL)
3217 * ends_how is terminator used. returned input must be free()'d 3222 * ends_how is terminator used. returned input must be free()'d
3218 */ 3223 */
3219char * 3224char *
3220rxvt_term::get_to_st (unicode_t &ends_how) 3225rxvt_term::get_to_st (string_term &st)
3221{ 3226{
3222 unicode_t ch; 3227 unicode_t ch;
3223 bool seen_esc = false; 3228 bool seen_esc = false;
3224 unsigned int n = 0; 3229 unsigned int n = 0;
3225 wchar_t string[CBUFSIZ]; 3230 wchar_t string[CBUFSIZ];
3254 string[n++] = ch; 3259 string[n++] = ch;
3255 } 3260 }
3256 3261
3257 string[n++] = '\0'; 3262 string[n++] = '\0';
3258 3263
3259 ends_how = (ch == 0x5c ? C0_ESC : ch); 3264 n = 0;
3265 if (ch == 0x5c)
3266 st.v[n++] = C0_ESC;
3267 st.v[n++] = ch;
3268 st.v[n] = '\0';
3260 3269
3261 return rxvt_wcstombs (string); 3270 return rxvt_wcstombs (string);
3262} 3271}
3263 3272
3264/*----------------------------------------------------------------------*/ 3273/*----------------------------------------------------------------------*/
3270{ 3279{
3271 /* 3280 /*
3272 * Not handled yet 3281 * Not handled yet
3273 */ 3282 */
3274 3283
3275 unicode_t eh; 3284 string_term st;
3276 char *s = get_to_st (eh); 3285 char *s = get_to_st (st);
3277 if (s) 3286 if (s)
3278 free (s); 3287 free (s);
3279 3288
3280 return; 3289 return;
3281} 3290}
3293 for (arg = 0; isdigit (ch); ch = cmd_getc ()) 3302 for (arg = 0; isdigit (ch); ch = cmd_getc ())
3294 arg = arg * 10 + (ch - '0'); 3303 arg = arg * 10 + (ch - '0');
3295 3304
3296 if (ch == ';') 3305 if (ch == ';')
3297 { 3306 {
3298 unicode_t eh; 3307 string_term st;
3299 char *s = get_to_st (eh); 3308 char *s = get_to_st (st);
3300 3309
3301 if (s) 3310 if (s)
3302 { 3311 {
3303 process_xterm_seq (arg, s, eh); 3312 process_xterm_seq (arg, s, st);
3304 free (s); 3313 free (s);
3305 } 3314 }
3306 } 3315 }
3307} 3316}
3308 3317
3408 3417
3409 return idx; 3418 return idx;
3410} 3419}
3411 3420
3412void 3421void
3413rxvt_term::process_color_seq (int report, int color, const char *str, char resp) 3422rxvt_term::process_color_seq (int report, int color, const char *str, string_term &st)
3414{ 3423{
3415 if (str[0] == '?' && !str[1]) 3424 if (str[0] == '?' && !str[1])
3416 { 3425 {
3417 rgba c; 3426 rgba c;
3418 pix_colors_focused[color].get (c); 3427 pix_colors_focused[color].get (c);
3424 else 3433 else
3425#endif 3434#endif
3426 snprintf (rgba_str, sizeof (rgba_str), "rgb:%04x/%04x/%04x", c.r, c.g, c.b); 3435 snprintf (rgba_str, sizeof (rgba_str), "rgb:%04x/%04x/%04x", c.r, c.g, c.b);
3427 3436
3428 if (IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) 3437 if (IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3429 tt_printf ("\033]%d;%d;%s%c", report, color - minCOLOR, rgba_str, resp); 3438 tt_printf ("\033]%d;%d;%s%s", report, color - minCOLOR, rgba_str, st.v);
3430 else 3439 else
3431 tt_printf ("\033]%d;%s%c", report, rgba_str, resp); 3440 tt_printf ("\033]%d;%s%s", report, rgba_str, st.v);
3432 } 3441 }
3433 else 3442 else
3434 set_window_color (color, str); 3443 set_window_color (color, str);
3435} 3444}
3436 3445
3437/* 3446/*
3438 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3447 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3439 */ 3448 */
3440void 3449void
3441rxvt_term::process_xterm_seq (int op, char *str, char resp) 3450rxvt_term::process_xterm_seq (int op, char *str, string_term &st)
3442{ 3451{
3443 int color; 3452 int color;
3444 char *buf, *name; 3453 char *buf, *name;
3445 bool query = str[0] == '?' && !str[1]; 3454 bool query = str[0] == '?' && !str[1];
3446 int saveop = op; 3455 int saveop = op;
3481 &nitems, &bytes_after, &value) == Success 3490 &nitems, &bytes_after, &value) == Success
3482 && actual_type != None 3491 && actual_type != None
3483 && actual_format == 8) 3492 && actual_format == 8)
3484 str = (const char *)(value); 3493 str = (const char *)(value);
3485 3494
3486 tt_printf ("\033]%d;%s%c", op, option (Opt_insecure) ? str : "", resp); 3495 tt_printf ("\033]%d;%s%s", op, option (Opt_insecure) ? str : "", st.v);
3487 3496
3488 XFree (value); 3497 XFree (value);
3489 } 3498 }
3490 else 3499 else
3491 { 3500 {
3515 break; 3524 break;
3516 3525
3517 if ((buf = strchr (name, ';')) != NULL) 3526 if ((buf = strchr (name, ';')) != NULL)
3518 *buf++ = '\0'; 3527 *buf++ = '\0';
3519 3528
3520 process_color_seq (op, color, name, resp); 3529 process_color_seq (op, color, name, st);
3521 } 3530 }
3522 break; 3531 break;
3523 case Rxvt_restoreFG: 3532 case Rxvt_restoreFG:
3524 case XTerm_Color00: 3533 case XTerm_Color00:
3525 process_color_seq (op, Color_fg, str, resp); 3534 process_color_seq (op, Color_fg, str, st);
3526 break; 3535 break;
3527 case Rxvt_restoreBG: 3536 case Rxvt_restoreBG:
3528 case XTerm_Color01: 3537 case XTerm_Color01:
3529 process_color_seq (op, Color_bg, str, resp); 3538 process_color_seq (op, Color_bg, str, st);
3530 break; 3539 break;
3531#ifndef NO_CURSORCOLOR 3540#ifndef NO_CURSORCOLOR
3532 case XTerm_Color_cursor: 3541 case XTerm_Color_cursor:
3533 process_color_seq (op, Color_cursor, str, resp); 3542 process_color_seq (op, Color_cursor, str, st);
3534 break; 3543 break;
3535#endif 3544#endif
3536 case XTerm_Color_pointer_fg: 3545 case XTerm_Color_pointer_fg:
3537 process_color_seq (op, Color_pointer_fg, str, resp); 3546 process_color_seq (op, Color_pointer_fg, str, st);
3538 break; 3547 break;
3539 case XTerm_Color_pointer_bg: 3548 case XTerm_Color_pointer_bg:
3540 process_color_seq (op, Color_pointer_bg, str, resp); 3549 process_color_seq (op, Color_pointer_bg, str, st);
3541 break; 3550 break;
3542#ifdef OPTION_HC 3551#ifdef OPTION_HC
3543 case XTerm_Color_HC: 3552 case XTerm_Color_HC:
3544 process_color_seq (op, Color_HC, str, resp); 3553 process_color_seq (op, Color_HC, str, st);
3545 break; 3554 break;
3546 case XTerm_Color_HTC: 3555 case XTerm_Color_HTC:
3547 process_color_seq (op, Color_HTC, str, resp); 3556 process_color_seq (op, Color_HTC, str, st);
3548 break; 3557 break;
3549#endif 3558#endif
3550#ifndef NO_BOLD_UNDERLINE_REVERSE 3559#ifndef NO_BOLD_UNDERLINE_REVERSE
3551 case URxvt_Color_BD: 3560 case URxvt_Color_BD:
3552 process_color_seq (op, Color_BD, str, resp); 3561 process_color_seq (op, Color_BD, str, st);
3553 break; 3562 break;
3554 case URxvt_Color_UL: 3563 case URxvt_Color_UL:
3555 process_color_seq (op, Color_UL, str, resp); 3564 process_color_seq (op, Color_UL, str, st);
3556 break; 3565 break;
3557 case URxvt_Color_IT: 3566 case URxvt_Color_IT:
3558 process_color_seq (op, Color_IT, str, resp); 3567 process_color_seq (op, Color_IT, str, st);
3559 break; 3568 break;
3560#endif 3569#endif
3561 case URxvt_Color_border: 3570 case URxvt_Color_border:
3562 process_color_seq (op, Color_border, str, resp); 3571 process_color_seq (op, Color_border, str, st);
3563 break; 3572 break;
3564 3573
3565 case XTerm_logfile: 3574 case XTerm_logfile:
3566 // TODO, when secure mode? 3575 // TODO, when secure mode?
3567 break; 3576 break;
3585 case URxvt_boldFont: 3594 case URxvt_boldFont:
3586 case URxvt_italicFont: 3595 case URxvt_italicFont:
3587 case URxvt_boldItalicFont: 3596 case URxvt_boldItalicFont:
3588#endif 3597#endif
3589 if (query) 3598 if (query)
3590 tt_printf ("\33]%d;%-.250s%c", saveop, 3599 tt_printf ("\33]%d;%-.250s%s", saveop,
3591 option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc 3600 option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc
3592 ? fontset[op - URxvt_font]->fontdesc : "", 3601 ? fontset[op - URxvt_font]->fontdesc : "",
3593 resp); 3602 st.v);
3594 else 3603 else
3595 { 3604 {
3596 const char *&res = rs[Rs_font + (op - URxvt_font)]; 3605 const char *&res = rs[Rs_font + (op - URxvt_font)];
3597 3606
3598 res = strdup (str); 3607 res = strdup (str);
3601 } 3610 }
3602 break; 3611 break;
3603 3612
3604 case URxvt_version: 3613 case URxvt_version:
3605 if (query) 3614 if (query)
3606 tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", 3615 tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%s",
3607 op, 3616 op,
3608 rs[Rs_name], VERSION[0], VERSION[2], 3617 rs[Rs_name], VERSION[0], VERSION[2],
3609 resp); 3618 st.v);
3610 break; 3619 break;
3611 3620
3612#if !ENABLE_MINIMAL 3621#if !ENABLE_MINIMAL
3613 case URxvt_cellinfo: 3622 case URxvt_cellinfo:
3614 if (query) 3623 if (query)
3615 tt_printf ("\33]%d;%d;%d;%d%c", saveop, 3624 tt_printf ("\33]%d;%d;%d;%d%s", saveop,
3616 fwidth, fheight, fbase, 3625 fwidth, fheight, fbase,
3617 resp); 3626 st.v);
3618 break; 3627 break;
3619 3628
3620 case URxvt_locale: 3629 case URxvt_locale:
3621 if (query) 3630 if (query)
3622 tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); 3631 tt_printf ("\33]%d;%-.250s%s", op, option (Opt_insecure) ? locale : "", st.v);
3623 else 3632 else
3624 { 3633 {
3625 set_locale (str); 3634 set_locale (str);
3626 pty->set_utf8_mode (enc_utf8); 3635 pty->set_utf8_mode (enc_utf8);
3627 init_xlocale (); 3636 init_xlocale ();
3642 break; 3651 break;
3643#endif 3652#endif
3644 3653
3645#if ENABLE_PERL 3654#if ENABLE_PERL
3646 case URxvt_perl: 3655 case URxvt_perl:
3647 HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END)); 3656 HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR, st.v, DT_END));
3648 break; 3657 break;
3649#endif 3658#endif
3650 } 3659 }
3651} 3660}
3652/*----------------------------------------------------------------------*/ 3661/*----------------------------------------------------------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines