diff options
| author | Karoly Lorentey | 2004-01-02 02:54:17 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-01-02 02:54:17 +0000 |
| commit | 7b00d185eba8e01f191a69740e3270c88f88159c (patch) | |
| tree | 1bddf818e98404035261883f3cbfc5e4c80f40bf /src | |
| parent | daf0170133e658c41f3ae2fc8558c5ab74227c1d (diff) | |
| download | emacs-7b00d185eba8e01f191a69740e3270c88f88159c.tar.gz emacs-7b00d185eba8e01f191a69740e3270c88f88159c.zip | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/.gdbinit | 2 | ||||
| -rw-r--r-- | src/config.in | 6 | ||||
| -rw-r--r-- | src/frame.c | 4 | ||||
| -rw-r--r-- | src/frame.h | 6 | ||||
| -rw-r--r-- | src/keyboard.c | 23 | ||||
| -rw-r--r-- | src/keyboard.h | 4 | ||||
| -rw-r--r-- | src/term.c | 56 | ||||
| -rw-r--r-- | src/termchar.h | 5 |
8 files changed, 78 insertions, 28 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index ccc36694da8..145f4f4df87 100644 --- a/src/.gdbinit +++ b/src/.gdbinit | |||
| @@ -383,7 +383,7 @@ set print sevenbit-strings | |||
| 383 | 383 | ||
| 384 | show environment DISPLAY | 384 | show environment DISPLAY |
| 385 | show environment TERM | 385 | show environment TERM |
| 386 | set args -geometry 80x40+0+0 | 386 | #set args -geometry 80x40+0+0 |
| 387 | 387 | ||
| 388 | # Don't let abort actually run, as it will make | 388 | # Don't let abort actually run, as it will make |
| 389 | # stdio stop working and therefore the `pr' command above as well. | 389 | # stdio stop working and therefore the `pr' command above as well. |
diff --git a/src/config.in b/src/config.in index 0fb4b3f3444..4fe82cd8f2d 100644 --- a/src/config.in +++ b/src/config.in | |||
| @@ -863,6 +863,12 @@ Boston, MA 02111-1307, USA. */ | |||
| 863 | #define HAVE_MOUSE | 863 | #define HAVE_MOUSE |
| 864 | #endif | 864 | #endif |
| 865 | 865 | ||
| 866 | /* Multi-tty support relies on MULTI_KBOARD. It seems safe to turn it | ||
| 867 | on unconditionally. */ | ||
| 868 | #ifndef MULTI_KBOARD | ||
| 869 | #define MULTI_KBOARD | ||
| 870 | #endif | ||
| 871 | |||
| 866 | /* Define USER_FULL_NAME to return a string | 872 | /* Define USER_FULL_NAME to return a string |
| 867 | that is the user's full name. | 873 | that is the user's full name. |
| 868 | It can assume that the variable `pw' | 874 | It can assume that the variable `pw' |
diff --git a/src/frame.c b/src/frame.c index 0b407181a6b..d1c0a220afb 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -488,6 +488,7 @@ make_terminal_frame (tty_name, tty_type) | |||
| 488 | char name[20]; | 488 | char name[20]; |
| 489 | 489 | ||
| 490 | #ifdef MULTI_KBOARD | 490 | #ifdef MULTI_KBOARD |
| 491 | /* Create the initial keyboard. */ | ||
| 491 | if (!initial_kboard) | 492 | if (!initial_kboard) |
| 492 | { | 493 | { |
| 493 | initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 494 | initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); |
| @@ -567,6 +568,9 @@ make_terminal_frame (tty_name, tty_type) | |||
| 567 | } | 568 | } |
| 568 | FRAME_TTY (f)->reference_count++; | 569 | FRAME_TTY (f)->reference_count++; |
| 569 | f->display_method = FRAME_TTY (f)->display_method; | 570 | f->display_method = FRAME_TTY (f)->display_method; |
| 571 | #ifdef MULTI_KBOARD | ||
| 572 | f->kboard = FRAME_TTY (f)->kboard; | ||
| 573 | #endif | ||
| 570 | } | 574 | } |
| 571 | 575 | ||
| 572 | #ifdef CANNOT_DUMP | 576 | #ifdef CANNOT_DUMP |
diff --git a/src/frame.h b/src/frame.h index 4a67744edaa..4bd52204886 100644 --- a/src/frame.h +++ b/src/frame.h | |||
| @@ -292,8 +292,10 @@ struct frame | |||
| 292 | 292 | ||
| 293 | #ifdef MULTI_KBOARD | 293 | #ifdef MULTI_KBOARD |
| 294 | /* A pointer to the kboard structure associated with this frame. | 294 | /* A pointer to the kboard structure associated with this frame. |
| 295 | For termcap frames, this points to initial_kboard. For X frames, | 295 | For termcap frames, it will be the same as |
| 296 | it will be the same as display.x->display_info->kboard. */ | 296 | output_data.tty->display_info->kboard. |
| 297 | For X frames, it will be the same as | ||
| 298 | output_data.x->display_info->kboard. */ | ||
| 297 | struct kboard *kboard; | 299 | struct kboard *kboard; |
| 298 | #endif | 300 | #endif |
| 299 | 301 | ||
diff --git a/src/keyboard.c b/src/keyboard.c index 532257e797f..d849b9ce4d6 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1205,7 +1205,8 @@ cmd_error_internal (data, context) | |||
| 1205 | running under a window system. */ | 1205 | running under a window system. */ |
| 1206 | || (!NILP (Vwindow_system) | 1206 | || (!NILP (Vwindow_system) |
| 1207 | && !inhibit_window_system | 1207 | && !inhibit_window_system |
| 1208 | && FRAME_TERMCAP_P (sf)) | 1208 | && FRAME_TERMCAP_P (sf) |
| 1209 | && !FRAME_TTY (sf)->type) /* XXX This is ugly. */ | ||
| 1209 | || noninteractive) | 1210 | || noninteractive) |
| 1210 | { | 1211 | { |
| 1211 | stream = Qexternal_debugging_output; | 1212 | stream = Qexternal_debugging_output; |
| @@ -6594,7 +6595,7 @@ read_avail_input (expected) | |||
| 6594 | { | 6595 | { |
| 6595 | struct input_event buf[KBD_BUFFER_SIZE]; | 6596 | struct input_event buf[KBD_BUFFER_SIZE]; |
| 6596 | register int i; | 6597 | register int i; |
| 6597 | int nread; | 6598 | int nread = 0; |
| 6598 | 6599 | ||
| 6599 | for (i = 0; i < KBD_BUFFER_SIZE; i++) | 6600 | for (i = 0; i < KBD_BUFFER_SIZE; i++) |
| 6600 | EVENT_INIT (buf[i]); | 6601 | EVENT_INIT (buf[i]); |
| @@ -6738,10 +6739,13 @@ read_avail_input (expected) | |||
| 6738 | #endif /* not MSDOS */ | 6739 | #endif /* not MSDOS */ |
| 6739 | #endif /* not WINDOWSNT */ | 6740 | #endif /* not WINDOWSNT */ |
| 6740 | 6741 | ||
| 6742 | if (!tty) | ||
| 6743 | abort (); | ||
| 6744 | |||
| 6741 | /* Select frame corresponding to the active tty. Note that the | 6745 | /* Select frame corresponding to the active tty. Note that the |
| 6742 | value of selected_frame is not reliable here, redisplay tends | 6746 | value of selected_frame is not reliable here, redisplay tends |
| 6743 | to temporarily change it. But tty should always be non-NULL. */ | 6747 | to temporarily change it. But tty should always be non-NULL. */ |
| 6744 | frame = (tty ? tty->top_frame : selected_frame); | 6748 | frame = tty->top_frame; |
| 6745 | 6749 | ||
| 6746 | for (i = 0; i < nread; i++) | 6750 | for (i = 0; i < nread; i++) |
| 6747 | { | 6751 | { |
| @@ -10245,13 +10249,10 @@ interrupt_signal (signalnum) /* If we don't have an argument, */ | |||
| 10245 | struct frame *sf = SELECTED_FRAME (); | 10249 | struct frame *sf = SELECTED_FRAME (); |
| 10246 | 10250 | ||
| 10247 | #if defined (USG) && !defined (POSIX_SIGNALS) | 10251 | #if defined (USG) && !defined (POSIX_SIGNALS) |
| 10248 | if (!read_socket_hook && NILP (Vwindow_system)) | 10252 | /* USG systems forget handlers when they are used; |
| 10249 | { | 10253 | must reestablish each time */ |
| 10250 | /* USG systems forget handlers when they are used; | 10254 | signal (SIGINT, interrupt_signal); |
| 10251 | must reestablish each time */ | 10255 | signal (SIGQUIT, interrupt_signal); |
| 10252 | signal (SIGINT, interrupt_signal); | ||
| 10253 | signal (SIGQUIT, interrupt_signal); | ||
| 10254 | } | ||
| 10255 | #endif /* USG */ | 10256 | #endif /* USG */ |
| 10256 | 10257 | ||
| 10257 | cancel_echoing (); | 10258 | cancel_echoing (); |
| @@ -10626,7 +10627,7 @@ init_keyboard () | |||
| 10626 | wipe_kboard (current_kboard); | 10627 | wipe_kboard (current_kboard); |
| 10627 | init_kboard (current_kboard); | 10628 | init_kboard (current_kboard); |
| 10628 | 10629 | ||
| 10629 | if (!noninteractive && !read_socket_hook && NILP (Vwindow_system)) | 10630 | if (!noninteractive) |
| 10630 | { | 10631 | { |
| 10631 | signal (SIGINT, interrupt_signal); | 10632 | signal (SIGINT, interrupt_signal); |
| 10632 | #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) | 10633 | #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) |
diff --git a/src/keyboard.h b/src/keyboard.h index 6a8e08d41f3..6c6e0344771 100644 --- a/src/keyboard.h +++ b/src/keyboard.h | |||
| @@ -21,7 +21,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 21 | /* Length of echobuf field in each KBOARD. */ | 21 | /* Length of echobuf field in each KBOARD. */ |
| 22 | 22 | ||
| 23 | /* Each KBOARD represents one logical input stream from which Emacs gets input. | 23 | /* Each KBOARD represents one logical input stream from which Emacs gets input. |
| 24 | If we are using an ordinary terminal, it has one KBOARD object. | 24 | If we are using ordinary terminals, it has one KBOARD object for each terminal device. |
| 25 | Usually each X display screen has its own KBOARD, | 25 | Usually each X display screen has its own KBOARD, |
| 26 | but when two of them are on the same X server, | 26 | but when two of them are on the same X server, |
| 27 | we assume they share a keyboard and give them one KBOARD in common. | 27 | we assume they share a keyboard and give them one KBOARD in common. |
| @@ -152,7 +152,7 @@ struct kboard | |||
| 152 | }; | 152 | }; |
| 153 | 153 | ||
| 154 | #ifdef MULTI_KBOARD | 154 | #ifdef MULTI_KBOARD |
| 155 | /* Temporarily used before a frame has been opened, and for termcap frames */ | 155 | /* Temporarily used before a frame has been opened. */ |
| 156 | extern KBOARD *initial_kboard; | 156 | extern KBOARD *initial_kboard; |
| 157 | 157 | ||
| 158 | /* In the single-kboard state, this is the kboard | 158 | /* In the single-kboard state, this is the kboard |
diff --git a/src/term.c b/src/term.c index c8310b5b85b..b35a20a2ff0 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2189,6 +2189,7 @@ term_dummy_init (void) | |||
| 2189 | tty_list->output = stdout; | 2189 | tty_list->output = stdout; |
| 2190 | tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | 2190 | tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); |
| 2191 | tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); | 2191 | tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); |
| 2192 | tty_list->kboard = initial_kboard; | ||
| 2192 | return tty_list; | 2193 | return tty_list; |
| 2193 | } | 2194 | } |
| 2194 | 2195 | ||
| @@ -2212,6 +2213,15 @@ term_init (Lisp_Object frame, char *name, char *terminal_type) | |||
| 2212 | the dummy terminal created for the initial frame. */ | 2213 | the dummy terminal created for the initial frame. */ |
| 2213 | if (tty->type) | 2214 | if (tty->type) |
| 2214 | return tty; | 2215 | return tty; |
| 2216 | |||
| 2217 | /* Free up temporary structures. */ | ||
| 2218 | if (tty->Wcm) | ||
| 2219 | xfree (tty->Wcm); | ||
| 2220 | if (tty->display_method) | ||
| 2221 | xfree (tty->display_method); | ||
| 2222 | if (tty->kboard != initial_kboard) | ||
| 2223 | abort (); | ||
| 2224 | tty->kboard = 0; | ||
| 2215 | } | 2225 | } |
| 2216 | else | 2226 | else |
| 2217 | { | 2227 | { |
| @@ -2221,20 +2231,18 @@ term_init (Lisp_Object frame, char *name, char *terminal_type) | |||
| 2221 | tty_list = tty; | 2231 | tty_list = tty; |
| 2222 | } | 2232 | } |
| 2223 | 2233 | ||
| 2224 | if (! tty->Wcm) | 2234 | tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); |
| 2225 | tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | 2235 | Wcm_clear (tty); |
| 2226 | 2236 | ||
| 2227 | if (! tty->display_method) | 2237 | /* Each termcap frame has its own display method. */ |
| 2228 | tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); | 2238 | tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); |
| 2239 | bzero (tty->display_method, sizeof (struct display_method)); | ||
| 2229 | 2240 | ||
| 2230 | /* Initialize the common members in the new display method with our | 2241 | /* Initialize the common members in the new display method with our |
| 2231 | predefined template. */ | 2242 | predefined template. */ |
| 2232 | *tty->display_method = tty_display_method_template; | 2243 | *tty->display_method = tty_display_method_template; |
| 2233 | f->display_method = tty->display_method; | 2244 | f->display_method = tty->display_method; |
| 2234 | 2245 | ||
| 2235 | /* Termcap-based displays don't support window-based redisplay. */ | ||
| 2236 | f->display_method->rif = 0; | ||
| 2237 | |||
| 2238 | /* Make sure the frame is live; if an error happens, it must be | 2246 | /* Make sure the frame is live; if an error happens, it must be |
| 2239 | deleted. */ | 2247 | deleted. */ |
| 2240 | f->output_method = output_termcap; | 2248 | f->output_method = output_termcap; |
| @@ -2278,7 +2286,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type) | |||
| 2278 | FrameCols (tty) = FRAME_COLS (f); | 2286 | FrameCols (tty) = FRAME_COLS (f); |
| 2279 | tty->specified_window = FRAME_LINES (f); | 2287 | tty->specified_window = FRAME_LINES (f); |
| 2280 | 2288 | ||
| 2281 | f->display_method->delete_in_insert_mode = 1; | 2289 | tty->display_method->delete_in_insert_mode = 1; |
| 2282 | 2290 | ||
| 2283 | UseTabs (tty) = 0; | 2291 | UseTabs (tty) = 0; |
| 2284 | FRAME_SCROLL_REGION_OK (f) = 0; | 2292 | FRAME_SCROLL_REGION_OK (f) = 0; |
| @@ -2509,7 +2517,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2509 | } | 2517 | } |
| 2510 | 2518 | ||
| 2511 | #if 0 /* This is not used anywhere. */ | 2519 | #if 0 /* This is not used anywhere. */ |
| 2512 | f->display_method->min_padding_speed = tgetnum ("pb"); | 2520 | tty->display_method->min_padding_speed = tgetnum ("pb"); |
| 2513 | #endif | 2521 | #endif |
| 2514 | 2522 | ||
| 2515 | TabWidth (tty) = tgetnum ("tw"); | 2523 | TabWidth (tty) = tgetnum ("tw"); |
| @@ -2723,6 +2731,19 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2723 | FRAME_CHAR_INS_DEL_OK (f) = 0; | 2731 | FRAME_CHAR_INS_DEL_OK (f) = 0; |
| 2724 | #endif | 2732 | #endif |
| 2725 | 2733 | ||
| 2734 | #ifdef MULTI_KBOARD | ||
| 2735 | tty->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | ||
| 2736 | init_kboard (tty->kboard); | ||
| 2737 | tty->kboard->next_kboard = all_kboards; | ||
| 2738 | all_kboards = tty->kboard; | ||
| 2739 | /* Don't let the initial kboard remain current longer than necessary. | ||
| 2740 | That would cause problems if a file loaded on startup tries to | ||
| 2741 | prompt in the mini-buffer. */ | ||
| 2742 | if (current_kboard == initial_kboard) | ||
| 2743 | current_kboard = tty->kboard; | ||
| 2744 | tty->kboard->reference_count++; | ||
| 2745 | #endif | ||
| 2746 | |||
| 2726 | /* Don't do this. I think termcap may still need the buffer. */ | 2747 | /* Don't do this. I think termcap may still need the buffer. */ |
| 2727 | /* xfree (buffer); */ | 2748 | /* xfree (buffer); */ |
| 2728 | 2749 | ||
| @@ -2735,7 +2756,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2735 | tty_set_terminal_modes (tty); | 2756 | tty_set_terminal_modes (tty); |
| 2736 | 2757 | ||
| 2737 | return tty; | 2758 | return tty; |
| 2738 | #endif /* WINDOWSNT */ | 2759 | #endif /* not WINDOWSNT */ |
| 2739 | } | 2760 | } |
| 2740 | 2761 | ||
| 2741 | /* VARARGS 1 */ | 2762 | /* VARARGS 1 */ |
| @@ -2844,6 +2865,13 @@ delete_tty (struct tty_display_info *tty) | |||
| 2844 | if (tty->display_method) | 2865 | if (tty->display_method) |
| 2845 | xfree (tty->display_method); | 2866 | xfree (tty->display_method); |
| 2846 | 2867 | ||
| 2868 | #ifdef MULTI_KBOARD | ||
| 2869 | if (tty->kboard && --tty->kboard->reference_count > 0) | ||
| 2870 | abort (); | ||
| 2871 | if (tty->kboard) | ||
| 2872 | delete_kboard (tty->kboard); | ||
| 2873 | #endif | ||
| 2874 | |||
| 2847 | bzero (tty, sizeof (struct tty_display_info)); | 2875 | bzero (tty, sizeof (struct tty_display_info)); |
| 2848 | xfree (tty); | 2876 | xfree (tty); |
| 2849 | deleting_tty = 0; | 2877 | deleting_tty = 0; |
| @@ -2897,9 +2925,13 @@ The function should accept no arguments. */); | |||
| 2897 | defsubr (&Sframe_tty_type); | 2925 | defsubr (&Sframe_tty_type); |
| 2898 | defsubr (&Sdelete_tty); | 2926 | defsubr (&Sdelete_tty); |
| 2899 | 2927 | ||
| 2900 | /* XXX tty_display_method_template initialization will go here. */ | ||
| 2901 | |||
| 2902 | Fprovide (intern ("multi-tty"), Qnil); | 2928 | Fprovide (intern ("multi-tty"), Qnil); |
| 2929 | |||
| 2930 | /* Initialize the display method template. */ | ||
| 2931 | |||
| 2932 | /* Termcap-based displays don't support window-based redisplay. */ | ||
| 2933 | tty_display_method_template.rif = 0; | ||
| 2934 | |||
| 2903 | } | 2935 | } |
| 2904 | 2936 | ||
| 2905 | 2937 | ||
diff --git a/src/termchar.h b/src/termchar.h index c54c1dde061..5b9082917fb 100644 --- a/src/termchar.h +++ b/src/termchar.h | |||
| @@ -182,6 +182,11 @@ struct tty_display_info | |||
| 182 | /* This is a copy of struct frame's display_method value; needed for | 182 | /* This is a copy of struct frame's display_method value; needed for |
| 183 | freeing up memory when deleting the tty. */ | 183 | freeing up memory when deleting the tty. */ |
| 184 | struct display_method *display_method; | 184 | struct display_method *display_method; |
| 185 | |||
| 186 | #ifdef MULTI_KBOARD | ||
| 187 | /* The terminal's keyboard object. */ | ||
| 188 | struct kboard *kboard; | ||
| 189 | #endif | ||
| 185 | }; | 190 | }; |
| 186 | 191 | ||
| 187 | /* A chain of structures for all tty devices currently in use. */ | 192 | /* A chain of structures for all tty devices currently in use. */ |