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.175 by root, Sat Dec 11 17:18:29 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 */
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:
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 */
3506unsigned char * 3519unsigned char *
3507rxvt_term::get_to_st (unicode_t &ends_how) 3520rxvt_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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines