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.14 by pcg, Mon Dec 8 23:14:40 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.14 2003/12/08 23:14:40 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
1146{ 1160{
1147 int i, want_timeout; 1161 int i, want_timeout;
1148 Window unused_root, unused_child; 1162 Window unused_root, unused_child;
1149 int unused_root_x, unused_root_y; 1163 int unused_root_x, unused_root_y;
1150 unsigned int unused_mask; 1164 unsigned int unused_mask;
1151 struct timeval tp;
1152 1165
1153#ifdef DEBUG_X 1166#ifdef DEBUG_X
1154 const char *const eventnames[] = 1167 const char *const eventnames[] =
1155 { /* mason - this matches my system */ 1168 { /* mason - this matches my system */
1156 "", 1169 "",
1187 "SelectionNotify", 1200 "SelectionNotify",
1188 "ColormapNotify", 1201 "ColormapNotify",
1189 "ClientMessage", 1202 "ClientMessage",
1190 "MappingNotify" 1203 "MappingNotify"
1191 }; 1204 };
1205#endif
1206
1207#ifdef DEBUG_X
1208 struct timeval tp;
1192 struct tm *ltt; 1209 struct tm *ltt;
1193#endif
1194
1195 /*
1196 * check if we need to get the time for any timeouts
1197 */
1198
1199 for (i = NUM_TIMEOUTS; i--; )
1200 if (R->timeout[i].tv_sec) {
1201 want_timeout = 1;
1202 break;
1203 }
1204
1205#ifndef DEBUG_X
1206 if (want_timeout)
1207#endif
1208 (void)gettimeofday(&tp, NULL); 1210 (void)gettimeofday(&tp, NULL);
1209
1210#ifdef DEBUG_X
1211 ltt = localtime(&(tp.tv_sec)); 1211 ltt = localtime(&(tp.tv_sec));
1212 D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial)); 1212 D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial));
1213#endif 1213#endif
1214
1215 /* X event timeouts */
1216 if (want_timeout)
1217 for (i = NUM_TIMEOUTS; i--; ) {
1218 if (R->timeout[i].tv_sec == 0)
1219 continue;
1220 if ((tp.tv_sec < R->timeout[i].tv_sec)
1221 || (tp.tv_sec == R->timeout[i].tv_sec
1222 && tp.tv_usec < R->timeout[i].tv_usec))
1223 continue;
1224 R->timeout[i].tv_sec = 0;
1225 switch(i) {
1226 case TIMEOUT_INCR:
1227 rxvt_print_error("data loss: timeout on INCR selection paste");
1228 R->selection_wait = Sel_none;
1229 break;
1230 default:
1231 break;
1232 }
1233 }
1234 1214
1235 switch (ev->type) { 1215 switch (ev->type) {
1236 case KeyPress: 1216 case KeyPress:
1237 rxvt_lookup_key(aR_ (XKeyEvent *)ev); 1217 rxvt_lookup_key(aR_ (XKeyEvent *)ev);
1238 break; 1218 break;
1454 &unused_xevent)) ; 1434 &unused_xevent)) ;
1455 while (XCheckTypedWindowEvent(R->Xdisplay, ev->xany.window, 1435 while (XCheckTypedWindowEvent(R->Xdisplay, ev->xany.window,
1456 GraphicsExpose, 1436 GraphicsExpose,
1457 &unused_xevent)) ; 1437 &unused_xevent)) ;
1458 if (isScrollbarWindow(ev->xany.window)) { 1438 if (isScrollbarWindow(ev->xany.window)) {
1459 scrollbar_setIdle(); 1439 R->scrollBar.setIdle();
1460 rxvt_scrollbar_show(aR_ 0); 1440 rxvt_scrollbar_show(aR_ 0);
1461 } 1441 }
1462#ifdef MENUBAR 1442#ifdef MENUBAR
1463 if (menubar_visible(aR) && isMenuBarWindow(ev->xany.window)) 1443 if (menubar_visible(aR) && isMenuBarWindow(ev->xany.window))
1464 rxvt_menubar_expose(aR); 1444 rxvt_menubar_expose(aR);
1577 */ 1557 */
1578 if (ev->window == R->TermWin.vt) 1558 if (ev->window == R->TermWin.vt)
1579 { 1559 {
1580#if RXVT_GRAPHICS 1560#if RXVT_GRAPHICS
1581 if (ev->subwindow != None) 1561 if (ev->subwindow != None)
1582 rxvt_Gr_ButtonPress(ev->x, ev->y); 1562 rxvt_Gr_ButtonPress (ev->x, ev->y);
1583 else 1563 else
1584#endif 1564#endif
1585 { 1565 {
1586 clickintime = ev->time - R->MEvent.time < MULTICLICK_TIME; 1566 clickintime = ev->time - R->MEvent.time < MULTICLICK_TIME;
1587 if (reportmode) 1567 if (reportmode)
1649/* 1629/*
1650 * Scrollbar window processing of button press 1630 * Scrollbar window processing of button press
1651 */ 1631 */
1652 if (isScrollbarWindow(ev->window)) 1632 if (isScrollbarWindow(ev->window))
1653 { 1633 {
1654 scrollbar_setIdle(); 1634 R->scrollBar.setIdle ();
1655 /* 1635 /*
1656 * Rxvt-style scrollbar: 1636 * Rxvt-style scrollbar:
1657 * move up if mouse is above slider 1637 * move up if mouse is above slider
1658 * move dn if mouse is below slider 1638 * move dn if mouse is below slider
1659 * 1639 *
1712#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1692#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1713 R->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; 1693 R->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY;
1714#endif 1694#endif
1715 if (rxvt_scr_page(aR_ upordown < 0 ? UP : DN, 1)) { 1695 if (rxvt_scr_page(aR_ upordown < 0 ? UP : DN, 1)) {
1716 if (upordown < 0) 1696 if (upordown < 0)
1717 scrollbar_setUp(); 1697 R->scrollBar.setUp ();
1718 else 1698 else
1719 scrollbar_setDn(); 1699 R->scrollBar.setDn ();
1720 } 1700 }
1721 } else 1701 } else
1722 switch (ev->button) { 1702 switch (ev->button) {
1723 case Button2: 1703 case Button2:
1724 switch (R->scrollbar_align) { 1704 switch (R->scrollbar_align) {
1736 || scrollbar_above_slider(ev->y) 1716 || scrollbar_above_slider(ev->y)
1737 || scrollbar_below_slider(ev->y)) 1717 || scrollbar_below_slider(ev->y))
1738 rxvt_scr_move_to(aR_ 1718 rxvt_scr_move_to(aR_
1739 scrollbar_position(ev->y) - R->csrO, 1719 scrollbar_position(ev->y) - R->csrO,
1740 scrollbar_size()); 1720 scrollbar_size());
1741 scrollbar_setMotion(); 1721 R->scrollBar.setMotion ();
1742 break; 1722 break;
1743 1723
1744 case Button1: 1724 case Button1:
1745 if (R->scrollbar_align == R_SB_ALIGN_CENTRE) 1725 if (R->scrollbar_align == R_SB_ALIGN_CENTRE)
1746 R->csrO = ev->y - R->scrollBar.top; 1726 R->csrO = ev->y - R->scrollBar.top;
1759 rxvt_scr_page(aR_ DN, R->TermWin.nrow - 1); 1739 rxvt_scr_page(aR_ DN, R->TermWin.nrow - 1);
1760# else 1740# else
1761 rxvt_scr_page(aR_ DN, R->TermWin.nrow / 4); 1741 rxvt_scr_page(aR_ DN, R->TermWin.nrow / 4);
1762# endif 1742# endif
1763 else 1743 else
1764 scrollbar_setMotion(); 1744 R->scrollBar.setMotion ();
1765 } else { 1745 } else {
1766 rxvt_scr_page(aR_ (ev->button == Button1 ? DN : UP), 1746 rxvt_scr_page(aR_ (ev->button == Button1 ? DN : UP),
1767 (R->TermWin.nrow 1747 (R->TermWin.nrow
1768 * scrollbar_position(ev->y) 1748 * scrollbar_position(ev->y)
1769 / scrollbar_size())); 1749 / scrollbar_size()));
1791 R->csrO = 0; /* reset csr Offset */ 1771 R->csrO = 0; /* reset csr Offset */
1792 if (!R->bypass_keystate) 1772 if (!R->bypass_keystate)
1793 reportmode = !!(R->PrivateModes & PrivMode_mouse_report); 1773 reportmode = !!(R->PrivateModes & PrivMode_mouse_report);
1794 1774
1795 if (scrollbar_isUpDn()) { 1775 if (scrollbar_isUpDn()) {
1796 scrollbar_setIdle(); 1776 R->scrollBar.setIdle ();
1797 rxvt_scrollbar_show(aR_ 0); 1777 rxvt_scrollbar_show(aR_ 0);
1798#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1778#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1799 R->refresh_type &= ~SMOOTH_REFRESH; 1779 R->refresh_type &= ~SMOOTH_REFRESH;
1800#endif 1780#endif
1801 } 1781 }
1852 break; 1832 break;
1853#ifdef MOUSE_WHEEL 1833#ifdef MOUSE_WHEEL
1854 case Button4: 1834 case Button4:
1855 case Button5: 1835 case Button5:
1856 { 1836 {
1857 int i, v; 1837 int i;
1838 page_dirn v;
1858 1839
1859 v = (ev->button == Button4) ? UP : DN; 1840 v = (ev->button == Button4) ? UP : DN;
1860 if (ev->state & ShiftMask) 1841 if (ev->state & ShiftMask)
1861 i = 1; 1842 i = 1;
1862 else if ((R->Options & Opt_mouseWheelScrollPage)) 1843 else if ((R->Options & Opt_mouseWheelScrollPage))
2037 n = 0; 2018 n = 0;
2038 if (pchanged) { 2019 if (pchanged) {
2039 for (; n < (unsigned int)i; n++) { 2020 for (; n < (unsigned int)i; n++) {
2040 XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[n], &wattr); 2021 XGetWindowAttributes(R->Xdisplay, R->TermWin.parent[n], &wattr);
2041 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"));
2042 if (wattr.depth != rootdepth || wattr.class == InputOnly) { 2023 if (wattr.depth != rootdepth || wattr.c_class == InputOnly) {
2043 n = (int)(sizeof(R->TermWin.parent) / sizeof(Window)) + 1; 2024 n = (int)(sizeof(R->TermWin.parent) / sizeof(Window)) + 1;
2044 break; 2025 break;
2045 } 2026 }
2046 } 2027 }
2047 } 2028 }
2616 2597
2617 case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */ 2598 case CSI_SD: /* 8.3.114: (1) SCROLL DOWN */
2618 arg[0] = -arg[0]; 2599 arg[0] = -arg[0];
2619 /* FALLTHROUGH */ 2600 /* FALLTHROUGH */
2620 case CSI_SU: /* 8.3.148: (1) SCROLL UP */ 2601 case CSI_SU: /* 8.3.148: (1) SCROLL UP */
2621 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);
2622 break; 2603 break;
2623 2604
2624 case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ 2605 case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */
2625 R->tt_write((const unsigned char *)VT100_ANS, 2606 R->tt_write((const unsigned char *)VT100_ANS,
2626 (unsigned int)(sizeof(VT100_ANS) - 1)); 2607 (unsigned int)(sizeof(VT100_ANS) - 1));
3395 } 3376 }
3396 3377
3397 if ((cmd == 'T') && (nargs >= 5)) { 3378 if ((cmd == 'T') && (nargs >= 5)) {
3398 int i, len = args[4]; 3379 int i, len = args[4];
3399 3380
3400 text = rxvt_malloc((len + 1) * sizeof(char)); 3381 text = (unsigned char *)rxvt_malloc((len + 1) * sizeof(char));
3401 3382
3402 if (text != NULL) { 3383 if (text != NULL) {
3403 for (i = 0; i < len; i++) 3384 for (i = 0; i < len; i++)
3404 text[i] = rxvt_cmd_getc(aR); 3385 text[i] = rxvt_cmd_getc(aR);
3405 text[len] = '\0'; 3386 text[len] = '\0';

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines