… | |
… | |
1277 | #endif |
1277 | #endif |
1278 | |
1278 | |
1279 | void |
1279 | void |
1280 | rxvt_term::mouse_report (XButtonEvent &ev) |
1280 | rxvt_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 | |
… | |
… | |
2354 | wchar_t ecb_hot |
2356 | wchar_t ecb_hot |
2355 | rxvt_term::next_char () NOTHROW |
2357 | rxvt_term::next_char () NOTHROW |
2356 | { |
2358 | { |
2357 | while (cmdbuf_ptr < cmdbuf_endp) |
2359 | while (cmdbuf_ptr < cmdbuf_endp) |
2358 | { |
2360 | { |
2359 | // assume 7-bit to be ascii ALWAYS |
2361 | // assume 7-bit to be ascii ALWAYS (always true in POSIX) |
2360 | if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) |
2362 | if (ecb_likely ((unsigned char)*cmdbuf_ptr <= 0x7f)) |
2361 | return *cmdbuf_ptr++; |
2363 | return *cmdbuf_ptr++; |
2362 | |
2364 | |
2363 | wchar_t wc; |
2365 | wchar_t wc; |
2364 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2366 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2365 | |
2367 | |
… | |
… | |
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; |
… | |
… | |
2872 | { |
2876 | { |
2873 | /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ |
2877 | /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */ |
2874 | scr_soft_reset (); |
2878 | scr_soft_reset (); |
2875 | |
2879 | |
2876 | static const int pm_h[] = { 7, 25 }; |
2880 | 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 }; |
2881 | static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1005, 1006, 1015, 1049 }; |
2878 | |
2882 | |
2879 | process_terminal_mode ('h', 0, ecb_array_length (pm_h), pm_h); |
2883 | 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); |
2884 | process_terminal_mode ('l', 0, ecb_array_length (pm_l), pm_l); |
2881 | } |
2885 | } |
2882 | break; |
2886 | break; |
… | |
… | |
3391 | void |
3395 | void |
3392 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3396 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3393 | { |
3397 | { |
3394 | if (str[0] == '?' && !str[1]) |
3398 | if (str[0] == '?' && !str[1]) |
3395 | { |
3399 | { |
|
|
3400 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
|
|
3401 | return; |
|
|
3402 | |
3396 | rgba c; |
3403 | rgba c; |
3397 | pix_colors_focused[color].get (c); |
3404 | pix_colors_focused[color].get (c); |
|
|
3405 | color -= minCOLOR; |
3398 | |
3406 | |
3399 | #if XFT |
3407 | #if XFT |
3400 | if (c.a != rgba::MAX_CC) |
3408 | 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); |
3409 | tt_printf ("\033]%d;%d;rgba:%04x/%04x/%04x/%04x%c", report, color, c.r, c.g, c.b, c.a, resp); |
3402 | else |
3410 | else |
3403 | #endif |
3411 | #endif |
3404 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3412 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", report, color, c.r, c.g, c.b, resp); |
3405 | } |
3413 | } |
3406 | else |
3414 | else |
3407 | set_window_color (color, str); |
3415 | set_window_color (color, str); |
3408 | } |
3416 | } |
3409 | |
3417 | |
… | |
… | |
3698 | { 1000, PrivMode_MouseX11 }, |
3706 | { 1000, PrivMode_MouseX11 }, |
3699 | { 1002, PrivMode_MouseBtnEvent }, |
3707 | { 1002, PrivMode_MouseBtnEvent }, |
3700 | { 1003, PrivMode_MouseAnyEvent }, |
3708 | { 1003, PrivMode_MouseAnyEvent }, |
3701 | #if ENABLE_FRILLS |
3709 | #if ENABLE_FRILLS |
3702 | { 1004, PrivMode_FocusEvent }, |
3710 | { 1004, PrivMode_FocusEvent }, |
3703 | { 1005, PrivMode_ExtModeMouse }, |
3711 | { 1005, PrivMode_ExtMouseUTF8 }, |
|
|
3712 | { 1006, PrivMode_ExtMouseSGR }, |
3704 | #endif |
3713 | #endif |
3705 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3714 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3706 | { 1011, PrivMode_Keypress }, // rxvt extension |
3715 | { 1011, PrivMode_Keypress }, // rxvt extension |
3707 | #if ENABLE_FRILLS |
3716 | #if ENABLE_FRILLS |
3708 | { 1015, PrivMode_ExtMouseRight }, // urxvt extension of 1005 |
3717 | { 1015, PrivMode_ExtMouseUrxvt }, // urxvt extension of 1005 |
3709 | #endif |
3718 | #endif |
3710 | // 1035 enable modifiers for alt, numlock NYI |
3719 | // 1035 enable modifiers for alt, numlock NYI |
3711 | // 1036 send ESC for meta keys NYI |
3720 | // 1036 send ESC for meta keys NYI |
3712 | // 1037 send DEL for keypad delete NYI |
3721 | // 1037 send DEL for keypad delete NYI |
3713 | { 1047, PrivMode_Screen }, |
3722 | { 1047, PrivMode_Screen }, |
… | |
… | |
3977 | case 38: // set fg color, ISO 8613-6 |
3986 | case 38: // set fg color, ISO 8613-6 |
3978 | case 48: // set bg color, ISO 8613-6 |
3987 | case 48: // set bg color, ISO 8613-6 |
3979 | { |
3988 | { |
3980 | unsigned int fgbg = arg[i] == 38 ? Color_fg : Color_bg; |
3989 | unsigned int fgbg = arg[i] == 38 ? Color_fg : Color_bg; |
3981 | unsigned int idx; |
3990 | unsigned int idx; |
3982 | |
3991 | |
3983 | if (nargs > i + 2 && arg[i + 1] == 5) |
3992 | if (nargs > i + 2 && arg[i + 1] == 5) |
3984 | { |
3993 | { |
3985 | idx = minCOLOR + arg[i + 2]; |
3994 | idx = minCOLOR + arg[i + 2]; |
3986 | i += 2; |
3995 | i += 2; |
3987 | |
3996 | |