… | |
… | |
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 | #include <wchar.h> |
53 | #include <wchar.h> |
|
|
54 | #include <signal.h> |
54 | |
55 | |
55 | /*----------------------------------------------------------------------*/ |
56 | /*----------------------------------------------------------------------*/ |
56 | |
57 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
59 | |
… | |
… | |
417 | { |
418 | { |
418 | /* normal XTerm key bindings */ |
419 | /* normal XTerm key bindings */ |
419 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | selection_request (ev.time, 0, 0); |
421 | selection_request (ev.time, 0, 0); |
421 | return; |
422 | return; |
422 | #if TODO // TODO |
423 | #if TODO |
423 | /* rxvt extras */ |
424 | /* rxvt extras */ |
424 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | change_font (FONT_UP); |
426 | change_font (FONT_UP); |
426 | return; |
427 | return; |
427 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
428 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
910 | #endif /* MENUBAR_MAX */ |
911 | #endif /* MENUBAR_MAX */ |
911 | |
912 | |
912 | void |
913 | void |
913 | rxvt_term::flush () |
914 | rxvt_term::flush () |
914 | { |
915 | { |
|
|
916 | flush_ev.stop (); |
|
|
917 | |
915 | #ifdef TRANSPARENT |
918 | #ifdef TRANSPARENT |
916 | if (want_full_refresh) |
919 | if (want_full_refresh) |
917 | { |
920 | { |
918 | want_full_refresh = 0; |
921 | want_full_refresh = 0; |
919 | scr_clear (); |
922 | scr_clear (); |
… | |
… | |
929 | IMSendSpot (); |
932 | IMSendSpot (); |
930 | #endif |
933 | #endif |
931 | } |
934 | } |
932 | |
935 | |
933 | display->flush (); |
936 | display->flush (); |
934 | |
|
|
935 | flush_ev.stop (); |
|
|
936 | } |
937 | } |
937 | |
938 | |
938 | void |
939 | void |
939 | rxvt_term::check_cb (check_watcher &w) |
940 | rxvt_term::check_cb (check_watcher &w) |
940 | { |
941 | { |
… | |
… | |
1057 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1058 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1058 | { |
1059 | { |
1059 | SET_R (this); |
1060 | SET_R (this); |
1060 | SET_LOCALE (locale); |
1061 | SET_LOCALE (locale); |
1061 | |
1062 | |
1062 | if (revents & EVENT_WRITE) |
|
|
1063 | tt_write (0, 0); |
|
|
1064 | else if (revents & EVENT_READ) |
1063 | if (revents & EVENT_READ) |
1065 | // loop, but don't allow a single term to monopolize us |
1064 | // loop, but don't allow a single term to monopolize us |
1066 | while (pty_fill ()) |
1065 | while (pty_fill ()) |
1067 | if (cmd_parse ()) |
1066 | if (cmd_parse ()) |
1068 | break; |
1067 | break; |
|
|
1068 | |
|
|
1069 | if (revents & EVENT_WRITE) |
|
|
1070 | pty_write (); |
1069 | } |
1071 | } |
1070 | |
1072 | |
1071 | void |
1073 | void |
1072 | rxvt_term::pointer_unblank () |
1074 | rxvt_term::pointer_unblank () |
1073 | { |
1075 | { |
… | |
… | |
1216 | if (ev.type == KeyPress && hidden_pointer == 0) |
1218 | if (ev.type == KeyPress && hidden_pointer == 0) |
1217 | pointer_blank (); |
1219 | pointer_blank (); |
1218 | } |
1220 | } |
1219 | #endif |
1221 | #endif |
1220 | |
1222 | |
1221 | #ifdef USE_XIM |
|
|
1222 | if (XFilterEvent (&ev, None)) |
|
|
1223 | return; |
|
|
1224 | #endif |
|
|
1225 | |
|
|
1226 | Window unused_root, unused_child; |
1223 | Window unused_root, unused_child; |
1227 | int unused_root_x, unused_root_y; |
1224 | int unused_root_x, unused_root_y; |
1228 | unsigned int unused_mask; |
1225 | unsigned int unused_mask; |
1229 | |
1226 | |
1230 | switch (ev.type) |
1227 | switch (ev.type) |
1231 | { |
1228 | { |
1232 | case KeyPress: |
1229 | case KeyPress: |
1233 | #if ISO_14755 |
1230 | #if ISO_14755 |
… | |
… | |
1338 | 0L, 1000000L, |
1335 | 0L, 1000000L, |
1339 | False, AnyPropertyType, |
1336 | False, AnyPropertyType, |
1340 | &ActualType, &ActualFormat, |
1337 | &ActualType, &ActualFormat, |
1341 | &Size, &RemainingBytes, |
1338 | &Size, &RemainingBytes, |
1342 | &data); |
1339 | &data); |
1343 | XChangeProperty (display->display, display->root, |
1340 | set_string_property (XA_CUT_BUFFER0, data); |
1344 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1345 | 8, PropModeReplace, |
|
|
1346 | data, strlen (data)); |
|
|
1347 | XFree (data); |
1341 | XFree (data); |
1348 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1342 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1349 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1343 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1350 | } |
1344 | } |
1351 | #endif /* OFFIX_DND */ |
1345 | #endif /* OFFIX_DND */ |
1352 | break; |
1346 | break; |
1353 | |
1347 | |
… | |
… | |
1457 | resize_all_windows (width, height, 1); |
1451 | resize_all_windows (width, height, 1); |
1458 | } |
1452 | } |
1459 | |
1453 | |
1460 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1454 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1461 | if (options & Opt_transparent) |
1455 | if (options & Opt_transparent) |
1462 | { |
|
|
1463 | check_our_parents (); |
1456 | check_our_parents (); |
1464 | if (am_transparent) |
|
|
1465 | want_refresh = want_full_refresh = 1; |
|
|
1466 | } |
|
|
1467 | #endif |
1457 | #endif |
1468 | } |
1458 | } |
1469 | break; |
1459 | break; |
1470 | |
1460 | |
1471 | case PropertyNotify: |
1461 | case PropertyNotify: |
… | |
… | |
1479 | selection_clear (); |
1469 | selection_clear (); |
1480 | break; |
1470 | break; |
1481 | |
1471 | |
1482 | case SelectionNotify: |
1472 | case SelectionNotify: |
1483 | if (selection_wait == Sel_normal) |
1473 | if (selection_wait == Sel_normal) |
1484 | selection_paste (ev.xselection.requestor, |
1474 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1485 | ev.xselection.property, True); |
|
|
1486 | break; |
1475 | break; |
1487 | |
1476 | |
1488 | case SelectionRequest: |
1477 | case SelectionRequest: |
1489 | selection_send (ev.xselectionrequest); |
1478 | selection_send (ev.xselectionrequest); |
1490 | break; |
1479 | break; |
… | |
… | |
1562 | { |
1551 | { |
1563 | menubar_control (ev.xbutton); |
1552 | menubar_control (ev.xbutton); |
1564 | break; |
1553 | break; |
1565 | } |
1554 | } |
1566 | #endif |
1555 | #endif |
1567 | if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1556 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1568 | break; |
1557 | break; |
1569 | |
1558 | |
1570 | if (ev.xany.window == TermWin.vt) |
1559 | if (ev.xany.window == TermWin.vt) |
1571 | { |
1560 | { |
1572 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1561 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
… | |
… | |
1575 | ; |
1564 | ; |
1576 | |
1565 | |
1577 | XQueryPointer (display->display, TermWin.vt, |
1566 | XQueryPointer (display->display, TermWin.vt, |
1578 | &unused_root, &unused_child, |
1567 | &unused_root, &unused_child, |
1579 | &unused_root_x, &unused_root_y, |
1568 | &unused_root_x, &unused_root_y, |
1580 | & (ev.xbutton.x), & (ev.xbutton.y), |
1569 | &ev.xbutton.x, &ev.xbutton.y, |
1581 | &unused_mask); |
1570 | &ev.xbutton.state); |
1582 | #ifdef MOUSE_THRESHOLD |
1571 | #ifdef MOUSE_THRESHOLD |
1583 | /* deal with a `jumpy' mouse */ |
1572 | /* deal with a `jumpy' mouse */ |
1584 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1573 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1585 | { |
1574 | { |
1586 | #endif |
1575 | #endif |
… | |
… | |
1591 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1580 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1592 | break; |
1581 | break; |
1593 | } |
1582 | } |
1594 | #endif |
1583 | #endif |
1595 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1584 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1596 | (ev.xbutton.state & Button3Mask) ? 2 : 0); |
1585 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1586 | |
1597 | #ifdef SELECTION_SCROLLING |
1587 | #ifdef SELECTION_SCROLLING |
1598 | if (ev.xbutton.y < TermWin.int_bwidth |
1588 | if (ev.xbutton.y < TermWin.int_bwidth |
1599 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1589 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1600 | { |
1590 | { |
1601 | int dist; |
1591 | int dist; |
… | |
… | |
1612 | selection_save_x = ev.xbutton.x; |
1602 | selection_save_x = ev.xbutton.x; |
1613 | selection_save_y = ev.xbutton.y; |
1603 | selection_save_y = ev.xbutton.y; |
1614 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1604 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1615 | |
1605 | |
1616 | /* calc number of lines to scroll */ |
1606 | /* calc number of lines to scroll */ |
1617 | if (ev.xbutton.y<TermWin.int_bwidth) |
1607 | if (ev.xbutton.y < TermWin.int_bwidth) |
1618 | { |
1608 | { |
1619 | scroll_selection_dir = UP; |
1609 | scroll_selection_dir = UP; |
1620 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1610 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1621 | } |
1611 | } |
1622 | else |
1612 | else |
… | |
… | |
1646 | } |
1636 | } |
1647 | } |
1637 | } |
1648 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1638 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1649 | { |
1639 | { |
1650 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1640 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1651 | MotionNotify, &ev)) ; |
1641 | MotionNotify, &ev)) |
|
|
1642 | ; |
|
|
1643 | |
1652 | XQueryPointer (display->display, scrollBar.win, |
1644 | XQueryPointer (display->display, scrollBar.win, |
1653 | &unused_root, &unused_child, |
1645 | &unused_root, &unused_child, |
1654 | &unused_root_x, &unused_root_y, |
1646 | &unused_root_x, &unused_root_y, |
1655 | & (ev.xbutton.x), & (ev.xbutton.y), |
1647 | &ev.xbutton.x, &ev.xbutton.y, |
1656 | &unused_mask); |
1648 | &unused_mask); |
1657 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1649 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1658 | scrollbar_size ()); |
1650 | scrollbar_size ()); |
1659 | scr_refresh (refresh_type); |
1651 | scr_refresh (refresh_type); |
1660 | refresh_limit = 0; |
1652 | refresh_limit = 0; |
… | |
… | |
1715 | return; |
1707 | return; |
1716 | } |
1708 | } |
1717 | #endif |
1709 | #endif |
1718 | |
1710 | |
1719 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1711 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
|
|
1712 | |
1720 | if (reportmode) |
1713 | if (reportmode) |
1721 | { |
1714 | { |
1722 | /* mouse report from vt window */ |
1715 | /* mouse report from vt window */ |
1723 | /* save the xbutton state (for ButtonRelease) */ |
1716 | /* save the xbutton state (for ButtonRelease) */ |
1724 | MEvent.state = ev.state; |
1717 | MEvent.state = ev.state; |
… | |
… | |
1753 | } |
1746 | } |
1754 | else |
1747 | else |
1755 | { |
1748 | { |
1756 | if (ev.button != MEvent.button) |
1749 | if (ev.button != MEvent.button) |
1757 | MEvent.clicks = 0; |
1750 | MEvent.clicks = 0; |
|
|
1751 | |
1758 | switch (ev.button) |
1752 | switch (ev.button) |
1759 | { |
1753 | { |
1760 | case Button1: |
1754 | case Button1: |
|
|
1755 | /* allow meta + click to select rectangular areas */ |
|
|
1756 | /* should be done in screen.C */ |
|
|
1757 | #if ENABLE_FRILLS |
|
|
1758 | selection.rect = !! (ev.state & ModMetaMask); |
|
|
1759 | #else |
|
|
1760 | selection.rect = false; |
|
|
1761 | #endif |
|
|
1762 | |
1761 | /* allow shift+left click to extend selection */ |
1763 | /* allow shift+left click to extend selection */ |
1762 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1764 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1763 | { |
1765 | { |
1764 | if (MEvent.button == Button1 && clickintime) |
1766 | if (MEvent.button == Button1 && clickintime) |
1765 | selection_rotate (ev.x, ev.y); |
1767 | selection_rotate (ev.x, ev.y); |
… | |
… | |
2407 | sy = 0; |
2409 | sy = 0; |
2408 | } |
2410 | } |
2409 | |
2411 | |
2410 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2412 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2411 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2413 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2414 | |
|
|
2415 | XSync (display->display, False); |
2412 | allowedxerror = -1; |
2416 | allowedxerror = -1; |
2413 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2417 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2414 | |
2418 | |
2415 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2419 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2416 | /* XXX: may need a delay here? */ |
2420 | /* XXX: may need a delay here? */ |
… | |
… | |
2462 | |
2466 | |
2463 | am_transparent = am_pixmap_trans = 1; |
2467 | am_transparent = am_pixmap_trans = 1; |
2464 | } |
2468 | } |
2465 | } |
2469 | } |
2466 | |
2470 | |
2467 | if (!am_pixmap_trans) |
2471 | if (am_pixmap_trans) |
|
|
2472 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
|
|
2473 | else |
2468 | { |
2474 | { |
2469 | unsigned int n; |
2475 | unsigned int n; |
2470 | /* |
2476 | /* |
2471 | * InheritPixmap transparency |
2477 | * InheritPixmap transparency |
2472 | */ |
2478 | */ |
… | |
… | |
2535 | if (scrollBar.win) |
2541 | if (scrollBar.win) |
2536 | { |
2542 | { |
2537 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2543 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2538 | scrollBar.setIdle (); |
2544 | scrollBar.setIdle (); |
2539 | scrollbar_show (0); |
2545 | scrollbar_show (0); |
|
|
2546 | } |
|
|
2547 | |
|
|
2548 | if (am_transparent) |
|
|
2549 | { |
|
|
2550 | want_refresh = want_full_refresh = 1; |
|
|
2551 | if (am_pixmap_trans) |
|
|
2552 | flush (); |
2540 | } |
2553 | } |
2541 | |
2554 | |
2542 | return pchanged; |
2555 | return pchanged; |
2543 | } |
2556 | } |
2544 | #endif |
2557 | #endif |
… | |
… | |
3504 | * ends_how is terminator used. returned input must be free()'d |
3517 | * ends_how is terminator used. returned input must be free()'d |
3505 | */ |
3518 | */ |
3506 | unsigned char * |
3519 | unsigned char * |
3507 | rxvt_term::get_to_st (unicode_t &ends_how) |
3520 | rxvt_term::get_to_st (unicode_t &ends_how) |
3508 | { |
3521 | { |
3509 | unicode_t seen_esc = 0, ch; |
3522 | unicode_t ch; |
|
|
3523 | bool seen_esc = false; |
3510 | unsigned int n = 0; |
3524 | unsigned int n = 0; |
3511 | unsigned char *s; |
|
|
3512 | unsigned char string[STRING_MAX]; |
3525 | wchar_t string[STRING_MAX]; |
3513 | |
3526 | |
3514 | while ((ch = cmd_getc ()) != NOCHAR) |
3527 | while ((ch = cmd_getc ()) != NOCHAR) |
3515 | { |
3528 | { |
3516 | if (seen_esc) |
3529 | if (seen_esc) |
3517 | { |
3530 | { |
… | |
… | |
3520 | else |
3533 | else |
3521 | return NULL; |
3534 | return NULL; |
3522 | } |
3535 | } |
3523 | else if (ch == C0_ESC) |
3536 | else if (ch == C0_ESC) |
3524 | { |
3537 | { |
3525 | seen_esc = 1; |
3538 | seen_esc = true; |
3526 | continue; |
3539 | continue; |
3527 | } |
3540 | } |
3528 | else if (ch == C0_BEL || ch == CHAR_ST) |
3541 | else if (ch == C0_BEL || ch == CHAR_ST) |
3529 | break; |
3542 | break; |
3530 | else if (ch < 0x20) |
3543 | else if (ch < 0x20) |
3531 | return NULL; /* other control character - exit */ |
3544 | return NULL; /* other control character - exit */ |
3532 | |
3545 | |
3533 | seen_esc = 0; |
3546 | seen_esc = false; |
3534 | |
3547 | |
3535 | if (n >= sizeof (string) - 1) |
3548 | if (n >= sizeof (string) - 1) |
3536 | // stop at some sane length |
3549 | // stop at some sane length |
3537 | return NULL; |
3550 | return NULL; |
3538 | |
3551 | |
… | |
… | |
3542 | string[n++] = ch; |
3555 | string[n++] = ch; |
3543 | } |
3556 | } |
3544 | |
3557 | |
3545 | string[n++] = '\0'; |
3558 | string[n++] = '\0'; |
3546 | |
3559 | |
3547 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3548 | return NULL; |
|
|
3549 | |
|
|
3550 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3560 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3551 | strncpy (s, string, n); |
3561 | |
3552 | return s; |
3562 | return (unsigned char *)rxvt_wcstombs (string); |
3553 | } |
3563 | } |
3554 | |
3564 | |
3555 | /*----------------------------------------------------------------------*/ |
3565 | /*----------------------------------------------------------------------*/ |
3556 | /* |
3566 | /* |
3557 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3567 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3658 | set_title (str); |
3668 | set_title (str); |
3659 | break; |
3669 | break; |
3660 | case XTerm_property: |
3670 | case XTerm_property: |
3661 | if (str[0] == '?') |
3671 | if (str[0] == '?') |
3662 | { |
3672 | { |
3663 | Atom prop = XInternAtom (display->display, str + 1, True); |
3673 | Atom prop = display->atom (str + 1); |
3664 | Atom actual_type; |
3674 | Atom actual_type; |
3665 | int actual_format; |
3675 | int actual_format; |
3666 | unsigned long nitems; |
3676 | unsigned long nitems; |
3667 | unsigned long bytes_after; |
3677 | unsigned long bytes_after; |
3668 | unsigned char *value = 0; |
3678 | unsigned char *value = 0; |
… | |
… | |
3686 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3696 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3687 | |
3697 | |
3688 | if (eq) |
3698 | if (eq) |
3689 | { |
3699 | { |
3690 | *eq = 0; |
3700 | *eq = 0; |
3691 | XChangeProperty (display->display, TermWin.parent[0], |
3701 | set_utf8_property (display->atom (str), eq + 1); |
3692 | display->atom (str), XA_STRING, 8, |
|
|
3693 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3694 | strlen (eq + 1)); |
|
|
3695 | } |
3702 | } |
3696 | else |
3703 | else |
3697 | XDeleteProperty (display->display, TermWin.parent[0], |
3704 | XDeleteProperty (display->display, TermWin.parent[0], |
3698 | display->atom (str)); |
3705 | display->atom (str)); |
3699 | } |
3706 | } |
… | |
… | |
3753 | break; |
3760 | break; |
3754 | case XTerm_Color_RV: |
3761 | case XTerm_Color_RV: |
3755 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3762 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3756 | break; |
3763 | break; |
3757 | #endif |
3764 | #endif |
3758 | #if TRANSPARENT || TINTING |
3765 | #if TRANSPARENT && TINTING |
3759 | case XTerm_Color_tint: |
3766 | case XTerm_Color_tint: |
3760 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3767 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3761 | check_our_parents (); |
3768 | check_our_parents (); |
3762 | if (am_transparent) |
3769 | if (am_transparent) |
3763 | want_full_refresh = want_refresh = 1; |
3770 | want_full_refresh = want_refresh = 1; |
… | |
… | |
4276 | |
4283 | |
4277 | /* ---------------------------------------------------------------------- */ |
4284 | /* ---------------------------------------------------------------------- */ |
4278 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4285 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4279 | * or generated by us in response to a query ESC sequence. |
4286 | * or generated by us in response to a query ESC sequence. |
4280 | */ |
4287 | */ |
|
|
4288 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4289 | |
4281 | void |
4290 | void |
4282 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4291 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4283 | { |
4292 | { |
4284 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4293 | if (v_buflen == 0) |
|
|
4294 | { |
|
|
4295 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4285 | |
4296 | |
4286 | if (len) |
4297 | if ((unsigned int)written == len) |
|
|
4298 | return; |
|
|
4299 | |
|
|
4300 | data += written; |
|
|
4301 | len -= written; |
4287 | { |
4302 | } |
|
|
4303 | |
|
|
4304 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4305 | |
|
|
4306 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4307 | v_buflen += len; |
|
|
4308 | |
|
|
4309 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4310 | } |
|
|
4311 | |
|
|
4312 | void rxvt_term::pty_write () |
|
|
4313 | { |
|
|
4314 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4315 | |
|
|
4316 | if (written > 0) |
|
|
4317 | { |
|
|
4318 | v_buflen -= written; |
|
|
4319 | |
4288 | if (v_buflen == 0) |
4320 | if (v_buflen == 0) |
4289 | { |
4321 | { |
4290 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4291 | |
|
|
4292 | if ((unsigned int)written == len) |
|
|
4293 | return; |
|
|
4294 | |
|
|
4295 | data += written; |
|
|
4296 | len -= written; |
|
|
4297 | } |
|
|
4298 | |
|
|
4299 | |
|
|
4300 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4301 | |
|
|
4302 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4303 | v_buflen += len; |
|
|
4304 | } |
|
|
4305 | |
|
|
4306 | for (;;) |
|
|
4307 | { |
|
|
4308 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4309 | |
|
|
4310 | if (written > 0) |
|
|
4311 | { |
|
|
4312 | v_buflen -= written; |
|
|
4313 | |
|
|
4314 | if (v_buflen == 0) |
|
|
4315 | { |
|
|
4316 | free (v_buffer); |
4322 | free (v_buffer); |
4317 | v_buffer = 0; |
4323 | v_buffer = 0; |
4318 | v_buflen = 0; |
4324 | v_buflen = 0; |
4319 | |
4325 | |
4320 | pty_ev.set (EVENT_READ); |
4326 | pty_ev.set (EVENT_READ); |
4321 | return; |
|
|
4322 | } |
|
|
4323 | |
|
|
4324 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
4325 | } |
|
|
4326 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4327 | // original code just ignores this... |
|
|
4328 | destroy (); |
|
|
4329 | else |
|
|
4330 | { |
|
|
4331 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4332 | return; |
4327 | return; |
4333 | } |
4328 | } |
|
|
4329 | |
|
|
4330 | memmove (v_buffer, v_buffer + written, v_buflen); |
4334 | } |
4331 | } |
|
|
4332 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4333 | // original code just ignores this... |
|
|
4334 | destroy (); |
4335 | } |
4335 | } |
4336 | |
4336 | |
4337 | /*----------------------- end-of-file (C source) -----------------------*/ |
4337 | /*----------------------- end-of-file (C source) -----------------------*/ |
4338 | |
4338 | |