… | |
… | |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "version.h" |
50 | #include "version.h" |
51 | #include "command.h" |
51 | #include "command.h" |
52 | |
52 | |
|
|
53 | #ifdef KEYSYM_RESOURCE |
|
|
54 | # include "keyboard.h" |
|
|
55 | #endif |
|
|
56 | |
53 | #include <wchar.h> |
57 | #include <cwchar> |
|
|
58 | #include <csignal> |
54 | |
59 | |
55 | /*----------------------------------------------------------------------*/ |
60 | /*----------------------------------------------------------------------*/ |
56 | |
61 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
62 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
63 | |
… | |
… | |
343 | valid_keysym = keysym != NoSymbol; |
348 | valid_keysym = keysym != NoSymbol; |
344 | } |
349 | } |
345 | |
350 | |
346 | if (valid_keysym) |
351 | if (valid_keysym) |
347 | { |
352 | { |
|
|
353 | #ifdef KEYSYM_RESOURCE |
|
|
354 | if (keyboard->dispatch (this, keysym, ev.state)) |
|
|
355 | return; |
|
|
356 | #endif |
|
|
357 | |
348 | if (TermWin.saveLines) |
358 | if (TermWin.saveLines) |
349 | { |
359 | { |
350 | #ifdef UNSHIFTED_SCROLLKEYS |
360 | #ifdef UNSHIFTED_SCROLLKEYS |
351 | if (!ctrl && !meta) |
361 | if (!ctrl && !meta) |
352 | #else |
362 | #else |
… | |
… | |
417 | { |
427 | { |
418 | /* normal XTerm key bindings */ |
428 | /* normal XTerm key bindings */ |
419 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
429 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | selection_request (ev.time, 0, 0); |
430 | selection_request (ev.time, 0, 0); |
421 | return; |
431 | return; |
422 | #if TODO // TODO |
432 | #if TODO |
423 | /* rxvt extras */ |
433 | /* rxvt extras */ |
424 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
434 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | change_font (FONT_UP); |
435 | change_font (FONT_UP); |
426 | return; |
436 | return; |
427 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
437 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
486 | } |
496 | } |
487 | #endif |
497 | #endif |
488 | |
498 | |
489 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
499 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
490 | { |
500 | { |
491 | #ifdef KEYSYM_RESOURCE |
|
|
492 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
|
|
493 | { |
|
|
494 | unsigned int l; |
|
|
495 | const unsigned char *kbuf0; |
|
|
496 | |
|
|
497 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
|
|
498 | l = (unsigned int)*kbuf0++; |
|
|
499 | |
|
|
500 | /* escape prefix */ |
|
|
501 | if (meta |
|
|
502 | # ifdef META8_OPTION |
|
|
503 | && meta_char == C0_ESC |
|
|
504 | # endif |
|
|
505 | ) |
|
|
506 | { |
|
|
507 | const unsigned char ch = C0_ESC; |
|
|
508 | tt_write (&ch, 1); |
|
|
509 | } |
|
|
510 | |
|
|
511 | tt_write (kbuf0, l); |
|
|
512 | return; |
|
|
513 | } |
|
|
514 | else |
|
|
515 | #endif |
|
|
516 | { |
501 | { |
517 | newlen = 1; |
502 | newlen = 1; |
518 | switch (keysym) |
503 | switch (keysym) |
519 | { |
504 | { |
520 | #ifndef NO_BACKSPACE_KEY |
505 | #ifndef NO_BACKSPACE_KEY |
… | |
… | |
787 | #undef FKEY |
772 | #undef FKEY |
788 | default: |
773 | default: |
789 | newlen = 0; |
774 | newlen = 0; |
790 | break; |
775 | break; |
791 | } |
776 | } |
|
|
777 | |
792 | if (newlen) |
778 | if (newlen) |
793 | len = strlen (kbuf); |
779 | len = strlen (kbuf); |
794 | } |
780 | } |
795 | |
781 | |
796 | /* |
782 | /* |
… | |
… | |
804 | } |
790 | } |
805 | else if (ctrl && keysym == XK_minus) |
791 | else if (ctrl && keysym == XK_minus) |
806 | { |
792 | { |
807 | len = 1; |
793 | len = 1; |
808 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
794 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
795 | } |
|
|
796 | else if (keysym == XK_ISO_Left_Tab) |
|
|
797 | { |
|
|
798 | strcpy (kbuf, "\033[Z"); |
|
|
799 | len = 3; |
809 | } |
800 | } |
810 | else |
801 | else |
811 | { |
802 | { |
812 | #ifdef META8_OPTION |
803 | #ifdef META8_OPTION |
813 | /* set 8-bit on */ |
804 | /* set 8-bit on */ |
… | |
… | |
872 | #endif /* DEBUG_CMD */ |
863 | #endif /* DEBUG_CMD */ |
873 | tt_write (kbuf, (unsigned int)len); |
864 | tt_write (kbuf, (unsigned int)len); |
874 | } |
865 | } |
875 | /*}}} */ |
866 | /*}}} */ |
876 | |
867 | |
877 | #if (MENUBAR_MAX) |
868 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
878 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
869 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
879 | /* attempt to `write' count to the input buffer */ |
870 | /* attempt to `write' count to the input buffer */ |
880 | unsigned int |
871 | unsigned int |
881 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
872 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
882 | { |
873 | { |
… | |
… | |
905 | |
896 | |
906 | cmd_parse (); |
897 | cmd_parse (); |
907 | |
898 | |
908 | return 0; |
899 | return 0; |
909 | } |
900 | } |
910 | #endif /* MENUBAR_MAX */ |
901 | #endif |
911 | |
902 | |
912 | void |
903 | void |
913 | rxvt_term::flush () |
904 | rxvt_term::flush () |
914 | { |
905 | { |
915 | flush_ev.stop (); |
906 | flush_ev.stop (); |
… | |
… | |
1016 | { |
1007 | { |
1017 | if (mouse_slip_wheel_speed == 0 |
1008 | if (mouse_slip_wheel_speed == 0 |
1018 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1009 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1019 | : scr_page (UP, mouse_slip_wheel_speed)) |
1010 | : scr_page (UP, mouse_slip_wheel_speed)) |
1020 | { |
1011 | { |
|
|
1012 | if (TermWin.view_start == TermWin.nscrolled || |
|
|
1013 | TermWin.view_start == 0) |
|
|
1014 | mouse_slip_wheel_speed = 0; |
|
|
1015 | |
1021 | refresh_type |= SMOOTH_REFRESH; |
1016 | refresh_type |= SMOOTH_REFRESH; |
1022 | want_refresh = 1; |
1017 | want_refresh = 1; |
1023 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1018 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1024 | } |
1019 | } |
1025 | } |
1020 | } |
… | |
… | |
1057 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1052 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1058 | { |
1053 | { |
1059 | SET_R (this); |
1054 | SET_R (this); |
1060 | SET_LOCALE (locale); |
1055 | SET_LOCALE (locale); |
1061 | |
1056 | |
1062 | if (revents & EVENT_WRITE) |
|
|
1063 | tt_write (0, 0); |
|
|
1064 | else if (revents & EVENT_READ) |
1057 | if (revents & EVENT_READ) |
1065 | // loop, but don't allow a single term to monopolize us |
1058 | // loop, but don't allow a single term to monopolize us |
1066 | while (pty_fill ()) |
1059 | while (pty_fill ()) |
1067 | if (cmd_parse ()) |
1060 | if (cmd_parse ()) |
1068 | break; |
1061 | break; |
|
|
1062 | |
|
|
1063 | if (revents & EVENT_WRITE) |
|
|
1064 | pty_write (); |
1069 | } |
1065 | } |
1070 | |
1066 | |
1071 | void |
1067 | void |
1072 | rxvt_term::pointer_unblank () |
1068 | rxvt_term::pointer_unblank () |
1073 | { |
1069 | { |
… | |
… | |
1087 | rxvt_term::pointer_blank () |
1083 | rxvt_term::pointer_blank () |
1088 | { |
1084 | { |
1089 | if (! (options & Opt_pointerBlank)) |
1085 | if (! (options & Opt_pointerBlank)) |
1090 | return; |
1086 | return; |
1091 | |
1087 | |
1092 | XDefineCursor (display->display, TermWin.vt, blank_cursor); |
1088 | XDefineCursor (display->display, TermWin.vt, display->blank_cursor); |
1093 | XFlush (display->display); |
1089 | XFlush (display->display); |
1094 | |
1090 | |
1095 | hidden_pointer = 1; |
1091 | hidden_pointer = 1; |
1096 | } |
1092 | } |
1097 | |
1093 | |
… | |
… | |
1216 | if (ev.type == KeyPress && hidden_pointer == 0) |
1212 | if (ev.type == KeyPress && hidden_pointer == 0) |
1217 | pointer_blank (); |
1213 | pointer_blank (); |
1218 | } |
1214 | } |
1219 | #endif |
1215 | #endif |
1220 | |
1216 | |
1221 | Window unused_root, unused_child; |
1217 | Window unused_root, unused_child; |
1222 | int unused_root_x, unused_root_y; |
1218 | int unused_root_x, unused_root_y; |
1223 | unsigned int unused_mask; |
1219 | unsigned int unused_mask; |
1224 | |
1220 | |
1225 | switch (ev.type) |
1221 | switch (ev.type) |
1226 | { |
1222 | { |
1227 | case KeyPress: |
1223 | case KeyPress: |
1228 | #if ISO_14755 |
1224 | #if ISO_14755 |
… | |
… | |
1333 | 0L, 1000000L, |
1329 | 0L, 1000000L, |
1334 | False, AnyPropertyType, |
1330 | False, AnyPropertyType, |
1335 | &ActualType, &ActualFormat, |
1331 | &ActualType, &ActualFormat, |
1336 | &Size, &RemainingBytes, |
1332 | &Size, &RemainingBytes, |
1337 | &data); |
1333 | &data); |
1338 | XChangeProperty (display->display, display->root, |
1334 | set_string_property (XA_CUT_BUFFER0, data); |
1339 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1340 | 8, PropModeReplace, |
|
|
1341 | data, strlen (data)); |
|
|
1342 | XFree (data); |
1335 | XFree (data); |
1343 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1336 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1344 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1337 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1345 | } |
1338 | } |
1346 | #endif /* OFFIX_DND */ |
1339 | #endif /* OFFIX_DND */ |
1347 | break; |
1340 | break; |
1348 | |
1341 | |
… | |
… | |
1452 | resize_all_windows (width, height, 1); |
1445 | resize_all_windows (width, height, 1); |
1453 | } |
1446 | } |
1454 | |
1447 | |
1455 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1448 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1456 | if (options & Opt_transparent) |
1449 | if (options & Opt_transparent) |
1457 | { |
|
|
1458 | check_our_parents (); |
1450 | check_our_parents (); |
1459 | if (am_transparent) |
|
|
1460 | want_refresh = want_full_refresh = 1; |
|
|
1461 | } |
|
|
1462 | #endif |
1451 | #endif |
1463 | } |
1452 | } |
1464 | break; |
1453 | break; |
1465 | |
1454 | |
1466 | case PropertyNotify: |
1455 | case PropertyNotify: |
… | |
… | |
1474 | selection_clear (); |
1463 | selection_clear (); |
1475 | break; |
1464 | break; |
1476 | |
1465 | |
1477 | case SelectionNotify: |
1466 | case SelectionNotify: |
1478 | if (selection_wait == Sel_normal) |
1467 | if (selection_wait == Sel_normal) |
1479 | selection_paste (ev.xselection.requestor, |
1468 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1480 | ev.xselection.property, True); |
|
|
1481 | break; |
1469 | break; |
1482 | |
1470 | |
1483 | case SelectionRequest: |
1471 | case SelectionRequest: |
1484 | selection_send (ev.xselectionrequest); |
1472 | selection_send (ev.xselectionrequest); |
1485 | break; |
1473 | break; |
… | |
… | |
1674 | case PropertyNotify: |
1662 | case PropertyNotify: |
1675 | /* |
1663 | /* |
1676 | * if user used some Esetroot compatible prog to set the root bg, |
1664 | * if user used some Esetroot compatible prog to set the root bg, |
1677 | * use the property to determine the pixmap. We use it later on. |
1665 | * use the property to determine the pixmap. We use it later on. |
1678 | */ |
1666 | */ |
1679 | if (xa[XA_XROOTPMAPID] == 0) |
|
|
1680 | xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); |
|
|
1681 | |
|
|
1682 | if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) |
1667 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1668 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1683 | return; |
1669 | return; |
1684 | |
1670 | |
1685 | /* FALLTHROUGH */ |
1671 | /* FALLTHROUGH */ |
1686 | case ReparentNotify: |
1672 | case ReparentNotify: |
1687 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1673 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
1759 | { |
1745 | { |
1760 | case Button1: |
1746 | case Button1: |
1761 | /* allow meta + click to select rectangular areas */ |
1747 | /* allow meta + click to select rectangular areas */ |
1762 | /* should be done in screen.C */ |
1748 | /* should be done in screen.C */ |
1763 | #if ENABLE_FRILLS |
1749 | #if ENABLE_FRILLS |
1764 | selection.rect = !! (ev.state & ModMetaMask); |
1750 | selection.rect = !!(ev.state & ModMetaMask); |
1765 | #else |
1751 | #else |
1766 | selection.rect = false; |
1752 | selection.rect = false; |
1767 | #endif |
1753 | #endif |
1768 | |
1754 | |
1769 | /* allow shift+left click to extend selection */ |
1755 | /* allow shift+left click to extend selection */ |
… | |
… | |
2357 | /* |
2343 | /* |
2358 | * Make the frame window set by the window manager have |
2344 | * Make the frame window set by the window manager have |
2359 | * the root background. Some window managers put multiple nested frame |
2345 | * the root background. Some window managers put multiple nested frame |
2360 | * windows for each client, so we have to take care about that. |
2346 | * windows for each client, so we have to take care about that. |
2361 | */ |
2347 | */ |
2362 | i = (xa[XA_XROOTPMAPID] |
2348 | i = (xa[XA_XROOTPMAP_ID] |
2363 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2349 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], |
2364 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2350 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2365 | &nitems, &bytes_after, &prop) == Success); |
2351 | &nitems, &bytes_after, &prop) == Success); |
2366 | |
2352 | |
2367 | if (!i || prop == NULL) |
2353 | if (!i || prop == NULL) |
2368 | i = (xa[XA_XSETROOTID] |
2354 | i = (xa[XA_ESETROOT_PMAP_ID] |
2369 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2355 | && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], |
2370 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2356 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2371 | &nitems, &bytes_after, &prop) == Success); |
2357 | &nitems, &bytes_after, &prop) == Success); |
2372 | |
2358 | |
2373 | if (!i || prop == NULL |
2359 | if (!i || prop == NULL |
2374 | #if TINTING |
2360 | #if TINTING |
… | |
… | |
2415 | sy = 0; |
2401 | sy = 0; |
2416 | } |
2402 | } |
2417 | |
2403 | |
2418 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2404 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2419 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2405 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2406 | |
|
|
2407 | XSync (display->display, False); |
2420 | allowedxerror = -1; |
2408 | allowedxerror = -1; |
2421 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2409 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2422 | |
2410 | |
2423 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2411 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2424 | /* XXX: may need a delay here? */ |
2412 | /* XXX: may need a delay here? */ |
… | |
… | |
2470 | |
2458 | |
2471 | am_transparent = am_pixmap_trans = 1; |
2459 | am_transparent = am_pixmap_trans = 1; |
2472 | } |
2460 | } |
2473 | } |
2461 | } |
2474 | |
2462 | |
2475 | if (!am_pixmap_trans) |
2463 | if (am_pixmap_trans) |
|
|
2464 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
|
|
2465 | else |
2476 | { |
2466 | { |
2477 | unsigned int n; |
2467 | unsigned int n; |
2478 | /* |
2468 | /* |
2479 | * InheritPixmap transparency |
2469 | * InheritPixmap transparency |
2480 | */ |
2470 | */ |
… | |
… | |
2543 | if (scrollBar.win) |
2533 | if (scrollBar.win) |
2544 | { |
2534 | { |
2545 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2535 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2546 | scrollBar.setIdle (); |
2536 | scrollBar.setIdle (); |
2547 | scrollbar_show (0); |
2537 | scrollbar_show (0); |
|
|
2538 | } |
|
|
2539 | |
|
|
2540 | if (am_transparent) |
|
|
2541 | { |
|
|
2542 | want_refresh = want_full_refresh = 1; |
|
|
2543 | if (am_pixmap_trans) |
|
|
2544 | flush (); |
2548 | } |
2545 | } |
2549 | |
2546 | |
2550 | return pchanged; |
2547 | return pchanged; |
2551 | } |
2548 | } |
2552 | #endif |
2549 | #endif |
… | |
… | |
2704 | if (len == (size_t)-1) |
2701 | if (len == (size_t)-1) |
2705 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2702 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2706 | |
2703 | |
2707 | // assume wchar == unicode |
2704 | // assume wchar == unicode |
2708 | cmdbuf_ptr += len; |
2705 | cmdbuf_ptr += len; |
2709 | return wc; |
2706 | return wc & UNICODE_MASK; |
2710 | } |
2707 | } |
2711 | |
2708 | |
2712 | return NOCHAR; |
2709 | return NOCHAR; |
2713 | } |
2710 | } |
2714 | |
2711 | |
… | |
… | |
3512 | * ends_how is terminator used. returned input must be free()'d |
3509 | * ends_how is terminator used. returned input must be free()'d |
3513 | */ |
3510 | */ |
3514 | unsigned char * |
3511 | unsigned char * |
3515 | rxvt_term::get_to_st (unicode_t &ends_how) |
3512 | rxvt_term::get_to_st (unicode_t &ends_how) |
3516 | { |
3513 | { |
3517 | unicode_t seen_esc = 0, ch; |
3514 | unicode_t ch; |
|
|
3515 | bool seen_esc = false; |
3518 | unsigned int n = 0; |
3516 | unsigned int n = 0; |
3519 | unsigned char *s; |
|
|
3520 | unsigned char string[STRING_MAX]; |
3517 | wchar_t string[STRING_MAX]; |
3521 | |
3518 | |
3522 | while ((ch = cmd_getc ()) != NOCHAR) |
3519 | while ((ch = cmd_getc ()) != NOCHAR) |
3523 | { |
3520 | { |
3524 | if (seen_esc) |
3521 | if (seen_esc) |
3525 | { |
3522 | { |
… | |
… | |
3528 | else |
3525 | else |
3529 | return NULL; |
3526 | return NULL; |
3530 | } |
3527 | } |
3531 | else if (ch == C0_ESC) |
3528 | else if (ch == C0_ESC) |
3532 | { |
3529 | { |
3533 | seen_esc = 1; |
3530 | seen_esc = true; |
3534 | continue; |
3531 | continue; |
3535 | } |
3532 | } |
3536 | else if (ch == C0_BEL || ch == CHAR_ST) |
3533 | else if (ch == C0_BEL || ch == CHAR_ST) |
3537 | break; |
3534 | break; |
3538 | else if (ch < 0x20) |
3535 | else if (ch < 0x20) |
3539 | return NULL; /* other control character - exit */ |
3536 | return NULL; /* other control character - exit */ |
3540 | |
3537 | |
3541 | seen_esc = 0; |
3538 | seen_esc = false; |
3542 | |
3539 | |
3543 | if (n >= sizeof (string) - 1) |
3540 | if (n >= sizeof (string) - 1) |
3544 | // stop at some sane length |
3541 | // stop at some sane length |
3545 | return NULL; |
3542 | return NULL; |
3546 | |
3543 | |
… | |
… | |
3550 | string[n++] = ch; |
3547 | string[n++] = ch; |
3551 | } |
3548 | } |
3552 | |
3549 | |
3553 | string[n++] = '\0'; |
3550 | string[n++] = '\0'; |
3554 | |
3551 | |
3555 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3556 | return NULL; |
|
|
3557 | |
|
|
3558 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3552 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3559 | strncpy (s, string, n); |
3553 | |
3560 | return s; |
3554 | return (unsigned char *)rxvt_wcstombs (string); |
3561 | } |
3555 | } |
3562 | |
3556 | |
3563 | /*----------------------------------------------------------------------*/ |
3557 | /*----------------------------------------------------------------------*/ |
3564 | /* |
3558 | /* |
3565 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3559 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3666 | set_title (str); |
3660 | set_title (str); |
3667 | break; |
3661 | break; |
3668 | case XTerm_property: |
3662 | case XTerm_property: |
3669 | if (str[0] == '?') |
3663 | if (str[0] == '?') |
3670 | { |
3664 | { |
3671 | Atom prop = XInternAtom (display->display, str + 1, True); |
3665 | Atom prop = display->atom (str + 1); |
3672 | Atom actual_type; |
3666 | Atom actual_type; |
3673 | int actual_format; |
3667 | int actual_format; |
3674 | unsigned long nitems; |
3668 | unsigned long nitems; |
3675 | unsigned long bytes_after; |
3669 | unsigned long bytes_after; |
3676 | unsigned char *value = 0; |
3670 | unsigned char *value = 0; |
… | |
… | |
3694 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3688 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3695 | |
3689 | |
3696 | if (eq) |
3690 | if (eq) |
3697 | { |
3691 | { |
3698 | *eq = 0; |
3692 | *eq = 0; |
3699 | XChangeProperty (display->display, TermWin.parent[0], |
3693 | set_utf8_property (display->atom (str), eq + 1); |
3700 | display->atom (str), XA_STRING, 8, |
|
|
3701 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3702 | strlen (eq + 1)); |
|
|
3703 | } |
3694 | } |
3704 | else |
3695 | else |
3705 | XDeleteProperty (display->display, TermWin.parent[0], |
3696 | XDeleteProperty (display->display, TermWin.parent[0], |
3706 | display->atom (str)); |
3697 | display->atom (str)); |
3707 | } |
3698 | } |
… | |
… | |
3761 | break; |
3752 | break; |
3762 | case XTerm_Color_RV: |
3753 | case XTerm_Color_RV: |
3763 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3754 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3764 | break; |
3755 | break; |
3765 | #endif |
3756 | #endif |
3766 | #if TRANSPARENT || TINTING |
3757 | #if TRANSPARENT && TINTING |
3767 | case XTerm_Color_tint: |
3758 | case XTerm_Color_tint: |
3768 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3759 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3769 | check_our_parents (); |
3760 | check_our_parents (); |
3770 | if (am_transparent) |
3761 | if (am_transparent) |
3771 | want_full_refresh = want_refresh = 1; |
3762 | want_full_refresh = want_refresh = 1; |
… | |
… | |
3837 | if (query) |
3828 | if (query) |
3838 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3829 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3839 | else |
3830 | else |
3840 | { |
3831 | { |
3841 | set_locale (str); |
3832 | set_locale (str); |
|
|
3833 | pty.set_utf8_mode (enc_utf8); |
3842 | # ifdef USE_XIM |
3834 | # ifdef USE_XIM |
3843 | im_cb (); |
3835 | im_cb (); |
3844 | # endif |
3836 | # endif |
3845 | } |
3837 | } |
3846 | break; |
3838 | break; |
… | |
… | |
4284 | |
4276 | |
4285 | /* ---------------------------------------------------------------------- */ |
4277 | /* ---------------------------------------------------------------------- */ |
4286 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4278 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4287 | * or generated by us in response to a query ESC sequence. |
4279 | * or generated by us in response to a query ESC sequence. |
4288 | */ |
4280 | */ |
|
|
4281 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4282 | |
4289 | void |
4283 | void |
4290 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4284 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4291 | { |
4285 | { |
4292 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4286 | if (v_buflen == 0) |
|
|
4287 | { |
|
|
4288 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4293 | |
4289 | |
4294 | if (len) |
4290 | if ((unsigned int)written == len) |
|
|
4291 | return; |
|
|
4292 | |
|
|
4293 | data += written; |
|
|
4294 | len -= written; |
4295 | { |
4295 | } |
|
|
4296 | |
|
|
4297 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4298 | |
|
|
4299 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4300 | v_buflen += len; |
|
|
4301 | |
|
|
4302 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4303 | } |
|
|
4304 | |
|
|
4305 | void rxvt_term::pty_write () |
|
|
4306 | { |
|
|
4307 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4308 | |
|
|
4309 | if (written > 0) |
|
|
4310 | { |
|
|
4311 | v_buflen -= written; |
|
|
4312 | |
4296 | if (v_buflen == 0) |
4313 | if (v_buflen == 0) |
4297 | { |
4314 | { |
4298 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4299 | |
|
|
4300 | if ((unsigned int)written == len) |
|
|
4301 | return; |
|
|
4302 | |
|
|
4303 | data += written; |
|
|
4304 | len -= written; |
|
|
4305 | } |
|
|
4306 | |
|
|
4307 | |
|
|
4308 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4309 | |
|
|
4310 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4311 | v_buflen += len; |
|
|
4312 | } |
|
|
4313 | |
|
|
4314 | for (;;) |
|
|
4315 | { |
|
|
4316 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4317 | |
|
|
4318 | if (written > 0) |
|
|
4319 | { |
|
|
4320 | v_buflen -= written; |
|
|
4321 | |
|
|
4322 | if (v_buflen == 0) |
|
|
4323 | { |
|
|
4324 | free (v_buffer); |
4315 | free (v_buffer); |
4325 | v_buffer = 0; |
4316 | v_buffer = 0; |
4326 | v_buflen = 0; |
4317 | v_buflen = 0; |
4327 | |
4318 | |
4328 | pty_ev.set (EVENT_READ); |
4319 | pty_ev.set (EVENT_READ); |
4329 | return; |
|
|
4330 | } |
|
|
4331 | |
|
|
4332 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
4333 | } |
|
|
4334 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4335 | // original code just ignores this... |
|
|
4336 | destroy (); |
|
|
4337 | else |
|
|
4338 | { |
|
|
4339 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4340 | return; |
4320 | return; |
4341 | } |
4321 | } |
|
|
4322 | |
|
|
4323 | memmove (v_buffer, v_buffer + written, v_buflen); |
4342 | } |
4324 | } |
|
|
4325 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4326 | // original code just ignores this... |
|
|
4327 | destroy (); |
4343 | } |
4328 | } |
4344 | |
4329 | |
4345 | /*----------------------- end-of-file (C source) -----------------------*/ |
4330 | /*----------------------- end-of-file (C source) -----------------------*/ |
4346 | |
4331 | |