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.55 by pcg, Sun Feb 22 20:08:18 2004 UTC vs.
Revision 1.64 by pcg, Wed Mar 3 04:07:52 2004 UTC

291 ^ !!ctrl) ? '\b' : '\177'; 291 ^ !!ctrl) ? '\b' : '\177';
292 kbuf[1] = '\0'; 292 kbuf[1] = '\0';
293 } 293 }
294 else 294 else
295 STRCPY (kbuf, key_backspace); 295 STRCPY (kbuf, key_backspace);
296# ifdef MULTICHAR_SET
297 if ((Options & Opt_mc_hack) && screen.cur.col > 0)
298 {
299 int col, row;
300
301 newlen = STRLEN (kbuf);
302 col = screen.cur.col - 1;
303 row = screen.cur.row + TermWin.saveLines;
304 if (IS_MULTI2 (screen.rend[row][col]))
305 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
306 }
307# endif
308 break; 296 break;
309#endif 297#endif
310#ifndef NO_DELETE_KEY 298#ifndef NO_DELETE_KEY
311 case XK_Delete: 299 case XK_Delete:
312 STRCPY (kbuf, key_delete); 300 STRCPY (kbuf, key_delete);
313# ifdef MULTICHAR_SET
314 if (Options & Opt_mc_hack)
315 {
316 int col, row;
317
318 newlen = STRLEN (kbuf);
319 col = screen.cur.col;
320 row = screen.cur.row + TermWin.saveLines;
321 if (IS_MULTI1 (screen.rend[row][col]))
322 MEMMOVE (kbuf + newlen, kbuf, newlen + 1);
323 }
324# endif
325 break; 301 break;
326#endif 302#endif
327 case XK_Tab: 303 case XK_Tab:
328 if (shft) 304 if (shft)
329 STRCPY (kbuf, "\033[Z"); 305 STRCPY (kbuf, "\033[Z");
371 kbuf[1] = 'O'; 347 kbuf[1] = 'O';
372 kbuf[2] = "dacb"[keysym - XK_Left]; 348 kbuf[2] = "dacb"[keysym - XK_Left];
373 } 349 }
374 else if (PrivateModes & PrivMode_aplCUR) 350 else if (PrivateModes & PrivMode_aplCUR)
375 kbuf[1] = 'O'; 351 kbuf[1] = 'O';
376#ifdef MULTICHAR_SET
377 //TODO: ??
378 if (Options & Opt_mc_hack)
379 {
380 int col, row, m;
381
382 col = screen.cur.col;
383 row = screen.cur.row + TermWin.saveLines;
384 m = 0;
385 if (keysym == XK_Right
386 && IS_MULTI1 (screen.rend[row][col]))
387 m = 1;
388 else if (keysym == XK_Left)
389 {
390 if (col > 0)
391 {
392 if (IS_MULTI2 (screen.rend[row][col - 1]))
393 m = 1;
394 }
395 else if (screen.cur.row > 0)
396 {
397 col = screen.tlen[--row];
398 if (col == -1)
399 col = TermWin.ncol - 1;
400 else
401 col--;
402 if (col > 0
403 && IS_MULTI2 (screen.rend[row][col]))
404 m = 1;
405 }
406 }
407 if (m)
408 MEMMOVE (kbuf + 3, kbuf, 3 + 1);
409 }
410#endif
411 break; 352 break;
412 353
413#ifndef UNSHIFTED_SCROLLKEYS 354#ifndef UNSHIFTED_SCROLLKEYS
414# ifdef XK_KP_Prior 355# ifdef XK_KP_Prior
415 case XK_KP_Prior: 356 case XK_KP_Prior:
694{ 635{
695 unsigned int n, s; 636 unsigned int n, s;
696 637
697 n = cmdbuf_ptr - cmdbuf_base; 638 n = cmdbuf_ptr - cmdbuf_base;
698 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp; 639 s = cmdbuf_base + BUFSIZ - 1 - cmdbuf_endp;
640
699 if (n > 0 && s < count) 641 if (n > 0 && s < count)
700 { 642 {
701 MEMMOVE (cmdbuf_base, cmdbuf_ptr, 643 MEMMOVE (cmdbuf_base, cmdbuf_ptr,
702 (unsigned int) (cmdbuf_endp - cmdbuf_ptr)); 644 (unsigned int) (cmdbuf_endp - cmdbuf_ptr));
703 cmdbuf_ptr = cmdbuf_base; 645 cmdbuf_ptr = cmdbuf_base;
704 cmdbuf_endp -= n; 646 cmdbuf_endp -= n;
705 s += n; 647 s += n;
706 } 648 }
649
707 if (count > s) 650 if (count > s)
708 { 651 {
709 rxvt_print_error ("data loss: cmd_write too large"); 652 rxvt_print_error ("data loss: cmd_write too large");
710 count = s; 653 count = s;
711 } 654 }
655
712 for (; count--;) 656 for (; count--;)
713 *cmdbuf_endp++ = *str++; 657 *cmdbuf_endp++ = *str++;
658
659 cmd_parse ();
660
714 return 0; 661 return 0;
715} 662}
716#endif /* MENUBAR_MAX */ 663#endif /* MENUBAR_MAX */
717 664
718void 665void
790 cmdbuf_endp += n; 737 cmdbuf_endp += n;
791 return true; 738 return true;
792 } 739 }
793 else if (n < 0 && errno != EAGAIN) 740 else if (n < 0 && errno != EAGAIN)
794 destroy (); 741 destroy ();
795 742
796 return false; 743 return false;
797} 744}
798 745
799void 746void
800rxvt_term::pty_cb (io_watcher &w, short revents) 747rxvt_term::pty_cb (io_watcher &w, short revents)
817 seen_input = 1; 764 seen_input = 1;
818 /* 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! */
819 tt_winch (); 766 tt_winch ();
820 } 767 }
821 768
769 if (cmd_parse ())
770 break;
771 }
772 }
773}
774
775bool
776rxvt_term::cmd_parse ()
777{
778 bool flag = false;
822 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;
823 798
824 for (;;) 799 for (;;)
825 { 800 {
826 if (ch == NOCHAR)
827 ch = next_char (); 801 ch = next_char ();
828 802
829 if (ch == NOCHAR) // TODO: improve 803 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
830 break; 804 break;
831 805 else
832 if (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r')
833 { 806 {
834 /* Read a text string from the input buffer */
835 uint32_t buf[BUFSIZ];
836 bool refreshnow = false;
837 int nlines = 0;
838 uint32_t *str = buf;
839
840 *str++ = ch; 807 *str++ = ch;
841 808
842 for (;;) 809 if (ch == '\n')
843 { 810 {
844 ch = next_char ();
845
846 if (ch == NOCHAR || (ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r'))
847 break;
848 else 811 nlines++;
812 refresh_count++;
813
814 if (! (Options & Opt_jumpScroll)
815 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
849 { 816 {
850 *str++ = ch;
851
852 if (ch == '\n')
853 {
854 nlines++;
855 refresh_count++;
856
857 if (! (Options & Opt_jumpScroll)
858 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1))))
859 {
860 refreshnow = true; 817 refreshnow = true;
861 flag = false; 818 flag = false;
862 ch = NOCHAR; 819 ch = NOCHAR;
863 break; 820 break;
864 } 821 }
865 822
866 // scr_add_lines only works for nlines < TermWin.nrow - 1. 823 // scr_add_lines only works for nlines < TermWin.nrow - 1.
867 if (nlines >= TermWin.nrow - 1) 824 if (nlines >= TermWin.nrow - 1)
868 { 825 {
869 scr_add_lines (buf, nlines, str - buf); 826 scr_add_lines (buf, nlines, str - buf);
870 nlines = 0; 827 nlines = 0;
871 str = buf; 828 str = buf;
872 }
873 }
874
875 if (str >= buf + BUFSIZ)
876 {
877 ch = NOCHAR;
878 break;
879 }
880 } 829 }
881 } 830 }
882 831
883 scr_add_lines (buf, nlines, str - buf); 832 if (str >= buf + BUFSIZ)
884
885 /*
886 * If there have been a lot of new lines, then update the screen
887 * What the heck I'll cheat and only refresh less than every page-full.
888 * the number of pages between refreshes is refresh_limit, which
889 * is incremented here because we must be doing flat-out scrolling.
890 *
891 * refreshing should be correct for small scrolls, because of the
892 * time-out
893 */
894 if (refreshnow)
895 { 833 {
896 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 834 ch = NOCHAR;
897 refresh_limit++; 835 break;
898
899 scr_refresh (refresh_type);
900 } 836 }
901
902 }
903 else
904 {
905 switch (ch)
906 {
907 default:
908 process_nonprinting (ch);
909 break;
910 case C0_ESC: /* escape char */
911 process_escape_seq ();
912 break;
913 /*case 0x9b: */ /* CSI */
914 /* process_csi_seq (); */
915 }
916
917 ch = NOCHAR;
918 } 837 }
919 } 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
920 } 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 }
921 } 876 }
877
878 return flag;
922} 879}
923 880
924// read the next character, currently handles UTF-8 881// read the next character, currently handles UTF-8
925// will probably handle all sorts of other stuff in the future 882// will probably handle all sorts of other stuff in the future
926uint32_t 883uint32_t
927rxvt_term::next_char () 884rxvt_term::next_char ()
928{ 885{
929 while (cmdbuf_ptr < cmdbuf_endp) 886 while (cmdbuf_ptr < cmdbuf_endp)
930 { 887 {
931 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)
932 return *cmdbuf_ptr++; 891 return *cmdbuf_ptr++;
933 892
934 wchar_t wc; 893 wchar_t wc;
935 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);
936 895
937 if (len == (size_t)-2) 896 if (len == (size_t)-2)
938 return NOCHAR; 897 {
898 // the mbstate stores incomplete sequences. didn't know this :/
899 cmdbuf_ptr = cmdbuf_endp;
900 break;
901 }
939 902
940 if (len == (size_t)-1) 903 if (len == (size_t)-1)
941 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
942 905
943 // assume wchar == unicode 906 // assume wchar == unicode
1004 pointer_blank (); 967 pointer_blank ();
1005} 968}
1006#endif 969#endif
1007 970
1008void 971void
1009rxvt_term::mouse_report (const XButtonEvent &ev) 972rxvt_term::mouse_report (XButtonEvent &ev)
1010{ 973{
1011 int button_number, key_state = 0; 974 int button_number, key_state = 0;
1012 int x, y; 975 int x, y;
1013 976
1014 x = ev.x; 977 x = ev.x;
1015 y = ev.y; 978 y = ev.y;
1016 pixel_position (&x, &y); 979 pixel_position (&x, &y);
1017 980
1422 pointer_unblank (); 1385 pointer_unblank ();
1423#endif 1386#endif
1424#if MENUBAR 1387#if MENUBAR
1425 if (isMenuBarWindow (ev.xany.window)) 1388 if (isMenuBarWindow (ev.xany.window))
1426 { 1389 {
1427 menubar_control (& (ev.xbutton)); 1390 menubar_control (ev.xbutton);
1428 break; 1391 break;
1429 } 1392 }
1430#endif 1393#endif
1431 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate)) 1394 if ((PrivateModes & PrivMode_mouse_report) && ! (bypass_keystate))
1432 break; 1395 break;
1561#endif 1524#endif
1562 } 1525 }
1563} 1526}
1564 1527
1565void 1528void
1566rxvt_term::button_press (const XButtonEvent &ev) 1529rxvt_term::button_press (XButtonEvent &ev)
1567{ 1530{
1568 int reportmode = 0, clickintime; 1531 int reportmode = 0, clickintime;
1569 1532
1570 bypass_keystate = ev.state & (ModMetaMask | ShiftMask); 1533 bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
1571 if (!bypass_keystate) 1534 if (!bypass_keystate)
1799 menubar_control (ev); 1762 menubar_control (ev);
1800#endif 1763#endif
1801} 1764}
1802 1765
1803void 1766void
1804rxvt_term::button_release (const XButtonEvent &ev) 1767rxvt_term::button_release (XButtonEvent &ev)
1805{ 1768{
1806 int reportmode = 0; 1769 int reportmode = 0;
1807 1770
1808 csrO = 0; /* reset csr Offset */ 1771 csrO = 0; /* reset csr Offset */
1809 if (!bypass_keystate) 1772 if (!bypass_keystate)
2344 scr_charset_set (2, (unsigned int)cmd_getc ()); 2307 scr_charset_set (2, (unsigned int)cmd_getc ());
2345 break; 2308 break;
2346 case '+': 2309 case '+':
2347 scr_charset_set (3, (unsigned int)cmd_getc ()); 2310 scr_charset_set (3, (unsigned int)cmd_getc ());
2348 break; 2311 break;
2349#ifdef MULTICHAR_SET
2350 case '$':
2351 scr_charset_set (-2, (unsigned int)cmd_getc ());
2352 break;
2353#endif
2354#ifndef NO_FRILLS 2312#ifndef NO_FRILLS
2355 case '6': 2313 case '6':
2356 scr_backindex (); 2314 scr_backindex ();
2357 break; 2315 break;
2358#endif 2316#endif
2699 case 7: /* unofficial extension */ 2657 case 7: /* unofficial extension */
2700 tt_printf ("%-.250s\n", rs[Rs_display_name]); 2658 tt_printf ("%-.250s\n", rs[Rs_display_name]);
2701 break; 2659 break;
2702#endif 2660#endif
2703 case 8: /* unofficial extension */ 2661 case 8: /* unofficial extension */
2704 xterm_seq (XTerm_title, APL_NAME "-" VERSION, CHAR_ST); 2662 xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
2705 break; 2663 break;
2706 } 2664 }
2707 break; 2665 break;
2708 2666
2709 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 2667 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
3081 case XTerm_logfile: 3039 case XTerm_logfile:
3082 break; 3040 break;
3083 case XTerm_font: 3041 case XTerm_font:
3084 change_font (str); 3042 change_font (str);
3085 break; 3043 break;
3044#ifndef NO_FRILLS
3086 case XTerm_locale: 3045 case XTerm_locale:
3087 if (str[0] == '?' && !str[1]) 3046 if (str[0] == '?' && !str[1])
3088 tt_printf ("%-.250s\n", locale); 3047 tt_printf ("%-.250s\n", locale);
3089 else 3048 else
3090 { 3049 {
3091 set_locale (str); 3050 set_locale (str);
3051# ifdef USE_XIM
3092 im_cb (); 3052 im_cb ();
3053# endif
3054 // TODO: call selection_make with the right values set
3055 // to re-fresh the selection.
3056 if (display->selection_owner == this)
3057 display->set_selection_owner (0);
3093 } 3058 }
3094 break; 3059 break;
3060#endif
3095#if 0 3061#if 0
3096 case XTerm_dumpscreen: /* no error notices */ 3062 case XTerm_dumpscreen: /* no error notices */
3097 { 3063 {
3098 int fd; 3064 int fd;
3099 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3065 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines