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.49 by pcg, Sat Feb 21 22:14:00 2004 UTC vs.
Revision 1.67 by pcg, Thu Mar 11 00:53:19 2004 UTC

110 SET_LOCALE (locale); 110 SET_LOCALE (locale);
111 111
112 if (status_return == XLookupChars 112 if (status_return == XLookupChars
113 || status_return == XLookupBoth) 113 || status_return == XLookupBoth)
114 { 114 {
115 /* make sure the user can type ctrl-@, i.e. NUL */
116 if (len == 1 && *wkbuf == 0)
117 {
118 kbuf[0] = 0;
119 len = 1;
120 }
121 else
122 {
115 wkbuf[len] = 0; 123 wkbuf[len] = 0;
116 len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ); 124 len = wcstombs ((char *)kbuf, wkbuf, KBUFSZ);
117 if (len < 0) 125 if (len < 0)
118 len = 0; 126 len = 0;
127 }
119 } 128 }
120 else 129 else
121 len = 0; 130 len = 0;
122 } 131 }
123 132
141 if (meta) 150 if (meta)
142# endif 151# endif
143 { 152 {
144 if (keysym == ks_bigfont) 153 if (keysym == ks_bigfont)
145 { 154 {
146 change_font (0, FONT_UP); 155 change_font (FONT_UP);
147 return; 156 return;
148 } 157 }
149 else if (keysym == ks_smallfont) 158 else if (keysym == ks_smallfont)
150 { 159 {
151 change_font (0, FONT_DN); 160 change_font (FONT_DN);
152 return; 161 return;
153 } 162 }
154 } 163 }
155#endif 164#endif
156 165
229 case XK_Insert: /* Shift+Insert = paste mouse selection */ 238 case XK_Insert: /* Shift+Insert = paste mouse selection */
230 selection_request (ev.time, 0, 0); 239 selection_request (ev.time, 0, 0);
231 return; 240 return;
232 /* rxvt extras */ 241 /* rxvt extras */
233 case XK_KP_Add: /* Shift+KP_Add = bigger font */ 242 case XK_KP_Add: /* Shift+KP_Add = bigger font */
234 change_font (0, FONT_UP); 243 change_font (FONT_UP);
235 return; 244 return;
236 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ 245 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */
237 change_font (0, FONT_DN); 246 change_font (FONT_DN);
238 return; 247 return;
239 } 248 }
240 } 249 }
241 } 250 }
242#ifdef PRINTPIPE 251#ifdef PRINTPIPE
243 if (keysym == XK_Print) 252 if (keysym == XK_Print)
244 { 253 {
245 scr_printscreen (ctrl | shft); 254 scr_printscreen (ctrl | shft);
246 return;
247 }
248#endif
249#ifdef GREEK_SUPPORT
250 if (keysym == ks_greekmodeswith)
251 {
252 greek_mode = !greek_mode;
253 if (greek_mode)
254 {
255 xterm_seq (XTerm_title,
256 (greek_getmode () == GREEK_ELOT928
257 ? "[Greek: iso]" : "[Greek: ibm]"), CHAR_ST);
258 greek_reset ();
259 }
260 else
261 xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST);
262 return; 255 return;
263 } 256 }
264#endif 257#endif
265 258
266 if (keysym >= 0xFF00 && keysym <= 0xFFFF) 259 if (keysym >= 0xFF00 && keysym <= 0xFFFF)
298 ^ !!ctrl) ? '\b' : '\177'; 291 ^ !!ctrl) ? '\b' : '\177';
299 kbuf[1] = '\0'; 292 kbuf[1] = '\0';
300 } 293 }
301 else 294 else
302 STRCPY (kbuf, key_backspace); 295 STRCPY (kbuf, key_backspace);
303# ifdef MULTICHAR_SET
304 if ((Options & Opt_mc_hack) && screen.cur.col > 0)
305 {
306 int col, row;
307
308 newlen = STRLEN (kbuf);
309 col = screen.cur.col - 1;
310 row = screen.cur.row + TermWin.saveLines;
311 if (IS_MULTI2 (screen.rend[row][col]))
312 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
313 }
314# endif
315 break; 296 break;
316#endif 297#endif
317#ifndef NO_DELETE_KEY 298#ifndef NO_DELETE_KEY
318 case XK_Delete: 299 case XK_Delete:
319 STRCPY (kbuf, key_delete); 300 STRCPY (kbuf, key_delete);
320# ifdef MULTICHAR_SET
321 if (Options & Opt_mc_hack)
322 {
323 int col, row;
324
325 newlen = STRLEN (kbuf);
326 col = screen.cur.col;
327 row = screen.cur.row + TermWin.saveLines;
328 if (IS_MULTI1 (screen.rend[row][col]))
329 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
330 }
331# endif
332 break; 301 break;
333#endif 302#endif
334 case XK_Tab: 303 case XK_Tab:
335 if (shft) 304 if (shft)
336 STRCPY (kbuf, "\033[Z"); 305 STRCPY (kbuf, "\033[Z");
378 kbuf[1] = 'O'; 347 kbuf[1] = 'O';
379 kbuf[2] = "dacb"[keysym - XK_Left]; 348 kbuf[2] = "dacb"[keysym - XK_Left];
380 } 349 }
381 else if (PrivateModes & PrivMode_aplCUR) 350 else if (PrivateModes & PrivMode_aplCUR)
382 kbuf[1] = 'O'; 351 kbuf[1] = 'O';
383#ifdef MULTICHAR_SET
384 //TODO: ??
385 if (Options & Opt_mc_hack)
386 {
387 int col, row, m;
388
389 col = screen.cur.col;
390 row = screen.cur.row + TermWin.saveLines;
391 m = 0;
392 if (keysym == XK_Right
393 && IS_MULTI1 (screen.rend[row][col]))
394 m = 1;
395 else if (keysym == XK_Left)
396 {
397 if (col > 0)
398 {
399 if (IS_MULTI2 (screen.rend[row][col - 1]))
400 m = 1;
401 }
402 else if (screen.cur.row > 0)
403 {
404 col = screen.tlen[--row];
405 if (col == -1)
406 col = TermWin.ncol - 1;
407 else
408 col--;
409 if (col > 0
410 && IS_MULTI2 (screen.rend[row][col]))
411 m = 1;
412 }
413 }
414 if (m)
415 MEMMOVE (kbuf + 3, kbuf, 3 + 1);
416 }
417#endif
418 break; 352 break;
419 353
420#ifndef UNSHIFTED_SCROLLKEYS 354#ifndef UNSHIFTED_SCROLLKEYS
421# ifdef XK_KP_Prior 355# ifdef XK_KP_Prior
422 case XK_KP_Prior: 356 case XK_KP_Prior:
638 for (ch = kbuf; ch < kbuf + len; ch++) 572 for (ch = kbuf; ch < kbuf + len; ch++)
639 *ch |= 0x80; 573 *ch |= 0x80;
640 meta = 0; 574 meta = 0;
641 } 575 }
642#endif 576#endif
643#ifdef GREEK_SUPPORT
644 if (greek_mode)
645 len = greek_xlat (kbuf, len);
646#endif
647 /* nil */ ; 577 /* nil */ ;
648 } 578 }
649 } 579 }
650 580
651 if (len <= 0) 581 if (len <= 0)
673 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); 603 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
674 604
675 /* escape prefix */ 605 /* escape prefix */
676 if (meta 606 if (meta
677#ifdef META8_OPTION 607#ifdef META8_OPTION
678 && (meta_char == C0_ESC) 608 && meta_char == C0_ESC
679#endif 609#endif
680 ) 610 )
681 { 611 {
682 const unsigned char ch = C0_ESC; 612 const unsigned char ch = C0_ESC;
683
684 tt_write (&ch, 1); 613 tt_write (&ch, 1);
685 } 614 }
615
686#ifdef DEBUG_CMD 616#if defined(DEBUG_CMD)
687 if (debug_key)
688 { /* Display keyboard buffer contents */ 617 /* Display keyboard buffer contents */
689 char *p; 618 unsigned char *p;
690 int i; 619 int i;
691 620
692 fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); 621 fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len);
693 for (i = 0, p = kbuf; i < len; i++, p++) 622 for (i = 0, p = kbuf; i < len; i++, p++)
694 fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); 623 fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p);
695 fprintf (stderr, "'\n"); 624 fprintf (stderr, "'\n");
696 }
697#endif /* DEBUG_CMD */ 625#endif /* DEBUG_CMD */
698 tt_write (kbuf, (unsigned int)len); 626 tt_write (kbuf, (unsigned int)len);
699} 627}
700/*}}} */ 628/*}}} */
701 629
707{ 635{
708 unsigned int n, s; 636 unsigned int n, s;
709 637
710 n = cmdbuf_ptr - cmdbuf_base; 638 n = cmdbuf_ptr - cmdbuf_base;
711 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; 639 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp;
640
712 if (n > 0 && s < count) 641 if (n > 0 && s < count)
713 { 642 {
714 MEMMOVE (cmdbuf_base, cmdbuf_ptr, 643 MEMMOVE (cmdbuf_base, cmdbuf_ptr,
715 (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); 644 (unsigned int) (cmdbuf_endp - cmdbuf_ptr));
716 cmdbuf_ptr = cmdbuf_base; 645 cmdbuf_ptr = cmdbuf_base;
717 cmdbuf_endp -= n; 646 cmdbuf_endp -= n;
718 s += n; 647 s += n;
719 } 648 }
649
720 if (count > s) 650 if (count > s)
721 { 651 {
722 rxvt_print_error ("data loss: cmd_write too large"); 652 rxvt_print_error ("data loss: cmd_write too large");
723 count = s; 653 count = s;
724 } 654 }
655
725 for (; count--;) 656 for (; count--;)
726 *cmdbuf_endp++ = *str++; 657 *cmdbuf_endp++ = *str++;
658
659 cmd_parse ();
660
727 return 0; 661 return 0;
728} 662}
729#endif /* MENUBAR_MAX */ 663#endif /* MENUBAR_MAX */
730 664
731void 665void
803 cmdbuf_endp += n; 737 cmdbuf_endp += n;
804 return true; 738 return true;
805 } 739 }
806 else if (n < 0 && errno != EAGAIN) 740 else if (n < 0 && errno != EAGAIN)
807 destroy (); 741 destroy ();
808 742
809 return false; 743 return false;
810} 744}
811 745
812void 746void
813rxvt_term::pty_cb (io_watcher &w, short revents) 747rxvt_term::pty_cb (io_watcher &w, short revents)
830 seen_input = 1; 764 seen_input = 1;
831 /* once we know the shell is running, send the screen size. Again! */ 765 /* once we know the shell is running, send the screen size. Again! */
832 tt_winch (); 766 tt_winch ();
833 } 767 }
834 768
769 if (cmd_parse ())
770 break;
771 }
772 }
773}
774
775bool
776rxvt_term::cmd_parse ()
777{
778 bool flag = false;
835 uint32_t ch = NOCHAR; 779 uint32_t ch = NOCHAR;
780
781 for (;;)
782 {
783 if (ch == NOCHAR)
784 ch = next_char ();
785
786 if (ch == NOCHAR) // TODO: improve
787 break;
788
789 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
790 {
791 /* Read a text string from the input buffer */
792 uint32_t buf[BUFSIZ];
793 bool refreshnow = false;
794 int nlines = 0;
795 uint32_t *str = buf;
796
797 *str++ = ch;
836 798
837 for (;;) 799 for (;;)
838 { 800 {
839 if (ch == NOCHAR)
840 ch = next_char (); 801 ch = next_char ();
841 802
842 if (ch == NOCHAR) // TODO: improve 803 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
843 break; 804 break;
844 805 else
845 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
846 { 806 {
847 /* Read a text string from the input buffer */
848 uint32_t buf[BUFSIZ];
849 bool refreshnow = false;
850 int nlines = 0;
851 uint32_t *str = buf;
852
853 *str++ = ch; 807 *str++ = ch;
854 808
855 for (;;) 809 if (ch == '\n')
856 { 810 {
857 ch = next_char ();
858
859 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
860 break;
861 else 811 nlines++;
812 refresh_count++;
813
814 if (! (Options & Opt_jumpScroll)
815 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
862 { 816 {
863 *str++ = ch;
864
865 if (ch == '\n')
866 {
867 nlines++;
868 refresh_count++;
869
870 if (! (Options & Opt_jumpScroll)
871 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
872 {
873 refreshnow = true; 817 refreshnow = true;
874 flag = false; 818 flag = false;
875 ch = NOCHAR; 819 ch = NOCHAR;
876 break; 820 break;
877 } 821 }
878 822
879 // scr_add_lines only works for nlines < TermWin.nrow - 1. 823 // scr_add_lines only works for nlines < TermWin.nrow - 1.
880 if (nlines >= TermWin.nrow - 1) 824 if (nlines >= TermWin.nrow - 1)
881 { 825 {
882 scr_add_lines (buf, nlines, str - buf); 826 scr_add_lines (buf, nlines, str - buf);
883 nlines = 0; 827 nlines = 0;
884 str = buf; 828 str = buf;
885 }
886 }
887
888 if (str >= buf + BUFSIZ)
889 {
890 ch = NOCHAR;
891 break;
892 }
893 } 829 }
894 } 830 }
895 831
896 scr_add_lines (buf, nlines, str - buf); 832 if (str >= buf + BUFSIZ)
897
898 /*
899 * If there have been a lot of new lines, then update the screen
900 * What the heck I'll cheat and only refresh less than every page-full.
901 * the number of pages between refreshes is refresh_limit, which
902 * is incremented here because we must be doing flat-out scrolling.
903 *
904 * refreshing should be correct for small scrolls, because of the
905 * time-out
906 */
907 if (refreshnow)
908 { 833 {
909 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 834 ch = NOCHAR;
910 refresh_limit++; 835 break;
911
912 scr_refresh (refresh_type);
913 } 836 }
914
915 }
916 else
917 {
918 switch (ch)
919 {
920 default:
921 process_nonprinting (ch);
922 break;
923 case C0_ESC: /* escape char */
924 process_escape_seq ();
925 break;
926 /*case 0x9b: */ /* CSI */
927 /* process_csi_seq (); */
928 }
929
930 ch = NOCHAR;
931 } 837 }
932 } 838 }
839
840 scr_add_lines (buf, nlines, str - buf);
841
842 /*
843 * If there have been a lot of new lines, then update the screen
844 * What the heck I'll cheat and only refresh less than every page-full.
845 * the number of pages between refreshes is refresh_limit, which
846 * is incremented here because we must be doing flat-out scrolling.
847 *
848 * refreshing should be correct for small scrolls, because of the
849 * time-out
850 */
851 if (refreshnow)
852 {
853 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
854 refresh_limit++;
855
856 scr_refresh (refresh_type);
857 }
858
859 }
860 else
933 } 861 {
862 switch (ch)
863 {
864 default:
865 process_nonprinting (ch);
866 break;
867 case C0_ESC: /* escape char */
868 process_escape_seq ();
869 break;
870 /*case 0x9b: */ /* CSI */
871 /* process_csi_seq (); */
872 }
873
874 ch = NOCHAR;
875 }
934 } 876 }
877
878 return flag;
935} 879}
936 880
937// read the next character, currently handles UTF-8 881// read the next character, currently handles UTF-8
938// will probably handle all sorts of other stuff in the future 882// will probably handle all sorts of other stuff in the future
939uint32_t 883uint32_t
940rxvt_term::next_char () 884rxvt_term::next_char ()
941{ 885{
942 while (cmdbuf_ptr < cmdbuf_endp) 886 while (cmdbuf_ptr < cmdbuf_endp)
943 { 887 {
944 if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh 888 // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh
889 if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr)
890 || !*cmdbuf_ptr)
945 return *cmdbuf_ptr++; 891 return *cmdbuf_ptr++;
946 892
947 wchar_t wc; 893 wchar_t wc;
948 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); 894 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
949 895
950 if (len == (size_t)-2) 896 if (len == (size_t)-2)
951 return NOCHAR; 897 {
898 // the mbstate stores incomplete sequences. didn't know this :/
899 cmdbuf_ptr = cmdbuf_endp;
900 break;
901 }
952 902
953 if (len == (size_t)-1) 903 if (len == (size_t)-1)
954 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 904 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
955 905
956 // assume wchar == unicode 906 // assume wchar == unicode
1017 pointer_blank (); 967 pointer_blank ();
1018} 968}
1019#endif 969#endif
1020 970
1021void 971void
1022rxvt_term::mouse_report (const XButtonEvent &ev) 972rxvt_term::mouse_report (XButtonEvent &ev)
1023{ 973{
1024 int button_number, key_state = 0; 974 int button_number, key_state = 0;
1025 int x, y; 975 int x, y;
1026 976
1027 x = ev.x; 977 x = ev.x;
1028 y = ev.y; 978 y = ev.y;
1029 pixel_position (&x, &y); 979 pixel_position (&x, &y);
1030 980
1424 } 1374 }
1425#ifdef MENUBAR 1375#ifdef MENUBAR
1426 if (menubar_visible () && isMenuBarWindow (ev.xany.window)) 1376 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1427 menubar_expose (); 1377 menubar_expose ();
1428#endif 1378#endif
1429#ifdef RXVT_GRAPHICS
1430 Gr_expose (ev.xany.window);
1431#endif
1432
1433 } 1379 }
1434 break; 1380 break;
1435 1381
1436 case MotionNotify: 1382 case MotionNotify:
1437#ifdef POINTER_BLANK 1383#ifdef POINTER_BLANK
1439 pointer_unblank (); 1385 pointer_unblank ();
1440#endif 1386#endif
1441#if MENUBAR 1387#if MENUBAR
1442 if (isMenuBarWindow (ev.xany.window)) 1388 if (isMenuBarWindow (ev.xany.window))
1443 { 1389 {
1444 menubar_control (& (ev.xbutton)); 1390 menubar_control (ev.xbutton);
1445 break; 1391 break;
1446 } 1392 }
1447#endif 1393#endif
1448 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) 1394 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate))
1449 break; 1395 break;
1578#endif 1524#endif
1579 } 1525 }
1580} 1526}
1581 1527
1582void 1528void
1583rxvt_term::button_press (const XButtonEvent &ev) 1529rxvt_term::button_press (XButtonEvent &ev)
1584{ 1530{
1585 int reportmode = 0, clickintime; 1531 int reportmode = 0, clickintime;
1586 1532
1587 bypass_keystate = ev.state & (ModMetaMask | ShiftMask); 1533 bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
1588 if (!bypass_keystate) 1534 if (!bypass_keystate)
1590 /* 1536 /*
1591 * VT window processing of button press 1537 * VT window processing of button press
1592 */ 1538 */
1593 if (ev.window == TermWin.vt) 1539 if (ev.window == TermWin.vt)
1594 { 1540 {
1595#if RXVT_GRAPHICS
1596 if (ev.subwindow != None)
1597 rxvt_Gr_ButtonPress (ev.x, ev.y);
1598 else
1599#endif
1600
1601 {
1602 clickintime = ev.time - MEvent.time < MULTICLICK_TIME; 1541 clickintime = ev.time - MEvent.time < MULTICLICK_TIME;
1603 if (reportmode) 1542 if (reportmode)
1543 {
1544 /* mouse report from vt window */
1545 /* save the xbutton state (for ButtonRelease) */
1546 MEvent.state = ev.state;
1547#ifdef MOUSE_REPORT_DOUBLECLICK
1548 if (ev.button == MEvent.button && clickintime)
1604 { 1549 {
1605 /* mouse report from vt window */ 1550 /* same button, within alloted time */
1606 /* save the xbutton state (for ButtonRelease) */ 1551 MEvent.clicks++;
1607 MEvent.state = ev.state; 1552 if (MEvent.clicks > 1)
1608#ifdef MOUSE_REPORT_DOUBLECLICK
1609 if (ev.button == MEvent.button && clickintime)
1610 { 1553 {
1611 /* same button, within alloted time */
1612 MEvent.clicks++;
1613 if (MEvent.clicks > 1)
1614 {
1615 /* only report double clicks */ 1554 /* only report double clicks */
1616 MEvent.clicks = 2; 1555 MEvent.clicks = 2;
1617 mouse_report (ev); 1556 mouse_report (ev);
1618 1557
1619 /* don't report the release */ 1558 /* don't report the release */
1620 MEvent.clicks = 0; 1559 MEvent.clicks = 0;
1621 MEvent.button = AnyButton; 1560 MEvent.button = AnyButton;
1622 }
1623 } 1561 }
1624 else
1625 {
1626 /* different button, or time expired */
1627 MEvent.clicks = 1;
1628 MEvent.button = ev.button;
1629 mouse_report (ev);
1630 }
1631#else
1632 MEvent.button = ev.button;
1633 mouse_report (ev);
1634#endif /* MOUSE_REPORT_DOUBLECLICK */
1635
1636 } 1562 }
1637 else 1563 else
1638 { 1564 {
1565 /* different button, or time expired */
1566 MEvent.clicks = 1;
1567 MEvent.button = ev.button;
1568 mouse_report (ev);
1569 }
1570#else
1571 MEvent.button = ev.button;
1572 mouse_report (ev);
1573#endif /* MOUSE_REPORT_DOUBLECLICK */
1574
1575 }
1576 else
1577 {
1639 if (ev.button != MEvent.button) 1578 if (ev.button != MEvent.button)
1640 MEvent.clicks = 0; 1579 MEvent.clicks = 0;
1641 switch (ev.button) 1580 switch (ev.button)
1642 { 1581 {
1643 case Button1: 1582 case Button1:
1644 /* allow shift+left click to extend selection */ 1583 /* allow shift+left click to extend selection */
1645 if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report)) 1584 if (ev.state & ShiftMask && ! (PrivateModes & PrivMode_mouse_report))
1646 { 1585 {
1647 if (MEvent.button == Button1 && clickintime)
1648 selection_rotate (ev.x, ev.y);
1649 else
1650 selection_extend (ev.x, ev.y, 1);
1651 }
1652 else
1653 {
1654 if (MEvent.button == Button1 && clickintime)
1655 MEvent.clicks++;
1656 else
1657 MEvent.clicks = 1;
1658
1659 selection_click (MEvent.clicks, ev.x, ev.y);
1660 }
1661
1662 MEvent.button = Button1;
1663 break;
1664
1665 case Button3:
1666 if (MEvent.button == Button3 && clickintime) 1586 if (MEvent.button == Button1 && clickintime)
1667 selection_rotate (ev.x, ev.y); 1587 selection_rotate (ev.x, ev.y);
1668 else 1588 else
1669 selection_extend (ev.x, ev.y, 1); 1589 selection_extend (ev.x, ev.y, 1);
1590 }
1591 else
1592 {
1593 if (MEvent.button == Button1 && clickintime)
1594 MEvent.clicks++;
1595 else
1596 MEvent.clicks = 1;
1597
1598 selection_click (MEvent.clicks, ev.x, ev.y);
1599 }
1600
1601 MEvent.button = Button1;
1602 break;
1603
1604 case Button3:
1605 if (MEvent.button == Button3 && clickintime)
1606 selection_rotate (ev.x, ev.y);
1607 else
1608 selection_extend (ev.x, ev.y, 1);
1670 MEvent.button = Button3; 1609 MEvent.button = Button3;
1671 break; 1610 break;
1672 }
1673 } 1611 }
1612 }
1674 MEvent.time = ev.time; 1613 MEvent.time = ev.time;
1675 return; 1614 return;
1676 }
1677 } 1615 }
1678 1616
1679 /* 1617 /*
1680 * Scrollbar window processing of button press 1618 * Scrollbar window processing of button press
1681 */ 1619 */
1824 menubar_control (ev); 1762 menubar_control (ev);
1825#endif 1763#endif
1826} 1764}
1827 1765
1828void 1766void
1829rxvt_term::button_release (const XButtonEvent &ev) 1767rxvt_term::button_release (XButtonEvent &ev)
1830{ 1768{
1831 int reportmode = 0; 1769 int reportmode = 0;
1832 1770
1833 csrO = 0; /* reset csr Offset */ 1771 csrO = 0; /* reset csr Offset */
1834 if (!bypass_keystate) 1772 if (!bypass_keystate)
1846#ifdef SELECTION_SCROLLING 1784#ifdef SELECTION_SCROLLING
1847 pending_scroll_selection=0; 1785 pending_scroll_selection=0;
1848#endif 1786#endif
1849 if (ev.window == TermWin.vt) 1787 if (ev.window == TermWin.vt)
1850 { 1788 {
1851#ifdef RXVT_GRAPHICS
1852 if (ev.subwindow != None)
1853 rxvt_Gr_ButtonRelease (ev.x, ev.y);
1854 else
1855#endif
1856
1857 {
1858 if (reportmode) 1789 if (reportmode)
1790 {
1791 /* mouse report from vt window */
1792 /* don't report release of wheel "buttons" */
1793 if (ev.button >= 4)
1794 return;
1795#ifdef MOUSE_REPORT_DOUBLECLICK
1796 /* only report the release of 'slow' single clicks */
1797 if (MEvent.button != AnyButton
1798 && (ev.button != MEvent.button
1799 || (ev.time - MEvent.time
1800 > MULTICLICK_TIME / 2)))
1859 { 1801 {
1860 /* mouse report from vt window */
1861 /* don't report release of wheel "buttons" */
1862 if (ev.button >= 4)
1863 return;
1864#ifdef MOUSE_REPORT_DOUBLECLICK
1865 /* only report the release of 'slow' single clicks */
1866 if (MEvent.button != AnyButton
1867 && (ev.button != MEvent.button
1868 || (ev.time - MEvent.time
1869 > MULTICLICK_TIME / 2)))
1870 {
1871 MEvent.clicks = 0; 1802 MEvent.clicks = 0;
1872 MEvent.button = AnyButton;
1873 mouse_report (ev);
1874 }
1875#else /* MOUSE_REPORT_DOUBLECLICK */
1876 MEvent.button = AnyButton; 1803 MEvent.button = AnyButton;
1877 mouse_report (ev); 1804 mouse_report (ev);
1805 }
1806#else /* MOUSE_REPORT_DOUBLECLICK */
1807 MEvent.button = AnyButton;
1808 mouse_report (ev);
1878#endif /* MOUSE_REPORT_DOUBLECLICK */ 1809#endif /* MOUSE_REPORT_DOUBLECLICK */
1879 return; 1810 return;
1880 } 1811 }
1881 /* 1812 /*
1882 * dumb hack to compensate for the failure of click-and-drag 1813 * dumb hack to compensate for the failure of click-and-drag
1883 * when overriding mouse reporting 1814 * when overriding mouse reporting
1884 */ 1815 */
1885 if (PrivateModes & PrivMode_mouse_report 1816 if (PrivateModes & PrivMode_mouse_report
1886 && bypass_keystate 1817 && bypass_keystate
1887 && ev.button == Button1 && MEvent.clicks <= 1) 1818 && ev.button == Button1 && MEvent.clicks <= 1)
1888 selection_extend (ev.x, ev.y, 0); 1819 selection_extend (ev.x, ev.y, 0);
1889 1820
1890 switch (ev.button) 1821 switch (ev.button)
1822 {
1823 case Button1:
1824 case Button3:
1825 selection_make (ev.time);
1826 break;
1827 case Button2:
1828 selection_request (ev.time, ev.x, ev.y);
1829 break;
1830#ifdef MOUSE_WHEEL
1831 case Button4:
1832 case Button5:
1891 { 1833 {
1892 case Button1: 1834 int i;
1893 case Button3: 1835 page_dirn v;
1894 selection_make (ev.time); 1836
1837 v = (ev.button == Button4) ? UP : DN;
1838 if (ev.state & ShiftMask)
1895 break; 1839 i = 1;
1896 case Button2: 1840 else if ((Options & Opt_mouseWheelScrollPage))
1897 selection_request (ev.time, ev.x, ev.y); 1841 i = TermWin.nrow - 1;
1842 else
1898 break; 1843 i = 5;
1899#ifdef MOUSE_WHEEL 1844# ifdef MOUSE_SLIP_WHEELING
1900 case Button4: 1845 if (ev.state & ControlMask)
1901 case Button5:
1902 { 1846 {
1903 int i;
1904 page_dirn v;
1905
1906 v = (ev.button == Button4) ? UP : DN;
1907 if (ev.state & ShiftMask)
1908 i = 1;
1909 else if ((Options & Opt_mouseWheelScrollPage))
1910 i = TermWin.nrow - 1;
1911 else
1912 i = 5;
1913# ifdef MOUSE_SLIP_WHEELING
1914 if (ev.state & ControlMask)
1915 {
1916 mouse_slip_wheel_speed += (v ? -1 : 1); 1847 mouse_slip_wheel_speed += (v ? -1 : 1);
1917 mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; 1848 mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY;
1918 } 1849 }
1919# endif 1850# endif
1920# ifdef JUMP_MOUSE_WHEEL 1851# ifdef JUMP_MOUSE_WHEEL
1852 scr_page (v, i);
1853 scr_refresh (SMOOTH_REFRESH);
1854 scrollbar_show (1);
1855# else
1856 while (i--)
1857 {
1921 scr_page (v, i); 1858 scr_page (v, 1);
1922 scr_refresh (SMOOTH_REFRESH); 1859 scr_refresh (SMOOTH_REFRESH);
1923 scrollbar_show (1); 1860 scrollbar_show (1);
1924# else
1925 while (i--)
1926 {
1927 scr_page (v, 1);
1928 scr_refresh (SMOOTH_REFRESH);
1929 scrollbar_show (1);
1930 } 1861 }
1931# endif 1862# endif
1932 1863
1933 }
1934 break;
1935#endif
1936
1937 } 1864 }
1865 break;
1866#endif
1867
1938 } 1868 }
1939 } 1869 }
1940#ifdef MENUBAR 1870#ifdef MENUBAR
1941 else if (isMenuBarWindow (ev.window)) 1871 else if (isMenuBarWindow (ev.window))
1942 menubar_control (ev); 1872 menubar_control (ev);
2004 if (have_pixmap) 1934 if (have_pixmap)
2005 { 1935 {
2006 /* 1936 /*
2007 * Copy display->root pixmap transparency 1937 * Copy display->root pixmap transparency
2008 */ 1938 */
2009 int sx, sy, nx, ny; 1939 int sx, sy, nx, ny;
2010 unsigned int nw, nh; 1940 unsigned int nw, nh;
2011 Window cr; 1941 Window cr;
2012 XImage *image; 1942 XImage *image;
2013 GC gc; 1943 GC gc;
2014 XGCValues gcvalue; 1944 XGCValues gcvalue;
2015 1945
2016 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1946 XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
2017 0, 0, &sx, &sy, &cr); 1947 0, 0, &sx, &sy, &cr);
2018 nw = (unsigned int)szHint.width; 1948 nw = (unsigned int)szHint.width;
2019 nh = (unsigned int)szHint.height; 1949 nh = (unsigned int)szHint.height;
2020 nx = ny = 0; 1950 nx = ny = 0;
1951
2021 if (sx < 0) 1952 if (sx < 0)
2022 { 1953 {
2023 nw += sx; 1954 nw += sx;
2024 nx = -sx; 1955 nx = -sx;
2025 sx = 0; 1956 sx = 0;
2026 } 1957 }
1958
2027 if (sy < 0) 1959 if (sy < 0)
2028 { 1960 {
2029 nh += sy; 1961 nh += sy;
2030 ny = -sy; 1962 ny = -sy;
2031 sy = 0; 1963 sy = 0;
2032 } 1964 }
1965
2033 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 1966 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
2034 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 1967 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
2035 allowedxerror = -1; 1968 allowedxerror = -1;
2036 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, 1969 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes,
2037 ZPixmap); 1970 ZPixmap);
2070 if (!am_transparent || !am_pixmap_trans) 2003 if (!am_transparent || !am_pixmap_trans)
2071 pchanged = 1; 2004 pchanged = 1;
2072 am_transparent = am_pixmap_trans = 1; 2005 am_transparent = am_pixmap_trans = 1;
2073 } 2006 }
2074 } 2007 }
2008
2075 if (!am_pixmap_trans) 2009 if (!am_pixmap_trans)
2076 { 2010 {
2077 unsigned int n; 2011 unsigned int n;
2078 /* 2012 /*
2079 * InheritPixmap transparency 2013 * InheritPixmap transparency
2094 break; 2028 break;
2095 } 2029 }
2096 if (oldp != TermWin.parent[i]) 2030 if (oldp != TermWin.parent[i])
2097 pchanged = 1; 2031 pchanged = 1;
2098 } 2032 }
2033
2099 n = 0; 2034 n = 0;
2035
2100 if (pchanged) 2036 if (pchanged)
2101 { 2037 {
2102 for (; n < (unsigned int)i; n++) 2038 for (; n < (unsigned int)i; n++)
2103 { 2039 {
2104 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); 2040 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr);
2108 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; 2044 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
2109 break; 2045 break;
2110 } 2046 }
2111 } 2047 }
2112 } 2048 }
2049
2113 if (n > (int) (sizeof (TermWin.parent) 2050 if (n > (int) (sizeof (TermWin.parent)
2114 / sizeof (TermWin.parent[0]))) 2051 / sizeof (TermWin.parent[0])))
2115 { 2052 {
2116 D_X ((stderr, "InheritPixmap Turning off")); 2053 D_X ((stderr, "InheritPixmap Turning off"));
2117 XSetWindowBackground (display->display, TermWin.parent[0], 2054 XSetWindowBackground (display->display, TermWin.parent[0],
2140 ParentRelative); 2077 ParentRelative);
2141 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2078 XSetWindowBackgroundPixmap (display->display, TermWin.vt,
2142 ParentRelative); 2079 ParentRelative);
2143 am_transparent = 1; 2080 am_transparent = 1;
2144 } 2081 }
2082
2145 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2083 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2146 TermWin.parent[i] = None; 2084 TermWin.parent[i] = None;
2147 } 2085 }
2148 return pchanged; 2086 return pchanged;
2149} 2087}
2155/*----------------------------------------------------------------------*/ 2093/*----------------------------------------------------------------------*/
2156#ifdef PRINTPIPE 2094#ifdef PRINTPIPE
2157FILE * 2095FILE *
2158rxvt_term::popen_printer () 2096rxvt_term::popen_printer ()
2159{ 2097{
2160 FILE *stream = popen (rs[Rs_print_pipe], "w"); 2098 FILE *stream = popen (rs[Rs_print_pipe], "w");
2161 2099
2162 if (stream == NULL) 2100 if (stream == NULL)
2163 rxvt_print_error ("can't open printer pipe"); 2101 rxvt_print_error ("can't open printer pipe");
2164 return stream; 2102 return stream;
2165} 2103}
2377 scr_charset_set (2, (unsigned int)cmd_getc ()); 2315 scr_charset_set (2, (unsigned int)cmd_getc ());
2378 break; 2316 break;
2379 case '+': 2317 case '+':
2380 scr_charset_set (3, (unsigned int)cmd_getc ()); 2318 scr_charset_set (3, (unsigned int)cmd_getc ());
2381 break; 2319 break;
2382#ifdef MULTICHAR_SET
2383 case '$':
2384 scr_charset_set (-2, (unsigned int)cmd_getc ());
2385 break;
2386#endif
2387#ifndef NO_FRILLS 2320#ifndef NO_FRILLS
2388 case '6': 2321 case '6':
2389 scr_backindex (); 2322 scr_backindex ();
2390 break; 2323 break;
2391#endif 2324#endif
2732 case 7: /* unofficial extension */ 2665 case 7: /* unofficial extension */
2733 tt_printf ("%-.250s\n", rs[Rs_display_name]); 2666 tt_printf ("%-.250s\n", rs[Rs_display_name]);
2734 break; 2667 break;
2735#endif 2668#endif
2736 case 8: /* unofficial extension */ 2669 case 8: /* unofficial extension */
2737 xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); 2670 xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
2738 break; 2671 break;
2739 } 2672 }
2740 break; 2673 break;
2741 2674
2742 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 2675 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
3016 * 10 = menu (may change in future) 2949 * 10 = menu (may change in future)
3017 * 20 = bg pixmap 2950 * 20 = bg pixmap
3018 * 39 = change default fg color 2951 * 39 = change default fg color
3019 * 49 = change default bg color 2952 * 49 = change default bg color
3020 * 55 = dump scrollback buffer and all of screen 2953 * 55 = dump scrollback buffer and all of screen
2954 * 701 = change locale
2955 * 702 = find font
3021 */ 2956 */
3022void 2957void
3023rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) 2958rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused)))
3024{ 2959{
3025 int changed = 0; 2960 int changed = 0;
3111 set_window_color (Color_bg, str); 3046 set_window_color (Color_bg, str);
3112 break; 3047 break;
3113 case XTerm_logfile: 3048 case XTerm_logfile:
3114 break; 3049 break;
3115 case XTerm_font: 3050 case XTerm_font:
3116 change_font (0, str); 3051 change_font (str);
3117 break; 3052 break;
3053#ifndef NO_FRILLS
3054 case XTerm_locale:
3055 if (str[0] == '?' && !str[1])
3056 tt_printf ("%-.250s\n", locale);
3057 else
3058 {
3059 set_locale (str);
3060# ifdef USE_XIM
3061 im_cb ();
3062# endif
3063 }
3064 break;
3065 case XTerm_findfont:
3066 {
3067 int fid = TermWin.fontset->find_font (atoi (str));
3068 tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name);
3069 }
3070 break;
3071#endif
3118#if 0 3072#if 0
3119 case XTerm_dumpscreen: /* no error notices */ 3073 case XTerm_dumpscreen: /* no error notices */
3120 { 3074 {
3121 int fd; 3075 int fd;
3122 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3076 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3250 */ 3204 */
3251 PrivMode (1, PrivMode_vt52); 3205 PrivMode (1, PrivMode_vt52);
3252 break; 3206 break;
3253 case 3: /* 80/132 */ 3207 case 3: /* 80/132 */
3254 if (PrivateModes & PrivMode_132OK) 3208 if (PrivateModes & PrivMode_132OK)
3255 set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth), 3209 set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height);
3256 (unsigned int)TermWin.height);
3257 break; 3210 break;
3258 case 4: /* smooth scrolling */ 3211 case 4: /* smooth scrolling */
3259 if (state) 3212 if (state)
3260 Options &= ~Opt_jumpScroll; 3213 Options &= ~Opt_jumpScroll;
3261 else 3214 else
3472void 3425void
3473rxvt_term::process_graphics () 3426rxvt_term::process_graphics ()
3474{ 3427{
3475 unsigned char ch, cmd = cmd_getc (); 3428 unsigned char ch, cmd = cmd_getc ();
3476 3429
3477#ifndef RXVT_GRAPHICS
3478 if (cmd == 'Q') 3430 if (cmd == 'Q')
3479 { /* query graphics */ 3431 { /* query graphics */
3480 tt_printf ("\033G0\n"); /* no graphics */ 3432 tt_printf ("\033G0\n"); /* no graphics */
3481 return; 3433 return;
3482 } 3434 }
3483 /* swallow other graphics sequences until terminating ':' */ 3435 /* swallow other graphics sequences until terminating ':' */
3484 do 3436 do
3485 ch = cmd_getc (); 3437 ch = cmd_getc ();
3486 while (ch != ':'); 3438 while (ch != ':');
3487#else
3488 unsigned int nargs;
3489 int args[NGRX_PTS];
3490 unsigned char *text = NULL;
3491
3492 if (cmd == 'Q')
3493 { /* query graphics */
3494 tt_printf ("\033G1\n"); /* yes, graphics (color) */
3495 return;
3496 }
3497 for (nargs = 0; nargs < (sizeof (args) / sizeof (args[0])) - 1;)
3498 {
3499 int neg;
3500
3501 ch = cmd_getc ();
3502 neg = (ch == '-');
3503 if (neg || ch == '+')
3504 ch = cmd_getc ();
3505
3506 for (args[nargs] = 0; isdigit (ch); ch = cmd_getc ())
3507 args[nargs] = args[nargs] * 10 + (ch - '0');
3508 if (neg)
3509 args[nargs] = -args[nargs];
3510
3511 nargs++;
3512 args[nargs] = 0;
3513 if (ch != ';')
3514 break;
3515 }
3516
3517 if ((cmd == 'T') && (nargs >= 5))
3518 {
3519 int i, len = args[4];
3520
3521 text = (unsigned char *)rxvt_malloc ((len + 1) * sizeof (char));
3522
3523 if (text != NULL)
3524 {
3525 for (i = 0; i < len; i++)
3526 text[i] = cmd_getc ();
3527 text[len] = '\0';
3528 }
3529 }
3530 Gr_do_graphics (cmd, nargs, args, text);
3531#endif
3532} 3439}
3533/*}}} */ 3440/*}}} */
3534 3441
3535/* ------------------------------------------------------------------------- */ 3442/* ------------------------------------------------------------------------- */
3536 3443

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines