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.584 by root, Sun Jul 7 08:02:15 2019 UTC vs.
Revision 1.589 by sf-exg, Sun May 9 15:48:26 2021 UTC

1277#endif 1277#endif
1278 1278
1279void 1279void
1280rxvt_term::mouse_report (XButtonEvent &ev) 1280rxvt_term::mouse_report (XButtonEvent &ev)
1281{ 1281{
1282 int button_number, key_state = 0; 1282 int button_number, state = 0;
1283 int x, y; 1283 int x, y;
1284 int code = 32; 1284 bool release = ev.type == ButtonRelease;
1285 1285
1286 x = Pixel2Col (ev.x) + 1; 1286 x = Pixel2Col (ev.x) + 1;
1287 y = Pixel2Row (ev.y) + 1; 1287 y = Pixel2Row (ev.y) + 1;
1288 1288
1289 if (ev.type == MotionNotify) 1289 if (ev.type == MotionNotify)
1291 if (x == mouse_row && y == mouse_col) 1291 if (x == mouse_row && y == mouse_col)
1292 return; 1292 return;
1293 1293
1294 mouse_row = x; 1294 mouse_row = x;
1295 mouse_col = y; 1295 mouse_col = y;
1296 code += 32; 1296 state += 32;
1297 }
1298
1299 if (MEvent.button == AnyButton)
1300 button_number = 3;
1301 else
1302 { 1297 }
1298
1303 button_number = MEvent.button - Button1; 1299 button_number = MEvent.button - Button1;
1304 /* add 0x3D for wheel events, like xterm does */ 1300 /* add 0x3D for wheel events, like xterm does */
1305 if (button_number >= 3) 1301 if (button_number >= 3)
1306 button_number += 64 - 3; 1302 button_number += 64 - 3;
1307 }
1308 1303
1309 if (priv_modes & PrivMode_MouseX10) 1304 if (priv_modes & PrivMode_MouseX10)
1310 { 1305 {
1311 /* 1306 /*
1312 * do not report ButtonRelease 1307 * do not report ButtonRelease
1313 * no state info allowed 1308 * no state info allowed
1314 */ 1309 */
1315 key_state = 0; 1310 if (release)
1316 if (button_number == 3)
1317 return; 1311 return;
1318 } 1312 }
1319 else 1313 else
1320 { 1314 {
1321 /* XTerm mouse reporting needs these values: 1315 /* XTerm mouse reporting needs these values:
1323 * 8 = Meta 1317 * 8 = Meta
1324 * 16 = Control 1318 * 16 = Control
1325 * plus will add in our own Double-Click reporting 1319 * plus will add in our own Double-Click reporting
1326 * 32 = Double Click 1320 * 32 = Double Click
1327 */ 1321 */
1328 key_state = ((MEvent.state & ShiftMask) ? 4 : 0) 1322 state += ((MEvent.state & ShiftMask) ? 4 : 0)
1329 + ((MEvent.state & ModMetaMask) ? 8 : 0) 1323 + ((MEvent.state & ModMetaMask) ? 8 : 0)
1330 + ((MEvent.state & ControlMask) ? 16 : 0); 1324 + ((MEvent.state & ControlMask) ? 16 : 0);
1331#ifdef MOUSE_REPORT_DOUBLECLICK 1325#ifdef MOUSE_REPORT_DOUBLECLICK
1332 key_state += ((MEvent.clicks > 1) ? 32 : 0); 1326 state += ((MEvent.clicks > 1) ? 32 : 0);
1333#endif 1327#endif
1334 } 1328 }
1329
1330 int code = 32 + (release ? 3 : button_number) + state;
1335 1331
1336#if DEBUG_MOUSEREPORT 1332#if DEBUG_MOUSEREPORT
1337 fprintf (stderr, "Mouse ["); 1333 fprintf (stderr, "Mouse [");
1338 if (key_state & 16) 1334 if (state & 16)
1339 fputc ('C', stderr); 1335 fputc ('C', stderr);
1340 if (key_state & 4) 1336 if (state & 4)
1341 fputc ('S', stderr); 1337 fputc ('S', stderr);
1342 if (key_state & 8) 1338 if (state & 8)
1343 fputc ('A', stderr); 1339 fputc ('A', stderr);
1344 if (key_state & 32) 1340 if (state & 32)
1345 fputc ('2', stderr); 1341 fputc ('2', stderr);
1346 fprintf (stderr, "]: <%d>, %d/%d\n", 1342 fprintf (stderr, "]: <%d>, %d/%d\n",
1347 button_number, 1343 button_number,
1348 x, 1344 x,
1349 y); 1345 y);
1350#endif 1346#endif
1351 1347
1352#if ENABLE_FRILLS 1348#if ENABLE_FRILLS
1353 if (priv_modes & PrivMode_ExtMouseRight) 1349 if (priv_modes & PrivMode_ExtMouseSGR)
1350 tt_printf ("\033[<%d;%d;%d%c",
1351 button_number + state,
1352 x,
1353 y,
1354 release ? 'm' : 'M');
1355 else if (priv_modes & PrivMode_ExtMouseUrxvt)
1354 tt_printf ("\033[%d;%d;%dM", 1356 tt_printf ("\033[%d;%d;%dM",
1355 code + button_number + key_state, 1357 code,
1356 x, 1358 x,
1357 y); 1359 y);
1358 else if (priv_modes & PrivMode_ExtModeMouse) 1360 else if (priv_modes & PrivMode_ExtMouseUTF8)
1359 tt_printf ("\033[M%c%lc%lc", 1361 tt_printf ("\033[M%c%lc%lc",
1360 code + button_number + key_state, 1362 code,
1361 wint_t (32 + x), 1363 wint_t (32 + x),
1362 wint_t (32 + y)); 1364 wint_t (32 + y));
1363 else 1365 else
1364#endif 1366#endif
1365 tt_printf ("\033[M%c%c%c", 1367 tt_printf ("\033[M%c%c%c",
1366 code + button_number + key_state, 1368 code,
1367 32 + x, 1369 32 + x,
1368 32 + y); 1370 32 + y);
1369} 1371}
1370 1372
1371/*{{{ process an X event */ 1373/*{{{ process an X event */
2149 && (ev.button != MEvent.button 2151 && (ev.button != MEvent.button
2150 || (ev.time - MEvent.time 2152 || (ev.time - MEvent.time
2151 > multiClickTime / 2))) 2153 > multiClickTime / 2)))
2152 { 2154 {
2153 MEvent.clicks = 0; 2155 MEvent.clicks = 0;
2154 MEvent.button = AnyButton; 2156 MEvent.button = ev.button;
2155 mouse_report (ev); 2157 mouse_report (ev);
2156 } 2158 }
2157#else /* MOUSE_REPORT_DOUBLECLICK */ 2159#else /* MOUSE_REPORT_DOUBLECLICK */
2158 MEvent.button = AnyButton; 2160 MEvent.button = ev.button;
2159 mouse_report (ev); 2161 mouse_report (ev);
2160#endif /* MOUSE_REPORT_DOUBLECLICK */ 2162#endif /* MOUSE_REPORT_DOUBLECLICK */
2161 return; 2163 return;
2162 } 2164 }
2163 2165
2690 wchar_t nlcr[] = { C0_LF, C0_CR }; 2692 wchar_t nlcr[] = { C0_LF, C0_CR };
2691 scr_add_lines (nlcr, ecb_array_length (nlcr), 1); 2693 scr_add_lines (nlcr, ecb_array_length (nlcr), 1);
2692 } 2694 }
2693 break; 2695 break;
2694 2696
2697#if 0 // disabled because embedded newlines can make exploits easier
2695 /* kidnapped escape sequence: Should be 8.3.48 */ 2698 /* kidnapped escape sequence: Should be 8.3.48 */
2696 case C1_ESA: /* ESC G */ 2699 case C1_ESA: /* ESC G */
2697 // used by original rxvt for rob nations own graphics mode 2700 // used by original rxvt for rob nations own graphics mode
2698 if (cmd_getc () == 'Q' && option (Opt_insecure)) 2701 if (cmd_getc () == 'Q' && option (Opt_insecure))
2699 tt_printf ("\033G0\012"); /* query graphics - no graphics */ 2702 tt_printf ("\033G0\012"); /* query graphics - no graphics */
2700 break; 2703 break;
2704#endif
2701 2705
2702 /* 8.3.63: CHARACTER TABULATION SET */ 2706 /* 8.3.63: CHARACTER TABULATION SET */
2703 case C1_HTS: /* ESC H */ 2707 case C1_HTS: /* ESC H */
2704 scr_set_tab (1); 2708 scr_set_tab (1);
2705 break; 2709 break;
2863 break; 2867 break;
2864 2868
2865 case '?': 2869 case '?':
2866 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2870 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
2867 process_terminal_mode (ch, priv, nargs, arg); 2871 process_terminal_mode (ch, priv, nargs, arg);
2872 if (prev_ch == '$' && ch == 'p')
2873 process_terminal_mode (ch, priv, nargs, arg);
2868 break; 2874 break;
2869 2875
2870 case '!': 2876 case '!':
2871 if (ch == CSI_70) 2877 if (ch == CSI_70)
2872 { 2878 {
2873 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ 2879 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */
2874 scr_soft_reset (); 2880 scr_soft_reset ();
2875 2881
2876 static const int pm_h[] = { 7, 25 }; 2882 static const int pm_h[] = { 7, 25 };
2877 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1015, 1049 }; 2883 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1006, 1015, 1049 };
2878 2884
2879 process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h); 2885 process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h);
2880 process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l); 2886 process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l);
2881 } 2887 }
2882 break; 2888 break;
3391void 3397void
3392rxvt_term::process_color_seq (int report, int color, const char *str, char resp) 3398rxvt_term::process_color_seq (int report, int color, const char *str, char resp)
3393{ 3399{
3394 if (str[0] == '?' && !str[1]) 3400 if (str[0] == '?' && !str[1])
3395 { 3401 {
3402 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3403 return;
3404
3396 rgba c; 3405 rgba c;
3397 pix_colors_focused[color].get (c); 3406 pix_colors_focused[color].get (c);
3407 color -= minCOLOR;
3398 3408
3399#if XFT 3409#if XFT
3400 if (c.a != rgba::MAX_CC) 3410 if (c.a != rgba::MAX_CC)
3401 tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.r, c.g, c.b, c.a, resp); 3411 tt_printf ("\033]%d;%d;rgba:%04x/%04x/%04x/%04x%c", report, color, c.r, c.g, c.b, c.a, resp);
3402 else 3412 else
3403#endif 3413#endif
3404 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); 3414 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", report, color, c.r, c.g, c.b, resp);
3405 } 3415 }
3406 else 3416 else
3407 set_window_color (color, str); 3417 set_window_color (color, str);
3408} 3418}
3409 3419
3698 { 1000, PrivMode_MouseX11 }, 3708 { 1000, PrivMode_MouseX11 },
3699 { 1002, PrivMode_MouseBtnEvent }, 3709 { 1002, PrivMode_MouseBtnEvent },
3700 { 1003, PrivMode_MouseAnyEvent }, 3710 { 1003, PrivMode_MouseAnyEvent },
3701#if ENABLE_FRILLS 3711#if ENABLE_FRILLS
3702 { 1004, PrivMode_FocusEvent }, 3712 { 1004, PrivMode_FocusEvent },
3703 { 1005, PrivMode_ExtModeMouse }, 3713 { 1005, PrivMode_ExtMouseUTF8 },
3714 { 1006, PrivMode_ExtMouseSGR },
3704#endif 3715#endif
3705 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3716 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3706 { 1011, PrivMode_Keypress }, // rxvt extension 3717 { 1011, PrivMode_Keypress }, // rxvt extension
3707#if ENABLE_FRILLS 3718#if ENABLE_FRILLS
3708 { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005 3719 { 1015, PrivMode_ExtMouseUrxvt }, // urxvt extension of 1005
3709#endif 3720#endif
3710 // 1035 enable modifiers for alt, numlock NYI 3721 // 1035 enable modifiers for alt, numlock NYI
3711 // 1036 send ESC for meta keys NYI 3722 // 1036 send ESC for meta keys NYI
3712 // 1037 send DEL for keypad delete NYI 3723 // 1037 send DEL for keypad delete NYI
3713 { 1047, PrivMode_Screen }, 3724 { 1047, PrivMode_Screen },
3717 { 2004, PrivMode_BracketPaste }, 3728 { 2004, PrivMode_BracketPaste },
3718 }; 3729 };
3719 3730
3720 if (nargs == 0) 3731 if (nargs == 0)
3721 return; 3732 return;
3733
3734 // DECRQM
3735 if (mode == 'p')
3736 {
3737 int status = 0;
3738 if (nargs != 1)
3739 return;
3740
3741 for (j = 0; j < ecb_array_length (argtopriv); j++)
3742 if (argtopriv[j].argval == arg[0])
3743 {
3744 status = (priv_modes & argtopriv[j].bit) ? 1 : 2;
3745 break;
3746 }
3747
3748 tt_printf ("\33[?%d;%d$y", arg[0], status);
3749 return;
3750 }
3722 3751
3723 /* make lo/hi boolean */ 3752 /* make lo/hi boolean */
3724 if (mode == 'l') 3753 if (mode == 'l')
3725 mode = 0; /* reset */ 3754 mode = 0; /* reset */
3726 else if (mode == 'h') 3755 else if (mode == 'h')
3977 case 38: // set fg color, ISO 8613-6 4006 case 38: // set fg color, ISO 8613-6
3978 case 48: // set bg color, ISO 8613-6 4007 case 48: // set bg color, ISO 8613-6
3979 { 4008 {
3980 unsigned int fgbg = arg[i] == 38 ? Color_fg : Color_bg; 4009 unsigned int fgbg = arg[i] == 38 ? Color_fg : Color_bg;
3981 unsigned int idx; 4010 unsigned int idx;
3982 4011
3983 if (nargs > i + 2 && arg[i + 1] == 5) 4012 if (nargs > i + 2 && arg[i + 1] == 5)
3984 { 4013 {
3985 idx = minCOLOR + arg[i + 2]; 4014 idx = minCOLOR + arg[i + 2];
3986 i += 2; 4015 i += 2;
3987 4016

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines