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.54 by pcg, Sun Feb 22 12:58:02 2004 UTC vs.
Revision 1.73 by pcg, Mon Mar 15 00:08:11 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
131 valid_keysym = keysym != NoSymbol; 140 valid_keysym = keysym != NoSymbol;
132 } 141 }
133 142
134 if (valid_keysym) 143 if (valid_keysym)
135 { 144 {
136 /* for some backwards compatibility */
137#if defined(HOTKEY_CTRL) || defined(HOTKEY_META)
138# ifdef HOTKEY_CTRL
139 if (ctrl)
140# else
141 if (meta)
142# endif
143 {
144 if (keysym == ks_bigfont)
145 {
146 change_font (FONT_UP);
147 return;
148 }
149 else if (keysym == ks_smallfont)
150 {
151 change_font (FONT_DN);
152 return;
153 }
154 }
155#endif
156
157 if (TermWin.saveLines) 145 if (TermWin.saveLines)
158 { 146 {
159#ifdef UNSHIFTED_SCROLLKEYS 147#ifdef UNSHIFTED_SCROLLKEYS
160 if (!ctrl && !meta) 148 if (!ctrl && !meta)
161 { 149 {
252#ifdef KEYSYM_RESOURCE 240#ifdef KEYSYM_RESOURCE
253 if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) 241 if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL)
254 { 242 {
255 unsigned int l; 243 unsigned int l;
256 const unsigned char *kbuf0; 244 const unsigned char *kbuf0;
257 const unsigned char ch = C0_ESC;
258 245
259 kbuf0 = (Keysym_map[keysym & 0xFF]); 246 kbuf0 = (Keysym_map[keysym & 0xFF]);
260 l = (unsigned int)*kbuf0++; 247 l = (unsigned int)*kbuf0++;
261 248
262 /* escape prefix */ 249 /* escape prefix */
263 if (meta) 250 if (meta
264# ifdef META8_OPTION 251# ifdef META8_OPTION
265 if (meta_char == C0_ESC) 252 && meta_char == C0_ESC
266# endif 253# endif
254 )
255 {
256 const unsigned char ch = C0_ESC;
267 tt_write (&ch, 1); 257 tt_write (&ch, 1);
258 }
259
268 tt_write (kbuf0, l); 260 tt_write (kbuf0, l);
269 return; 261 return;
270 } 262 }
271 else 263 else
272#endif 264#endif
282 ^ !!ctrl) ? '\b' : '\177'; 274 ^ !!ctrl) ? '\b' : '\177';
283 kbuf[1] = '\0'; 275 kbuf[1] = '\0';
284 } 276 }
285 else 277 else
286 STRCPY (kbuf, key_backspace); 278 STRCPY (kbuf, key_backspace);
287# ifdef MULTICHAR_SET
288 if ((Options & Opt_mc_hack) && screen.cur.col > 0)
289 {
290 int col, row;
291
292 newlen = STRLEN (kbuf);
293 col = screen.cur.col - 1;
294 row = screen.cur.row + TermWin.saveLines;
295 if (IS_MULTI2 (screen.rend[row][col]))
296 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
297 }
298# endif
299 break; 279 break;
300#endif 280#endif
301#ifndef NO_DELETE_KEY 281#ifndef NO_DELETE_KEY
302 case XK_Delete: 282 case XK_Delete:
303 STRCPY (kbuf, key_delete); 283 STRCPY (kbuf, key_delete);
304# ifdef MULTICHAR_SET
305 if (Options & Opt_mc_hack)
306 {
307 int col, row;
308
309 newlen = STRLEN (kbuf);
310 col = screen.cur.col;
311 row = screen.cur.row + TermWin.saveLines;
312 if (IS_MULTI1 (screen.rend[row][col]))
313 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
314 }
315# endif
316 break; 284 break;
317#endif 285#endif
318 case XK_Tab: 286 case XK_Tab:
319 if (shft) 287 if (shft)
320 STRCPY (kbuf, "\033[Z"); 288 STRCPY (kbuf, "\033[Z");
362 kbuf[1] = 'O'; 330 kbuf[1] = 'O';
363 kbuf[2] = "dacb"[keysym - XK_Left]; 331 kbuf[2] = "dacb"[keysym - XK_Left];
364 } 332 }
365 else if (PrivateModes & PrivMode_aplCUR) 333 else if (PrivateModes & PrivMode_aplCUR)
366 kbuf[1] = 'O'; 334 kbuf[1] = 'O';
367#ifdef MULTICHAR_SET
368 //TODO: ??
369 if (Options & Opt_mc_hack)
370 {
371 int col, row, m;
372
373 col = screen.cur.col;
374 row = screen.cur.row + TermWin.saveLines;
375 m = 0;
376 if (keysym == XK_Right
377 && IS_MULTI1 (screen.rend[row][col]))
378 m = 1;
379 else if (keysym == XK_Left)
380 {
381 if (col > 0)
382 {
383 if (IS_MULTI2 (screen.rend[row][col - 1]))
384 m = 1;
385 }
386 else if (screen.cur.row > 0)
387 {
388 col = screen.tlen[--row];
389 if (col == -1)
390 col = TermWin.ncol - 1;
391 else
392 col--;
393 if (col > 0
394 && IS_MULTI2 (screen.rend[row][col]))
395 m = 1;
396 }
397 }
398 if (m)
399 MEMMOVE (kbuf + 3, kbuf, 3 + 1);
400 }
401#endif
402 break; 335 break;
403 336
404#ifndef UNSHIFTED_SCROLLKEYS 337#ifndef UNSHIFTED_SCROLLKEYS
405# ifdef XK_KP_Prior 338# ifdef XK_KP_Prior
406 case XK_KP_Prior: 339 case XK_KP_Prior:
595 break; 528 break;
596 } 529 }
597 if (newlen) 530 if (newlen)
598 len = STRLEN (kbuf); 531 len = STRLEN (kbuf);
599 } 532 }
533
600 /* 534 /*
601 * Pass meta for all function keys, if 'meta' option set 535 * Pass meta for all function keys, if 'meta' option set
602 */ 536 */
603#ifdef META8_OPTION 537#ifdef META8_OPTION
604 if (meta && (meta_char == 0x80) && len > 0) 538 if (meta && (meta_char == 0x80) && len > 0)
619 { 553 {
620 unsigned char *ch; 554 unsigned char *ch;
621 555
622 for (ch = kbuf; ch < kbuf + len; ch++) 556 for (ch = kbuf; ch < kbuf + len; ch++)
623 *ch |= 0x80; 557 *ch |= 0x80;
558
624 meta = 0; 559 meta = 0;
625 } 560 }
626#endif 561#endif
627 /* nil */ ; 562 /* nil */ ;
628 } 563 }
653 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); 588 kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~'));
654 589
655 /* escape prefix */ 590 /* escape prefix */
656 if (meta 591 if (meta
657#ifdef META8_OPTION 592#ifdef META8_OPTION
658 && (meta_char == C0_ESC) 593 && meta_char == C0_ESC
659#endif 594#endif
660 ) 595 )
661 { 596 {
662 const unsigned char ch = C0_ESC; 597 const unsigned char ch = C0_ESC;
663
664 tt_write (&ch, 1); 598 tt_write (&ch, 1);
665 } 599 }
600
666#ifdef DEBUG_CMD 601#if defined(DEBUG_CMD)
667 if (debug_key)
668 { /* Display keyboard buffer contents */ 602 /* Display keyboard buffer contents */
669 char *p; 603 unsigned char *p;
670 int i; 604 int i;
671 605
672 fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); 606 fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len);
673 for (i = 0, p = kbuf; i < len; i++, p++) 607 for (i = 0, p = kbuf; i < len; i++, p++)
674 fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); 608 fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p);
675 fprintf (stderr, "'\n"); 609 fprintf (stderr, "'\n");
676 }
677#endif /* DEBUG_CMD */ 610#endif /* DEBUG_CMD */
678 tt_write (kbuf, (unsigned int)len); 611 tt_write (kbuf, (unsigned int)len);
679} 612}
680/*}}} */ 613/*}}} */
681 614
687{ 620{
688 unsigned int n, s; 621 unsigned int n, s;
689 622
690 n = cmdbuf_ptr - cmdbuf_base; 623 n = cmdbuf_ptr - cmdbuf_base;
691 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; 624 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp;
625
692 if (n > 0 && s < count) 626 if (n > 0 && s < count)
693 { 627 {
694 MEMMOVE (cmdbuf_base, cmdbuf_ptr, 628 MEMMOVE (cmdbuf_base, cmdbuf_ptr,
695 (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); 629 (unsigned int) (cmdbuf_endp - cmdbuf_ptr));
696 cmdbuf_ptr = cmdbuf_base; 630 cmdbuf_ptr = cmdbuf_base;
697 cmdbuf_endp -= n; 631 cmdbuf_endp -= n;
698 s += n; 632 s += n;
699 } 633 }
634
700 if (count > s) 635 if (count > s)
701 { 636 {
702 rxvt_print_error ("data loss: cmd_write too large"); 637 rxvt_print_error ("data loss: cmd_write too large");
703 count = s; 638 count = s;
704 } 639 }
640
705 for (; count--;) 641 for (; count--;)
706 *cmdbuf_endp++ = *str++; 642 *cmdbuf_endp++ = *str++;
643
644 cmd_parse ();
645
707 return 0; 646 return 0;
708} 647}
709#endif /* MENUBAR_MAX */ 648#endif /* MENUBAR_MAX */
710 649
711void 650void
783 cmdbuf_endp += n; 722 cmdbuf_endp += n;
784 return true; 723 return true;
785 } 724 }
786 else if (n < 0 && errno != EAGAIN) 725 else if (n < 0 && errno != EAGAIN)
787 destroy (); 726 destroy ();
788 727
789 return false; 728 return false;
790} 729}
791 730
792void 731void
793rxvt_term::pty_cb (io_watcher &w, short revents) 732rxvt_term::pty_cb (io_watcher &w, short revents)
810 seen_input = 1; 749 seen_input = 1;
811 /* once we know the shell is running, send the screen size. Again! */ 750 /* once we know the shell is running, send the screen size. Again! */
812 tt_winch (); 751 tt_winch ();
813 } 752 }
814 753
815 uint32_t ch = NOCHAR; 754 if (cmd_parse ())
755 break;
756 }
757 }
758}
759
760bool
761rxvt_term::cmd_parse ()
762{
763 bool flag = false;
764 unicode_t ch = NOCHAR;
765
766 for (;;)
767 {
768 if (ch == NOCHAR)
769 ch = next_char ();
770
771 if (ch == NOCHAR) // TODO: improve
772 break;
773
774 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
775 {
776 /* Read a text string from the input buffer */
777 unicode_t buf[BUFSIZ];
778 bool refreshnow = false;
779 int nlines = 0;
780 unicode_t *str = buf;
781
782 *str++ = ch;
816 783
817 for (;;) 784 for (;;)
818 { 785 {
819 if (ch == NOCHAR)
820 ch = next_char (); 786 ch = next_char ();
821 787
822 if (ch == NOCHAR) // TODO: improve 788 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
823 break; 789 break;
824 790 else
825 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
826 { 791 {
827 /* Read a text string from the input buffer */
828 uint32_t buf[BUFSIZ];
829 bool refreshnow = false;
830 int nlines = 0;
831 uint32_t *str = buf;
832
833 *str++ = ch; 792 *str++ = ch;
834 793
835 for (;;) 794 if (ch == '\n')
836 { 795 {
837 ch = next_char ();
838
839 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
840 break;
841 else 796 nlines++;
797 refresh_count++;
798
799 if (! (Options & Opt_jumpScroll)
800 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
842 { 801 {
843 *str++ = ch;
844
845 if (ch == '\n')
846 {
847 nlines++;
848 refresh_count++;
849
850 if (! (Options & Opt_jumpScroll)
851 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
852 {
853 refreshnow = true; 802 refreshnow = true;
854 flag = false; 803 flag = false;
855 ch = NOCHAR; 804 ch = NOCHAR;
856 break; 805 break;
857 } 806 }
858 807
859 // scr_add_lines only works for nlines < TermWin.nrow - 1. 808 // scr_add_lines only works for nlines < TermWin.nrow - 1.
860 if (nlines >= TermWin.nrow - 1) 809 if (nlines >= TermWin.nrow - 1)
861 { 810 {
862 scr_add_lines (buf, nlines, str - buf); 811 scr_add_lines (buf, nlines, str - buf);
863 nlines = 0; 812 nlines = 0;
864 str = buf; 813 str = buf;
865 }
866 }
867
868 if (str >= buf + BUFSIZ)
869 {
870 ch = NOCHAR;
871 break;
872 }
873 } 814 }
874 } 815 }
875 816
876 scr_add_lines (buf, nlines, str - buf); 817 if (str >= buf + BUFSIZ)
877
878 /*
879 * If there have been a lot of new lines, then update the screen
880 * What the heck I'll cheat and only refresh less than every page-full.
881 * the number of pages between refreshes is refresh_limit, which
882 * is incremented here because we must be doing flat-out scrolling.
883 *
884 * refreshing should be correct for small scrolls, because of the
885 * time-out
886 */
887 if (refreshnow)
888 { 818 {
889 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 819 ch = NOCHAR;
890 refresh_limit++; 820 break;
891
892 scr_refresh (refresh_type);
893 } 821 }
894
895 }
896 else
897 {
898 switch (ch)
899 {
900 default:
901 process_nonprinting (ch);
902 break;
903 case C0_ESC: /* escape char */
904 process_escape_seq ();
905 break;
906 /*case 0x9b: */ /* CSI */
907 /* process_csi_seq (); */
908 }
909
910 ch = NOCHAR;
911 } 822 }
912 } 823 }
824
825 scr_add_lines (buf, nlines, str - buf);
826
827 /*
828 * If there have been a lot of new lines, then update the screen
829 * What the heck I'll cheat and only refresh less than every page-full.
830 * the number of pages between refreshes is refresh_limit, which
831 * is incremented here because we must be doing flat-out scrolling.
832 *
833 * refreshing should be correct for small scrolls, because of the
834 * time-out
835 */
836 if (refreshnow)
837 {
838 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
839 refresh_limit++;
840
841 scr_refresh (refresh_type);
842 }
843
844 }
845 else
913 } 846 {
847 switch (ch)
848 {
849 default:
850 process_nonprinting (ch);
851 break;
852 case C0_ESC: /* escape char */
853 process_escape_seq ();
854 break;
855 /*case 0x9b: */ /* CSI */
856 /* process_csi_seq (); */
857 }
858
859 ch = NOCHAR;
860 }
914 } 861 }
862
863 return flag;
915} 864}
916 865
917// read the next character, currently handles UTF-8 866// read the next character, currently handles UTF-8
918// will probably handle all sorts of other stuff in the future 867// will probably handle all sorts of other stuff in the future
919uint32_t 868unicode_t
920rxvt_term::next_char () 869rxvt_term::next_char ()
921{ 870{
922 while (cmdbuf_ptr < cmdbuf_endp) 871 while (cmdbuf_ptr < cmdbuf_endp)
923 { 872 {
924 if (*cmdbuf_ptr < 0x80) // assume < 0x80 to be ascii ALWAYS (all shift-states etc.) uh-oh 873 // assume 0x20 .. 0x7f to be ascii ALWAYS (all shift-states etc.) uh-oh
874 if ((*cmdbuf_ptr <= 0x7f && 0x20 <= *cmdbuf_ptr)
875 || !*cmdbuf_ptr)
925 return *cmdbuf_ptr++; 876 return *cmdbuf_ptr++;
926 877
927 wchar_t wc; 878 wchar_t wc;
928 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); 879 size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
929 880
930 if (len == (size_t)-2) 881 if (len == (size_t)-2)
931 return NOCHAR; 882 {
883 // the mbstate stores incomplete sequences. didn't know this :/
884 cmdbuf_ptr = cmdbuf_endp;
885 break;
886 }
932 887
933 if (len == (size_t)-1) 888 if (len == (size_t)-1)
934 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 889 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
935 890
936 // assume wchar == unicode 891 // assume wchar == unicode
944/* rxvt_cmd_getc () - Return next input character */ 899/* rxvt_cmd_getc () - Return next input character */
945/* 900/*
946 * Return the next input character after first passing any keyboard input 901 * Return the next input character after first passing any keyboard input
947 * to the command. 902 * to the command.
948 */ 903 */
949uint32_t 904unicode_t
950rxvt_term::cmd_getc () 905rxvt_term::cmd_getc ()
951{ 906{
952 for (;;) 907 for (;;)
953 { 908 {
954 uint32_t c = next_char (); 909 unicode_t c = next_char ();
955 if (c != NOCHAR) 910 if (c != NOCHAR)
956 return c; 911 return c;
957 912
958 // incomplete sequences should occur rarely, still, a better solution 913 // incomplete sequences should occur rarely, still, a better solution
959 // would be preferred. either setjmp/longjmp or better design. 914 // would be preferred. either setjmp/longjmp or better design.
997 pointer_blank (); 952 pointer_blank ();
998} 953}
999#endif 954#endif
1000 955
1001void 956void
1002rxvt_term::mouse_report (const XButtonEvent &ev) 957rxvt_term::mouse_report (XButtonEvent &ev)
1003{ 958{
1004 int button_number, key_state = 0; 959 int button_number, key_state = 0;
1005 int x, y; 960 int x, y;
1006 961
1007 x = ev.x; 962 x = ev.x;
1008 y = ev.y; 963 y = ev.y;
1009 pixel_position (&x, &y); 964 pixel_position (&x, &y);
1010 965
1415 pointer_unblank (); 1370 pointer_unblank ();
1416#endif 1371#endif
1417#if MENUBAR 1372#if MENUBAR
1418 if (isMenuBarWindow (ev.xany.window)) 1373 if (isMenuBarWindow (ev.xany.window))
1419 { 1374 {
1420 menubar_control (& (ev.xbutton)); 1375 menubar_control (ev.xbutton);
1421 break; 1376 break;
1422 } 1377 }
1423#endif 1378#endif
1424 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) 1379 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate))
1425 break; 1380 break;
1554#endif 1509#endif
1555 } 1510 }
1556} 1511}
1557 1512
1558void 1513void
1559rxvt_term::button_press (const XButtonEvent &ev) 1514rxvt_term::button_press (XButtonEvent &ev)
1560{ 1515{
1561 int reportmode = 0, clickintime; 1516 int reportmode = 0, clickintime;
1562 1517
1563 bypass_keystate = ev.state & (ModMetaMask | ShiftMask); 1518 bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
1564 if (!bypass_keystate) 1519 if (!bypass_keystate)
1792 menubar_control (ev); 1747 menubar_control (ev);
1793#endif 1748#endif
1794} 1749}
1795 1750
1796void 1751void
1797rxvt_term::button_release (const XButtonEvent &ev) 1752rxvt_term::button_release (XButtonEvent &ev)
1798{ 1753{
1799 int reportmode = 0; 1754 int reportmode = 0;
1800 1755
1801 csrO = 0; /* reset csr Offset */ 1756 csrO = 0; /* reset csr Offset */
1802 if (!bypass_keystate) 1757 if (!bypass_keystate)
1964 if (have_pixmap) 1919 if (have_pixmap)
1965 { 1920 {
1966 /* 1921 /*
1967 * Copy display->root pixmap transparency 1922 * Copy display->root pixmap transparency
1968 */ 1923 */
1969 int sx, sy, nx, ny; 1924 int sx, sy, nx, ny;
1970 unsigned int nw, nh; 1925 unsigned int nw, nh;
1971 Window cr; 1926 Window cr;
1972 XImage *image; 1927 XImage *image;
1973 GC gc; 1928 GC gc;
1974 XGCValues gcvalue; 1929 XGCValues gcvalue;
1975 1930
1976 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1931 XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
1977 0, 0, &sx, &sy, &cr); 1932 0, 0, &sx, &sy, &cr);
1978 nw = (unsigned int)szHint.width; 1933 nw = (unsigned int)szHint.width;
1979 nh = (unsigned int)szHint.height; 1934 nh = (unsigned int)szHint.height;
1980 nx = ny = 0; 1935 nx = ny = 0;
1936
1981 if (sx < 0) 1937 if (sx < 0)
1982 { 1938 {
1983 nw += sx; 1939 nw += sx;
1984 nx = -sx; 1940 nx = -sx;
1985 sx = 0; 1941 sx = 0;
1986 } 1942 }
1943
1987 if (sy < 0) 1944 if (sy < 0)
1988 { 1945 {
1989 nh += sy; 1946 nh += sy;
1990 ny = -sy; 1947 ny = -sy;
1991 sy = 0; 1948 sy = 0;
1992 } 1949 }
1950
1993 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 1951 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
1994 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 1952 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
1995 allowedxerror = -1; 1953 allowedxerror = -1;
1996 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, 1954 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes,
1997 ZPixmap); 1955 ZPixmap);
2030 if (!am_transparent || !am_pixmap_trans) 1988 if (!am_transparent || !am_pixmap_trans)
2031 pchanged = 1; 1989 pchanged = 1;
2032 am_transparent = am_pixmap_trans = 1; 1990 am_transparent = am_pixmap_trans = 1;
2033 } 1991 }
2034 } 1992 }
1993
2035 if (!am_pixmap_trans) 1994 if (!am_pixmap_trans)
2036 { 1995 {
2037 unsigned int n; 1996 unsigned int n;
2038 /* 1997 /*
2039 * InheritPixmap transparency 1998 * InheritPixmap transparency
2054 break; 2013 break;
2055 } 2014 }
2056 if (oldp != TermWin.parent[i]) 2015 if (oldp != TermWin.parent[i])
2057 pchanged = 1; 2016 pchanged = 1;
2058 } 2017 }
2018
2059 n = 0; 2019 n = 0;
2020
2060 if (pchanged) 2021 if (pchanged)
2061 { 2022 {
2062 for (; n < (unsigned int)i; n++) 2023 for (; n < (unsigned int)i; n++)
2063 { 2024 {
2064 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); 2025 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr);
2068 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; 2029 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
2069 break; 2030 break;
2070 } 2031 }
2071 } 2032 }
2072 } 2033 }
2034
2073 if (n > (int) (sizeof (TermWin.parent) 2035 if (n > (int) (sizeof (TermWin.parent)
2074 / sizeof (TermWin.parent[0]))) 2036 / sizeof (TermWin.parent[0])))
2075 { 2037 {
2076 D_X ((stderr, "InheritPixmap Turning off")); 2038 D_X ((stderr, "InheritPixmap Turning off"));
2077 XSetWindowBackground (display->display, TermWin.parent[0], 2039 XSetWindowBackground (display->display, TermWin.parent[0],
2100 ParentRelative); 2062 ParentRelative);
2101 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2063 XSetWindowBackgroundPixmap (display->display, TermWin.vt,
2102 ParentRelative); 2064 ParentRelative);
2103 am_transparent = 1; 2065 am_transparent = 1;
2104 } 2066 }
2067
2105 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2068 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2106 TermWin.parent[i] = None; 2069 TermWin.parent[i] = None;
2107 } 2070 }
2108 return pchanged; 2071 return pchanged;
2109} 2072}
2115/*----------------------------------------------------------------------*/ 2078/*----------------------------------------------------------------------*/
2116#ifdef PRINTPIPE 2079#ifdef PRINTPIPE
2117FILE * 2080FILE *
2118rxvt_term::popen_printer () 2081rxvt_term::popen_printer ()
2119{ 2082{
2120 FILE *stream = popen (rs[Rs_print_pipe], "w"); 2083 FILE *stream = popen (rs[Rs_print_pipe], "w");
2121 2084
2122 if (stream == NULL) 2085 if (stream == NULL)
2123 rxvt_print_error ("can't open printer pipe"); 2086 rxvt_print_error ("can't open printer pipe");
2124 return stream; 2087 return stream;
2125} 2088}
2337 scr_charset_set (2, (unsigned int)cmd_getc ()); 2300 scr_charset_set (2, (unsigned int)cmd_getc ());
2338 break; 2301 break;
2339 case '+': 2302 case '+':
2340 scr_charset_set (3, (unsigned int)cmd_getc ()); 2303 scr_charset_set (3, (unsigned int)cmd_getc ());
2341 break; 2304 break;
2342#ifdef MULTICHAR_SET
2343 case '$':
2344 scr_charset_set (-2, (unsigned int)cmd_getc ());
2345 break;
2346#endif
2347#ifndef NO_FRILLS 2305#ifndef NO_FRILLS
2348 case '6': 2306 case '6':
2349 scr_backindex (); 2307 scr_backindex ();
2350 break; 2308 break;
2351#endif 2309#endif
2373 break; 2331 break;
2374 2332
2375 /* 8.3.87: NEXT LINE */ 2333 /* 8.3.87: NEXT LINE */
2376 case C1_NEL: /* ESC E */ 2334 case C1_NEL: /* ESC E */
2377 { 2335 {
2378 uint32_t nlcr[] = { '\n', '\r' }; 2336 unicode_t nlcr[] = { L'\n', L'\r' };
2379 scr_add_lines (nlcr, 1, 2); 2337 scr_add_lines (nlcr, 1, 2);
2380 } 2338 }
2381 break; 2339 break;
2382 2340
2383 /* kidnapped escape sequence: Should be 8.3.48 */ 2341 /* kidnapped escape sequence: Should be 8.3.48 */
2692 case 7: /* unofficial extension */ 2650 case 7: /* unofficial extension */
2693 tt_printf ("%-.250s\n", rs[Rs_display_name]); 2651 tt_printf ("%-.250s\n", rs[Rs_display_name]);
2694 break; 2652 break;
2695#endif 2653#endif
2696 case 8: /* unofficial extension */ 2654 case 8: /* unofficial extension */
2697 xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); 2655 xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
2698 break; 2656 break;
2699 } 2657 }
2700 break; 2658 break;
2701 2659
2702 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 2660 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
2971 * 19 = change underlined character color 2929 * 19 = change underlined character color
2972 * 46 = change logfile (not implemented) 2930 * 46 = change logfile (not implemented)
2973 * 50 = change font 2931 * 50 = change font
2974 * 2932 *
2975 * rxvt extensions: 2933 * rxvt extensions:
2976 * 9 = change locale (NYI)
2977 * 10 = menu (may change in future) 2934 * 10 = menu (may change in future)
2978 * 20 = bg pixmap 2935 * 20 = bg pixmap
2979 * 39 = change default fg color 2936 * 39 = change default fg color
2980 * 49 = change default bg color 2937 * 49 = change default bg color
2981 * 55 = dump scrollback buffer and all of screen 2938 * 55 = dump scrollback buffer and all of screen
2939 * 701 = change locale
2940 * 702 = find font
2982 */ 2941 */
2983void 2942void
2984rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) 2943rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused)))
2985{ 2944{
2986 int changed = 0; 2945 int changed = 0;
3074 case XTerm_logfile: 3033 case XTerm_logfile:
3075 break; 3034 break;
3076 case XTerm_font: 3035 case XTerm_font:
3077 change_font (str); 3036 change_font (str);
3078 break; 3037 break;
3038#ifndef NO_FRILLS
3079 case XTerm_locale: 3039 case XTerm_locale:
3080 if (str[0] == '?' && !str[1]) 3040 if (str[0] == '?' && !str[1])
3081 tt_printf ("%-.250s\n", locale); 3041 tt_printf ("%-.250s\n", locale);
3082 else 3042 else
3083 { 3043 {
3084 set_locale (str); 3044 set_locale (str);
3045# ifdef USE_XIM
3085 im_cb (); 3046 im_cb ();
3047# endif
3086 } 3048 }
3087 break; 3049 break;
3050 case XTerm_findfont:
3051 {
3052 int fid = TermWin.fontset->find_font (atoi (str));
3053 tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name);
3054 }
3055 break;
3056#endif
3088#if 0 3057#if 0
3089 case XTerm_dumpscreen: /* no error notices */ 3058 case XTerm_dumpscreen: /* no error notices */
3090 { 3059 {
3091 int fd; 3060 int fd;
3092 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3061 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3157 { menuBar_esc, PrivMode_menuBar }, 3126 { menuBar_esc, PrivMode_menuBar },
3158#endif 3127#endif
3159#ifdef scrollBar_esc 3128#ifdef scrollBar_esc
3160 { scrollBar_esc, PrivMode_scrollBar }, 3129 { scrollBar_esc, PrivMode_scrollBar },
3161#endif 3130#endif
3131 // 18, 19 printing-related
3162 { 25, PrivMode_VisibleCursor }, 3132 { 25, PrivMode_VisibleCursor },
3133 // 30 show scrollbar rxvt. extension
3163 { 35, PrivMode_ShiftKeys }, 3134 { 35, PrivMode_ShiftKeys }, // rxvt extension
3164 { 40, PrivMode_132OK }, 3135 { 40, PrivMode_132OK },
3136 // 41 xterm more fixes NYI
3137 // 45 margin bell NYI
3138 // 46 start logging
3165 { 47, PrivMode_Screen }, 3139 { 47, PrivMode_Screen },
3166 { 66, PrivMode_aplKP }, 3140 { 66, PrivMode_aplKP },
3167#ifndef NO_BACKSPACE_KEY 3141#ifndef NO_BACKSPACE_KEY
3168 { 67, PrivMode_BackSpace }, 3142 { 67, PrivMode_BackSpace },
3169#endif 3143#endif
3170 { 1000, PrivMode_MouseX11 }, 3144 { 1000, PrivMode_MouseX11 },
3145 // 1001 Use Hilite Mouse Tracking. NYI, TODO
3146 // 1002 Use Cell Motion Mouse Tracking. NYI, TODO
3147 // 1003 Use All Motion Mouse Tracking. NYI, TODO
3171 { 1010, PrivMode_TtyOutputInh }, 3148 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3172 { 1011, PrivMode_Keypress }, 3149 { 1011, PrivMode_Keypress }, // rxvt extension
3150 // 1035 enable modifiers for alt, numlock NYI
3151 // 1036 send ESC for meta keys NYI
3152 // 1037 send DEL for keypad delete NYI
3173 { 1047, PrivMode_Screen }, 3153 { 1047, PrivMode_Screen },
3154 // 1048 save and restore cursor
3174 { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ 3155 { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */
3156 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3175 }; 3157 };
3176 3158
3177 if (nargs == 0) 3159 if (nargs == 0)
3178 return; 3160 return;
3179 3161
3194 state = privcases (mode, argtopriv[j].bit); 3176 state = privcases (mode, argtopriv[j].bit);
3195 break; 3177 break;
3196 } 3178 }
3197 3179
3198 /* extra handling for values with state unkept */ 3180 /* extra handling for values with state unkept */
3181 switch (arg[i])
3182 {
3183 case 1048: /* alternative cursor save */
3184 case 1049:
3185 if (mode == 0)
3186 scr_cursor (RESTORE);
3187 else if (mode == 1)
3188 scr_cursor (SAVE);
3189 /* FALLTHROUGH */
3190 }
3191
3199 if (state == -1) 3192 if (state >= 0)
3193 /* extra handling for values with valid 0 or 1 state */
3200 switch (arg[i]) 3194 switch (arg[i])
3201 { 3195 {
3202 case 1048: /* alternative cursor save */ 3196 /* case 1: - application cursor keys */
3197 case 2: /* VT52 mode */
3198 /* oddball mode. should be set regardless of set/reset
3199 * parameter. Return from VT52 mode with an ESC < from
3200 * within VT52 mode
3201 */
3202 PrivMode (1, PrivMode_vt52);
3203 break;
3204 case 3: /* 80/132 */
3205 if (PrivateModes & PrivMode_132OK)
3206 set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height);
3207 break;
3208 case 4: /* smooth scrolling */
3203 if (mode == 0) 3209 if (state)
3204 scr_cursor (RESTORE); 3210 Options &= ~Opt_jumpScroll;
3205 else if (mode == 1) 3211 else
3206 scr_cursor (SAVE); 3212 Options |= Opt_jumpScroll;
3213 break;
3214 case 5: /* reverse video */
3215 scr_rvideo_mode (state);
3216 break;
3217 case 6: /* relative/absolute origins */
3218 scr_relative_origin (state);
3219 break;
3220 case 7: /* autowrap */
3221 scr_autowrap (state);
3222 break;
3223 /* case 8: - auto repeat, can't do on a per window basis */
3224 case 9: /* X10 mouse reporting */
3225 if (state) /* orthogonal */
3226 PrivateModes &= ~ (PrivMode_MouseX11);
3227 break;
3228#ifdef menuBar_esc
3229 case menuBar_esc:
3230#ifdef MENUBAR
3231 map_menuBar (state);
3232#endif
3233 break;
3234#endif
3235#ifdef scrollBar_esc
3236 case scrollBar_esc:
3237 if (scrollbar_mapping (state))
3238 {
3239 resize_all_windows (0, 0, 0);
3240 scr_touch (true);
3241 }
3242 break;
3243#endif
3244 case 25: /* visible/invisible cursor */
3245 scr_cursor_visible (state);
3246 break;
3247 /* case 35: - shift keys */
3248 /* case 40: - 80 <--> 132 mode */
3249 case 47: /* secondary screen */
3250 scr_change_screen (state);
3251 break;
3252 /* case 66: - application key pad */
3253 /* case 67: - backspace key */
3254 case 1000: /* X11 mouse reporting */
3255 if (state) /* orthogonal */
3256 PrivateModes &= ~ (PrivMode_MouseX10);
3257 break;
3258#if 0
3259 case 1001:
3260 break; /* X11 mouse highlighting */
3261#endif
3262 case 1010: /* scroll to bottom on TTY output inhibit */
3263 if (state)
3264 Options &= ~Opt_scrollTtyOutput;
3265 else
3266 Options |= Opt_scrollTtyOutput;
3267 break;
3268 case 1011: /* scroll to bottom on key press */
3269 if (state)
3270 Options |= Opt_scrollTtyKeypress;
3271 else
3272 Options &= ~Opt_scrollTtyKeypress;
3273 break;
3274 case 1047: /* secondary screen w/ clearing */
3275 case 1049: /* better secondary screen w/ clearing, but not fully implemented */
3276 if (current_screen != PRIMARY)
3277 scr_erase_screen (2);
3278 scr_change_screen (state);
3207 /* FALLTHROUGH */ 3279 /* FALLTHROUGH */
3208 default: 3280 default:
3209 continue; /* for (;i;) */ 3281 break;
3210 } 3282 }
3211
3212 /* extra handling for values with valid 0 or 1 state */
3213 switch (arg[i])
3214 {
3215 /* case 1: - application cursor keys */
3216 case 2: /* VT52 mode */
3217 /* oddball mode. should be set regardless of set/reset
3218 * parameter. Return from VT52 mode with an ESC < from
3219 * within VT52 mode
3220 */
3221 PrivMode (1, PrivMode_vt52);
3222 break;
3223 case 3: /* 80/132 */
3224 if (PrivateModes & PrivMode_132OK)
3225 set_widthheight ( (unsigned int) ((state ? 132 : 80) * TermWin.fwidth),
3226 (unsigned int)TermWin.height);
3227 break;
3228 case 4: /* smooth scrolling */
3229 if (state)
3230 Options &= ~Opt_jumpScroll;
3231 else
3232 Options |= Opt_jumpScroll;
3233 break;
3234 case 5: /* reverse video */
3235 scr_rvideo_mode (state);
3236 break;
3237 case 6: /* relative/absolute origins */
3238 scr_relative_origin (state);
3239 break;
3240 case 7: /* autowrap */
3241 scr_autowrap (state);
3242 break;
3243 /* case 8: - auto repeat, can't do on a per window basis */
3244 case 9: /* X10 mouse reporting */
3245 if (state) /* orthogonal */
3246 PrivateModes &= ~ (PrivMode_MouseX11);
3247 break;
3248#ifdef menuBar_esc
3249 case menuBar_esc:
3250#ifdef MENUBAR
3251 map_menuBar (state);
3252#endif
3253 break;
3254#endif
3255#ifdef scrollBar_esc
3256 case scrollBar_esc:
3257 if (scrollbar_mapping (state))
3258 {
3259 resize_all_windows (0, 0, 0);
3260 scr_touch (true);
3261 }
3262 break;
3263#endif
3264 case 25: /* visible/invisible cursor */
3265 scr_cursor_visible (state);
3266 break;
3267 /* case 35: - shift keys */
3268 /* case 40: - 80 <--> 132 mode */
3269 case 47: /* secondary screen */
3270 scr_change_screen (state);
3271 break;
3272 /* case 66: - application key pad */
3273 /* case 67: - backspace key */
3274 case 1000: /* X11 mouse reporting */
3275 if (state) /* orthogonal */
3276 PrivateModes &= ~ (PrivMode_MouseX10);
3277 break;
3278#if 0
3279 case 1001:
3280 break; /* X11 mouse highlighting */
3281#endif
3282 case 1010: /* scroll to bottom on TTY output inhibit */
3283 if (state)
3284 Options &= ~Opt_scrollTtyOutput;
3285 else
3286 Options |= Opt_scrollTtyOutput;
3287 break;
3288 case 1011: /* scroll to bottom on key press */
3289 if (state)
3290 Options |= Opt_scrollTtyKeypress;
3291 else
3292 Options &= ~Opt_scrollTtyKeypress;
3293 break;
3294 case 1047: /* secondary screen w/ clearing */
3295 case 1049: /* better secondary screen w/ clearing, but not fully implemented */
3296 if (current_screen != PRIMARY)
3297 scr_erase_screen (2);
3298 scr_change_screen (state);
3299 /* FALLTHROUGH */
3300 default:
3301 break;
3302 }
3303 } 3283 }
3304} 3284}
3305/*}}} */ 3285/*}}} */
3306 3286
3307/*{{{ process sgr sequences */ 3287/*{{{ process sgr sequences */
3335 rendset = 1, rendstyle = RS_Blink; 3315 rendset = 1, rendstyle = RS_Blink;
3336 break; 3316 break;
3337 case 7: 3317 case 7:
3338 rendset = 1, rendstyle = RS_RVid; 3318 rendset = 1, rendstyle = RS_RVid;
3339 break; 3319 break;
3320 case 8:
3321 // invisible. NYI
3322 break;
3340 case 22: 3323 case 22:
3341 rendset = 0, rendstyle = RS_Bold; 3324 rendset = 0, rendstyle = RS_Bold;
3342 break; 3325 break;
3343 case 24: 3326 case 24:
3344 rendset = 0, rendstyle = RS_Uline; 3327 rendset = 0, rendstyle = RS_Uline;
3347 rendset = 0, rendstyle = RS_Blink; 3330 rendset = 0, rendstyle = RS_Blink;
3348 break; 3331 break;
3349 case 27: 3332 case 27:
3350 rendset = 0, rendstyle = RS_RVid; 3333 rendset = 0, rendstyle = RS_RVid;
3351 break; 3334 break;
3335 case 28:
3336 // visible. NYI
3337 break;
3352 } 3338 }
3339
3353 if (rendset != -1) 3340 if (rendset != -1)
3354 { 3341 {
3355 scr_rendition (rendset, rendstyle); 3342 scr_rendition (rendset, rendstyle);
3356 continue; /* for (;i;) */ 3343 continue; /* for (;i;) */
3357 } 3344 }
3364 case 33: 3351 case 33:
3365 case 34: 3352 case 34:
3366 case 35: 3353 case 35:
3367 case 36: 3354 case 36:
3368 case 37: 3355 case 37:
3369 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), 3356 scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg);
3370 Color_fg);
3371 break; 3357 break;
3372#ifdef TTY_256COLOR 3358#ifdef TTY_256COLOR
3373 case 38: 3359 case 38:
3374 if (nargs > i + 2 && arg[i + 1] == 5) 3360 if (nargs > i + 2 && arg[i + 1] == 5)
3375 { 3361 {
3376 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), 3362 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg);
3377 Color_fg);
3378 i += 2; 3363 i += 2;
3379 } 3364 }
3380 break; 3365 break;
3381#endif 3366#endif
3382 case 39: /* default fg */ 3367 case 39: /* default fg */
3389 case 43: 3374 case 43:
3390 case 44: 3375 case 44:
3391 case 45: 3376 case 45:
3392 case 46: 3377 case 46:
3393 case 47: 3378 case 47:
3394 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), 3379 scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg);
3395 Color_bg);
3396 break; 3380 break;
3397#ifdef TTY_256COLOR 3381#ifdef TTY_256COLOR
3398 case 48: 3382 case 48:
3399 if (nargs > i + 2 && arg[i + 1] == 5) 3383 if (nargs > i + 2 && arg[i + 1] == 5)
3400 { 3384 {
3401 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), 3385 scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg);
3402 Color_bg);
3403 i += 2; 3386 i += 2;
3404 } 3387 }
3405 break; 3388 break;
3406#endif 3389#endif
3407 case 49: /* default bg */ 3390 case 49: /* default bg */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines