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.163 by root, Wed Aug 25 03:47:20 2004 UTC vs.
Revision 1.176 by root, Mon Dec 13 01:29:03 2004 UTC

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
912void 913void
913rxvt_term::flush () 914rxvt_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
938void 939void
939rxvt_term::check_cb (check_watcher &w) 940rxvt_term::check_cb (check_watcher &w)
940{ 941{
1216 if (ev.type == KeyPress && hidden_pointer == 0) 1217 if (ev.type == KeyPress && hidden_pointer == 0)
1217 pointer_blank (); 1218 pointer_blank ();
1218 } 1219 }
1219#endif 1220#endif
1220 1221
1221#ifdef USE_XIM
1222 if (XFilterEvent (&ev, None))
1223 return;
1224#endif
1225
1226 Window unused_root, unused_child; 1222 Window unused_root, unused_child;
1227 int unused_root_x, unused_root_y; 1223 int unused_root_x, unused_root_y;
1228 unsigned int unused_mask; 1224 unsigned int unused_mask;
1229 1225
1230 switch (ev.type) 1226 switch (ev.type)
1231 { 1227 {
1232 case KeyPress: 1228 case KeyPress:
1233#if ISO_14755 1229#if ISO_14755
1338 0L, 1000000L, 1334 0L, 1000000L,
1339 False, AnyPropertyType, 1335 False, AnyPropertyType,
1340 &ActualType, &ActualFormat, 1336 &ActualType, &ActualFormat,
1341 &Size, &RemainingBytes, 1337 &Size, &RemainingBytes,
1342 &data); 1338 &data);
1343 XChangeProperty (display->display, display->root, 1339 set_string_property (XA_CUT_BUFFER0, data);
1344 XA_CUT_BUFFER0, XA_STRING,
1345 8, PropModeReplace,
1346 data, strlen (data));
1347 XFree (data); 1340 XFree (data);
1348 selection_paste (display->root, XA_CUT_BUFFER0, True); 1341 selection_paste (display->root, XA_CUT_BUFFER0, true);
1349 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); 1342 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime);
1350 } 1343 }
1351#endif /* OFFIX_DND */ 1344#endif /* OFFIX_DND */
1352 break; 1345 break;
1353 1346
1457 resize_all_windows (width, height, 1); 1450 resize_all_windows (width, height, 1);
1458 } 1451 }
1459 1452
1460#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1453#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1461 if (options & Opt_transparent) 1454 if (options & Opt_transparent)
1462 {
1463 check_our_parents (); 1455 check_our_parents ();
1464 if (am_transparent)
1465 want_refresh = want_full_refresh = 1;
1466 }
1467#endif 1456#endif
1468 } 1457 }
1469 break; 1458 break;
1470 1459
1471 case PropertyNotify: 1460 case PropertyNotify:
1479 selection_clear (); 1468 selection_clear ();
1480 break; 1469 break;
1481 1470
1482 case SelectionNotify: 1471 case SelectionNotify:
1483 if (selection_wait == Sel_normal) 1472 if (selection_wait == Sel_normal)
1484 selection_paste (ev.xselection.requestor, 1473 selection_paste (ev.xselection.requestor, ev.xselection.property, true);
1485 ev.xselection.property, True);
1486 break; 1474 break;
1487 1475
1488 case SelectionRequest: 1476 case SelectionRequest:
1489 selection_send (ev.xselectionrequest); 1477 selection_send (ev.xselectionrequest);
1490 break; 1478 break;
1562 { 1550 {
1563 menubar_control (ev.xbutton); 1551 menubar_control (ev.xbutton);
1564 break; 1552 break;
1565 } 1553 }
1566#endif 1554#endif
1567 if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) 1555 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1568 break; 1556 break;
1569 1557
1570 if (ev.xany.window == TermWin.vt) 1558 if (ev.xany.window == TermWin.vt)
1571 { 1559 {
1572 if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1560 if (ev.xbutton.state & (Button1Mask | Button3Mask))
1575 ; 1563 ;
1576 1564
1577 XQueryPointer (display->display, TermWin.vt, 1565 XQueryPointer (display->display, TermWin.vt,
1578 &unused_root, &unused_child, 1566 &unused_root, &unused_child,
1579 &unused_root_x, &unused_root_y, 1567 &unused_root_x, &unused_root_y,
1580 & (ev.xbutton.x), & (ev.xbutton.y), 1568 &ev.xbutton.x, &ev.xbutton.y,
1581 &unused_mask); 1569 &ev.xbutton.state);
1582#ifdef MOUSE_THRESHOLD 1570#ifdef MOUSE_THRESHOLD
1583 /* deal with a `jumpy' mouse */ 1571 /* deal with a `jumpy' mouse */
1584 if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) 1572 if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD)
1585 { 1573 {
1586#endif 1574#endif
1591 iso14755_54 (ev.xbutton.x, ev.xbutton.y); 1579 iso14755_54 (ev.xbutton.x, ev.xbutton.y);
1592 break; 1580 break;
1593 } 1581 }
1594#endif 1582#endif
1595 selection_extend (ev.xbutton.x, ev.xbutton.y, 1583 selection_extend (ev.xbutton.x, ev.xbutton.y,
1596 (ev.xbutton.state & Button3Mask) ? 2 : 0); 1584 ev.xbutton.state & Button3Mask ? 2 : 0);
1585
1597#ifdef SELECTION_SCROLLING 1586#ifdef SELECTION_SCROLLING
1598 if (ev.xbutton.y < TermWin.int_bwidth 1587 if (ev.xbutton.y < TermWin.int_bwidth
1599 || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) 1588 || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1))
1600 { 1589 {
1601 int dist; 1590 int dist;
1612 selection_save_x = ev.xbutton.x; 1601 selection_save_x = ev.xbutton.x;
1613 selection_save_y = ev.xbutton.y; 1602 selection_save_y = ev.xbutton.y;
1614 selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; 1603 selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0;
1615 1604
1616 /* calc number of lines to scroll */ 1605 /* calc number of lines to scroll */
1617 if (ev.xbutton.y<TermWin.int_bwidth) 1606 if (ev.xbutton.y < TermWin.int_bwidth)
1618 { 1607 {
1619 scroll_selection_dir = UP; 1608 scroll_selection_dir = UP;
1620 dist = TermWin.int_bwidth - ev.xbutton.y; 1609 dist = TermWin.int_bwidth - ev.xbutton.y;
1621 } 1610 }
1622 else 1611 else
1646 } 1635 }
1647 } 1636 }
1648 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1637 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ())
1649 { 1638 {
1650 while (XCheckTypedWindowEvent (display->display, scrollBar.win, 1639 while (XCheckTypedWindowEvent (display->display, scrollBar.win,
1651 MotionNotify, &ev)) ; 1640 MotionNotify, &ev))
1641 ;
1642
1652 XQueryPointer (display->display, scrollBar.win, 1643 XQueryPointer (display->display, scrollBar.win,
1653 &unused_root, &unused_child, 1644 &unused_root, &unused_child,
1654 &unused_root_x, &unused_root_y, 1645 &unused_root_x, &unused_root_y,
1655 & (ev.xbutton.x), & (ev.xbutton.y), 1646 &ev.xbutton.x, &ev.xbutton.y,
1656 &unused_mask); 1647 &unused_mask);
1657 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1648 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1658 scrollbar_size ()); 1649 scrollbar_size ());
1659 scr_refresh (refresh_type); 1650 scr_refresh (refresh_type);
1660 refresh_limit = 0; 1651 refresh_limit = 0;
1715 return; 1706 return;
1716 } 1707 }
1717#endif 1708#endif
1718 1709
1719 clickintime = ev.time - MEvent.time < MULTICLICK_TIME; 1710 clickintime = ev.time - MEvent.time < MULTICLICK_TIME;
1711
1720 if (reportmode) 1712 if (reportmode)
1721 { 1713 {
1722 /* mouse report from vt window */ 1714 /* mouse report from vt window */
1723 /* save the xbutton state (for ButtonRelease) */ 1715 /* save the xbutton state (for ButtonRelease) */
1724 MEvent.state = ev.state; 1716 MEvent.state = ev.state;
1753 } 1745 }
1754 else 1746 else
1755 { 1747 {
1756 if (ev.button != MEvent.button) 1748 if (ev.button != MEvent.button)
1757 MEvent.clicks = 0; 1749 MEvent.clicks = 0;
1750
1758 switch (ev.button) 1751 switch (ev.button)
1759 { 1752 {
1760 case Button1: 1753 case Button1:
1754 /* allow meta + click to select rectangular areas */
1755 /* should be done in screen.C */
1756#if ENABLE_FRILLS
1757 selection.rect = !! (ev.state & ModMetaMask);
1758#else
1759 selection.rect = false;
1760#endif
1761
1761 /* allow shift+left click to extend selection */ 1762 /* allow shift+left click to extend selection */
1762 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1763 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report))
1763 { 1764 {
1764 if (MEvent.button == Button1 && clickintime) 1765 if (MEvent.button == Button1 && clickintime)
1765 selection_rotate (ev.x, ev.y); 1766 selection_rotate (ev.x, ev.y);
2407 sy = 0; 2408 sy = 0;
2408 } 2409 }
2409 2410
2410 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 2411 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
2411 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 2412 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
2413
2414 XSync (display->display, False);
2412 allowedxerror = -1; 2415 allowedxerror = -1;
2413 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); 2416 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2414 2417
2415 /* XXX: handle BadMatch - usually because we're outside the pixmap */ 2418 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2416 /* XXX: may need a delay here? */ 2419 /* XXX: may need a delay here? */
2462 2465
2463 am_transparent = am_pixmap_trans = 1; 2466 am_transparent = am_pixmap_trans = 1;
2464 } 2467 }
2465 } 2468 }
2466 2469
2467 if (!am_pixmap_trans) 2470 if (am_pixmap_trans)
2471 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
2472 else
2468 { 2473 {
2469 unsigned int n; 2474 unsigned int n;
2470 /* 2475 /*
2471 * InheritPixmap transparency 2476 * InheritPixmap transparency
2472 */ 2477 */
2535 if (scrollBar.win) 2540 if (scrollBar.win)
2536 { 2541 {
2537 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); 2542 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
2538 scrollBar.setIdle (); 2543 scrollBar.setIdle ();
2539 scrollbar_show (0); 2544 scrollbar_show (0);
2545 }
2546
2547 if (am_transparent)
2548 {
2549 want_refresh = want_full_refresh = 1;
2550 if (am_pixmap_trans)
2551 flush ();
2540 } 2552 }
2541 2553
2542 return pchanged; 2554 return pchanged;
2543} 2555}
2544#endif 2556#endif
3504 * ends_how is terminator used. returned input must be free()'d 3516 * ends_how is terminator used. returned input must be free()'d
3505 */ 3517 */
3506unsigned char * 3518unsigned char *
3507rxvt_term::get_to_st (unicode_t &ends_how) 3519rxvt_term::get_to_st (unicode_t &ends_how)
3508{ 3520{
3509 unicode_t seen_esc = 0, ch; 3521 unicode_t ch;
3522 bool seen_esc = false;
3510 unsigned int n = 0; 3523 unsigned int n = 0;
3511 unsigned char *s;
3512 unsigned char string[STRING_MAX]; 3524 wchar_t string[STRING_MAX];
3513 3525
3514 while ((ch = cmd_getc ()) != NOCHAR) 3526 while ((ch = cmd_getc ()) != NOCHAR)
3515 { 3527 {
3516 if (seen_esc) 3528 if (seen_esc)
3517 { 3529 {
3520 else 3532 else
3521 return NULL; 3533 return NULL;
3522 } 3534 }
3523 else if (ch == C0_ESC) 3535 else if (ch == C0_ESC)
3524 { 3536 {
3525 seen_esc = 1; 3537 seen_esc = true;
3526 continue; 3538 continue;
3527 } 3539 }
3528 else if (ch == C0_BEL || ch == CHAR_ST) 3540 else if (ch == C0_BEL || ch == CHAR_ST)
3529 break; 3541 break;
3530 else if (ch < 0x20) 3542 else if (ch < 0x20)
3531 return NULL; /* other control character - exit */ 3543 return NULL; /* other control character - exit */
3532 3544
3533 seen_esc = 0; 3545 seen_esc = false;
3534 3546
3535 if (n >= sizeof (string) - 1) 3547 if (n >= sizeof (string) - 1)
3536 // stop at some sane length 3548 // stop at some sane length
3537 return NULL; 3549 return NULL;
3538 3550
3542 string[n++] = ch; 3554 string[n++] = ch;
3543 } 3555 }
3544 3556
3545 string[n++] = '\0'; 3557 string[n++] = '\0';
3546 3558
3547 if ((s = (unsigned char *)rxvt_malloc (n)) == NULL)
3548 return NULL;
3549
3550 ends_how = (ch == 0x5c ? C0_ESC : ch); 3559 ends_how = (ch == 0x5c ? C0_ESC : ch);
3551 strncpy (s, string, n); 3560
3552 return s; 3561 return (unsigned char *)rxvt_wcstombs (string);
3553} 3562}
3554 3563
3555/*----------------------------------------------------------------------*/ 3564/*----------------------------------------------------------------------*/
3556/* 3565/*
3557 * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' 3566 * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)'
3658 set_title (str); 3667 set_title (str);
3659 break; 3668 break;
3660 case XTerm_property: 3669 case XTerm_property:
3661 if (str[0] == '?') 3670 if (str[0] == '?')
3662 { 3671 {
3663 Atom prop = XInternAtom (display->display, str + 1, True); 3672 Atom prop = display->atom (str + 1);
3664 Atom actual_type; 3673 Atom actual_type;
3665 int actual_format; 3674 int actual_format;
3666 unsigned long nitems; 3675 unsigned long nitems;
3667 unsigned long bytes_after; 3676 unsigned long bytes_after;
3668 unsigned char *value = 0; 3677 unsigned char *value = 0;
3686 char *eq = strchr (str, '='); // constness lost, but verified to be ok 3695 char *eq = strchr (str, '='); // constness lost, but verified to be ok
3687 3696
3688 if (eq) 3697 if (eq)
3689 { 3698 {
3690 *eq = 0; 3699 *eq = 0;
3691 XChangeProperty (display->display, TermWin.parent[0], 3700 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 } 3701 }
3696 else 3702 else
3697 XDeleteProperty (display->display, TermWin.parent[0], 3703 XDeleteProperty (display->display, TermWin.parent[0],
3698 display->atom (str)); 3704 display->atom (str));
3699 } 3705 }
3753 break; 3759 break;
3754 case XTerm_Color_RV: 3760 case XTerm_Color_RV:
3755 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3761 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3756 break; 3762 break;
3757#endif 3763#endif
3758#if TRANSPARENT || TINTING 3764#if TRANSPARENT && TINTING
3759 case XTerm_Color_tint: 3765 case XTerm_Color_tint:
3760 process_color_seq (XTerm_Color_tint, Color_tint, str, resp); 3766 process_color_seq (XTerm_Color_tint, Color_tint, str, resp);
3761 check_our_parents (); 3767 check_our_parents ();
3762 if (am_transparent) 3768 if (am_transparent)
3763 want_full_refresh = want_refresh = 1; 3769 want_full_refresh = want_refresh = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines