aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorKaroly Lorentey2003-12-26 04:24:54 +0000
committerKaroly Lorentey2003-12-26 04:24:54 +0000
commit9628b8878f46b2b7eeeb4f272d20f2e64de19f4a (patch)
treecfccb4da4a6b898780d3bc9856b377fd5d85e4e6 /src/sysdep.c
parent4f0359deff8eb9ec9ed95e75d77a0dd59f39428c (diff)
downloademacs-9628b8878f46b2b7eeeb4f272d20f2e64de19f4a.tar.gz
emacs-9628b8878f46b2b7eeeb4f272d20f2e64de19f4a.zip
lib-src/emacsclient.c: Implemented --here option (open a new Emacs tty). Needs more work.
(here): New variable. (decode_options): Use it. (ec_get_tty, ec_set_tty, init_tty, window_change, hang_up_signal): New functions. (window_change_signal, init_signals, reset_tty, init_pty, copy_from_to): Ditto. (pty_conversation): Ditto. (main): Use them. (master, pty_name, old_tty, tty, old_tty_valid, tty_erase_char): New variables. (flow_control, meta_key, _sobuf, in_conversation, quit_conversation): Ditto. lisp/server.el (server-process-filter): Added support for opening a new terminal frame. dispextern.h (get_frame_size): Renamed to get_tty_size, added tty_output parameter. dispnew.c (Fredraw_frame): fflush the current terminal instead of stdout. (direct_output_for_insert, direct_output_forward_char, update_frame_1): Ditto. (Fding, bitch_at_user): Ditto. (update_frame_1): Count pending output for current terminal instead of stdout. (window_change_signal): Resize all terminals. (change_frame_size): Don't resize all terminals to the same size. frame.c (Vterminal_frame): Removed. (syms_of_frame): Removed declaration of Vterminal_frame. (make_terminal_frame): Set the top frame of the terminal to the new frame. (Fmake_terminal_frame): Get a new frame size from get_tty_size, don't copy it. (do_switch_frame): Handle terminal frame visibility. (next_frame, prev_frame): Skip over frames on different terminals. frame.h (Vterminal_frame): Removed. keyboard.c (input_fd): Removed. (read_avail_input): Removed first argument from read_socket_hook. Try to read from each available tty, until one succeeds. (Fsuspend_emacs): Don't suspend if there are multiple terminals. lisp.h (get_frame_size): Removed superflous declaration. xterm.c (Xtread_socket): Removed first parameter. macterm.h (XTread_socket): Ditto. w32inevt.c (w32_console_read_socket): Ditto. w32term.c (w32_read_socket): Ditto. sysdep.c (input_fd): Removed. (change_input_fd): Removed. (discard_tty_input): Discard pending input on _all_ input descriptors. (stuff_char, tabs_safe_p): Use current terminal instead of input_fd. (init_baud_rate, request_sigio, unrequest_sigio): Ditto. (init_sys_modes, reset_sys_modes): Ditto. (narrow_foreground_group, widen_foreground_group): Use stdin. (init_sys_modes, reset_sys_modes): otty parameter renamed to tty_out. (get_frame_size): Renamed to get_tty_size, added tty_out parameter. term.c (read_socket_hook): Removed first parameter. (clear_end_of_line): Use updating_frame, if possible. (write_glyphs, insert_glyphs, ins_del_lines): Ditto. (term_init): Renamed get_frame_size to get_tty_size. termchar.h (struct tty_output): New entries: top_frame, previous_terminal_frame. termhooks.h (read_socket_hook): Removed first parameter. window.c (init_window_once): Removed reference to Vterminal_frame. xdisp.c (previous_terminal_frame): Moved to struct tty_output. (redisplay_internal): Updated to use previous_terminal_frame in tty_output. Allow for simultaneous refresh of multiple ttys. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-5
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c174
1 files changed, 90 insertions, 84 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 7573cc4b9de..43a7d7c25da 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -246,11 +246,6 @@ static int baud_convert[] =
246 246
247int emacs_ospeed; 247int emacs_ospeed;
248 248
249/* The file descriptor for Emacs's input terminal.
250 Under Unix, this is normally zero except when using X;
251 under VMS, we place the input channel number here. */
252int input_fd;
253
254void croak P_ ((char *)); 249void croak P_ ((char *));
255 250
256#ifdef AIXHFT 251#ifdef AIXHFT
@@ -263,16 +258,7 @@ void hft_reset ();
263SIGMASKTYPE sigprocmask_set; 258SIGMASKTYPE sigprocmask_set;
264 259
265 260
266/* Specify a different file descriptor for further input operations. */ 261/* Discard pending input on all input descriptors. */
267
268void
269change_input_fd (fd)
270 int fd;
271{
272 input_fd = fd;
273}
274
275/* Discard pending input on descriptor input_fd. */
276 262
277void 263void
278discard_tty_input () 264discard_tty_input ()
@@ -290,22 +276,28 @@ discard_tty_input ()
290 276
291#ifdef VMS 277#ifdef VMS
292 end_kbd_input (); 278 end_kbd_input ();
293 SYS$QIOW (0, input_fd, IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0, 279 SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0,
294 &buf.main, 0, 0, terminator_mask, 0, 0); 280 &buf.main, 0, 0, terminator_mask, 0, 0);
295 queue_kbd_input (); 281 queue_kbd_input ();
296#else /* not VMS */ 282#else /* not VMS */
297#ifdef APOLLO 283#ifdef APOLLO
298 { 284 {
299 int zero = 0; 285 int zero = 0;
300 ioctl (input_fd, TIOCFLUSH, &zero); 286 ioctl (fileno (TTY_INPUT (CURTTY())), TIOCFLUSH, &zero);
301 } 287 }
302#else /* not Apollo */ 288#else /* not Apollo */
303#ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ 289#ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */
304 while (dos_keyread () != -1) 290 while (dos_keyread () != -1)
305 ; 291 ;
306#else /* not MSDOS */ 292#else /* not MSDOS */
307 EMACS_GET_TTY (input_fd, &buf); 293 {
308 EMACS_SET_TTY (input_fd, &buf, 0); 294 struct tty_output tty;
295 for (tty = tty_list; tty; tty = tty->next)
296 {
297 EMACS_GET_TTY (fileno (TTY_INPUT (tty)), &buf);
298 EMACS_SET_TTY (fileno (TTY_INPUT (tty)), &buf, 0);
299 }
300 }
309#endif /* not MSDOS */ 301#endif /* not MSDOS */
310#endif /* not Apollo */ 302#endif /* not Apollo */
311#endif /* not VMS */ 303#endif /* not VMS */
@@ -330,7 +322,7 @@ stuff_char (c)
330 322
331/* Should perhaps error if in batch mode */ 323/* Should perhaps error if in batch mode */
332#ifdef TIOCSTI 324#ifdef TIOCSTI
333 ioctl (input_fd, TIOCSTI, &c); 325 ioctl (fileno (TTY_INPUT (CURTTY())), TIOCSTI, &c);
334#else /* no TIOCSTI */ 326#else /* no TIOCSTI */
335 error ("Cannot stuff terminal input characters in this version of Unix"); 327 error ("Cannot stuff terminal input characters in this version of Unix");
336#endif /* no TIOCSTI */ 328#endif /* no TIOCSTI */
@@ -354,7 +346,7 @@ init_baud_rate ()
354#ifdef VMS 346#ifdef VMS
355 struct sensemode sg; 347 struct sensemode sg;
356 348
357 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &sg, 0, 0, 349 SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_SENSEMODE, &sg, 0, 0,
358 &sg.class, 12, 0, 0, 0, 0 ); 350 &sg.class, 12, 0, 0, 0, 0 );
359 emacs_ospeed = sg.xmit_baud; 351 emacs_ospeed = sg.xmit_baud;
360#else /* not VMS */ 352#else /* not VMS */
@@ -362,7 +354,7 @@ init_baud_rate ()
362 struct termios sg; 354 struct termios sg;
363 355
364 sg.c_cflag = B9600; 356 sg.c_cflag = B9600;
365 tcgetattr (input_fd, &sg); 357 tcgetattr (fileno (TTY_INPUT (CURTTY())), &sg);
366 emacs_ospeed = cfgetospeed (&sg); 358 emacs_ospeed = cfgetospeed (&sg);
367#if defined (USE_GETOBAUD) && defined (getobaud) 359#if defined (USE_GETOBAUD) && defined (getobaud)
368 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ 360 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */
@@ -375,16 +367,16 @@ init_baud_rate ()
375 367
376 sg.c_cflag = B9600; 368 sg.c_cflag = B9600;
377#ifdef HAVE_TCATTR 369#ifdef HAVE_TCATTR
378 tcgetattr (input_fd, &sg); 370 tcgetattr (fileno (TTY_INPUT (CURTTY())), &sg);
379#else 371#else
380 ioctl (input_fd, TCGETA, &sg); 372 ioctl (fileno (TTY_INPUT (CURTTY())), TCGETA, &sg);
381#endif 373#endif
382 emacs_ospeed = sg.c_cflag & CBAUD; 374 emacs_ospeed = sg.c_cflag & CBAUD;
383#else /* neither VMS nor TERMIOS nor TERMIO */ 375#else /* neither VMS nor TERMIOS nor TERMIO */
384 struct sgttyb sg; 376 struct sgttyb sg;
385 377
386 sg.sg_ospeed = B9600; 378 sg.sg_ospeed = B9600;
387 if (ioctl (input_fd, TIOCGETP, &sg) < 0) 379 if (ioctl (fileno (TTY_INPUT (CURTTY())), TIOCGETP, &sg) < 0)
388 abort (); 380 abort ();
389 emacs_ospeed = sg.sg_ospeed; 381 emacs_ospeed = sg.sg_ospeed;
390#endif /* not HAVE_TERMIO */ 382#endif /* not HAVE_TERMIO */
@@ -947,7 +939,7 @@ request_sigio ()
947#ifdef SIGWINCH 939#ifdef SIGWINCH
948 sigunblock (sigmask (SIGWINCH)); 940 sigunblock (sigmask (SIGWINCH));
949#endif 941#endif
950 fcntl (input_fd, F_SETFL, old_fcntl_flags | FASYNC); 942 fcntl (fileno (TTY_INPUT (CURTTY())), F_SETFL, old_fcntl_flags | FASYNC);
951 943
952 interrupts_deferred = 0; 944 interrupts_deferred = 0;
953} 945}
@@ -961,7 +953,7 @@ unrequest_sigio ()
961#ifdef SIGWINCH 953#ifdef SIGWINCH
962 sigblock (sigmask (SIGWINCH)); 954 sigblock (sigmask (SIGWINCH));
963#endif 955#endif
964 fcntl (input_fd, F_SETFL, old_fcntl_flags); 956 fcntl (fileno (TTY_INPUT (CURTTY())), F_SETFL, old_fcntl_flags);
965 interrupts_deferred = 1; 957 interrupts_deferred = 1;
966} 958}
967 959
@@ -976,7 +968,7 @@ request_sigio ()
976 if (read_socket_hook) 968 if (read_socket_hook)
977 return; 969 return;
978 970
979 ioctl (input_fd, FIOASYNC, &on); 971 ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &on);
980 interrupts_deferred = 0; 972 interrupts_deferred = 0;
981} 973}
982 974
@@ -988,7 +980,7 @@ unrequest_sigio ()
988 if (read_socket_hook) 980 if (read_socket_hook)
989 return; 981 return;
990 982
991 ioctl (input_fd, FIOASYNC, &off); 983 ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &off);
992 interrupts_deferred = 1; 984 interrupts_deferred = 1;
993} 985}
994 986
@@ -1009,7 +1001,7 @@ request_sigio ()
1009 1001
1010 sigemptyset (&st); 1002 sigemptyset (&st);
1011 sigaddset (&st, SIGIO); 1003 sigaddset (&st, SIGIO);
1012 ioctl (input_fd, FIOASYNC, &on); 1004 ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &on);
1013 interrupts_deferred = 0; 1005 interrupts_deferred = 0;
1014 sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0); 1006 sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0);
1015} 1007}
@@ -1022,7 +1014,7 @@ unrequest_sigio ()
1022 if (read_socket_hook) 1014 if (read_socket_hook)
1023 return; 1015 return;
1024 1016
1025 ioctl (input_fd, FIOASYNC, &off); 1017 ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &off);
1026 interrupts_deferred = 1; 1018 interrupts_deferred = 1;
1027} 1019}
1028 1020
@@ -1088,7 +1080,7 @@ narrow_foreground_group ()
1088 1080
1089 setpgrp (0, inherited_pgroup); 1081 setpgrp (0, inherited_pgroup);
1090 if (inherited_pgroup != me) 1082 if (inherited_pgroup != me)
1091 EMACS_SET_TTY_PGRP (input_fd, &me); 1083 EMACS_SET_TTY_PGRP (fileno (stdin), &me); /* stdin is intentional here */
1092 setpgrp (0, me); 1084 setpgrp (0, me);
1093} 1085}
1094 1086
@@ -1097,7 +1089,7 @@ void
1097widen_foreground_group () 1089widen_foreground_group ()
1098{ 1090{
1099 if (inherited_pgroup != getpid ()) 1091 if (inherited_pgroup != getpid ())
1100 EMACS_SET_TTY_PGRP (input_fd, &inherited_pgroup); 1092 EMACS_SET_TTY_PGRP (fileno (stdin), &inherited_pgroup); /* stdin is intentional here */
1101 setpgrp (0, inherited_pgroup); 1093 setpgrp (0, inherited_pgroup);
1102} 1094}
1103 1095
@@ -1300,8 +1292,8 @@ init_all_sys_modes (void)
1300} 1292}
1301 1293
1302void 1294void
1303init_sys_modes (otty) 1295init_sys_modes (tty_out)
1304 struct tty_output *otty; 1296 struct tty_output *tty_out;
1305{ 1297{
1306 struct emacs_tty tty; 1298 struct emacs_tty tty;
1307 1299
@@ -1357,7 +1349,7 @@ nil means don't delete them until `list-processes' is run. */);
1357#ifndef VMS4_4 1349#ifndef VMS4_4
1358 sys_access_reinit (); 1350 sys_access_reinit ();
1359#endif 1351#endif
1360#endif /* not VMS */ 1352#endif /* VMS */
1361 1353
1362#ifdef BSD_PGRPS 1354#ifdef BSD_PGRPS
1363 if (! read_socket_hook && EQ (Vwindow_system, Qnil)) 1355 if (! read_socket_hook && EQ (Vwindow_system, Qnil))
@@ -1370,14 +1362,14 @@ nil means don't delete them until `list-processes' is run. */);
1370 if (!read_socket_hook && EQ (Vwindow_system, Qnil)) 1362 if (!read_socket_hook && EQ (Vwindow_system, Qnil))
1371#endif 1363#endif
1372 { 1364 {
1373 EMACS_GET_TTY (input_fd, &otty->old_tty); 1365 EMACS_GET_TTY (fileno (TTY_INPUT (tty_out)), &tty_out->old_tty);
1374 1366
1375 otty->old_tty_valid = 1; 1367 tty_out->old_tty_valid = 1;
1376 1368
1377 tty = otty->old_tty; 1369 tty = tty_out->old_tty;
1378 1370
1379#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) 1371#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
1380 XSETINT (Vtty_erase_char, otty->old_tty.main.c_cc[VERASE]); 1372 XSETINT (Vtty_erase_char, tty_out->old_tty.main.c_cc[VERASE]);
1381 1373
1382#ifdef DGUX 1374#ifdef DGUX
1383 /* This allows meta to be sent on 8th bit. */ 1375 /* This allows meta to be sent on 8th bit. */
@@ -1542,7 +1534,7 @@ nil means don't delete them until `list-processes' is run. */);
1542 tty.tchars.t_stopc = '\023'; 1534 tty.tchars.t_stopc = '\023';
1543 } 1535 }
1544 1536
1545 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | otty->old_tty.lmode; 1537 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | tty_out->old_tty.lmode;
1546#ifdef ultrix 1538#ifdef ultrix
1547 /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt 1539 /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt
1548 anything, and leaving it in breaks the meta key. Go figure. */ 1540 anything, and leaving it in breaks the meta key. Go figure. */
@@ -1560,28 +1552,28 @@ nil means don't delete them until `list-processes' is run. */);
1560 tty.ltchars = new_ltchars; 1552 tty.ltchars = new_ltchars;
1561#endif /* HAVE_LTCHARS */ 1553#endif /* HAVE_LTCHARS */
1562#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */ 1554#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida, MW Aug 1993 */
1563 if (!otty->term_initted) 1555 if (!tty_out->term_initted)
1564 internal_terminal_init (); 1556 internal_terminal_init ();
1565 dos_ttraw (); 1557 dos_ttraw ();
1566#endif 1558#endif
1567 1559
1568 EMACS_SET_TTY (input_fd, &tty, 0); 1560 EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)), &tty, 0);
1569 1561
1570 /* This code added to insure that, if flow-control is not to be used, 1562 /* This code added to insure that, if flow-control is not to be used,
1571 we have an unlocked terminal at the start. */ 1563 we have an unlocked terminal at the start. */
1572 1564
1573#ifdef TCXONC 1565#ifdef TCXONC
1574 if (!flow_control) ioctl (input_fd, TCXONC, 1); 1566 if (!flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TCXONC, 1);
1575#endif 1567#endif
1576#ifndef APOLLO 1568#ifndef APOLLO
1577#ifdef TIOCSTART 1569#ifdef TIOCSTART
1578 if (!flow_control) ioctl (input_fd, TIOCSTART, 0); 1570 if (!flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TIOCSTART, 0);
1579#endif 1571#endif
1580#endif 1572#endif
1581 1573
1582#if defined (HAVE_TERMIOS) || defined (HPUX9) 1574#if defined (HAVE_TERMIOS) || defined (HPUX9)
1583#ifdef TCOON 1575#ifdef TCOON
1584 if (!flow_control) tcflow (input_fd, TCOON); 1576 if (!flow_control) tcflow (fileno (TTY_INPUT (tty_out)), TCOON);
1585#endif 1577#endif
1586#endif 1578#endif
1587 1579
@@ -1601,7 +1593,7 @@ nil means don't delete them until `list-processes' is run. */);
1601 1593
1602#ifdef VMS 1594#ifdef VMS
1603/* Appears to do nothing when in PASTHRU mode. 1595/* Appears to do nothing when in PASTHRU mode.
1604 SYS$QIOW (0, input_fd, IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0, 1596 SYS$QIOW (0, fileno (TTY_INPUT (tty_out)), IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0,
1605 interrupt_signal, oob_chars, 0, 0, 0, 0); 1597 interrupt_signal, oob_chars, 0, 0, 0, 0);
1606*/ 1598*/
1607 queue_kbd_input (0); 1599 queue_kbd_input (0);
@@ -1614,9 +1606,9 @@ nil means don't delete them until `list-processes' is run. */);
1614 if (interrupt_input 1606 if (interrupt_input
1615 && ! read_socket_hook && EQ (Vwindow_system, Qnil)) 1607 && ! read_socket_hook && EQ (Vwindow_system, Qnil))
1616 { 1608 {
1617 old_fcntl_owner = fcntl (input_fd, F_GETOWN, 0); 1609 old_fcntl_owner = fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0);
1618 fcntl (input_fd, F_SETOWN, getpid ()); 1610 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, getpid ());
1619 init_sigio (input_fd); 1611 init_sigio (fileno (TTY_INPUT (tty_out)));
1620 } 1612 }
1621#endif /* F_GETOWN */ 1613#endif /* F_GETOWN */
1622#endif /* F_SETOWN_BUG */ 1614#endif /* F_SETOWN_BUG */
@@ -1624,7 +1616,7 @@ nil means don't delete them until `list-processes' is run. */);
1624 1616
1625#ifdef BSD4_1 1617#ifdef BSD4_1
1626 if (interrupt_input) 1618 if (interrupt_input)
1627 init_sigio (input_fd); 1619 init_sigio (fileno (TTY_INPUT (tty_out)));
1628#endif 1620#endif
1629 1621
1630#ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */ 1622#ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */
@@ -1634,9 +1626,9 @@ nil means don't delete them until `list-processes' is run. */);
1634 /* This symbol is defined on recent USG systems. 1626 /* This symbol is defined on recent USG systems.
1635 Someone says without this call USG won't really buffer the file 1627 Someone says without this call USG won't really buffer the file
1636 even with a call to setbuf. */ 1628 even with a call to setbuf. */
1637 setvbuf (stdout, (char *) _sobuf, _IOFBF, sizeof _sobuf); 1629 setvbuf (TTY_OUTPUT (tty_out), (char *) _sobuf, _IOFBF, sizeof _sobuf);
1638#else 1630#else
1639 setbuf (stdout, (char *) _sobuf); 1631 setbuf (TTY_OUTPUT (tty_out), (char *) _sobuf);
1640#endif 1632#endif
1641#ifdef HAVE_WINDOW_SYSTEM 1633#ifdef HAVE_WINDOW_SYSTEM
1642 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore 1634 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
@@ -1649,26 +1641,37 @@ nil means don't delete them until `list-processes' is run. */);
1649#endif 1641#endif
1650 ) 1642 )
1651#endif 1643#endif
1652 set_terminal_modes (otty); 1644 set_terminal_modes (tty_out);
1653 1645
1654 if (!otty->term_initted 1646 if (!tty_out->term_initted)
1655 && FRAMEP (Vterminal_frame) 1647 {
1656 && FRAME_TERMCAP_P (XFRAME (Vterminal_frame))) 1648 Lisp_Object tail, frame;
1657 init_frame_faces (XFRAME (Vterminal_frame)); 1649 FOR_EACH_FRAME (tail, frame)
1650 {
1651 if (FRAME_TERMCAP_P (XFRAME (frame))
1652 && FRAME_TTY (XFRAME (frame)) == tty_out)
1653 init_frame_faces (XFRAME (frame));
1654 }
1655 }
1658 1656
1659 if (otty->term_initted && no_redraw_on_reenter) 1657 if (tty_out->term_initted && no_redraw_on_reenter)
1660 { 1658 {
1661 if (display_completed) 1659 if (display_completed)
1662 direct_output_forward_char (0); 1660 direct_output_forward_char (0);
1663 } 1661 }
1664 else 1662 else
1665 { 1663 {
1664 Lisp_Object tail, frame;
1666 frame_garbaged = 1; 1665 frame_garbaged = 1;
1667 if (FRAMEP (Vterminal_frame)) 1666 FOR_EACH_FRAME (tail, frame)
1668 FRAME_GARBAGED_P (XFRAME (Vterminal_frame)) = 1; 1667 {
1668 if (FRAME_TERMCAP_P (XFRAME (frame))
1669 && FRAME_TTY (XFRAME (frame)) == tty_out)
1670 FRAME_GARBAGED_P (XFRAME (frame)) = 1;
1671 }
1669 } 1672 }
1670 1673
1671 otty->term_initted = 1; 1674 tty_out->term_initted = 1;
1672} 1675}
1673 1676
1674/* Return nonzero if safe to use tabs in output. 1677/* Return nonzero if safe to use tabs in output.
@@ -1679,7 +1682,7 @@ tabs_safe_p ()
1679{ 1682{
1680 struct emacs_tty tty; 1683 struct emacs_tty tty;
1681 1684
1682 EMACS_GET_TTY (input_fd, &tty); 1685 EMACS_GET_TTY (fileno (TTY_INPUT (CURTTY())), &tty);
1683 return EMACS_TTY_TABS_OK (&tty); 1686 return EMACS_TTY_TABS_OK (&tty);
1684} 1687}
1685 1688
@@ -1688,7 +1691,8 @@ tabs_safe_p ()
1688 We store 0 if there's no valid information. */ 1691 We store 0 if there's no valid information. */
1689 1692
1690void 1693void
1691get_frame_size (widthp, heightp) 1694get_tty_size (tty_out, widthp, heightp)
1695 struct tty_output *tty_out;
1692 int *widthp, *heightp; 1696 int *widthp, *heightp;
1693{ 1697{
1694 1698
@@ -1697,7 +1701,7 @@ get_frame_size (widthp, heightp)
1697 /* BSD-style. */ 1701 /* BSD-style. */
1698 struct winsize size; 1702 struct winsize size;
1699 1703
1700 if (ioctl (input_fd, TIOCGWINSZ, &size) == -1) 1704 if (ioctl (fileno (TTY_INPUT (tty_out)), TIOCGWINSZ, &size) == -1)
1701 *widthp = *heightp = 0; 1705 *widthp = *heightp = 0;
1702 else 1706 else
1703 { 1707 {
@@ -1711,7 +1715,7 @@ get_frame_size (widthp, heightp)
1711 /* SunOS - style. */ 1715 /* SunOS - style. */
1712 struct ttysize size; 1716 struct ttysize size;
1713 1717
1714 if (ioctl (input_fd, TIOCGSIZE, &size) == -1) 1718 if (ioctl (fileno (TTY_INPUT (tty_out)), TIOCGSIZE, &size) == -1)
1715 *widthp = *heightp = 0; 1719 *widthp = *heightp = 0;
1716 else 1720 else
1717 { 1721 {
@@ -1724,7 +1728,7 @@ get_frame_size (widthp, heightp)
1724 1728
1725 struct sensemode tty; 1729 struct sensemode tty;
1726 1730
1727 SYS$QIOW (0, input_fd, IO$_SENSEMODE, &tty, 0, 0, 1731 SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_SENSEMODE, &tty, 0, 0,
1728 &tty.class, 12, 0, 0, 0, 0); 1732 &tty.class, 12, 0, 0, 0, 0);
1729 *widthp = tty.scr_wid; 1733 *widthp = tty.scr_wid;
1730 *heightp = tty.scr_len; 1734 *heightp = tty.scr_len;
@@ -1794,8 +1798,8 @@ reset_all_sys_modes (void)
1794/* Prepare the terminal for exiting Emacs; move the cursor to the 1798/* Prepare the terminal for exiting Emacs; move the cursor to the
1795 bottom of the frame, turn off interrupt-driven I/O, etc. */ 1799 bottom of the frame, turn off interrupt-driven I/O, etc. */
1796void 1800void
1797reset_sys_modes (otty) 1801reset_sys_modes (tty_out)
1798 struct tty_output *otty; 1802 struct tty_output *tty_out;
1799{ 1803{
1800 struct frame *sf; 1804 struct frame *sf;
1801 1805
@@ -1804,7 +1808,7 @@ reset_sys_modes (otty)
1804 fflush (stdout); 1808 fflush (stdout);
1805 return; 1809 return;
1806 } 1810 }
1807 if (!otty->term_initted) 1811 if (!tty_out->term_initted)
1808 return; 1812 return;
1809#ifdef HAVE_WINDOW_SYSTEM 1813#ifdef HAVE_WINDOW_SYSTEM
1810 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore 1814 /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
@@ -1834,12 +1838,12 @@ reset_sys_modes (otty)
1834 } 1838 }
1835#endif 1839#endif
1836 1840
1837 reset_terminal_modes (otty); 1841 reset_terminal_modes (tty_out);
1838 fflush (stdout); 1842 fflush (TTY_OUTPUT (tty_out));
1839#ifdef BSD_SYSTEM 1843#ifdef BSD_SYSTEM
1840#ifndef BSD4_1 1844#ifndef BSD4_1
1841 /* Avoid possible loss of output when changing terminal modes. */ 1845 /* Avoid possible loss of output when changing terminal modes. */
1842 fsync (fileno (stdout)); 1846 fsync (TTY_OUTPUT (tty_out));
1843#endif 1847#endif
1844#endif 1848#endif
1845 1849
@@ -1849,12 +1853,13 @@ reset_sys_modes (otty)
1849 if (interrupt_input) 1853 if (interrupt_input)
1850 { 1854 {
1851 reset_sigio (); 1855 reset_sigio ();
1852 fcntl (input_fd, F_SETOWN, old_fcntl_owner); 1856 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, old_fcntl_owner);
1853 } 1857 }
1854#endif /* F_SETOWN */ 1858#endif /* F_SETOWN */
1855#endif /* F_SETOWN_BUG */ 1859#endif /* F_SETOWN_BUG */
1856#ifdef O_NDELAY 1860#ifdef O_NDELAY
1857 fcntl (input_fd, F_SETFL, fcntl (input_fd, F_GETFL, 0) & ~O_NDELAY); 1861 fcntl (fileno (TTY_INPUT (tty_out)), F_SETFL,
1862 fcntl (fileno (TTY_INPUT (tty_out)), F_GETFL, 0) & ~O_NDELAY);
1858#endif 1863#endif
1859#endif /* F_SETFL */ 1864#endif /* F_SETFL */
1860#ifdef BSD4_1 1865#ifdef BSD4_1
@@ -1862,8 +1867,9 @@ reset_sys_modes (otty)
1862 reset_sigio (); 1867 reset_sigio ();
1863#endif /* BSD4_1 */ 1868#endif /* BSD4_1 */
1864 1869
1865 if (otty->old_tty_valid) 1870 if (tty_out->old_tty_valid)
1866 while (EMACS_SET_TTY (input_fd, &otty->old_tty, 0) < 0 && errno == EINTR) 1871 while (EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)),
1872 &tty_out->old_tty, 0) < 0 && errno == EINTR)
1867 ; 1873 ;
1868 1874
1869#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ 1875#ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */
@@ -1874,7 +1880,7 @@ reset_sys_modes (otty)
1874 /* Ultrix's termios *ignores* any line discipline except TERMIODISC. 1880 /* Ultrix's termios *ignores* any line discipline except TERMIODISC.
1875 A different old line discipline is therefore not restored, yet. 1881 A different old line discipline is therefore not restored, yet.
1876 Restore the old line discipline by hand. */ 1882 Restore the old line discipline by hand. */
1877 ioctl (0, TIOCSETD, &otty->old_tty.main.c_line); 1883 ioctl (0, TIOCSETD, &tty_out->old_tty.main.c_line);
1878#endif 1884#endif
1879 1885
1880#ifdef AIXHFT 1886#ifdef AIXHFT
@@ -1947,9 +1953,9 @@ init_vms_input ()
1947{ 1953{
1948 int status; 1954 int status;
1949 1955
1950 if (input_fd == 0) 1956 if (fileno (TTY_INPUT (CURTTY())) == 0)
1951 { 1957 {
1952 status = SYS$ASSIGN (&input_dsc, &input_fd, 0, 0); 1958 status = SYS$ASSIGN (&input_dsc, &fileno (TTY_INPUT (CURTTY())), 0, 0);
1953 if (! (status & 1)) 1959 if (! (status & 1))
1954 LIB$STOP (status); 1960 LIB$STOP (status);
1955 } 1961 }
@@ -1960,7 +1966,7 @@ init_vms_input ()
1960void 1966void
1961stop_vms_input () 1967stop_vms_input ()
1962{ 1968{
1963 return SYS$DASSGN (input_fd); 1969 return SYS$DASSGN (fileno (TTY_INPUT (CURTTY())));
1964} 1970}
1965 1971
1966short input_buffer; 1972short input_buffer;
@@ -1976,7 +1982,7 @@ queue_kbd_input ()
1976 1982
1977 waiting_for_ast = 0; 1983 waiting_for_ast = 0;
1978 stop_input = 0; 1984 stop_input = 0;
1979 status = SYS$QIO (0, input_fd, IO$_READVBLK, 1985 status = SYS$QIO (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK,
1980 &input_iosb, kbd_input_ast, 1, 1986 &input_iosb, kbd_input_ast, 1,
1981 &input_buffer, 1, 0, terminator_mask, 0, 0); 1987 &input_buffer, 1, 0, terminator_mask, 0, 0);
1982} 1988}
@@ -2093,7 +2099,7 @@ end_kbd_input ()
2093#endif 2099#endif
2094 if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */ 2100 if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */
2095 { 2101 {
2096 SYS$CANCEL (input_fd); 2102 SYS$CANCEL (fileno (TTY_INPUT (CURTTY())));
2097 return; 2103 return;
2098 } 2104 }
2099 2105
@@ -2102,7 +2108,7 @@ end_kbd_input ()
2102 SYS$CLREF (input_ef); 2108 SYS$CLREF (input_ef);
2103 waiting_for_ast = 1; 2109 waiting_for_ast = 1;
2104 stop_input = 1; 2110 stop_input = 1;
2105 SYS$CANCEL (input_fd); 2111 SYS$CANCEL (fileno (TTY_INPUT (CURTTY())));
2106 SYS$SETAST (1); 2112 SYS$SETAST (1);
2107 SYS$WAITFR (input_ef); 2113 SYS$WAITFR (input_ef);
2108 waiting_for_ast = 0; 2114 waiting_for_ast = 0;