Commit 7b00d185 authored by Karoly Lorentey's avatar Karoly Lorentey

MULTI_KBOARD support for ttys. Input-related bugfixes for X+tty sessions.

lib-src/emacsclient.c (pty_conversation): Fix errno check for read from fileno(in).

src/config.in: Unconditionally define MULTI_KBOARD.

src/frame.c (make_terminal_frame): Initialize f->kboard.

src/keyboard.c (cmd_error_internal): Don't kill Emacs if a Quit was
pressed on the tty of a X+tty session.
(read_avail_input): Initialize nread to zero.  Abort if there is no
tty after a termcap read.
(interrupt_signal)[USG]: Always reset signal handler.
(init_keyboard): Always set signal handler for SIGINT/SIGQUIT if
noninteractive.

src/term.c (term_dummy_init): Initialize kboard to the initial_kboard.
(term_init): Free component structures of the initial tty. Clear xmalloced structures.
Moved rif initialization to syms_of_term.
(term_init)[MULTI_KBOARD]: Initialize tty->kboard.
(delete_tty)[MULTI_KBOARD]: Delete the keyboard.
(syms_of_term): Initialize tty_display_method_template.

src/termchar.h (tty_output)[MULTI_KBOARD]: Added kboard member.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-31
parent daf01701
This diff is collapsed.
......@@ -794,7 +794,7 @@ pty_conversation (FILE *in)
{
do {
res = read (fileno (in), string, BUFSIZ-1);
} while (res == EINTR);
} while (res < 0 && errno == EINTR);
if (res < 0)
{
reset_tty ();
......
......@@ -383,7 +383,7 @@ set print sevenbit-strings
show environment DISPLAY
show environment TERM
set args -geometry 80x40+0+0
#set args -geometry 80x40+0+0
# Don't let abort actually run, as it will make
# stdio stop working and therefore the `pr' command above as well.
......
......@@ -863,6 +863,12 @@ Boston, MA 02111-1307, USA. */
#define HAVE_MOUSE
#endif
/* Multi-tty support relies on MULTI_KBOARD. It seems safe to turn it
on unconditionally. */
#ifndef MULTI_KBOARD
#define MULTI_KBOARD
#endif
/* Define USER_FULL_NAME to return a string
that is the user's full name.
It can assume that the variable `pw'
......
......@@ -488,6 +488,7 @@ make_terminal_frame (tty_name, tty_type)
char name[20];
#ifdef MULTI_KBOARD
/* Create the initial keyboard. */
if (!initial_kboard)
{
initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
......@@ -567,6 +568,9 @@ make_terminal_frame (tty_name, tty_type)
}
FRAME_TTY (f)->reference_count++;
f->display_method = FRAME_TTY (f)->display_method;
#ifdef MULTI_KBOARD
f->kboard = FRAME_TTY (f)->kboard;
#endif
}
#ifdef CANNOT_DUMP
......
......@@ -292,8 +292,10 @@ struct frame
#ifdef MULTI_KBOARD
/* A pointer to the kboard structure associated with this frame.
For termcap frames, this points to initial_kboard. For X frames,
it will be the same as display.x->display_info->kboard. */
For termcap frames, it will be the same as
output_data.tty->display_info->kboard.
For X frames, it will be the same as
output_data.x->display_info->kboard. */
struct kboard *kboard;
#endif
......
......@@ -1205,7 +1205,8 @@ cmd_error_internal (data, context)
running under a window system. */
|| (!NILP (Vwindow_system)
&& !inhibit_window_system
&& FRAME_TERMCAP_P (sf))
&& FRAME_TERMCAP_P (sf)
&& !FRAME_TTY (sf)->type) /* XXX This is ugly. */
|| noninteractive)
{
stream = Qexternal_debugging_output;
......@@ -6594,7 +6595,7 @@ read_avail_input (expected)
{
struct input_event buf[KBD_BUFFER_SIZE];
register int i;
int nread;
int nread = 0;
for (i = 0; i < KBD_BUFFER_SIZE; i++)
EVENT_INIT (buf[i]);
......@@ -6738,10 +6739,13 @@ read_avail_input (expected)
#endif /* not MSDOS */
#endif /* not WINDOWSNT */
if (!tty)
abort ();
/* Select frame corresponding to the active tty. Note that the
value of selected_frame is not reliable here, redisplay tends
to temporarily change it. But tty should always be non-NULL. */
frame = (tty ? tty->top_frame : selected_frame);
frame = tty->top_frame;
for (i = 0; i < nread; i++)
{
......@@ -10245,13 +10249,10 @@ interrupt_signal (signalnum) /* If we don't have an argument, */
struct frame *sf = SELECTED_FRAME ();
#if defined (USG) && !defined (POSIX_SIGNALS)
if (!read_socket_hook && NILP (Vwindow_system))
{
/* USG systems forget handlers when they are used;
must reestablish each time */
signal (SIGINT, interrupt_signal);
signal (SIGQUIT, interrupt_signal);
}
/* USG systems forget handlers when they are used;
must reestablish each time */
signal (SIGINT, interrupt_signal);
signal (SIGQUIT, interrupt_signal);
#endif /* USG */
cancel_echoing ();
......@@ -10626,7 +10627,7 @@ init_keyboard ()
wipe_kboard (current_kboard);
init_kboard (current_kboard);
if (!noninteractive && !read_socket_hook && NILP (Vwindow_system))
if (!noninteractive)
{
signal (SIGINT, interrupt_signal);
#if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
......
......@@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA. */
/* Length of echobuf field in each KBOARD. */
/* Each KBOARD represents one logical input stream from which Emacs gets input.
If we are using an ordinary terminal, it has one KBOARD object.
If we are using ordinary terminals, it has one KBOARD object for each terminal device.
Usually each X display screen has its own KBOARD,
but when two of them are on the same X server,
we assume they share a keyboard and give them one KBOARD in common.
......@@ -152,7 +152,7 @@ struct kboard
};
#ifdef MULTI_KBOARD
/* Temporarily used before a frame has been opened, and for termcap frames */
/* Temporarily used before a frame has been opened. */
extern KBOARD *initial_kboard;
/* In the single-kboard state, this is the kboard
......
......@@ -2189,6 +2189,7 @@ term_dummy_init (void)
tty_list->output = stdout;
tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method));
tty_list->kboard = initial_kboard;
return tty_list;
}
......@@ -2212,6 +2213,15 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
the dummy terminal created for the initial frame. */
if (tty->type)
return tty;
/* Free up temporary structures. */
if (tty->Wcm)
xfree (tty->Wcm);
if (tty->display_method)
xfree (tty->display_method);
if (tty->kboard != initial_kboard)
abort ();
tty->kboard = 0;
}
else
{
......@@ -2221,20 +2231,18 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
tty_list = tty;
}
if (! tty->Wcm)
tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
Wcm_clear (tty);
if (! tty->display_method)
tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method));
/* Each termcap frame has its own display method. */
tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method));
bzero (tty->display_method, sizeof (struct display_method));
/* Initialize the common members in the new display method with our
predefined template. */
*tty->display_method = tty_display_method_template;
f->display_method = tty->display_method;
/* Termcap-based displays don't support window-based redisplay. */
f->display_method->rif = 0;
/* Make sure the frame is live; if an error happens, it must be
deleted. */
f->output_method = output_termcap;
......@@ -2278,7 +2286,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
FrameCols (tty) = FRAME_COLS (f);
tty->specified_window = FRAME_LINES (f);
f->display_method->delete_in_insert_mode = 1;
tty->display_method->delete_in_insert_mode = 1;
UseTabs (tty) = 0;
FRAME_SCROLL_REGION_OK (f) = 0;
......@@ -2509,7 +2517,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
}
#if 0 /* This is not used anywhere. */
f->display_method->min_padding_speed = tgetnum ("pb");
tty->display_method->min_padding_speed = tgetnum ("pb");
#endif
TabWidth (tty) = tgetnum ("tw");
......@@ -2723,6 +2731,19 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
FRAME_CHAR_INS_DEL_OK (f) = 0;
#endif
#ifdef MULTI_KBOARD
tty->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
init_kboard (tty->kboard);
tty->kboard->next_kboard = all_kboards;
all_kboards = tty->kboard;
/* Don't let the initial kboard remain current longer than necessary.
That would cause problems if a file loaded on startup tries to
prompt in the mini-buffer. */
if (current_kboard == initial_kboard)
current_kboard = tty->kboard;
tty->kboard->reference_count++;
#endif
/* Don't do this. I think termcap may still need the buffer. */
/* xfree (buffer); */
......@@ -2735,7 +2756,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
tty_set_terminal_modes (tty);
return tty;
#endif /* WINDOWSNT */
#endif /* not WINDOWSNT */
}
/* VARARGS 1 */
......@@ -2844,6 +2865,13 @@ delete_tty (struct tty_display_info *tty)
if (tty->display_method)
xfree (tty->display_method);
#ifdef MULTI_KBOARD
if (tty->kboard && --tty->kboard->reference_count > 0)
abort ();
if (tty->kboard)
delete_kboard (tty->kboard);
#endif
bzero (tty, sizeof (struct tty_display_info));
xfree (tty);
deleting_tty = 0;
......@@ -2897,9 +2925,13 @@ The function should accept no arguments. */);
defsubr (&Sframe_tty_type);
defsubr (&Sdelete_tty);
/* XXX tty_display_method_template initialization will go here. */
Fprovide (intern ("multi-tty"), Qnil);
/* Initialize the display method template. */
/* Termcap-based displays don't support window-based redisplay. */
tty_display_method_template.rif = 0;
}
......
......@@ -182,6 +182,11 @@ struct tty_display_info
/* This is a copy of struct frame's display_method value; needed for
freeing up memory when deleting the tty. */
struct display_method *display_method;
#ifdef MULTI_KBOARD
/* The terminal's keyboard object. */
struct kboard *kboard;
#endif
};
/* A chain of structures for all tty devices currently in use. */
......
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