Commit 3224dac1 authored by Karoly Lorentey's avatar Karoly Lorentey

Hookified termcap devices, added bootstrap display device, plus many bugfixes.

lisp/frame.el (display-color-cells): Pass display parameter to tty-display-color-cells.

lisp/term/xterm.el (xterm-register-default-colors): Pass the selected-frame to display-color-cells.

src/dispextern.h (set_terminal_modes, reset_terminal_modes): Removed declarations.
(get_named_tty_display): New prototype.
(tty_clear_end_of_line, term_init): Updated to new prototype.
(initial_term_init): Renamed to init_initial_display.

src/dispnew.c (Fredraw_frame): ifdef-out DOS-specific code.  Add display parameter to set_terminal_modes call.
(update_frame): Don't flush the tty of there is no tty.
(init_display): Set up a termcap display on the controlling tty and
change the initial frame to use that.  Delete the initial display.

src/frame.c (Fframep): Return t for the initial frame.
(make_initial_frame): New function for creating the initial frame during bootstrap.  Use init_initial_display, not initial_term_init.
(make_terminal_frame): Removed special cases for creating the initial frame.

src/frame.h (enum output_method): New entry: output_initial for the bootstrap display.
(FRAME_INITIAL_P): New macro.
(make_initial_frame): New prototype.

src/keyboard.c (interrupt_signal): Exit Emacs on SIGINT from the (frameless) controlling tty, if possible.  Explain this in a comment.
(init_keyboard): Added comment about exiting on SIGINT.
(Fset_input_mode): A termcap frame is never the initial frame anymore.

src/sysdep.c (init_sys_modes): Update tty_set_terminal_modes call to the new prototype.
(reset_sys_modes): Comment out tty_clear_end_of_line call; it doesn't work anymore.  Update tty_reset_terminal_modes call.

src/termchar.h (struct tty_display_info): Added pointer to the display structure, for reset_sys_modes.

src/termhooks.h (struct display): Added display parameter to set_terminal_modes_hook and reset_terminal_modes_hook.

src/term.c (initial_display): New variable.
(tty_ring_bell, tty_update_end, tty_set_terminal_window, tty_cursor_to)
(tty_raw_cursor_to, tty_clear_to_end, tty_clear_frame, tty_clear_end_of_line)
(tty_write_glyphs, tty_insert_glyphs, tty_delete_glyphs, tty_ins_del_lines): New functions.
(ring_bell, update_end, set_terminal_window, cursor_to, raw_cursor_to)
(clear_to_end, clear_frame, clear_end_of_line, write_glyphs, insert_glyphs)
(delete_glyphs, ins_del_lines): Removed special casing of termcap displays.
(get_tty_display): New function.
(Ftty_display_color_p, Ftty_display_color_cells): Use it.
(get_named_tty_display): Removed static.
(tty_set_terminal_modes, tty_reset_terminal_modes): Changed to use a display parameter
instead of tty_display_info for hook compatibility.
(set_terminal_modes, reset_terminal_modes): Removed.
(initial_term_init): Renamed to init_initial_display.  Set up an
output_initial device, not a termcap display.
(delete_initial_display): New function.
(maybe_fatal): New function, for private use of term_init.
(term_init): New parameter for choosing between fatal and simple errors.
Removed incomprehensible special casing for the second initialization of the
controlling tty.  Use maybe_fatal for error handling.
Initialize termcap display hooks in the new device.
Initialize the display pointer in the tty_display_info structure.
(delete_tty): Replace order of reset_sys_modes and delete_display.

src/window.c (init_window_once): Call make_initial_frame instead of make_terminal_frame.

src/xfaces.c (realize_default_face, realize_face): Don't abort on the bootstrap display device.

src/xterm.c (XTset_terminal_modes, XTreset_terminal_modes): Added display parameter.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-48
parent 08c8c725
-*- coding: utf-8; -*-
-*- coding: utf-8; mode: text; -*-
GOAL
----
......@@ -131,7 +131,12 @@ THINGS TO DO
sessions automatically convert the face colors to terminal colors
when the face is loaded. This conversion must happen instead on
the fly in write_glyphs, which might be problematic, as color
approximation is done in lisp (term/tty-colors.el).)
approximation is currently done in lisp (term/tty-colors.el).)
** frame-creation-function should always create a frame that is on the
same display as the selected frame. Maybe frame-creation-function
should simply be removed and make-frame changed to do the right
thing.
** The command `emacsclient -t -e '(delete-frame)'' fails to exit.
......@@ -141,6 +146,11 @@ THINGS TO DO
extend emacsclient to handle suspend/resume. A `kill -STOP' almost
works right now.)
** If there are no frames on its controlling terminal, Emacs should
exit if the uses presses C-c there. (See the SIGTERM comment in
interrupt_signal on why this seems to be impossible to solve
generally.)
** During an X session, Emacs seems to read from stdin.
** Move baud_rate to struct display.
......@@ -152,11 +162,20 @@ THINGS TO DO
an initial frame. (The user would connect to it and open frames
later, with emacsclient.) Not necessarily a good idea.
** Fix Mac support (I can't do this myself).
** Fix Mac support (I can't do this myself). Note that the current
state of Mac-specific source files in the multi-tty tree are not
useful; before starting work on Mac support, revert to pristine,
pre-multi-tty versions.
** Fix W32 support (I can't do this myself).
** Fix W32 support (I can't do this myself). Note that the current
state of W32-specific source files in the multi-tty tree are not
useful; before starting work on W32 support, revert to pristine,
pre-multi-tty versions.
** Fix DOS support (I can't do this myself).
** Fix DOS support (I can't do this myself). Note that the current
state of DOS-specific source files in the multi-tty tree are not
useful; before starting work on DOS support, revert to pristine,
pre-multi-tty versions.
** Do a grep on XXX and ?? for more issues.
......@@ -349,7 +368,7 @@ DIARY OF CHANGES
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
seems to be related to the xfreeing or bzeroing of
tty_output.Wcm. Maybe there are outside references to struct Wcm?
Why were these vars collected into a struct before multi-tty
support?)
......@@ -358,18 +377,18 @@ DIARY OF CHANGES
with hypothetical external references to Wcm, or any other
tty_output component; it was simply that delete_tty closed the
filehandles of secondary ttys twice, resulting in fclose doubly
free()ing memory. Utterly trivial matter. I love the C's memory
freeing memory. Utterly trivial matter. I love the C's memory
management, it puts hair on your chest.)
-- Support raw secondary terminals. (Note that SIGIO works only on
the controlling terminal.) Hint: extend read_input_waiting() for
the controlling terminal.) Hint: extend read_input_waiting for
multiple ttys and hopefully this will be fixed.
(Done, it seems to have been working already for some time. It
seems F_SETOWN does work, after all. Not sure what made it fail
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
read_input_waiting is only used in sys_select, don't change
it.) (Update: After adding X support, it's broken again.)
-- Find out why does Emacs abort when it wants to close its
......@@ -381,7 +400,7 @@ DIARY OF CHANGES
term_init/delete_tty. The hint was right, in a way.)
-- Issue with SIGIO: it needs to be disabled during redisplay. See if
fcntl() kernel behaviour could be emulated by emacsclient.
fcntl kernel behaviour could be emulated by emacsclient.
(Done. Simply disabled the SIGIO emulation hack in emacsclient.)
(Update: it was added back.)
......
......@@ -1137,7 +1137,7 @@ the question is inapplicable to a certain kind of display."
((eq frame-type 'pc)
16)
(t
(tty-display-color-cells)))))
(tty-display-color-cells display)))))
(defun display-visual-class (&optional display)
"Returns the visual class of DISPLAY.
......
......@@ -123,7 +123,7 @@ for the currently selected frame. The first 16 colors are taken from
`xterm-standard-colors', which see, while the rest are computed assuming
either the 88- or 256-color standard color scheme supported by latest
versions of xterm."
(let* ((ncolors (display-color-cells))
(let* ((ncolors (display-color-cells (selected-frame)))
(colors xterm-standard-colors)
(color (car colors)))
(if (> ncolors 0)
......
......@@ -2728,8 +2728,6 @@ extern Lisp_Object Qredisplay_dont_pause;
/* Defined in term.c */
extern void ring_bell P_ ((void));
extern void set_terminal_modes P_ ((void));
extern void reset_terminal_modes P_ ((void));
extern void update_begin P_ ((struct frame *));
extern void update_end P_ ((struct frame *));
extern void set_terminal_window P_ ((int));
......@@ -2740,7 +2738,7 @@ extern void background_highlight P_ ((struct tty_display_info *));
extern void clear_frame P_ ((void));
extern void clear_end_of_line P_ ((int));
extern void clear_end_of_line_raw P_ ((int));
extern void tty_clear_end_of_line P_ ((struct tty_display_info *, int));
extern void tty_clear_end_of_line P_ ((int));
extern void delete_glyphs P_ ((int));
extern void ins_del_lines P_ ((int, int));
extern int string_cost P_ ((char *));
......@@ -2748,8 +2746,9 @@ extern int per_line_cost P_ ((char *));
extern void calculate_costs P_ ((struct frame *));
extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
extern void tty_setup_colors P_ ((struct tty_display_info *, int));
extern struct display *term_init P_ ((char *, char *));
extern struct display *initial_term_init P_ ((void));
extern struct display *get_named_tty_display P_ ((char *));
extern struct display *init_initial_display P_ ((void));
extern struct display *term_init P_ ((char *, char *, int));
extern void fatal P_ ((/* char *, ... */));
void cursor_to P_ ((int, int));
extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
......
......@@ -3306,8 +3306,10 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
return Qnil;
update_begin (f);
#ifdef MSDOS
if (FRAME_MSDOS_P (f))
set_terminal_modes ();
set_terminal_modes (FRAME_DISPLAY (f));
#endif
clear_frame ();
clear_current_matrices (f);
update_end (f);
......@@ -3833,9 +3835,12 @@ update_frame (f, force_p, inhibit_hairy_id_p)
paused_p = update_frame_1 (f, force_p, inhibit_hairy_id_p);
update_end (f);
if (TTY_TERMSCRIPT (FRAME_TTY (f)))
fflush (TTY_TERMSCRIPT (FRAME_TTY (f)));
fflush (TTY_OUTPUT (FRAME_TTY (f)));
if (FRAME_TERMCAP_P (f))
{
if (TTY_TERMSCRIPT (FRAME_TTY (f)))
fflush (TTY_TERMSCRIPT (FRAME_TTY (f)));
fflush (TTY_OUTPUT (FRAME_TTY (f)));
}
/* Check window matrices for lost pointers. */
#if GLYPH_DEBUG
......@@ -6634,10 +6639,24 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
{
struct display *d;
d = term_init (0, terminal_type);
struct frame *f = XFRAME (selected_frame);
/* Open a display on the controlling tty. */
d = term_init (0, terminal_type, 1); /* Errors are fatal. */
/* Convert the initial frame to use the new display. */
if (! f->output_method == output_initial)
abort ();
f->output_method = d->type;
f->display = d;
d->display_info.tty->top_frame = selected_frame;
change_frame_size (XFRAME (selected_frame), FrameRows (d->display_info.tty), FrameCols (d->display_info.tty), 0, 0, 1);
/* Delete the initial display. */
if (--initial_display->reference_count == 0
&& initial_display->delete_display_hook)
(*initial_display->delete_display_hook) (initial_display);
}
{
......
......@@ -202,6 +202,7 @@ See also `frame-live-p'. */)
return Qnil;
switch (XFRAME (object)->output_method)
{
case output_initial: /* The initial frame is like a termcap frame. */
case output_termcap:
return Qt;
case output_x_window:
......@@ -502,15 +503,12 @@ make_minibuffer_frame ()
static int terminal_frame_count;
struct frame *
make_terminal_frame (tty_name, tty_type)
char *tty_name;
char *tty_type;
make_initial_frame (void)
{
register struct frame *f;
struct frame *f;
struct display *display;
Lisp_Object frame;
char name[20];
#ifdef MULTI_KBOARD
/* Create the initial keyboard. */
if (!initial_kboard)
......@@ -526,12 +524,51 @@ make_terminal_frame (tty_name, tty_type)
if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
Vframe_list = Qnil;
display = init_initial_display ();
f = make_frame (1);
XSETFRAME (frame, f);
Vframe_list = Fcons (frame, Vframe_list);
terminal_frame_count = 1;
f->name = build_string ("F1");
f->visible = 1;
f->async_visible = 1;
f->output_method = display->type;
f->display = display;
f->display->reference_count++;
f->output_data.nothing = 0;
FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
#ifdef MULTI_KBOARD
f->kboard = initial_kboard;
#endif
return f;
}
struct frame *
make_terminal_frame (tty_name, tty_type)
char *tty_name;
char *tty_type;
{
register struct frame *f;
struct display *display;
Lisp_Object frame;
char name[20];
/* Open the display before creating the new frame, because
create_tty_display might throw an error. */
if (initialized)
display = term_init (tty_name, tty_type);
else
display = initial_term_init ();
display = term_init (tty_name, tty_type, 0); /* Errors are not fatal. */
f = make_frame (1);
......
......@@ -41,6 +41,7 @@ extern int message_buf_print;
enum output_method
{
output_initial,
output_termcap,
output_x_window,
output_msdos_raw,
......@@ -462,6 +463,7 @@ typedef struct frame *FRAME_PTR;
#define WINDOW_FRAME(w) (w)->frame
/* Test a frame for particular kinds of display methods. */
#define FRAME_INITIAL_P(f) ((f)->output_method == output_initial)
#define FRAME_TERMCAP_P(f) ((f)->output_method == output_termcap)
#define FRAME_X_P(f) ((f)->output_method == output_x_window)
#define FRAME_W32_P(f) ((f)->output_method == output_w32)
......@@ -771,7 +773,8 @@ extern Lisp_Object Qframep, Qframe_live_p;
extern struct frame *last_nonminibuf_frame;
extern struct frame *make_terminal_frame P_ ((char *tty, char *tty_type));
extern struct frame *make_initial_frame P_ ((void));
extern struct frame *make_terminal_frame P_ ((char *, char *));
extern struct frame *make_frame P_ ((int));
#ifdef HAVE_WINDOW_SYSTEM
extern struct frame *make_minibuffer_frame P_ ((void));
......
......@@ -10281,8 +10281,26 @@ interrupt_signal (signalnum) /* If we don't have an argument, */
signal (SIGQUIT, interrupt_signal);
#endif /* USG */
if (! tty_list)
{
/* If there are no tty frames, exit Emacs.
Emacs should exit on SIGINT if and only if there are no
frames on its controlling tty and the signal came from there.
We can check for the first condition, but (alas) not for the
second. The best we can do is that we only exit if we are
sure that the SIGINT was from the controlling tty, i.e., if
there are no termcap frames.
*/
Fkill_emacs (Qnil);
errno = old_errno;
return;
}
cancel_echoing ();
/* XXX This code needs to be revised for multi-tty support. */
if (!NILP (Vquit_flag)
&& (FRAME_TERMCAP_P (sf) || FRAME_MSDOS_P (sf)))
{
......@@ -10463,7 +10481,7 @@ See also `current-input-mode'. */)
#ifndef DOS_NT
/* this causes startup screen to be restored and messes with the mouse */
if (FRAME_TERMCAP_P (SELECTED_FRAME ()) && CURTTY ()->type)
if (FRAME_TERMCAP_P (SELECTED_FRAME ()))
reset_sys_modes (CURTTY ());
#endif
......@@ -10502,7 +10520,7 @@ See also `current-input-mode'. */)
tty->meta_key = 2;
}
if (!NILP (quit))
if (FRAME_TERMCAP_P (XFRAME (selected_frame)) && !NILP (quit))
/* Don't let this value be out of range. */
quit_char = XINT (quit) & (CURTTY ()->meta_key ? 0377 : 0177);
......@@ -10660,6 +10678,11 @@ init_keyboard ()
if (!noninteractive)
{
/* Before multi-tty support, these handlers used to be installed
only if the current session was a tty session. Now an Emacs
session may have multiple display types, so we always handle
SIGINT. There is special code in interrupt_signal to exit
Emacs on SIGINT when there are no termcap frames. */
signal (SIGINT, interrupt_signal);
#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
/* For systems with SysV TERMIO, C-g is set up for both SIGINT and
......
......@@ -1689,7 +1689,7 @@ nil means don't delete them until `list-processes' is run. */);
)
#endif
#endif
tty_set_terminal_modes (tty_out);
tty_set_terminal_modes (tty_out->display);
if (!tty_out->term_initted)
{
......@@ -1869,7 +1869,9 @@ reset_sys_modes (tty_out)
#endif
cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
#if 0 /* XXX This doesn't work anymore, the signature has changed. */
tty_clear_end_of_line (tty_out, FrameCols (tty_out));
#endif
cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
fflush (tty_out->output);
......@@ -1884,7 +1886,7 @@ reset_sys_modes (tty_out)
}
#endif
tty_reset_terminal_modes (tty_out);
tty_reset_terminal_modes (tty_out->display);
fflush (TTY_OUTPUT (tty_out));
#ifdef BSD_SYSTEM
#ifndef BSD4_1
......
This diff is collapsed.
......@@ -52,6 +52,9 @@ struct tty_display_info
int reference_count; /* Number of frames that are on this display. */
struct display *display; /* Points back to the generic display
structure. This is sometimes handy. */
/* Info on cursor positioning. */
struct cm *Wcm;
......
......@@ -344,8 +344,8 @@ struct display
void (*ring_bell_hook) P_ ((void));
void (*reset_terminal_modes_hook) P_ ((void));
void (*set_terminal_modes_hook) P_ ((void));
void (*reset_terminal_modes_hook) P_ ((struct display *));
void (*set_terminal_modes_hook) P_ ((struct display *));
void (*update_begin_hook) P_ ((struct frame *));
void (*update_end_hook) P_ ((struct frame *));
void (*set_terminal_window_hook) P_ ((int));
......
......@@ -6394,7 +6394,7 @@ and scrolling positions. */)
void
init_window_once ()
{
struct frame *f = make_terminal_frame (0, 0);
struct frame *f = make_initial_frame ();
XSETFRAME (selected_frame, f);
Vterminal_frame = selected_frame;
minibuf_window = f->minibuffer_window;
......
......@@ -6728,7 +6728,7 @@ realize_default_face (f)
LFACE_FOREGROUND (lface) = XCDR (color);
else if (FRAME_WINDOW_P (f))
return 0;
else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
LFACE_FOREGROUND (lface) = build_string (unspecified_fg);
else
abort ();
......@@ -6743,7 +6743,7 @@ realize_default_face (f)
LFACE_BACKGROUND (lface) = XCDR (color);
else if (FRAME_WINDOW_P (f))
return 0;
else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
else if (FRAME_INITIAL_P (f) || FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
LFACE_BACKGROUND (lface) = build_string (unspecified_bg);
else
abort ();
......@@ -6830,7 +6830,7 @@ realize_face (cache, attrs, c, base_face, former_face_id)
if (FRAME_WINDOW_P (cache->f))
face = realize_x_face (cache, attrs, c, base_face);
else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f))
else if (FRAME_INITIAL_P (cache->f) || FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f))
face = realize_tty_face (cache, attrs, c);
else
abort ();
......
......@@ -331,8 +331,8 @@ static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
static int x_compute_min_glyph_bounds P_ ((struct frame *));
static void x_update_end P_ ((struct frame *));
static void XTframe_up_to_date P_ ((struct frame *));
static void XTset_terminal_modes P_ ((void));
static void XTreset_terminal_modes P_ ((void));
static void XTset_terminal_modes P_ ((struct display *));
static void XTreset_terminal_modes P_ ((struct display *));
static void x_clear_frame P_ ((void));
static void frame_highlight P_ ((struct frame *));
static void frame_unhighlight P_ ((struct frame *));
......@@ -747,7 +747,7 @@ x_draw_fringe_bitmap (w, row, p)
rarely happens). */
static void
XTset_terminal_modes ()
XTset_terminal_modes (struct display *display)
{
}
......@@ -755,7 +755,7 @@ XTset_terminal_modes ()
the X-windows go away, and suspending requires no action. */
static void
XTreset_terminal_modes ()
XTreset_terminal_modes (struct display *display)
{
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment