Commit 0b0d3e0b authored by Karoly Lorentey's avatar Karoly Lorentey

Implemented suspending of emacsclient frames.

lib-src/emacsclient.c (quote_file_name): Renamed to quote_argument.
(unquote_argument, handle_sigcont, handle_sigtstp): New functions.
(out, in): New global variables for communicating with the Emacs process.
(init_signals): Set up handlers for SIGCONT, SIGTSTP and SIGTTOU.
(main): Changed out and in to global variables.  Prepend `-eval' or
'-file' to each argument.  Use fsync to force sending the strings to Emacs.
Removed obsolete -bad-version code.  Support the -suspend command.
Cleaned up newline handling.

lisp/frame.el (suspend-frame): New function.
Substitute key definition of suspend-emacs with suspend-frame.

lisp/server.el (server-log): Cosmetic change in log format.
(server-handle-delete-tty, server-handle-delete-frame): Added logging.
(server-handle-suspend-tty, server-quote-arg): New functions.
(server-start): Install server-handle-suspend-tty.
(server-process-filter): Reorganized source code for clarity.
Implemented -resume, -suspend and -ignore commands.

lisp/term/x-win.el (x-initialize-window-system): Don't change the
binding of C-z.

src/cm.c: Replaced TTY_INPUT, TTY_OUTPUT, TTY_TERMSCRIPT calls with
their macro expansion.
src/dispnew.c: Ditto.
src/frame.c: Ditto.
src/keyboard.c: Ditto.
src/sysdep.c: Ditto.

src/keyboard.c (tty_read_avail_input): Don't read if the terminal is
suspended.
src/sysdep.c (discard_tty_input, init_sys_modes, reset_sys_modes): Ditto.
src/term.c (tty_set_terminal_modes, tty_reset_terminal_modes): Ditto.

src/term.c (Vsuspend_tty_functions, Vresume_tty_functions): New hooks.
(syms_of_term): Defvar them.
(term_init): Don't allow opening a new frame on a suspended tty device.
(Fsuspend_tty, Fresume_tty): New functions.
(syms_of_term): Defsubr them.

src/termchar.c (struct tty_display_info): Update documentation of
input and output.
(TTY_INPUT, TTY_OUTPUT, TTY_TERMSCRIPT): Removed.


git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-105
parent 2fc0cf2a
......@@ -200,22 +200,50 @@ THINGS TO DO
argument-handling is done in Lisp, so this should be quite easy to
implement.
** Very strange bug: visible-bell does not work on secondary
terminals. This might be something xterm (konsole) specific.
** Make `struct display' accessible to Lisp programs. Accessor functions:
** Find out the best way to support suspending Emacs with multiple
ttys. My guess: disable it on the controlling tty, but from other
ttys pass it on to emacsclient somehow. (It is (I hope) trivial to
extend emacsclient to handle suspend/resume. A `kill -STOP' almost
works right now.)
(displayp OBJECT): Returns t if OBJECT is a display.
** Clean up the frame-local variable system. I think it's ugly and
error-prone. But maybe I just haven't yet fully understood it.
(selected-display): Returns the display object of the selected frame.
(frame-display FRAME): Returns the display object of FRAME.
(display-frames DISPLAY): Returns a list of frames on DISPLAY.
(display-type DISPLAY): Returns the type of DISPLAY, as a
symbol. (See `framep'.)
(display-device DISPLAY): Returns the name of the device that
DISPLAY uses, as a string. (E.g: "/dev/pts/16", or
":0.0")
See next issue why this is necessary.
** The following needs to be supported:
$ emacsclient -t
C-z
$ bg
$ emacsclient -t
(This fails now.)
The cleanest way to solve this is to allow multiple displays on the
same terminal device; each new emacsclient process should create
its own display. As displays are currently identified by their
device names, this is not possible until struct display becomes
accessible as a Lisp-level object.
** Add an elaborate mechanism for display-local variables. (There are
already a few of these; search for `terminal-local' in the Elisp
manual.)
** Very strange bug: visible-bell does not work on secondary
terminals in xterm and konsole. The screen does flicker a bit,
but it's so quick it isn't noticable.
** Clean up the frame-local variable system. I think it's ugly and
error-prone. But maybe I just haven't yet fully understood it.
** Move baud_rate to struct display.
** Implement support for starting an interactive Emacs session without
......@@ -667,4 +695,15 @@ DIARY OF CHANGES
complaints seem to be caused by bugs in term.el; they are not
related to multi-tty.)
-- Find out the best way to support suspending Emacs with multiple
ttys. My guess: disable it on the controlling tty, but from other
ttys pass it on to emacsclient somehow. (It is (I hope) trivial to
extend emacsclient to handle suspend/resume. A `kill -STOP' almost
works right now.)
(Done. I needed to play with signal handling and the server
protocol a bit to make emacsclient behave as a normal UNIX program
wrt foreground/background process groups.)
;;; arch-tag: 8da1619e-2e79-41a8-9ac9-a0485daad17d
This diff is collapsed.
......@@ -750,6 +750,22 @@ Otherwise, that variable should be nil."
(iconify-frame)
(make-frame-visible)))
(defun suspend-frame ()
"Do whatever is right to suspend the current frame.
Calls `suspend-emacs' if invoked from the controlling terminal,
`suspend-tty' from a secondary terminal, and
`iconify-or-deiconify-frame' from an X frame."
(interactive)
(let ((type (framep (selected-frame))))
(cond
((eq type 'x) (iconify-or-deiconify-frame))
((eq type t)
(if (frame-tty-name)
(suspend-tty)
(suspend-emacs)))
(t (suspend-emacs)))))
(defun make-frame-names-alist ()
(let* ((current-frame (selected-frame))
(falist
......@@ -1374,6 +1390,8 @@ Use Custom to set this variable to get the display updated."
(define-key ctl-x-5-map "0" 'delete-frame)
(define-key ctl-x-5-map "o" 'other-frame)
(substitute-key-definition 'suspend-emacs 'suspend-frame global-map)
(provide 'frame)
;;; arch-tag: 82979c70-b8f2-4306-b2ad-ddbd6b328b56
......
This diff is collapsed.
......@@ -2442,11 +2442,7 @@ order until succeed.")
(if res-selection-timeout
(setq x-selection-timeout (string-to-number res-selection-timeout))))
;; XXX This is wrong in general with multi-tty support.
(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
global-map)
;; XXX This is wrong in general with multi-tty support.
;; Don't let Emacs suspend under X.
(add-hook 'suspend-hook 'x-win-suspend-error)
;; Arrange for the kill and yank functions to set and check the clipboard.
......
......@@ -64,9 +64,9 @@ int
cmputc (c)
char c;
{
if (TTY_TERMSCRIPT (current_tty))
putc (c & 0177, TTY_TERMSCRIPT (current_tty));
putc (c & 0177, TTY_OUTPUT (current_tty));
if (current_tty->termscript)
putc (c & 0177, current_tty->termscript);
putc (c & 0177, current_tty->output);
return c;
}
......@@ -136,12 +136,12 @@ cmcheckmagic (struct tty_display_info *tty)
{
if (!MagicWrap (tty) || curY (tty) >= FrameRows (tty) - 1)
abort ();
if (TTY_TERMSCRIPT (tty))
putc ('\r', TTY_TERMSCRIPT (tty));
putc ('\r', TTY_OUTPUT (tty));
if (TTY_TERMSCRIPT (tty))
putc ('\n', TTY_TERMSCRIPT (tty));
putc ('\n', TTY_OUTPUT (tty));
if (tty->termscript)
putc ('\r', tty->termscript);
putc ('\r', tty->output);
if (tty->termscript)
putc ('\n', tty->termscript);
putc ('\n', tty->output);
curX (tty) = 0;
curY (tty)++;
}
......
......@@ -3316,7 +3316,7 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
clear_current_matrices (f);
update_end (f);
if (FRAME_TERMCAP_P (f))
fflush (TTY_OUTPUT (FRAME_TTY (f)));
fflush (FRAME_TTY (f)->output);
windows_or_buffers_changed++;
/* Mark all windows as inaccurate, so that every window will have
its redisplay done. */
......@@ -3659,7 +3659,7 @@ direct_output_for_insert (g)
update_end (f);
updated_row = NULL;
if (FRAME_TERMCAP_P (f))
fflush (TTY_OUTPUT (FRAME_TTY (f)));
fflush (FRAME_TTY (f)->output);
TRACE ((stderr, "direct output for insert\n"));
mark_window_display_accurate (it.window, 1);
......@@ -3751,7 +3751,7 @@ direct_output_forward_char (n)
}
if (FRAME_TERMCAP_P (f))
fflush (TTY_OUTPUT (FRAME_TTY (f)));
fflush (FRAME_TTY (f)->output);
redisplay_performed_directly_p = 1;
return 1;
}
......@@ -3849,9 +3849,9 @@ update_frame (f, force_p, inhibit_hairy_id_p)
if (FRAME_TERMCAP_P (f))
{
if (TTY_TERMSCRIPT (FRAME_TTY (f)))
fflush (TTY_TERMSCRIPT (FRAME_TTY (f)));
fflush (TTY_OUTPUT (FRAME_TTY (f)));
if (FRAME_TTY (f)->termscript)
fflush (FRAME_TTY (f)->termscript);
fflush (FRAME_TTY (f)->output);
}
/* Check window matrices for lost pointers. */
......@@ -5133,18 +5133,18 @@ update_frame_1 (f, force_p, inhibit_id_p)
Also flush out if likely to have more than 1k buffered
otherwise. I'm told that some telnet connections get
really screwed by more than 1k output at once. */
int outq = PENDING_OUTPUT_COUNT (TTY_OUTPUT (FRAME_TTY (f)));
int outq = PENDING_OUTPUT_COUNT (FRAME_TTY (f)->output);
if (outq > 900
|| (outq > 20 && ((i - 1) % preempt_count == 0)))
{
fflush (TTY_OUTPUT (FRAME_TTY (f)));
fflush (FRAME_TTY (f)->output);
if (preempt_count == 1)
{
#ifdef EMACS_OUTQSIZE
if (EMACS_OUTQSIZE (0, &outq) < 0)
/* Probably not a tty. Ignore the error and reset
the outq count. */
outq = PENDING_OUTPUT_COUNT (TTY_OUTPUT (FRAME_TTY (f)));
outq = PENDING_OUTPUT_COUNT (FRAME_TTY (f->output));
#endif
outq *= 10;
if (baud_rate <= outq && baud_rate > 0)
......@@ -5999,7 +5999,7 @@ window_change_signal (signalnum) /* If we don't have an argument, */
if (! tty->term_initted)
continue;
get_tty_size (fileno (TTY_INPUT (tty)), &width, &height);
get_tty_size (fileno (tty->input), &width, &height);
{
Lisp_Object tail, frame;
......@@ -6211,15 +6211,22 @@ FILE = nil means just close any termscript file currently open. */)
(file)
Lisp_Object file;
{
if (TTY_TERMSCRIPT (CURTTY ()) != 0)
fclose (TTY_TERMSCRIPT (CURTTY ()));
TTY_TERMSCRIPT (CURTTY ()) = 0;
struct tty_display_info *tty;
if (! FRAME_TERMCAP_P (SELECTED_FRAME ()))
error ("Current frame is not on a tty device");
tty = CURTTY ();
if (tty->termscript != 0)
fclose (tty->termscript);
tty->termscript = 0;
if (! NILP (file))
{
file = Fexpand_file_name (file, Qnil);
TTY_TERMSCRIPT (CURTTY ()) = fopen (SDATA (file), "w");
if (TTY_TERMSCRIPT (CURTTY ()) == 0)
tty->termscript = fopen (SDATA (file), "w");
if (tty->termscript == 0)
report_file_error ("Opening termscript", Fcons (file, Qnil));
}
return Qnil;
......@@ -6233,20 +6240,23 @@ Control characters in STRING will have terminal-dependent effects. */)
(string)
Lisp_Object string;
{
struct tty_display_info *tty;
/* ??? Perhaps we should do something special for multibyte strings here. */
CHECK_STRING (string);
if (! FRAME_TERMCAP_P (SELECTED_FRAME ()))
error ("Current frame is not on a tty device");
tty = CURTTY ();
if (TTY_TERMSCRIPT (CURTTY ()))
if (tty->termscript)
{
fwrite (SDATA (string), 1, SBYTES (string),
TTY_TERMSCRIPT (CURTTY ()));
fflush (TTY_TERMSCRIPT (CURTTY ()));
fwrite (SDATA (string), 1, SBYTES (string), tty->termscript);
fflush (tty->termscript);
}
fwrite (SDATA (string), 1, SBYTES (string),
TTY_OUTPUT (CURTTY ()));
fflush (TTY_OUTPUT (CURTTY ()));
fwrite (SDATA (string), 1, SBYTES (string), tty->output);
fflush (tty->output);
return Qnil;
}
......@@ -6265,7 +6275,7 @@ terminate any keyboard macro currently executing. */)
else
ring_bell ();
if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
fflush (TTY_OUTPUT (CURTTY ()));
fflush (CURTTY ()->output);
}
else
bitch_at_user ();
......@@ -6283,7 +6293,7 @@ bitch_at_user ()
else
ring_bell ();
if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
fflush (TTY_OUTPUT (CURTTY ()));
fflush (CURTTY ()->output);
}
......
......@@ -667,7 +667,8 @@ and the `tty-type' parameter specifies the terminal type. Example:
(make-terminal-frame '((tty . "/dev/pts/5") (tty-type . "xterm")))
Note that changing the size of one terminal frame automatically affects all. */)
Note that changing the size of one terminal frame automatically
affects all frames on the same terminal device. */)
(parms)
Lisp_Object parms;
{
......@@ -742,7 +743,7 @@ Note that changing the size of one terminal frame automatically affects all. */
{
int width, height;
get_tty_size (fileno (TTY_INPUT (FRAME_TTY (f))), &width, &height);
get_tty_size (fileno (FRAME_TTY (f)->input), &width, &height);
change_frame_size (f, height, width, 0, 0, 0);
}
......
......@@ -6704,10 +6704,13 @@ tty_read_avail_input (struct display *display,
if (! tty->term_initted) /* In case we get called during bootstrap. */
return 0;
if (! tty->input)
return 0; /* The terminal is suspended. */
/* Determine how many characters we should *try* to read. */
#ifdef FIONREAD
/* Find out how much input is available. */
if (ioctl (fileno (TTY_INPUT (tty)), FIONREAD, &n_to_read) < 0)
if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
{
if (! noninteractive)
return -2; /* Close this display. */
......@@ -6722,7 +6725,7 @@ tty_read_avail_input (struct display *display,
#if defined (USG) || defined (DGUX) || defined(CYGWIN)
/* Read some input if available, but don't wait. */
n_to_read = sizeof cbuf;
fcntl (fileno (TTY_INPUT (tty)), F_SETFL, O_NDELAY);
fcntl (fileno (tty->input), F_SETFL, O_NDELAY);
#else
you lose;
#endif
......@@ -6732,7 +6735,7 @@ tty_read_avail_input (struct display *display,
NREAD is set to the number of chars read. */
do
{
nread = emacs_read (fileno (TTY_INPUT (tty)), cbuf, n_to_read);
nread = emacs_read (fileno (tty->input), cbuf, n_to_read);
/* POSIX infers that processes which are not in the session leader's
process group won't get SIGHUP's at logout time. BSDI adheres to
this part standard and returns -1 from read (0) with errno==EIO
......@@ -6770,7 +6773,7 @@ tty_read_avail_input (struct display *display,
#ifndef FIONREAD
#if defined (USG) || defined (DGUX) || defined (CYGWIN)
fcntl (fileno (TTY_INPUT (tty)), F_SETFL, 0);
fcntl (fileno (tty->input), F_SETFL, 0);
#endif /* USG or DGUX or CYGWIN */
#endif /* no FIONREAD */
......@@ -10168,7 +10171,7 @@ On such systems, Emacs starts a subshell instead of suspending. */)
call1 (Vrun_hooks, intern ("suspend-hook"));
GCPRO1 (stuffstring);
get_tty_size (fileno (TTY_INPUT (CURTTY ())), &old_width, &old_height);
get_tty_size (fileno (CURTTY ()->input), &old_width, &old_height);
reset_all_sys_modes ();
/* sys_suspend can get an error if it tries to fork a subshell
and the system resources aren't available for that. */
......@@ -10184,7 +10187,7 @@ On such systems, Emacs starts a subshell instead of suspending. */)
/* Check if terminal/window size has changed.
Note that this is not useful when we are running directly
with a window system; but suspend should be disabled in that case. */
get_tty_size (fileno (TTY_INPUT (CURTTY ())), &width, &height);
get_tty_size (fileno (CURTTY ()->input), &width, &height);
if (width != old_width || height != old_height)
change_frame_size (SELECTED_FRAME (), height, width, 0, 0, 0);
......
......@@ -274,7 +274,7 @@ discard_tty_input ()
#ifdef VMS
end_kbd_input ();
SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0,
SYS$QIOW (0, fileno (CURTTY()->input), IO$_READVBLK|IO$M_PURGE, input_iosb, 0, 0,
&buf.main, 0, 0, terminator_mask, 0, 0);
queue_kbd_input ();
#else /* not VMS */
......@@ -284,7 +284,8 @@ discard_tty_input ()
for (tty = tty_list; tty; tty = tty->next)
{
int zero = 0;
ioctl (fileno (TTY_INPUT (tty)), TIOCFLUSH, &zero);
if (tty->input)
ioctl (fileno (tty->input), TIOCFLUSH, &zero);
}
}
#else /* not Apollo */
......@@ -296,8 +297,11 @@ discard_tty_input ()
struct tty_display_info *tty;
for (tty = tty_list; tty; tty = tty->next)
{
EMACS_GET_TTY (fileno (TTY_INPUT (tty)), &buf);
EMACS_SET_TTY (fileno (TTY_INPUT (tty)), &buf, 0);
if (tty->input) /* Is the device suspended? */
{
EMACS_GET_TTY (fileno (tty->input), &buf);
EMACS_SET_TTY (fileno (tty->input), &buf, 0);
}
}
}
#endif /* not MSDOS */
......@@ -322,7 +326,7 @@ stuff_char (char c)
/* Should perhaps error if in batch mode */
#ifdef TIOCSTI
ioctl (fileno (TTY_INPUT (CURTTY())), TIOCSTI, &c);
ioctl (fileno (CURTTY()->input), TIOCSTI, &c);
#else /* no TIOCSTI */
error ("Cannot stuff terminal input characters in this version of Unix");
#endif /* no TIOCSTI */
......@@ -1005,7 +1009,7 @@ request_sigio ()
return;
/* XXX CURTTY() is bogus here. */
ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &on);
ioctl (fileno (CURTTY ()->input), FIOASYNC, &on);
interrupts_deferred = 0;
}
......@@ -1018,7 +1022,7 @@ unrequest_sigio ()
return;
/* XXX CURTTY() is bogus here. */
ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &off);
ioctl (fileno (CURTTY ()->input), FIOASYNC, &off);
interrupts_deferred = 1;
}
......@@ -1366,6 +1370,9 @@ nil means don't delete them until `list-processes' is run. */);
if (noninteractive)
return;
if (!tty_out->output)
return; /* The tty is suspended. */
#ifdef VMS
if (!input_ef)
input_ef = get_kbd_event_flag ();
......@@ -1404,13 +1411,13 @@ nil means don't delete them until `list-processes' is run. */);
unconditionally will not cause any problems. */
if (! read_socket_hook && EQ (Vinitial_window_system, Qnil))
#endif
narrow_foreground_group (fileno (TTY_INPUT (tty_out)));
narrow_foreground_group (fileno (tty_out->input));
#endif
if (! tty_out->old_tty)
tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
EMACS_GET_TTY (fileno (TTY_INPUT (tty_out)), tty_out->old_tty);
EMACS_GET_TTY (fileno (tty_out->input), tty_out->old_tty);
tty = *tty_out->old_tty;
......@@ -1626,23 +1633,23 @@ nil means don't delete them until `list-processes' is run. */);
dos_ttraw ();
#endif
EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)), &tty, 0);
EMACS_SET_TTY (fileno (tty_out->input), &tty, 0);
/* This code added to insure that, if flow-control is not to be used,
we have an unlocked terminal at the start. */
#ifdef TCXONC
if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TCXONC, 1);
if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TCXONC, 1);
#endif
#ifndef APOLLO
#ifdef TIOCSTART
if (!tty_out->flow_control) ioctl (fileno (TTY_INPUT (tty_out)), TIOCSTART, 0);
if (!tty_out->flow_control) ioctl (fileno (tty_out->input), TIOCSTART, 0);
#endif
#endif
#if defined (HAVE_TERMIOS) || defined (HPUX9)
#ifdef TCOON
if (!tty_out->flow_control) tcflow (fileno (TTY_INPUT (tty_out)), TCOON);
if (!tty_out->flow_control) tcflow (fileno (tty_out->input), TCOON);
#endif
#endif
......@@ -1662,7 +1669,7 @@ nil means don't delete them until `list-processes' is run. */);
#ifdef VMS
/* Appears to do nothing when in PASTHRU mode.
SYS$QIOW (0, fileno (TTY_INPUT (tty_out)), IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0,
SYS$QIOW (0, fileno (tty_out->input), IO$_SETMODE|IO$M_OUTBAND, 0, 0, 0,
interrupt_signal, oob_chars, 0, 0, 0, 0);
*/
queue_kbd_input (0);
......@@ -1673,10 +1680,10 @@ nil means don't delete them until `list-processes' is run. */);
#ifdef F_GETOWN /* F_SETFL does not imply existence of F_GETOWN */
if (interrupt_input)
{
old_fcntl_owner[fileno (TTY_INPUT (tty_out))] =
fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0);
fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, getpid ());
init_sigio (fileno (TTY_INPUT (tty_out)));
old_fcntl_owner[fileno (tty_out->input)] =
fcntl (fileno (tty_out->input), F_GETOWN, 0);
fcntl (fileno (tty_out->input), F_SETOWN, getpid ());
init_sigio (fileno (tty_out->input));
}
#endif /* F_GETOWN */
#endif /* F_SETOWN_BUG */
......@@ -1684,7 +1691,7 @@ nil means don't delete them until `list-processes' is run. */);
#ifdef BSD4_1
if (interrupt_input)
init_sigio (fileno (TTY_INPUT (tty_out)));
init_sigio (fileno (tty_out->input));
#endif
#ifdef VMS /* VMS sometimes has this symbol but lacks setvbuf. */
......@@ -1694,9 +1701,9 @@ nil means don't delete them until `list-processes' is run. */);
/* This symbol is defined on recent USG systems.
Someone says without this call USG won't really buffer the file
even with a call to setbuf. */
setvbuf (TTY_OUTPUT (tty_out), (char *) _sobuf, _IOFBF, sizeof _sobuf);
setvbuf (tty_out->output, (char *) _sobuf, _IOFBF, sizeof _sobuf);
#else
setbuf (TTY_OUTPUT (tty_out), (char *) _sobuf);
setbuf (tty_out->output, (char *) _sobuf);
#endif
tty_set_terminal_modes (tty_out->display);
......@@ -1867,10 +1874,13 @@ reset_sys_modes (tty_out)
if (!tty_out->term_initted)
return;
if (!tty_out->output)
return; /* The tty is suspended. */
/* Go to and clear the last line of the terminal. */
cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
/* Code adapted from tty_clear_end_of_line. */
if (tty_out->TS_clr_line)
{
......@@ -1880,13 +1890,13 @@ reset_sys_modes (tty_out)
{ /* have to do it the hard way */
int i;
turn_off_insert (tty_out);
for (i = curX (tty_out); i < FrameCols (tty_out) - 1; i++)
{
fputc (' ', TTY_OUTPUT (tty_out));
}
{
fputc (' ', tty_out->output);
}
}
cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
fflush (tty_out->output);
......@@ -1902,11 +1912,11 @@ reset_sys_modes (tty_out)
#endif
tty_reset_terminal_modes (tty_out->display);
fflush (TTY_OUTPUT (tty_out));
fflush (tty_out->output);
#ifdef BSD_SYSTEM
#ifndef BSD4_1
/* Avoid possible loss of output when changing terminal modes. */
fsync (fileno (TTY_OUTPUT (tty_out)));
fsync (fileno (tty_out->output));
#endif
#endif
......@@ -1915,24 +1925,24 @@ reset_sys_modes (tty_out)
#ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */
if (interrupt_input)
{
reset_sigio (fileno (TTY_INPUT (tty_out)));
fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN,
old_fcntl_owner[fileno (TTY_INPUT (tty_out))]);
reset_sigio (fileno (tty_out->input));
fcntl (fileno (tty_out->input), F_SETOWN,
old_fcntl_owner[fileno (tty_out->input)]);
}
#endif /* F_SETOWN */
#endif /* F_SETOWN_BUG */
#ifdef O_NDELAY
fcntl (fileno (TTY_INPUT (tty_out)), F_SETFL,
fcntl (fileno (TTY_INPUT (tty_out)), F_GETFL, 0) & ~O_NDELAY);
fcntl (fileno (tty_out->input), F_SETFL,
fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NDELAY);
#endif
#endif /* F_SETFL */
#ifdef BSD4_1
if (interrupt_input)
reset_sigio (fileno (TTY_INPUT (tty_out)));
reset_sigio (fileno (tty_out->input));
#endif /* BSD4_1 */
if (tty_out->old_tty)
while (EMACS_SET_TTY (fileno (TTY_INPUT (tty_out)),
while (EMACS_SET_TTY (fileno (tty_out->input),
tty_out->old_tty, 0) < 0 && errno == EINTR)
;
......@@ -1952,7 +1962,7 @@ reset_sys_modes (tty_out)
#endif
#ifdef BSD_PGRPS
widen_foreground_group (fileno (TTY_INPUT (tty_out)));
widen_foreground_group (fileno (tty_out->input));
#endif
}
......@@ -2017,9 +2027,9 @@ init_vms_input ()
{
int status;
if (fileno (TTY_INPUT (CURTTY())) == 0)
if (fileno (CURTTY ()->input)) == 0)
{
status = SYS$ASSIGN (&input_dsc, &fileno (TTY_INPUT (CURTTY())), 0, 0);
status = SYS$ASSIGN (&input_dsc, &fileno (CURTTY ()->input)), 0, 0);
if (! (status & 1))
LIB$STOP (status);
}
......@@ -2030,7 +2040,7 @@ init_vms_input ()
void
stop_vms_input ()
{
return SYS$DASSGN (fileno (TTY_INPUT (CURTTY())));
return SYS$DASSGN (fileno (CURTTY ()->input)));
}
short input_buffer;
......@@ -2046,7 +2056,7 @@ queue_kbd_input ()
waiting_for_ast = 0;
stop_input = 0;
status = SYS$QIO (0, fileno (TTY_INPUT (CURTTY())), IO$_READVBLK,
status = SYS$QIO (0, fileno (CURTTY()->input), IO$_READVBLK,
&input_iosb, kbd_input_ast, 1,
&input_buffer, 1, 0, terminator_mask, 0, 0);
}
......@@ -2163,7 +2173,7 @@ end_kbd_input ()
#endif
if (LIB$AST_IN_PROG ()) /* Don't wait if suspending from kbd_buffer_store_event! */
{
SYS$CANCEL (fileno (TTY_INPUT (CURTTY())));
SYS$CANCEL (fileno (CURTTY()->input));
return;
}
......@@ -2172,7 +2182,7 @@ end_kbd_input ()
SYS$CLREF (input_ef);
waiting_for_ast = 1;
stop_input = 1;
SYS$CANCEL (fileno (TTY_INPUT (CURTTY())));
SYS$CANCEL (fileno (CURTTY()->input));
SYS$SETAST (1);
SYS$WAITFR (input_ef);
waiting_for_ast = 0;
......
This diff is collapsed.
......@@ -42,8 +42,10 @@ struct tty_display_info
/* Input/output */
FILE *input; /* The stream to be used for terminal input. */
FILE *output; /* The stream to be used for terminal output. */
FILE *input; /* The stream to be used for terminal input.
NULL if the terminal is suspended. */
FILE *output; /* The stream to be used for terminal output.
NULL if the terminal is suspended. */
FILE *termscript; /* If nonzero, send all terminal output
characters to this stream also. */
......@@ -200,9 +202,5 @@ extern struct tty_display_info *tty_list;
#define CURTTY() FRAME_TTY (SELECTED_FRAME())
#define TTY_INPUT(t) ((t)->input)