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.6 by pcg, Tue Nov 25 17:11:33 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.6 2003/11/25 17:11:33 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
1006 quick_timeout |= R->want_full_refresh; 1011 quick_timeout |= R->want_full_refresh;
1007#endif 1012#endif
1008#endif 1013#endif
1009} 1014}
1010 1015
1011#ifdef POINTER_BLANK
1012void 1016void
1013rxvt_term::pointer_unblank () 1017rxvt_term::pointer_unblank ()
1014{ 1018{
1015 if (!(Options & Opt_pointerBlank))
1016 return;
1017
1018 XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor); 1019 XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor);
1019 rxvt_recolour_cursor (this); 1020 rxvt_recolour_cursor (this);
1021
1022#ifdef POINTER_BLANK
1020 hidden_pointer = 0; 1023 hidden_pointer = 0;
1021 1024
1025 if (Options & Opt_pointerBlank)
1022 pointer_ev.start (NOW + pointerBlankDelay); 1026 pointer_ev.start (NOW + pointerBlankDelay);
1027#endif
1023} 1028}
1024 1029
1030#ifdef POINTER_BLANK
1025void 1031void
1026rxvt_term::pointer_blank () 1032rxvt_term::pointer_blank ()
1027{ 1033{
1028 pointer_ev.stop (); 1034 pointer_ev.stop ();
1029 1035
1288 * in the GraphicsExpose parts, which means that after each refresh, 1294 * in the GraphicsExpose parts, which means that after each refresh,
1289 * we need to wait for the graphics expose or Noexpose events, 1295 * we need to wait for the graphics expose or Noexpose events,
1290 * which ought to make things real slow! 1296 * which ought to make things real slow!
1291 */ 1297 */
1292 case VisibilityNotify: 1298 case VisibilityNotify:
1293 switch (ev->xvisibility.state) { 1299 switch (ev->xvisibility.state)
1300 {
1294 case VisibilityUnobscured: 1301 case VisibilityUnobscured:
1295 R->refresh_type = FAST_REFRESH; 1302 R->refresh_type = FAST_REFRESH;
1296 break; 1303 break;
1297 case VisibilityPartiallyObscured: 1304 case VisibilityPartiallyObscured:
1298 R->refresh_type = SLOW_REFRESH; 1305 R->refresh_type = SLOW_REFRESH;
1299 break; 1306 break;
1300 default: 1307 default:
1301 R->refresh_type = NO_REFRESH; 1308 R->refresh_type = NO_REFRESH;
1302 break; 1309 break;
1303 } 1310 }
1304 break; 1311 break;
1305 1312
1306 case FocusIn: 1313 case FocusIn:
1307 if (!R->TermWin.focus) { 1314 if (!R->TermWin.focus) {
1308 R->TermWin.focus = 1; 1315 R->TermWin.focus = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines