Commit fca177d4 authored by Karoly Lorentey's avatar Karoly Lorentey
Browse files

Fully eliminated global tty state variables.

lib-src/emacsclient.c (main.c): Fix error message.

lisp/frame.el (make-frame-on-tty): New function.

lisp/server.el (server-process-filter): Notify emacsclient if there
was on error during evaluation.

src/cm.c: Fix remaining cases of direct Wcm references.

src/dispextern.h: Updated prototypes.

src/dispnew.c (Fredraw_frame): Fix set_terminal_modes call.
(init_display): Remove reference to meta_key.

src/frame.c (make_terminal_frame): Renamed first parameter to
tty_name.  Call term_init before creating the frame.
(Fmake_terminal_frame): Look up the `tty' and `tty-type' frame
parameters from the currently selected terminal before the global
default.
(Fdelete_frame): Make sure that the new selected frame is live.

src/keyboard.c (meta_key): Moved to struct tty_output.
(read_avail_input): Fix C syntax.  Update references to meta_key.
(Fsuspend_emacs): pass current tty to init_sys_modes via
record_unwind_protect.
(Fset_input_mode): Update references to meta_key.
(Fcurrent_input_mode): Ditto.

src/sysdep.c (init_sys_modes): Updated old_tty and meta_key
references.  Don't call set_terminal_modes, it needs termcap strings.
(reset_sys_modes): Call tty_reset_terminal_modes instead of
reset_terminal_modes.  Updated old_tty references.

src/term.c: Massive updates throuout the file.
(TS_*, TN_*): Moved to struct tty_output.
(RPov, delete_in_insert_mode se_is_so, costs_set, insert_mode): Ditto.
(standout_mode, specified_window, tty_cursor_hidden): Ditto.
(tty_set_terminal_modes, tty_reset_terminal_modes): New functions.
(turn_on_insert, turn_off_insert): Added tty parameter.
(turn_on_highlight, turn_off_highlight, toggle_highlight): Added tty parameter.
(tty_hide_cursor, tty_show_cursor): Ditto.
(background_highlight, highlight_if_desired): Ditto.
(tty_capable_p): Changed first parameter to tty_output.
(term_init): Make sure top_frame is initialized.  Don't exit on errors
if this would have been a secondary terminal.  Call set_terminal_modes
on the end.
(delete_tty): New function.
(delete_tty_1): New function.
(print_all_frames): New function, marginally useful for debugging.

src/termchar.h (struct tty_output): Changed old_tty to be a pointer.
Removed old_tty_valid member.  Added tty-specific variables from term.c.

src/xfaces.c (Ftty_supports_face_attributes_p): Update for new
tty_capable_p.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-9
parent 6548cf00
...@@ -27,8 +27,8 @@ STATUS ...@@ -27,8 +27,8 @@ STATUS
Basic support is there; there are some rough edges, but it already Basic support is there; there are some rough edges, but it already
seems to be usable. Input is read from all terminals (NOT via seems to be usable. Input is read from all terminals (NOT via
MULTIKBOARD!). At the moment, the type of the new terminals must be MULTIKBOARD!). At the moment, the type of the new terminals must be
the same as the initial terminal. Emacsclient was extended to support the same as the initial terminal. Emacsclient has been extended to
opening a new terminal frame. support opening a new terminal frame.
To try it out, start up the emacs server (M-x server-start), and then To try it out, start up the emacs server (M-x server-start), and then
(from a shell prompt on another terminal) start emacsclient with (from a shell prompt on another terminal) start emacsclient with
...@@ -147,38 +147,68 @@ DIARY OF CHANGES ...@@ -147,38 +147,68 @@ DIARY OF CHANGES
(Done, emacsclient signals Emacs after writing to the proxy pseudo (Done, emacsclient signals Emacs after writing to the proxy pseudo
terminal. This means that multi-tty does not work with raw ttys!) terminal. This means that multi-tty does not work with raw ttys!)
THINGS TO DO
------------
** Implement sane error handling after initialization. (Currently -- Make make-terminal-frame look up the `tty' and `tty-type' frame
parameters from the currently selected terminal before the global
default.
(Done.)
-- Put all cached terminal escape sequences into struct tty_output.
Currently, they are still stored in global variables, so we don't
really support multiple terminal types.
(Done.)
-- Implement sane error handling after initialization. (Currently
emacs exits if you specify a bad terminal type.) The helpful error emacs exits if you specify a bad terminal type.) The helpful error
messages must still be provided when Emacs starts. messages must still be provided when Emacs starts.
** C-g should work on secondary terminals. (Done.)
-- Implement terminal deletion, i.e., deleting local frames, closing
the tty device and restoring its previous state without exiting
Emacs.
** Make make-terminal-frame look up the tty and tty-type parameters (Done, but at the moment only called when an error happens during
from the currently selected terminal before the global default. initialization. There is a memory corruption error around this
somewhere.)
THINGS TO DO
------------
** Fix mysterious memory corruption error with tty deletion. To
trigger it, try the following shell command:
while true; do TERM=no-such-terminal-definition emacsclient -h; done
Emacs usually dumps core after a few dozen iterations. (The bug
seems to be related to the xfree()ing or bzero()ing of
tty_output.Wcm. Maybe there are outside references to struct Wcm?
Sounds logical, otherwise these vars would not have been collected
into a struct. But where?)
This does not seem to happen if the error occurs before terminal
initialization or if I comment out all xfree()s in delete_frame.
Update: yes it does, although it is much rarer.
** C-g should work on secondary terminals.
** Move optimalization parameters (costs) from union output_data to ** Move optimalization parameters (costs) from union output_data to
a backend-neutral per-device structure. a backend-neutral per-device structure.
** Implement terminal deletion, i.e., deleting local frames, closing
the tty device and restoring its previous state without exiting
Emacs. This should be exported to the Lisp environment.
** Implement automatic deletion of terminals when the last frame on ** Implement automatic deletion of terminals when the last frame on
that terminal is closed. that terminal is closed.
** Put all cached terminal escape sequences into struct tty_output.
Currently, they are still stored in global variables, so we don't
really support multiple terminal types.
** Make parts of struct tty_output accessible from Lisp. The device ** Make parts of struct tty_output accessible from Lisp. The device
name and the type is sufficient. name and the type is sufficient.
** Export delete_tty to the Lisp environment.
** Implement support for starting an interactive Emacs session without ** Implement support for starting an interactive Emacs session without
an initial frame. (The user would connect to it and open frames an initial frame. (The user would connect to it and open frames
later, with emacsclient.) Not necessary a good idea. later, with emacsclient.) Not necessarily a good idea.
** Support raw secondary terminals. (This one is tricky, SIGIO works ** Support raw secondary terminals. (This one is tricky, SIGIO works
only on the controlling terminal.) only on the controlling terminal.)
......
...@@ -1095,7 +1095,7 @@ To start the server in Emacs, type \"M-x server-start\".\n", ...@@ -1095,7 +1095,7 @@ To start the server in Emacs, type \"M-x server-start\".\n",
if (emacs_pid == 0) if (emacs_pid == 0)
{ {
reset_tty (); reset_tty ();
fprintf (stderr, "%s: Could not get process id of Emacs\n", argv[0]); fprintf (stderr, "%s: %s\n", argv[0], str);
fail (argc, argv); fail (argc, argv);
} }
......
...@@ -558,6 +558,24 @@ The optional second argument PARAMETERS specifies additional frame parameters." ...@@ -558,6 +558,24 @@ The optional second argument PARAMETERS specifies additional frame parameters."
(error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN")) (error "Invalid display, not HOST:SERVER or HOST:SERVER.SCREEN"))
(make-frame (cons (cons 'display display) parameters))) (make-frame (cons (cons 'display display) parameters)))
;;;###autoload
(defun make-frame-on-tty (device type &optional parameters)
"Make a frame on terminal DEVICE which is of type TYPE (e.g., \"xterm\").
The optional third argument PARAMETERS specifies additional frame parameters.
DEVICE must be a proxy psudo terminal created by emacsclient,
otherwise there will be problems with terminal input and window
resizes. (The kernel notifies processes about pending input or
terminal resizes only on the controlling terminal, so we need
emacsclient to sit on the real terminal device, create SIGIO
signals upon terminal input, and forward SIGWINCH signals to
us.)"
(unless device
(error "Invalid terminal device"))
(unless type
(error "Invalid terminal type"))
(make-frame `((tty . ,device) (tty-type . ,type) . ,parameters)))
(defun make-frame-command () (defun make-frame-command ()
"Make a new frame, and select it if the terminal displays only one frame." "Make a new frame, and select it if the terminal displays only one frame."
(interactive) (interactive)
......
...@@ -345,12 +345,15 @@ PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"." ...@@ -345,12 +345,15 @@ PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"."
(if coding-system (if coding-system
(setq arg (decode-coding-string arg coding-system))) (setq arg (decode-coding-string arg coding-system)))
(if eval (if eval
(let ((v (eval (car (read-from-string arg))))) (condition-case err
(when v (let ((v (eval (car (read-from-string arg)))))
(with-temp-buffer (when v
(let ((standard-output (current-buffer))) (with-temp-buffer
(pp v) (let ((standard-output (current-buffer)))
(process-send-region proc (point-min) (point-max)))))) (pp v)
(process-send-region proc (point-min) (point-max))))))
(error (process-send-string proc (concat "*Error* " (error-message-string err)))))
;; ARG is a file name. ;; ARG is a file name.
;; Collapse multiple slashes to single slashes. ;; Collapse multiple slashes to single slashes.
(setq arg (command-line-normalize-file-name arg)) (setq arg (command-line-normalize-file-name arg))
......
...@@ -83,9 +83,9 @@ cmputc (c) ...@@ -83,9 +83,9 @@ cmputc (c)
*/ */
static static
at (row, col) { at (tty, row, col) {
curY = row; curY (tty) = row;
curX = col; curX (tty) = col;
} }
/* /*
...@@ -93,8 +93,8 @@ at (row, col) { ...@@ -93,8 +93,8 @@ at (row, col) {
*/ */
static static
addcol (n) { addcol (tty, n) {
curX += n; curX (tty) += n;
/* /*
* If cursor hit edge of screen, what happened? * If cursor hit edge of screen, what happened?
...@@ -104,21 +104,21 @@ addcol (n) { ...@@ -104,21 +104,21 @@ addcol (n) {
* of the last line. * of the last line.
*/ */
if (curX == Wcm.cm_cols) { if (curX (tty) == tty->Wcm->cm_cols) {
/* /*
* Well, if magicwrap, still there, past the edge of the * Well, if magicwrap, still there, past the edge of the
* screen (!). If autowrap, on the col 0 of the next line. * screen (!). If autowrap, on the col 0 of the next line.
* Otherwise on last column. * Otherwise on last column.
*/ */
if (Wcm.cm_magicwrap) if (tty->Wcm->cm_magicwrap)
; /* "limbo" */ ; /* "limbo" */
else if (Wcm.cm_autowrap) { else if (tty->Wcm->cm_autowrap) {
curX = 0; curX (tty) = 0;
curY++; /* Beware end of screen! */ curY (tty) ++; /* Beware end of screen! */
} }
else else
curX--; curX (tty)--;
} }
} }
#endif #endif
......
...@@ -2724,15 +2724,15 @@ extern Lisp_Object Qredisplay_dont_pause; ...@@ -2724,15 +2724,15 @@ extern Lisp_Object Qredisplay_dont_pause;
/* Defined in term.c */ /* Defined in term.c */
extern void ring_bell P_ ((void)); extern void ring_bell P_ ((void));
extern void set_terminal_modes P_ (()); extern void set_terminal_modes P_ ((void));
extern void reset_terminal_modes P_ (()); extern void reset_terminal_modes P_ ((void));
extern void update_begin P_ ((struct frame *)); extern void update_begin P_ ((struct frame *));
extern void update_end P_ ((struct frame *)); extern void update_end P_ ((struct frame *));
extern void set_terminal_window P_ ((int)); extern void set_terminal_window P_ ((int));
extern void set_scroll_region P_ ((int, int)); extern void set_scroll_region P_ ((int, int));
extern void turn_off_insert P_ ((void)); extern void turn_off_insert P_ ((struct tty_output *));
extern void turn_off_highlight P_ ((void)); extern void turn_off_highlight P_ ((struct tty_output *));
extern void background_highlight P_ ((void)); extern void background_highlight P_ ((struct tty_output *));
extern void clear_frame P_ ((void)); extern void clear_frame P_ ((void));
extern void clear_end_of_line P_ ((int)); extern void clear_end_of_line P_ ((int));
extern void clear_end_of_line_raw P_ ((int)); extern void clear_end_of_line_raw P_ ((int));
...@@ -2742,12 +2742,12 @@ extern int string_cost P_ ((char *)); ...@@ -2742,12 +2742,12 @@ extern int string_cost P_ ((char *));
extern int per_line_cost P_ ((char *)); extern int per_line_cost P_ ((char *));
extern void calculate_costs P_ ((struct frame *)); extern void calculate_costs P_ ((struct frame *));
extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
extern void tty_setup_colors P_ ((int)); extern void tty_setup_colors P_ ((struct tty_output *, int));
extern struct tty_output *term_init P_ ((char *, char *)); extern struct tty_output *term_init P_ ((char *, char *));
extern struct tty_output *term_dummy_init P_ ((void)); extern struct tty_output *term_dummy_init P_ ((void));
extern void fatal P_ ((/* char *, ... */)); extern void fatal P_ ((/* char *, ... */));
void cursor_to P_ ((int, int)); void cursor_to P_ ((int, int));
extern int tty_capable_p P_ ((struct frame *, unsigned, unsigned long, unsigned long)); extern int tty_capable_p P_ ((struct tty_output *, unsigned, unsigned long, unsigned long));
/* Defined in scroll.c */ /* Defined in scroll.c */
......
...@@ -3313,7 +3313,7 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0, ...@@ -3313,7 +3313,7 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
update_begin (f); update_begin (f);
if (FRAME_MSDOS_P (f)) if (FRAME_MSDOS_P (f))
set_terminal_modes (0); set_terminal_modes ();
clear_frame (); clear_frame ();
clear_current_matrices (f); clear_current_matrices (f);
update_end (f); update_end (f);
...@@ -6485,7 +6485,6 @@ init_display () ...@@ -6485,7 +6485,6 @@ init_display ()
SET_CHAR_GLYPH_FROM_GLYPH (space_glyph, ' '); SET_CHAR_GLYPH_FROM_GLYPH (space_glyph, ' ');
space_glyph.charpos = -1; space_glyph.charpos = -1;
meta_key = 0;
inverse_video = 0; inverse_video = 0;
cursor_in_echo_area = 0; cursor_in_echo_area = 0;
terminal_type = (char *) 0; terminal_type = (char *) 0;
......
...@@ -478,14 +478,21 @@ make_minibuffer_frame () ...@@ -478,14 +478,21 @@ make_minibuffer_frame ()
static int terminal_frame_count; static int terminal_frame_count;
struct frame * struct frame *
make_terminal_frame (tty, tty_type) make_terminal_frame (tty_name, tty_type)
char *tty; char *tty_name;
char *tty_type; char *tty_type;
{ {
register struct frame *f; register struct frame *f;
Lisp_Object frame; Lisp_Object frame;
char name[20]; char name[20];
struct tty_output *tty;
/* init_term may throw an error, so create the tty first. */
if (initialized)
tty = term_init (tty_name, tty_type);
else
tty = term_dummy_init ();
#ifdef MULTI_KBOARD #ifdef MULTI_KBOARD
if (!initial_kboard) if (!initial_kboard)
{ {
...@@ -544,10 +551,7 @@ make_terminal_frame (tty, tty_type) ...@@ -544,10 +551,7 @@ make_terminal_frame (tty, tty_type)
make_mac_terminal_frame (f); make_mac_terminal_frame (f);
#else #else
f->output_method = output_termcap; f->output_method = output_termcap;
if (initialized) f->output_data.tty = tty;
f->output_data.tty = term_init (tty, tty_type);
else
f->output_data.tty = term_dummy_init ();
f->output_data.tty->top_frame = frame; f->output_data.tty->top_frame = frame;
#ifdef CANNOT_DUMP #ifdef CANNOT_DUMP
FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR; FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR;
...@@ -607,6 +611,8 @@ Note that changing the size of one terminal frame automatically affects all. */ ...@@ -607,6 +611,8 @@ Note that changing the size of one terminal frame automatically affects all. */
/* XXX Ugh, there must be a better way to do this. */ /* XXX Ugh, there must be a better way to do this. */
tty = Fassq (Qtty, parms); tty = Fassq (Qtty, parms);
if (EQ (tty, Qnil))
tty = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
if (EQ (tty, Qnil)) if (EQ (tty, Qnil))
tty = Fassq (Qtty, Vdefault_frame_alist); tty = Fassq (Qtty, Vdefault_frame_alist);
if (! EQ (tty, Qnil)) if (! EQ (tty, Qnil))
...@@ -617,6 +623,8 @@ Note that changing the size of one terminal frame automatically affects all. */ ...@@ -617,6 +623,8 @@ Note that changing the size of one terminal frame automatically affects all. */
tty_type = Fassq (Qtty_type, parms); tty_type = Fassq (Qtty_type, parms);
if (EQ (tty_type, Qnil)) if (EQ (tty_type, Qnil))
tty_type = Fassq (Qtty_type, Vdefault_frame_alist); tty_type = Fassq (Qtty_type, Vdefault_frame_alist);
if (EQ (tty_type, Qnil))
tty_type = Fassq (Qtty, XFRAME (selected_frame)->param_alist);
if (! EQ (tty_type, Qnil)) if (! EQ (tty_type, Qnil))
tty_type = XCDR (tty_type); tty_type = XCDR (tty_type);
if (EQ (tty_type, Qnil) || !STRINGP (tty_type)) if (EQ (tty_type, Qnil) || !STRINGP (tty_type))
...@@ -1300,7 +1308,7 @@ The functions are run with one arg, the frame to be deleted. */) ...@@ -1300,7 +1308,7 @@ The functions are run with one arg, the frame to be deleted. */)
{ {
FOR_EACH_FRAME (tail, frame1) FOR_EACH_FRAME (tail, frame1)
{ {
if (! EQ (frame, frame1)) if (! EQ (frame, frame1) && FRAME_LIVE_P (XFRAME (frame1)))
break; break;
} }
} }
......
...@@ -461,11 +461,6 @@ FILE *dribble; ...@@ -461,11 +461,6 @@ FILE *dribble;
/* Nonzero if input is available. */ /* Nonzero if input is available. */
int input_pending; int input_pending;
/* 1 if should obey 0200 bit in input chars as "Meta", 2 if should
keep 0200 bit in input chars. 0 to ignore the 0200 bit. */
int meta_key;
/* Non-zero means force key bindings update in parse_menu_item. */ /* Non-zero means force key bindings update in parse_menu_item. */
int update_menu_bindings; int update_menu_bindings;
...@@ -6593,7 +6588,9 @@ read_avail_input (expected) ...@@ -6593,7 +6588,9 @@ read_avail_input (expected)
of characters on some systems when input is stuffed at us. */ of characters on some systems when input is stuffed at us. */
unsigned char cbuf[KBD_BUFFER_SIZE - 1]; unsigned char cbuf[KBD_BUFFER_SIZE - 1];
int n_to_read; int n_to_read;
struct tty_output *tty;
Lisp_Object frame;
#ifdef WINDOWSNT #ifdef WINDOWSNT
return 0; return 0;
#else /* not WINDOWSNT */ #else /* not WINDOWSNT */
...@@ -6607,12 +6604,14 @@ read_avail_input (expected) ...@@ -6607,12 +6604,14 @@ read_avail_input (expected)
#else /* not MSDOS */ #else /* not MSDOS */
struct tty_output *tty;
nread = 0; nread = 0;
/* Try to read from each available tty, until one succeeds. */ /* Try to read from each available tty, until one succeeds. */
for (tty = tty_list; tty; tty = tty->next) { for (tty = tty_list; tty; tty = tty->next) {
if (! tty->term_initted)
continue;
/* Determine how many characters we should *try* to read. */ /* Determine how many characters we should *try* to read. */
#ifdef FIONREAD #ifdef FIONREAD
/* Find out how much input is available. */ /* Find out how much input is available. */
...@@ -6720,15 +6719,15 @@ read_avail_input (expected) ...@@ -6720,15 +6719,15 @@ read_avail_input (expected)
/* Select frame corresponding to the active tty. Note that the /* Select frame corresponding to the active tty. Note that the
value of selected_frame is not reliable here, redisplay tends value of selected_frame is not reliable here, redisplay tends
to temporarily change it. But tty should always be non-NULL. */ to temporarily change it. But tty should always be non-NULL. */
Lisp_Object frame = (tty ? tty->top_frame : selected_frame); frame = (tty ? tty->top_frame : selected_frame);
for (i = 0; i < nread; i++) for (i = 0; i < nread; i++)
{ {
buf[i].kind = ASCII_KEYSTROKE_EVENT; buf[i].kind = ASCII_KEYSTROKE_EVENT;
buf[i].modifiers = 0; buf[i].modifiers = 0;
if (meta_key == 1 && (cbuf[i] & 0x80)) if (tty->meta_key == 1 && (cbuf[i] & 0x80))
buf[i].modifiers = meta_modifier; buf[i].modifiers = meta_modifier;
if (meta_key != 2) if (tty->meta_key != 2)
cbuf[i] &= ~0x80; cbuf[i] &= ~0x80;
buf[i].code = cbuf[i]; buf[i].code = cbuf[i];
...@@ -10109,7 +10108,7 @@ On such systems, Emacs starts a subshell instead of suspending. */) ...@@ -10109,7 +10108,7 @@ On such systems, Emacs starts a subshell instead of suspending. */)
/* sys_suspend can get an error if it tries to fork a subshell /* sys_suspend can get an error if it tries to fork a subshell
and the system resources aren't available for that. */ and the system resources aren't available for that. */
record_unwind_protect ((Lisp_Object (*) P_ ((Lisp_Object))) init_sys_modes, record_unwind_protect ((Lisp_Object (*) P_ ((Lisp_Object))) init_sys_modes,
Qnil); (Lisp_Object)CURTTY()); /* XXX */
stuff_buffered_input (stuffstring); stuff_buffered_input (stuffstring);
if (cannot_suspend) if (cannot_suspend)
sys_subshell (); sys_subshell ();
...@@ -10438,14 +10437,14 @@ See also `current-input-mode'. */) ...@@ -10438,14 +10437,14 @@ See also `current-input-mode'. */)
flow_control = !NILP (flow); flow_control = !NILP (flow);
if (NILP (meta)) if (NILP (meta))
meta_key = 0; FRAME_TTY (SELECTED_FRAME ())->meta_key = 0;
else if (EQ (meta, Qt)) else if (EQ (meta, Qt))
meta_key = 1; FRAME_TTY (SELECTED_FRAME ())->meta_key = 1;
else else
meta_key = 2; FRAME_TTY (SELECTED_FRAME ())->meta_key = 2;
if (!NILP (quit)) if (!NILP (quit))
/* Don't let this value be out of range. */ /* Don't let this value be out of range. */
quit_char = XINT (quit) & (meta_key ? 0377 : 0177); quit_char = XINT (quit) & (FRAME_TTY (SELECTED_FRAME ())->meta_key ? 0377 : 0177);
#ifndef DOS_NT #ifndef DOS_NT
init_all_sys_modes (); init_all_sys_modes ();
...@@ -10478,7 +10477,9 @@ The elements of this list correspond to the arguments of ...@@ -10478,7 +10477,9 @@ The elements of this list correspond to the arguments of
val[0] = interrupt_input ? Qt : Qnil; val[0] = interrupt_input ? Qt : Qnil;
val[1] = flow_control ? Qt : Qnil; val[1] = flow_control ? Qt : Qnil;
val[2] = meta_key == 2 ? make_number (0) : meta_key == 1 ? Qt : Qnil; val[2] = FRAME_TTY (SELECTED_FRAME ())->meta_key == 2
? make_number (0)
: FRAME_TTY (SELECTED_FRAME ())->meta_key == 1 ? Qt : Qnil;
XSETFASTINT (val[3], quit_char); XSETFASTINT (val[3], quit_char);
return Flist (sizeof (val) / sizeof (val[0]), val); return Flist (sizeof (val) / sizeof (val[0]), val);
......
...@@ -1362,14 +1362,15 @@ nil means don't delete them until `list-processes' is run. */); ...@@ -1362,14 +1362,15 @@ nil means don't delete them until `list-processes' is run. */);
if (!read_socket_hook && EQ (Vwindow_system, Qnil)) if (!read_socket_hook && EQ (Vwindow_system, Qnil))
#endif #endif
{ {
EMACS_GET_TTY (fileno (TTY_INPUT (tty_out)), &tty_out->old_tty); if (! tty_out->old_tty)
tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct emacs_tty));
tty_out->old_tty_valid = 1;
EMACS_GET_TTY (fileno (TTY_INPUT (tty_out)), tty_out->old_tty);
tty = tty_out->old_tty; tty = *tty_out->old_tty;
#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
XSETINT (Vtty_erase_char, tty_out->old_tty.main.c_cc[VERASE]); XSETINT (Vtty_erase_char, tty.main.c_cc[VERASE]);
#ifdef DGUX #ifdef DGUX
/* This allows meta to be sent on 8th bit. */ /* This allows meta to be sent on 8th bit. */
...@@ -1403,7 +1404,7 @@ nil means don't delete them until `list-processes' is run. */); ...@@ -1403,7 +1404,7 @@ nil means don't delete them until `list-processes' is run. */);
on output */ on output */
tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */ tty.main.c_oflag &= ~TAB3; /* Disable tab expansion */
#ifdef CS8 #ifdef CS8
if (meta_key) if (tty_out->meta_key)
{ {
tty.main.c_cflag |= CS8; /* allow 8th bit on input */ tty.main.c_cflag |= CS8; /* allow 8th bit on input */
tty.main.c_cflag &= ~PARENB;/* Don't check parity */ tty.main.c_cflag &= ~PARENB;/* Don't check parity */
...@@ -1641,7 +1642,6 @@ nil means don't delete them until `list-processes' is run. */); ...@@ -1641,7 +1642,6 @@ nil means don't delete them until `list-processes' is run. */);
#endif #endif
) )
#endif #endif
set_terminal_modes (tty_out);
if (!tty_out->term_initted) if (!tty_out->term_initted)
{ {
...@@ -1838,7 +1838,7 @@ reset_sys_modes (tty_out) ...@@ -1838,7 +1838,7 @@ reset_sys_modes (tty_out)
} }
#endif #endif
reset_terminal_modes (tty_out); tty_reset_terminal_modes (tty_out);
fflush (TTY_OUTPUT (tty_out)); fflush (TTY_OUTPUT (tty_out));
#ifdef BSD_SYSTEM #ifdef BSD_SYSTEM
#ifndef BSD4_1 #ifndef BSD4_1
...@@ -1867,9 +1867,9 @@ reset_sys_modes (tty_out) ...@@ -1867,9 +1867,9 @@ reset_sys_modes (tty_out)
reset_sigio (); reset_sigio ();
#endif /* BSD4_1 */ #endif /* BSD4_1 */