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.15 by pcg, Tue Dec 16 23:04:13 2003 UTC vs.
Revision 1.19 by pcg, Thu Dec 18 05:45:11 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: command.c 2 * File: command.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: command.C,v 1.15 2003/12/16 23:04:13 pcg Exp $ 4 * $Id: command.C,v 1.19 2003/12/18 05:45:11 pcg Exp $
5 * 5 *
6 * All portions of code are copyright by their respective author/s. 6 * All portions of code are copyright by their respective author/s.
7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
8 * - original version 8 * - original version
9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
88 if (R->Input_Context) 88 if (R->Input_Context)
89 { 89 {
90 Status status_return; 90 Status status_return;
91 91
92#ifdef X_HAVE_UTF8_STRING 92#ifdef X_HAVE_UTF8_STRING
93 len = Xutf8LookupString(R->Input_Context, ev, (char *)kbuf, 93 len = Xutf8LookupString (R->Input_Context, ev, (char *)kbuf,
94 KBUFSZ, &keysym, &status_return); 94 KBUFSZ, &keysym, &status_return);
95#else 95#else
96 wchar_t wkbuf[KBUFSZ + 1];
97
98 // assume wchar_t == unicode or better
96 len = XmbLookupString(R->Input_Context, ev, (char *)kbuf, 99 len = XwcLookupString (R->Input_Context, ev, wkbuf,
97 KBUFSZ, &keysym, &status_return); 100 KBUFSZ, &keysym, &status_return);
101
102 if (status_return == XLookupChars
103 || status_return == XLookupBoth)
104 {
105 wkbuf[len] = 0;
106 len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ);
107 }
108 else
109 len = 0;
98#endif 110#endif
99 valid_keysym = ((status_return == XLookupKeySym) 111 valid_keysym = status_return == XLookupKeySym
100 || (status_return == XLookupBoth)); 112 || status_return == XLookupBoth;
101 } 113 }
102 else 114 else
103#endif 115#endif
104 { 116 {
105 len = XLookupString(ev, (char *)kbuf, KBUFSZ, &keysym, &R->compose); 117 len = XLookupString (ev, (char *)kbuf, KBUFSZ, &keysym, &R->compose);
106 valid_keysym = !len; 118 valid_keysym = !len;
107 } 119 }
108 120
109 if (valid_keysym) 121 if (valid_keysym)
110 { 122 {
679 691
680void 692void
681rxvt_term::check_cb (check_watcher &w) 693rxvt_term::check_cb (check_watcher &w)
682{ 694{
683 SET_R (this); 695 SET_R (this);
696 SET_LOCALE (locale);
684 697
685 flush (); 698 flush ();
686} 699}
687 700
688void 701void
732} 745}
733 746
734void 747void
735rxvt_term::blink_cb (time_watcher &w) 748rxvt_term::blink_cb (time_watcher &w)
736{ 749{
737 SET_R (this);
738
739 w.at += BLINK_INTERVAL; 750 w.at += BLINK_INTERVAL;
740 hidden_cursor = !hidden_cursor; 751 hidden_cursor = !hidden_cursor;
741 want_refresh = 1; 752 want_refresh = 1;
742} 753}
743 754
744void 755void
745rxvt_term::x_cb (io_watcher &w, short revents) 756rxvt_term::x_cb (io_watcher &w, short revents)
746{ 757{
747 SET_R (this); 758 SET_R (this);
759 SET_LOCALE (locale);
748 760
749 process_x_events (); 761 process_x_events ();
750} 762}
751 763
752bool 764bool
773 785
774void 786void
775rxvt_term::pty_cb (io_watcher &w, short revents) 787rxvt_term::pty_cb (io_watcher &w, short revents)
776{ 788{
777 SET_R (this); 789 SET_R (this);
790 SET_LOCALE (locale);
778 791
779 if (revents & EVENT_WRITE) 792 if (revents & EVENT_WRITE)
780 tt_write (0, 0); 793 tt_write (0, 0);
781 else if (revents & EVENT_READ) 794 else if (revents & EVENT_READ)
782 { 795 {
1026 1039
1027void 1040void
1028rxvt_term::pointer_unblank () 1041rxvt_term::pointer_unblank ()
1029{ 1042{
1030 XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor); 1043 XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor);
1031 rxvt_recolour_cursor (this); 1044 recolour_cursor ();
1032 1045
1033#ifdef POINTER_BLANK 1046#ifdef POINTER_BLANK
1034 hidden_pointer = 0; 1047 hidden_pointer = 0;
1035 1048
1036 if (Options & Opt_pointerBlank) 1049 if (Options & Opt_pointerBlank)
1055 1068
1056void 1069void
1057rxvt_term::pointer_cb (time_watcher &w) 1070rxvt_term::pointer_cb (time_watcher &w)
1058{ 1071{
1059 SET_R (this); 1072 SET_R (this);
1073 SET_LOCALE (locale);
1060 1074
1061 pointer_blank (); 1075 pointer_blank ();
1062} 1076}
1063#endif 1077#endif
1064 1078
1420 &unused_xevent)) ; 1434 &unused_xevent)) ;
1421 while (XCheckTypedWindowEvent(R->Xdisplay, ev->xany.window, 1435 while (XCheckTypedWindowEvent(R->Xdisplay, ev->xany.window,
1422 GraphicsExpose, 1436 GraphicsExpose,
1423 &unused_xevent)) ; 1437 &unused_xevent)) ;
1424 if (isScrollbarWindow(ev->xany.window)) { 1438 if (isScrollbarWindow(ev->xany.window)) {
1425 scrollbar_setIdle(); 1439 R->scrollBar.setIdle();
1426 rxvt_scrollbar_show(aR_ 0); 1440 rxvt_scrollbar_show(aR_ 0);
1427 } 1441 }
1428#ifdef MENUBAR 1442#ifdef MENUBAR
1429 if (menubar_visible(aR) && isMenuBarWindow(ev->xany.window)) 1443 if (menubar_visible(aR) && isMenuBarWindow(ev->xany.window))
1430 rxvt_menubar_expose(aR); 1444 rxvt_menubar_expose(aR);
1543 */ 1557 */
1544 if (ev->window == R->TermWin.vt) 1558 if (ev->window == R->TermWin.vt)
1545 { 1559 {
1546#if RXVT_GRAPHICS 1560#if RXVT_GRAPHICS
1547 if (ev->subwindow != None) 1561 if (ev->subwindow != None)
1548 rxvt_Gr_ButtonPress(ev->x, ev->y); 1562 rxvt_Gr_ButtonPress (ev->x, ev->y);
1549 else 1563 else
1550#endif 1564#endif
1551 { 1565 {
1552 clickintime = ev->time - R->MEvent.time < MULTICLICK_TIME; 1566 clickintime = ev->time - R->MEvent.time < MULTICLICK_TIME;
1553 if (reportmode) 1567 if (reportmode)
1615/* 1629/*
1616 * Scrollbar window processing of button press 1630 * Scrollbar window processing of button press
1617 */ 1631 */
1618 if (isScrollbarWindow(ev->window)) 1632 if (isScrollbarWindow(ev->window))
1619 { 1633 {
1620 scrollbar_setIdle(); 1634 R->scrollBar.setIdle ();
1621 /* 1635 /*
1622 * Rxvt-style scrollbar: 1636 * Rxvt-style scrollbar:
1623 * move up if mouse is above slider 1637 * move up if mouse is above slider
1624 * move dn if mouse is below slider 1638 * move dn if mouse is below slider
1625 * 1639 *
1678#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1692#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1679 R->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; 1693 R->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY;
1680#endif 1694#endif
1681 if (rxvt_scr_page(aR_ upordown < 0 ? UP : DN, 1)) { 1695 if (rxvt_scr_page(aR_ upordown < 0 ? UP : DN, 1)) {
1682 if (upordown < 0) 1696 if (upordown < 0)
1683 scrollbar_setUp(); 1697 R->scrollBar.setUp ();
1684 else 1698 else
1685 scrollbar_setDn(); 1699 R->scrollBar.setDn ();
1686 } 1700 }
1687 } else 1701 } else
1688 switch (ev->button) { 1702 switch (ev->button) {
1689 case Button2: 1703 case Button2:
1690 switch (R->scrollbar_align) { 1704 switch (R->scrollbar_align) {
1702 || scrollbar_above_slider(ev->y) 1716 || scrollbar_above_slider(ev->y)
1703 || scrollbar_below_slider(ev->y)) 1717 || scrollbar_below_slider(ev->y))
1704 rxvt_scr_move_to(aR_ 1718 rxvt_scr_move_to(aR_
1705 scrollbar_position(ev->y) - R->csrO, 1719 scrollbar_position(ev->y) - R->csrO,
1706 scrollbar_size()); 1720 scrollbar_size());
1707 scrollbar_setMotion(); 1721 R->scrollBar.setMotion ();
1708 break; 1722 break;
1709 1723
1710 case Button1: 1724 case Button1:
1711 if (R->scrollbar_align == R_SB_ALIGN_CENTRE) 1725 if (R->scrollbar_align == R_SB_ALIGN_CENTRE)
1712 R->csrO = ev->y - R->scrollBar.top; 1726 R->csrO = ev->y - R->scrollBar.top;
1725 rxvt_scr_page(aR_ DN, R->TermWin.nrow - 1); 1739 rxvt_scr_page(aR_ DN, R->TermWin.nrow - 1);
1726# else 1740# else
1727 rxvt_scr_page(aR_ DN, R->TermWin.nrow / 4); 1741 rxvt_scr_page(aR_ DN, R->TermWin.nrow / 4);
1728# endif 1742# endif
1729 else 1743 else
1730 scrollbar_setMotion(); 1744 R->scrollBar.setMotion ();
1731 } else { 1745 } else {
1732 rxvt_scr_page(aR_ (ev->button == Button1 ? DN : UP), 1746 rxvt_scr_page(aR_ (ev->button == Button1 ? DN : UP),
1733 (R->TermWin.nrow 1747 (R->TermWin.nrow
1734 * scrollbar_position(ev->y) 1748 * scrollbar_position(ev->y)
1735 / scrollbar_size())); 1749 / scrollbar_size()));
1757 R->csrO = 0; /* reset csr Offset */ 1771 R->csrO = 0; /* reset csr Offset */
1758 if (!R->bypass_keystate) 1772 if (!R->bypass_keystate)
1759 reportmode = !!(R->PrivateModes & PrivMode_mouse_report); 1773 reportmode = !!(R->PrivateModes & PrivMode_mouse_report);
1760 1774
1761 if (scrollbar_isUpDn()) { 1775 if (scrollbar_isUpDn()) {
1762 scrollbar_setIdle(); 1776 R->scrollBar.setIdle ();
1763 rxvt_scrollbar_show(aR_ 0); 1777 rxvt_scrollbar_show(aR_ 0);
1764#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1778#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1765 R->refresh_type &= ~SMOOTH_REFRESH; 1779 R->refresh_type &= ~SMOOTH_REFRESH;
1766#endif 1780#endif
1767 } 1781 }
1818 break; 1832 break;
1819#ifdef MOUSE_WHEEL 1833#ifdef MOUSE_WHEEL
1820 case Button4: 1834 case Button4:
1821 case Button5: 1835 case Button5:
1822 { 1836 {
1823 int i, v; 1837 int i;
1838 page_dirn v;
1824 1839
1825 v = (ev->button == Button4) ? UP : DN; 1840 v = (ev->button == Button4) ? UP : DN;
1826 if (ev->state & ShiftMask) 1841 if (ev->state & ShiftMask)
1827 i = 1; 1842 i = 1;
1828 else if ((R->Options & Opt_mouseWheelScrollPage)) 1843 else if ((R->Options & Opt_mouseWheelScrollPage))
2003 n = 0; 2018 n = 0;
2004 if (pchanged) { 2019 if (pchanged) {
2005 for (; n < (unsigned int)i; n++) { 2020 for (; n < (unsigned int)i; n++) {
2006 XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[n], &wattr); 2021 XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[n], &wattr);
2007 D_X((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL")); 2022 D_X((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL"));
2008 if (wattr.depth != rootdepth || wattr.class == InputOnly) { 2023 if (wattr.depth != rootdepth || wattr.c_class == InputOnly) {
2009 n = (int)(sizeof(R->TermWin.parent) / sizeof(Window)) + 1; 2024 n = (int)(sizeof(R->TermWin.parent) / sizeof(Window)) + 1;
2010 break; 2025 break;
2011 } 2026 }
2012 } 2027 }
2013 } 2028 }
2582 2597
2583 case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */ 2598 case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */
2584 arg[0] = -arg[0]; 2599 arg[0] = -arg[0];
2585 /* FALLTHROUGH */ 2600 /* FALLTHROUGH */
2586 case CSI_SU: /* 8.3.148: (1) SCROLL UP */ 2601 case CSI_SU: /* 8.3.148: (1) SCROLL UP */
2587 rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, arg[0], 0); 2602 R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, arg[0], 0);
2588 break; 2603 break;
2589 2604
2590 case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ 2605 case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */
2591 R->tt_write((const unsigned char *)VT100_ANS, 2606 R->tt_write((const unsigned char *)VT100_ANS,
2592 (unsigned int)(sizeof(VT100_ANS) - 1)); 2607 (unsigned int)(sizeof(VT100_ANS) - 1));
3361 } 3376 }
3362 3377
3363 if ((cmd == 'T') && (nargs >= 5)) { 3378 if ((cmd == 'T') && (nargs >= 5)) {
3364 int i, len = args[4]; 3379 int i, len = args[4];
3365 3380
3366 text = rxvt_malloc((len + 1) * sizeof(char)); 3381 text = (unsigned char *)rxvt_malloc((len + 1) * sizeof(char));
3367 3382
3368 if (text != NULL) { 3383 if (text != NULL) {
3369 for (i = 0; i < len; i++) 3384 for (i = 0; i < len; i++)
3370 text[i] = rxvt_cmd_getc(aR); 3385 text[i] = rxvt_cmd_getc(aR);
3371 text[len] = '\0'; 3386 text[len] = '\0';

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines