Commit daf01701 authored by Karoly Lorentey's avatar Karoly Lorentey

Fixed X support, preliminary support for X-tty combo sessions.

lib-src/emacsclient.c (copy_from_to, pty_conversation): Re-added SIGIO
hack.  (Sigh.)

lisp/frame.el (make-frame-on-tty): Use make-terminal-frame, not
make-frame.

src/dispnew.c (line_hash_code, line_draw_cost): Updated to use
the new display_method parameters.
(Fredraw_frame): fflush the tty only if f is a termcap frame.
(direct_output_for_insert): Updated to use the new display_method
parameters. fflush the tty only if f is a termcap frame.
(direct_output_forward_char, update_frame_1, scrolling): Ditto.
(update_frame_line, Fding, bitch_at_user): Ditto.
(Fsend_string_to_terminal): Fail if current frame is not on a tty.
(init_display): Frame size change is safe here.


src/frame.c (Vterminal_frame): Restored previously deleted variable.
(syms_of_frame): Initialize it.
(make_terminal_frame): Copy the frame's display_method from tty_display_info.
(Fmake_terminal_frame): Enable simultaneous X and tty frames (buggy).
(Fredirect_frame_focus): Don't call frame_rehighlight_hook if frame
is on a termcap device.

src/frame.h (struct frame): Renamed display to display_method.
(Vterminal_frame): Re-added declaration.

src/keyboard.c (flow_control): Moved to struct tty_display_info.
(read_avail_input): Check ttys even if there is a read_socket_hook.
(Fset_input_mode): Call reset_sys_modes/init_sys_modes and set
flow_control or meta_key only when the frame is a termcap frame.
(Fcurrent_input_mode): Handle flow_control and meta_key right on
non-termcap frames.

src/scroll.c (calculate_scrolling, calculate_direct_scrolling): Update
to use the new display_method parameters.
(scrolling_1, scroll_cost): Ditto.

src/sysdep.c (init_sys_modes, reset_sys_modes): Always set the
terminal parameters if tty_out->input is not stdin.  Updated to the
new location of flow_control.
(hft_init): Moved HFT init code to term_init, as it needs the frame.

src/term.c (tty_display_method_template): New variable.
(update_begin): Added rif hack.
(set_terminal_window, ins_del_lines, term_init): Updated to use the
new display_method parameters.
(insert_glyphs, ins_del_lines): Only call insert_glyphs_hook if the
current frame is not on a tty.
(calculate_costs): Don't calculate costs if not on a tty.
(term_dummy_init): Fixed tty->output initialization. Preallocate Wcm
and display_method.
(term_init): Allocate & initialize display_method.  Blindly fixed
WINDOWSNT-specific parts.  Added HFT-specific initialization
exception from hft_init.
(delete_tty): Only delete termcap frames.  Free() the display_method.

src/termchar.h (struct tty_display_info): Moved high-level terminal
characteristics to struct display_method.  Added flow_control and
display_method members.

src/termhooks.h (struct display_method): New struct (renamed from
struct device).  Added accessor macros.

src/window.c (init_window_once): Initialize Vterminal_frame.

src/xdisp.c (init_iterator, expose_frame): Added rif hack.
(try_window_id): Updated to use the new display_method parameters.

src/xfaces.c (realize_basic_faces): Don't call
x_update_menu_appearance if the frame is a tty frame.

src/xfns.c (Fx_create_frame): Added rif hack.  Initialize
display_method.
(x_create_tip_frame): Initialize display_method.

src/xterm.c (x_display_method): New variable.
(x_flush, x_frame_of_widget, XTmouse_position): Ignore non-X frames.
(x_window_to_scroll_bar, x_window_to_menu_bar): Ditto.
(xim_destroy_callback, xim_instantiate_callback): Ditto.
(frame_highlight, frame_unhighlight): Added rif hack.
(x_initialize): Don't initialize rif.  Do initialize x_display_method.

src/xterm.h (x_display_method): New declaration.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-30
parent 28d7d09f
......@@ -16,7 +16,7 @@ Patches or suggestions are welcome!
Retrieving the latest version of the branch:
tla register-archive lorentey@elte.hu--2004 http://lorentey.web.elte.hu/arch/2004/
tla get lorentey@elte.hu--2004/emacs--multi-tty--0 <directory>
tla get lorentey@elte.hu--2004/emacs--multi-tty <directory>
(I use tla 1.1.)
......@@ -33,11 +33,11 @@ commands:
mkdir +build
cd +build
../configure --with-x-toolkit=no --without-x
../configure
make bootstrap
then start up the emacs server (src/emacs, M-x server-start), and then
(from a shell prompt on another terminal) start emacsclient with
then start up the emacs server (src/emacs -nw, M-x server-start), and
then (from a shell prompt on another terminal) start emacsclient with
lib-src/emacsclient -f /optional/file/names...
......@@ -50,7 +50,10 @@ works exactly as before. Suspending Emacs is disabled at the moment.
If you exit emacs, all terminals should be restored to their previous
states.
X, Mac, Windows and DOS support is broken, probably doesn't even
X support is (I hope) working, but at the moment there are problems
with simultaneous X and tty devices, so don't do that.
Mac, Windows and DOS support is broken, probably doesn't even
compile -- this will be solved later.
Only tested on my GNU/Linux box.
......@@ -91,9 +94,9 @@ DIARY OF CHANGES
(ex-TODO items with explanations.)
-- Introduce a new abstraction for terminal devices.
-- Introduce a new struct for terminal devices.
(Done, see struct tty_output. The abstraction is not yet
(Done, see struct tty_output. The list of members is not yet
complete.)
-- Change the bootstrap procedure to initialize tty_list.
......@@ -112,6 +115,8 @@ DIARY OF CHANGES
(Update: They do, now.)
(Update2: After enabling X, they don't.)
-- other-frame should cycle through the frames on the `current'
terminal only.
......@@ -167,6 +172,8 @@ DIARY OF CHANGES
read_input_waiting was not necessary. Secondary ttys do seem to
send signals on input.)
(Update^3: Not any more.)
-- Make make-terminal-frame look up the `tty' and `tty-type' frame
parameters from the currently selected terminal before the global
default.
......@@ -191,7 +198,7 @@ DIARY OF CHANGES
(Done, but at the moment only called when an error happens during
initialization. There is a memory corruption error around this
somewhere.)
somewhere.) (Update: now it is fully enabled.)
-- Implement automatic deletion of terminals when the last frame on
that terminal is closed.
......@@ -214,9 +221,10 @@ DIARY OF CHANGES
server-frames may be removed from server.el.)
(Done, nothing to do. It seems that Emacs does not receive SIGHUP
from secondary ttys.)
from secondary ttys, which is actually a good thing.) (Update: I
think it would be a bad idea to remove server-frames anyway.)
-- Change emacsclient/server.el to support the -h argument better,
-- Change emacsclient/server.el to support the -t argument better,
i.e. automatically close the socket when the frame is closed.
(Seems to be working OK.)
......@@ -248,7 +256,7 @@ DIARY OF CHANGES
earlier, but it seems to be fixed (there were several changes
around request_sigio, maybe one of them did it).
read_input_waiting() is only used in sys_select(), don't change
it.)
it.) (Update: After adding X support, it's broken again.)
-- Find out why does Emacs abort when it wants to close its
controlling tty. Hint: chan_process[] array. Hey, maybe
......@@ -262,6 +270,7 @@ DIARY OF CHANGES
fcntl() kernel behaviour could be emulated by emacsclient.
(Done. Simply disabled the SIGIO emulation hack in emacsclient.)
(Update: it was added back.)
-- server.el: There are issues with saving files in buffers of closed
clients. Try editing a file with emacsclient -f, and (without
......@@ -273,7 +282,7 @@ DIARY OF CHANGES
pending buffers, and modified buffers don't seem to be deleted.)
-- emacsclient.el, server.el: Handle eval or file open errors when
doing -f.
doing -t.
(Done.)
......@@ -286,32 +295,52 @@ DIARY OF CHANGES
(Done, see delete-tty.)
-- Get rid of the accessor macros in termchar.h, or define macros for
all members.
(Done.)
-- Move device-specific parameters (like costs) commonly used by
device backends to a common, device-dependent structure.
(Done. See struct display_method in termhooks.h.)
-- Fix X support.
(Done. Well, it seems to be working.)
-- Allow simultaneous X and tty frames. (Handling input could be
tricky. Or maybe not.)
(Done. Allowed, that is. It is currently extremely unstable, to
the point of being unusable. The rif variable causes constant
core dumps. Handling input is indeed tricky.)
THINGS TO DO
------------
** Fix rif issue with X-tty combo sessions. IMHO the best thing to do
is to get rid of that global variable (and use the value value in
display_method, which is guaranteed to be correct).
** Fix faces on tty frames during X-tty combo sessions.
** Find out the best way to support suspending Emacs with multiple
ttys. My guess: disable it on the controlling tty, but other ttys
should 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.)
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.)
** Move baud_rate to tty_output.
** Move device-specific parameters (like costs) commonly used by
device backends to a common, device-dependent structure.
** Do tty output through term_hooks, like graphical display backends.
** Fix X support.
** Allow simultaneous X and tty frames. (Handling input could be
tricky. Or maybe not.)
** Implement support for starting an interactive Emacs session without
an initial frame. (The user would connect to it and open frames
later, with emacsclient.) Not necessarily a good idea.
** Fix input from raw ttys (again).
** Fix Mac support (I can't do this myself).
** Fix W32 support (I can't do this myself).
......@@ -320,14 +349,22 @@ THINGS TO DO
** Do a grep on XXX and ?? for more issues.
** Get rid of the accessor macros in termchar.h, or define macros for
all members.
** Understand Emacs's low-level input system (it seems complicated)
:-) and maybe rewrite multi-tty input in terms of MULTI_KBOARD.
(Update: This backtrace from a tty-X combo session hints that this
may be necessary.)
** Understand Emacs's low-level input system (it seems complicated) :-)
and maybe rewrite multi-tty input in terms of MULTIKBOARD.
#0 abort () at /home/lorentey/work/emacs/emacs--multi-tty/src/emacs.c:417
#1 0x081104fb in read_char (commandflag=0, nmaps=0, maps=0x0, prev_event=675499188, used_mouse_menu=0x0) at /home/lorentey/work/emacs/emacs--multi-tty/src/keyboard.c:2581
#2 0x0819f23e in read_filtered_event (no_switch_frame=1, ascii_required=0, error_nonascii=0, input_method=0) at /home/lorentey/work/emacs/emacs--multi-tty/src/lread.c:468
#3 0x0819387c in Fy_or_n_p (prompt=1759896324) at /home/lorentey/work/emacs/emacs--multi-tty/src/fns.c:3115
...
** What does interrupt_input do? I tried to disable it for raw
secondary tty support, but it does not seem to do anything useful.
(Update: Look again. X unconditionally enables this, maybe that's
why raw terminal support is broken again. I really do need to
understand input.)
** Make sure C-g goes to the right frame. This is hard, as SIGINT
doesn't have a tty parameter. :-(
......@@ -335,7 +372,6 @@ THINGS TO DO
** I have seen a case when Emacs with multiple ttys fell into a loop
eating 100% of CPU time. Strace showed this loop:
getpid() = 30284
kill(30284, SIGIO) = 0
--- SIGIO (I/O possible) @ 0 (0) ---
......
......@@ -720,7 +720,7 @@ init_pty ()
}
int
copy_from_to (int in, int out)
copy_from_to (int in, int out, int sigio)
{
static char buf[BUFSIZ];
int nread = read (in, &buf, BUFSIZ);
......@@ -740,6 +740,9 @@ copy_from_to (int in, int out)
if (r < 0)
return 0;
if (sigio && emacs_pid)
kill (emacs_pid, SIGIO);
}
return 1;
}
......@@ -774,7 +777,7 @@ pty_conversation (FILE *in)
if (FD_ISSET (master, &rset))
{
/* Copy Emacs output to stdout. */
if (! copy_from_to (master, 0))
if (! copy_from_to (master, 0, 0))
{
FD_CLR (master, &set);
}
......@@ -782,7 +785,7 @@ pty_conversation (FILE *in)
if (FD_ISSET (1, &rset))
{
/* Forward user input to Emacs. */
if (! copy_from_to (1, master))
if (! copy_from_to (1, master, 1))
{
FD_CLR (master, &set);
}
......
......@@ -587,7 +587,7 @@ us.)"
(error "Invalid terminal device"))
(unless type
(error "Invalid terminal type"))
(make-frame `((tty . ,device) (tty-type . ,type) . ,parameters)))
(make-terminal-frame (append (list (cons 'tty device) (cons 'tty-type type)) parameters)))
(defun make-frame-command ()
"Make a new frame, and select it if the terminal displays only one frame."
......
......@@ -1111,7 +1111,7 @@ process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \
regex.o: regex.c syntax.h buffer.h $(config_h) regex.h category.h charset.h
region-cache.o: region-cache.c buffer.h region-cache.h
scroll.o: scroll.c systty.h termchar.h dispextern.h frame.h msdos.h keyboard.h \
$(config_h)
termhooks.h $(config_h)
search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \
blockinput.h atimer.h systime.h category.h charset.h composite.h $(config_h)
strftime.o: strftime.c $(config_h)
......
......@@ -297,8 +297,10 @@ int glyph_pool_count;
static struct frame *frame_matrix_frame;
/* Current interface for window-based redisplay. Set from init_xterm.
A null value means we are not using window-based redisplay. */
/* Current interface for window-based redisplay. Set from
update_begin. A null value means we are not using window-based
redisplay. */
/* XXX this variable causes frequent coredumps */
struct redisplay_interface *rif;
......@@ -1390,7 +1392,7 @@ line_hash_code (row)
{
int c = glyph->u.ch;
int face_id = glyph->face_id;
if (TTY_MUST_WRITE_SPACES (CURTTY ()))
if (FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */
c -= SPACEGLYPH;
hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + c;
hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + face_id;
......@@ -1422,7 +1424,7 @@ line_draw_cost (matrix, vpos)
int glyph_table_len = GLYPH_TABLE_LENGTH;
/* Ignore trailing and leading spaces if we can. */
if (!TTY_MUST_WRITE_SPACES (CURTTY ()))
if (!FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */
{
/* Skip from the end over trailing spaces. */
while (end > beg && CHAR_GLYPH_SPACE_P (*(end - 1)))
......@@ -3317,7 +3319,8 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
clear_frame ();
clear_current_matrices (f);
update_end (f);
fflush (TTY_OUTPUT (FRAME_TTY (f)));
if (FRAME_TERMCAP_P (f))
fflush (TTY_OUTPUT (FRAME_TTY (f)));
windows_or_buffers_changed++;
/* Mark all windows as inaccurate, so that every window will have
its redisplay done. */
......@@ -3457,7 +3460,7 @@ direct_output_for_insert (g)
/* If we can't insert glyphs, we can use this method only
at the end of a line. */
if (!TTY_CHAR_INS_DEL_OK (FRAME_TTY (f)))
if (!FRAME_CHAR_INS_DEL_OK (f))
if (PT != ZV && FETCH_BYTE (PT_BYTE) != '\n')
return 0;
......@@ -3654,7 +3657,8 @@ direct_output_for_insert (g)
rif->update_window_end_hook (w, 1, 0);
update_end (f);
updated_row = NULL;
fflush (TTY_OUTPUT (CURTTY ()));
if (FRAME_TERMCAP_P (f))
fflush (TTY_OUTPUT (FRAME_TTY (f)));
TRACE ((stderr, "direct output for insert\n"));
mark_window_display_accurate (it.window, 1);
......@@ -3745,7 +3749,8 @@ direct_output_forward_char (n)
cursor_to (y, x);
}
fflush (TTY_OUTPUT (CURTTY ()));
if (FRAME_TERMCAP_P (f))
fflush (TTY_OUTPUT (FRAME_TTY (f)));
redisplay_performed_directly_p = 1;
return 1;
}
......@@ -5070,7 +5075,7 @@ update_frame_1 (f, force_p, inhibit_id_p)
}
/* If we cannot insert/delete lines, it's no use trying it. */
if (!TTY_LINE_INS_DEL_OK (FRAME_TTY (f)))
if (!FRAME_LINE_INS_DEL_OK (f))
inhibit_id_p = 1;
/* See if any of the desired lines are enabled; don't compute for
......@@ -5288,7 +5293,7 @@ scrolling (frame)
}
/* If changed lines are few, don't allow preemption, don't scroll. */
if ((!TTY_SCROLL_REGION_OK (FRAME_TTY (frame))
if ((!FRAME_SCROLL_REGION_OK (frame)
&& changed_lines < baud_rate / 2400)
|| unchanged_at_bottom == FRAME_LINES (frame))
return 1;
......@@ -5296,14 +5301,14 @@ scrolling (frame)
window_size = (FRAME_LINES (frame) - unchanged_at_top
- unchanged_at_bottom);
if (TTY_SCROLL_REGION_OK (FRAME_TTY (frame)))
if (FRAME_SCROLL_REGION_OK (frame))
free_at_end_vpos -= unchanged_at_bottom;
else if (TTY_MEMORY_BELOW_FRAME (FRAME_TTY (frame)))
else if (FRAME_MEMORY_BELOW_FRAME (frame))
free_at_end_vpos = -1;
/* If large window, fast terminal and few lines in common between
current frame and desired frame, don't bother with i/d calc. */
if (!TTY_SCROLL_REGION_OK (FRAME_TTY (frame))
if (!FRAME_SCROLL_REGION_OK (frame)
&& window_size >= 18 && baud_rate > 2400
&& (window_size >=
10 * scrolling_max_lines_saved (unchanged_at_top,
......@@ -5384,7 +5389,7 @@ update_frame_line (f, vpos)
struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos);
struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos);
int must_write_whole_line_p;
int write_spaces_p = TTY_MUST_WRITE_SPACES (FRAME_TTY (f));
int write_spaces_p = FRAME_MUST_WRITE_SPACES (f);
int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background
!= FACE_TTY_DEFAULT_BG_COLOR);
......@@ -5463,7 +5468,7 @@ update_frame_line (f, vpos)
nlen--;
/* If there's no i/d char, quickly do the best we can without it. */
if (!TTY_CHAR_INS_DEL_OK (FRAME_TTY (f)))
if (!FRAME_CHAR_INS_DEL_OK (f))
{
int i, j;
......@@ -5566,7 +5571,7 @@ update_frame_line (f, vpos)
tem = (nlen - nsp) - (olen - osp);
if (endmatch && tem
&& (!TTY_CHAR_INS_DEL_OK (FRAME_TTY (f))
&& (!FRAME_CHAR_INS_DEL_OK (f)
|| endmatch <= char_ins_del_cost (f)[tem]))
endmatch = 0;
......@@ -5576,7 +5581,7 @@ update_frame_line (f, vpos)
Is it worth it? */
if (nsp != osp
&& (!TTY_CHAR_INS_DEL_OK (FRAME_TTY (f))
&& (!FRAME_CHAR_INS_DEL_OK (f)
|| begmatch + endmatch <= char_ins_del_cost (f)[nsp - osp]))
{
begmatch = 0;
......@@ -6167,6 +6172,9 @@ Control characters in STRING will have terminal-dependent effects. */)
{
/* ??? 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");
if (TTY_TERMSCRIPT (CURTTY ()))
{
fwrite (SDATA (string), 1, SBYTES (string),
......@@ -6193,7 +6201,8 @@ terminate any keyboard macro currently executing. */)
putchar (07);
else
ring_bell ();
fflush (TTY_OUTPUT (CURTTY ()));
if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
fflush (TTY_OUTPUT (CURTTY ()));
}
else
bitch_at_user ();
......@@ -6210,7 +6219,8 @@ bitch_at_user ()
error ("Keyboard macro terminated by a command ringing the bell");
else
ring_bell ();
fflush (TTY_OUTPUT (CURTTY ()));
if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
fflush (TTY_OUTPUT (CURTTY ()));
}
......@@ -6628,7 +6638,7 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
struct tty_display_info *tty;
tty = term_init (selected_frame, 0, terminal_type);
change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 0);
change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 1);
}
{
......
......@@ -114,6 +114,7 @@ Lisp_Object Qfullscreen, Qfullwidth, Qfullheight, Qfullboth;
Lisp_Object Qface_set_after_frame_default;
Lisp_Object Vterminal_frame;
Lisp_Object Vdefault_frame_alist;
Lisp_Object Vdefault_frame_scroll_bars;
Lisp_Object Vmouse_position_function;
......@@ -122,8 +123,8 @@ Lisp_Object Vdelete_frame_functions;
static void
set_menu_bar_lines_1 (window, n)
Lisp_Object window;
int n;
Lisp_Object window;
int n;
{
struct window *w = XWINDOW (window);
......@@ -565,6 +566,7 @@ make_terminal_frame (tty_name, tty_type)
f->output_data.tty->display_info = term_dummy_init ();
}
FRAME_TTY (f)->reference_count++;
f->display_method = FRAME_TTY (f)->display_method;
}
#ifdef CANNOT_DUMP
......@@ -614,9 +616,11 @@ Note that changing the size of one terminal frame automatically affects all. */
if (sf->output_method != output_mac)
error ("Not running on a Macintosh screen; cannot make a new Macintosh frame");
#else
#if 0 /* This should work now! */
if (sf->output_method != output_termcap)
error ("Not using an ASCII terminal now; cannot make a new ASCII frame");
#endif
#endif
#endif /* not MSDOS */
{
......@@ -1909,7 +1913,7 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */)
XFRAME (frame)->focus_frame = focus_frame;
if (frame_rehighlight_hook)
if (!FRAME_TERMCAP_P (XFRAME (frame)) && frame_rehighlight_hook)
(*frame_rehighlight_hook) (XFRAME (frame));
return Qnil;
......@@ -4137,6 +4141,9 @@ Setting this variable does not affect existing frames, only new ones. */);
= intern ("inhibit-default-face-x-resources");
staticpro (&Qinhibit_default_face_x_resources);
DEFVAR_LISP ("terminal-frame", &Vterminal_frame,
doc: /* The initial frame-object, which represents Emacs's stdout. */);
DEFVAR_LISP ("emacs-iconified", &Vemacs_iconified,
doc: /* Non-nil if all of emacs is iconified and frame updates are not needed. */);
Vemacs_iconified = Qnil;
......
......@@ -257,7 +257,7 @@ struct frame
int line_height;
/* The display hooks to use with this frame. */
struct display *display;
struct display_method *display_method;
/* The output method says how the contents of this frame
are displayed. It could be using termcap, or using an X window. */
......@@ -783,6 +783,8 @@ extern int other_visible_frames P_ ((struct frame *));
extern Lisp_Object Vframe_list;
extern Lisp_Object Vdefault_frame_alist;
extern Lisp_Object Vterminal_frame;
extern Lisp_Object Vmouse_highlight;
/* The currently selected frame. */
......
......@@ -617,9 +617,6 @@ int interrupt_input;
/* Nonzero while interrupts are temporarily deferred during redisplay. */
int interrupts_deferred;
/* Nonzero means use ^S/^Q for flow control. */
int flow_control;
/* Allow m- file to inhibit use of FIONREAD. */
#ifdef BROKEN_FIONREAD
#undef FIONREAD
......@@ -6605,7 +6602,8 @@ read_avail_input (expected)
if (read_socket_hook)
/* No need for FIONREAD or fcntl; just say don't wait. */
nread = (*read_socket_hook) (buf, KBD_BUFFER_SIZE, expected);
else
if (!nread && tty_list)
{
/* Using KBD_BUFFER_SIZE - 1 here avoids reading more than
the kbd_buffer can really hold. That may prevent loss
......@@ -10433,7 +10431,8 @@ See also `current-input-mode'. */)
#ifndef DOS_NT
/* this causes startup screen to be restored and messes with the mouse */
reset_sys_modes (CURTTY ());
if (FRAME_TERMCAP_P (SELECTED_FRAME ()))
reset_sys_modes (CURTTY ());
#endif
#ifdef SIGIO
......@@ -10459,19 +10458,25 @@ See also `current-input-mode'. */)
interrupt_input = 1;
#endif
flow_control = !NILP (flow);
if (NILP (meta))
CURTTY ()->meta_key = 0;
else if (EQ (meta, Qt))
CURTTY ()->meta_key = 1;
else
CURTTY ()->meta_key = 2;
if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
{
struct tty_display_info *tty = CURTTY ();
tty->flow_control = !NILP (flow);
if (NILP (meta))
tty->meta_key = 0;
else if (EQ (meta, Qt))
tty->meta_key = 1;
else
tty->meta_key = 2;
}
if (!NILP (quit))
/* Don't let this value be out of range. */
quit_char = XINT (quit) & (CURTTY ()->meta_key ? 0377 : 0177);
#ifndef DOS_NT
init_sys_modes (CURTTY ());
if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
init_sys_modes (CURTTY ());
#endif
#ifdef POLL_FOR_INPUT
......@@ -10498,12 +10503,21 @@ The elements of this list correspond to the arguments of
()
{
Lisp_Object val[4];
struct frame *sf = XFRAME (selected_frame);
val[0] = interrupt_input ? Qt : Qnil;
val[1] = flow_control ? Qt : Qnil;
val[2] = FRAME_TTY (SELECTED_FRAME ())->meta_key == 2
? make_number (0)
: FRAME_TTY (SELECTED_FRAME ())->meta_key == 1 ? Qt : Qnil;
if (FRAME_TERMCAP_P (sf))
{
val[1] = FRAME_TTY (sf)->flow_control ? Qt : Qnil;
val[2] = FRAME_TTY (sf)->meta_key == 2
? make_number (0)
: CURTTY ()->meta_key == 1 ? Qt : Qnil;
}
else
{
val[1] = Qnil;
val[2] = Qt;
}
XSETFASTINT (val[3], quit_char);
return Flist (sizeof (val) / sizeof (val[0]), val);
......
......@@ -29,6 +29,7 @@ Boston, MA 02111-1307, USA. */
#include "keyboard.h"
#include "frame.h"
#include "window.h"
#include "termhooks.h"
/* All costs measured in characters.
So no cost can exceed the area of a frame, measured in characters.
......@@ -102,7 +103,7 @@ calculate_scrolling (frame, matrix, window_size, lines_below,
register int cost, cost1;
int lines_moved = window_size
+ (TTY_SCROLL_REGION_OK (FRAME_TTY (frame)) ? 0 : lines_below);
+ (FRAME_SCROLL_REGION_OK (frame) ? 0 : lines_below);
/* first_insert_cost[I] is the cost of doing the first insert-line
at the i'th line of the lines we are considering,
where I is origin 1 (as it is below). */
......@@ -469,7 +470,7 @@ calculate_direct_scrolling (frame, matrix, window_size, lines_below,
cost of scrolling by a distance of one. The extra cost is
added once for consistency with the cost vectors */
scroll_overhead
= TTY_SCROLL_REGION_COST (FRAME_TTY (frame)) + extra_cost;
= FRAME_SCROLL_REGION_COST (frame) + extra_cost;
/* initialize the top left corner of the matrix */
matrix->writecost = 0;
......@@ -821,7 +822,7 @@ scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom,
matrix = ((struct matrix_elt *)
alloca ((window_size + 1) * (window_size + 1) * sizeof *matrix));
if (TTY_SCROLL_REGION_OK (FRAME_TTY (frame)))
if (FRAME_SCROLL_REGION_OK (frame))
{
calculate_direct_scrolling (frame, matrix, window_size,
unchanged_at_bottom,
......@@ -917,7 +918,7 @@ scroll_cost (frame, from, to, amount)
if (amount == 0)
return 0;
if (! TTY_SCROLL_REGION_OK (FRAME_TTY (frame)))
if (! FRAME_SCROLL_REGION_OK (frame))
limit = height;
else if (amount > 0)
limit += amount;
......
......@@ -1368,7 +1368,7 @@ nil means don't delete them until `list-processes' is run. */);
#ifdef HAVE_WINDOW_SYSTEM
/* Emacs' window system on MSDOG uses the `internal terminal' and therefore
needs the initialization code below. */
if (!read_socket_hook && EQ (Vwindow_system, Qnil))
if (tty_out->input != stdin || (!read_socket_hook && EQ (Vwindow_system, Qnil)))
#endif
{
if (! tty_out->old_tty)
......@@ -1400,7 +1400,7 @@ nil means don't delete them until `list-processes' is run. */);
tty.main.c_lflag &= ~IEXTEN; /* Disable other editing characters. */
#endif
tty.main.c_lflag |= ISIG; /* Enable signals */
if (flow_control)
if (tty_out->flow_control)
{
tty.main.c_iflag |= IXON; /* Enable start/stop output control */
#ifdef IXANY
......@@ -1454,7 +1454,7 @@ nil means don't delete them until `list-processes' is run. */);
tty.main.c_cc[VDISCARD] = CDISABLE;
#endif /* VDISCARD */
if (flow_control)
if (tty_out->flow_control)
{
#ifdef VSTART
tty.main.c_cc[VSTART] = '\021';
......@@ -1490,7 +1490,7 @@ nil means don't delete them until `list-processes' is run. */);
tty.main.c_cc[VSUSP] = 255;
tty.main.c_cc[VDSUSP] = 255;