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.7 by pcg, Tue Nov 25 17:34:47 2003 UTC vs.
Revision 1.8 by pcg, Wed Nov 26 10:42:34 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: command.c 2 * File: command.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: command.C,v 1.7 2003/11/25 17:34:47 pcg Exp $ 4 * $Id: command.C,v 1.8 2003/11/26 10:42:34 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>
707rxvt_term::blink_cb (time_watcher &w) 707rxvt_term::blink_cb (time_watcher &w)
708{ 708{
709 w.at += BLINK_INTERVAL; 709 w.at += BLINK_INTERVAL;
710 hidden_cursor = !hidden_cursor; 710 hidden_cursor = !hidden_cursor;
711 want_refresh = 1; 711 want_refresh = 1;
712 flush(); 712 flush ();
713} 713}
714 714
715void 715void
716rxvt_term::x_cb (io_watcher &w, short revents) 716rxvt_term::x_cb (io_watcher &w, short revents)
717{ 717{
774 774
775 return NOCHAR; 775 return NOCHAR;
776} 776}
777 777
778bool 778bool
779rxvt_term::pty_fill (size_t count) 779rxvt_term::pty_fill ()
780{ 780{
781 ssize_t n = cmdbuf_endp - cmdbuf_ptr; 781 ssize_t n = cmdbuf_endp - cmdbuf_ptr;
782 782
783 memmove (cmdbuf_base, cmdbuf_ptr, n); 783 memmove (cmdbuf_base, cmdbuf_ptr, n);
784 cmdbuf_ptr = cmdbuf_base; 784 cmdbuf_ptr = cmdbuf_base;
785 cmdbuf_endp = cmdbuf_ptr + n; 785 cmdbuf_endp = cmdbuf_ptr + n;
786 786
787 n = read (cmd_fd, cmdbuf_endp, count); 787 n = read (cmd_fd, cmdbuf_endp, BUFSIZ - n);
788 788
789 if (n > 0) 789 if (n > 0)
790 { 790 {
791 cmdbuf_endp += n; 791 cmdbuf_endp += n;
792 return true; 792 return true;
793 } 793 }
794 else if (n < 0 && errno == EAGAIN) 794 else if (n < 0 && errno == EAGAIN)
795 return false; 795 return false;
796 796
797 rxvt_clean_exit(); 797 rxvt_clean_exit ();
798 exit(EXIT_FAILURE); /* bad order of events? */ 798 exit (EXIT_FAILURE); /* bad order of events? */
799} 799}
800 800
801void 801void
802rxvt_term::pty_cb (io_watcher &w, short revents) 802rxvt_term::pty_cb (io_watcher &w, short revents)
803{ 803{
804 while (pty_fill (BUFSIZ - (cmdbuf_endp - cmdbuf_ptr))) 804 // loop, but don't allow a single term to monopolize us
805 // the number of loops is fully arbitrary, and thus wrong
806 for (int i = 7; i-- && pty_fill (); )
805 { 807 {
808 //TODO:
806 /* once we know the shell is running, send the screen size. Again! */ 809 /* once we know the shell is running, send the screen size. Again! */
807 //ch = rxvt_cmd_getc(aR); /* wait for something */ 810 //ch = rxvt_cmd_getc(aR); /* wait for something */
808 //rxvt_tt_winsize(cmd_fd, TermWin.ncol, TermWin.nrow, cmd_pid); 811 //rxvt_tt_winsize(cmd_fd, TermWin.ncol, TermWin.nrow, cmd_pid);
809 812
810 uint32_t ch = NOCHAR; 813 uint32_t ch = NOCHAR;
921#ifdef USE_XIM 924#ifdef USE_XIM
922 rxvt_IMSendSpot (this); 925 rxvt_IMSendSpot (this);
923#endif 926#endif
924 } 927 }
925 928
929 if (XPending (Xdisplay)) process_x_events ();
926 XFlush (Xdisplay); 930 XFlush (Xdisplay);
931 if (XPending (Xdisplay)) process_x_events ();
927} 932}
928 933
929/* rxvt_cmd_getc() - Return next input character */ 934/* rxvt_cmd_getc() - Return next input character */
930/* 935/*
931 * Return the next input character after first passing any keyboard input 936 * Return the next input character after first passing any keyboard input
942 return c; 947 return c;
943 948
944 // incomplete sequences should occur rarely, still, a better solution 949 // incomplete sequences should occur rarely, still, a better solution
945 // would be preferred. either setjmp/longjmp or better design. 950 // would be preferred. either setjmp/longjmp or better design.
946 fcntl (R->cmd_fd, F_SETFL, 0); 951 fcntl (R->cmd_fd, F_SETFL, 0);
947 R->pty_fill (1); 952 R->pty_fill ();
948 fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK); 953 fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK);
949 } 954 }
950 955
951#if 0 956#if 0
952#define TIMEOUT_USEC 5000 957#define TIMEOUT_USEC 5000
1289 * in the GraphicsExpose parts, which means that after each refresh, 1294 * in the GraphicsExpose parts, which means that after each refresh,
1290 * we need to wait for the graphics expose or Noexpose events, 1295 * we need to wait for the graphics expose or Noexpose events,
1291 * which ought to make things real slow! 1296 * which ought to make things real slow!
1292 */ 1297 */
1293 case VisibilityNotify: 1298 case VisibilityNotify:
1294 switch (ev->xvisibility.state) { 1299 switch (ev->xvisibility.state)
1300 {
1295 case VisibilityUnobscured: 1301 case VisibilityUnobscured:
1296 R->refresh_type = FAST_REFRESH; 1302 R->refresh_type = FAST_REFRESH;
1297 break; 1303 break;
1298 case VisibilityPartiallyObscured: 1304 case VisibilityPartiallyObscured:
1299 R->refresh_type = SLOW_REFRESH; 1305 R->refresh_type = SLOW_REFRESH;
1300 break; 1306 break;
1301 default: 1307 default:
1302 R->refresh_type = NO_REFRESH; 1308 R->refresh_type = NO_REFRESH;
1303 break; 1309 break;
1304 } 1310 }
1305 break; 1311 break;
1306 1312
1307 case FocusIn: 1313 case FocusIn:
1308 if (!R->TermWin.focus) { 1314 if (!R->TermWin.focus) {
1309 R->TermWin.focus = 1; 1315 R->TermWin.focus = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines