diff options
| author | Karoly Lorentey | 2003-12-29 07:16:26 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2003-12-29 07:16:26 +0000 |
| commit | 0a1258976b3ac8f6ffc56115def6bd2e5b76f8bc (patch) | |
| tree | 350c7e580c8d856ec227d350cf396dacac4ce20a /src/term.c | |
| parent | 04c3243c2a25812c6d0a324d29b8fd1d5acaa715 (diff) | |
| download | emacs-0a1258976b3ac8f6ffc56115def6bd2e5b76f8bc.tar.gz emacs-0a1258976b3ac8f6ffc56115def6bd2e5b76f8bc.zip | |
Bugfix festival.
lib-src/emacsclient.c (main_argc, main_argv): New variables.
(main): Initialize them.
(fail): Use them.
(window_change, copy_from_to): Don't kill if emacs_pid is zero.
(pty_conversation): Watch the command socket, too. Read emacs_pid
here. Emacs and emacsclient could deadlock if Emacs tried to do a
reset_sys_modes before sending its pid.
lisp/server.el: Automatically delete the client frame when done editing.
(server-frames): New variable.
(server-process-filter, server-sentinel, server-buffer-done): Use it.
(server-process-filter): Do a redisplay before evaluating other
parameters. (Prevents "emacsclient -h -e '(delete-frame)'" from
messing up the system.
src/dispextern.h: Update prototypes.
src/dispnew.c (window_change_signal): Do nothing if !term_initted.
(init_display): Set the frame size from the tty data after term_init.
src/emacs.c (main): Make sure things that init_sys_modes needs are
initialized before init_display (which calls init_sys_modes now).
(sort_args): Use xfree, not free.
(shut_down_emacs) [!EMACS_HAVE_TTY_PGRP]: Use reset_all_sys_modes
instead of reset_sys_modes.
src/frame.c (make_terminal_frame): Sigh. Move terminal initialization
back to the middle of frame setup. Handle errors by making sure that
the delete_tty() called from term_init() will see and delete this
frame.
(Fdelete_frame): Kill the frame before calling delete_tty(). Fix
condition for tty deletion.
src/keyboard.c (Fset_input_mode): Use reset_sys_modes on the current
terminal only.
src/lisp.h: Remove duplicate prototypes.
src/msdos.c (croak): use reset_all_sys_modes().
src/sysdeps.c (init_baud_rate): Added tty parameter, use it instead of CURTTY.
(child_setup_tty): Reset sigio on stdin, not CURTTY().
(reset_sigio): Added fd parameter, put explicit fcntl there.
(request_sigio, unrequest_sigio)[FASYNC]: Simply block/unblock the
SIGIO signal, don't touch the file params. There are multiple ttys
now, and we can't disable the SIGIO from emacsclient.
(get_tty_size)[VMS]: Use tty_out instead of CURTTY().
(reset_sys_modes): Don't call cursor_to, clear_end_of_line; call
cmgoto and tty_clear_end_of_line instead. The frame may already be
dead. Updated reset_sigio call.
src/term.c (clear_and_of_line): Separate tty-dependent stuff to
tty_clear_end_of_line() for reset_sys_modes.
(tty_clear_end_of_line): New function.
(term_init): Added frame parameter, don't use selected_frame.
Set the frame's output_data.tty value (in case there is an error
later). Set the frame size in Wcm, not in the frame. Only free the
termcap buffer if there is a termcap-related error. Call
init_sys_modes last, not first.
(deleting_tty): New variable.
(delete_tty): Use it for handling recursive calls. Free deleted tty,
except its Wcm (there is still a dangling reference somewhere).
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-19
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 169 |
1 files changed, 91 insertions, 78 deletions
diff --git a/src/term.c b/src/term.c index 63b198bbf2a..3b029da0b7f 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -651,8 +651,6 @@ void | |||
| 651 | clear_end_of_line (first_unused_hpos) | 651 | clear_end_of_line (first_unused_hpos) |
| 652 | int first_unused_hpos; | 652 | int first_unused_hpos; |
| 653 | { | 653 | { |
| 654 | register int i; | ||
| 655 | |||
| 656 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 654 | struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
| 657 | struct tty_output *tty; | 655 | struct tty_output *tty; |
| 658 | 656 | ||
| @@ -663,8 +661,13 @@ clear_end_of_line (first_unused_hpos) | |||
| 663 | return; | 661 | return; |
| 664 | } | 662 | } |
| 665 | 663 | ||
| 666 | tty = FRAME_TTY (f); | 664 | tty_clear_end_of_line (FRAME_TTY (f), first_unused_hpos); |
| 665 | } | ||
| 667 | 666 | ||
| 667 | void | ||
| 668 | tty_clear_end_of_line (struct tty_output *tty, int first_unused_hpos) | ||
| 669 | { | ||
| 670 | register int i; | ||
| 668 | /* Detect the case where we are called from reset_sys_modes | 671 | /* Detect the case where we are called from reset_sys_modes |
| 669 | and the costs have never been calculated. Do nothing. */ | 672 | and the costs have never been calculated. Do nothing. */ |
| 670 | if (! tty->costs_set) | 673 | if (! tty->costs_set) |
| @@ -683,8 +686,8 @@ clear_end_of_line (first_unused_hpos) | |||
| 683 | 686 | ||
| 684 | /* Do not write in last row last col with Auto-wrap on. */ | 687 | /* Do not write in last row last col with Auto-wrap on. */ |
| 685 | if (AutoWrap (tty) | 688 | if (AutoWrap (tty) |
| 686 | && curY (tty) == FRAME_LINES (f) - 1 | 689 | && curY (tty) == FrameRows (tty) - 1 |
| 687 | && first_unused_hpos == FRAME_COLS (f)) | 690 | && first_unused_hpos == FrameCols (tty)) |
| 688 | first_unused_hpos--; | 691 | first_unused_hpos--; |
| 689 | 692 | ||
| 690 | for (i = curX (tty); i < first_unused_hpos; i++) | 693 | for (i = curX (tty); i < first_unused_hpos; i++) |
| @@ -2124,9 +2127,7 @@ term_dummy_init (void) | |||
| 2124 | 2127 | ||
| 2125 | 2128 | ||
| 2126 | struct tty_output * | 2129 | struct tty_output * |
| 2127 | term_init (name, terminal_type) | 2130 | term_init (Lisp_Object frame, char *name, char *terminal_type) |
| 2128 | char *name; | ||
| 2129 | char *terminal_type; | ||
| 2130 | { | 2131 | { |
| 2131 | char *area; | 2132 | char *area; |
| 2132 | char **address = &area; | 2133 | char **address = &area; |
| @@ -2134,20 +2135,16 @@ term_init (name, terminal_type) | |||
| 2134 | int buffer_size = 4096; | 2135 | int buffer_size = 4096; |
| 2135 | register char *p; | 2136 | register char *p; |
| 2136 | int status; | 2137 | int status; |
| 2137 | struct frame *sf = XFRAME (selected_frame); | 2138 | struct frame *f = XFRAME (frame); |
| 2138 | |||
| 2139 | struct tty_output *tty; | 2139 | struct tty_output *tty; |
| 2140 | 2140 | ||
| 2141 | tty = get_named_tty (name); | 2141 | tty = get_named_tty (name); |
| 2142 | if (tty) | 2142 | if (tty) |
| 2143 | { | 2143 | { |
| 2144 | /* Return the previously initialized terminal, except if it is the dummy | 2144 | /* Return the previously initialized terminal, except if it is |
| 2145 | terminal created for the initial frame. */ | 2145 | the dummy terminal created for the initial frame. */ |
| 2146 | if (tty->type) | 2146 | if (tty->type) |
| 2147 | return tty; | 2147 | return tty; |
| 2148 | |||
| 2149 | /* In the latter case, initialize top_frame to the current terminal. */ | ||
| 2150 | tty->top_frame = selected_frame; | ||
| 2151 | } | 2148 | } |
| 2152 | else | 2149 | else |
| 2153 | { | 2150 | { |
| @@ -2160,21 +2157,25 @@ term_init (name, terminal_type) | |||
| 2160 | if (! tty->Wcm) | 2157 | if (! tty->Wcm) |
| 2161 | tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | 2158 | tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); |
| 2162 | 2159 | ||
| 2160 | /* Make sure the frame is live; if an error happens, it must be | ||
| 2161 | deleted. */ | ||
| 2162 | f->output_method = output_termcap; | ||
| 2163 | f->output_data.tty = tty; | ||
| 2164 | |||
| 2163 | if (name) | 2165 | if (name) |
| 2164 | { | 2166 | { |
| 2165 | int fd; | 2167 | int fd; |
| 2166 | FILE *f; | 2168 | FILE *file; |
| 2167 | fd = emacs_open (name, O_RDWR, 0); | 2169 | fd = emacs_open (name, O_RDWR, 0); |
| 2168 | if (fd < 0) | 2170 | if (fd < 0) |
| 2169 | { | 2171 | { |
| 2170 | tty_list = tty->next; | 2172 | delete_tty (tty); |
| 2171 | xfree (tty); | ||
| 2172 | error ("Could not open file: %s", name); | 2173 | error ("Could not open file: %s", name); |
| 2173 | } | 2174 | } |
| 2174 | f = fdopen (fd, "w+"); | 2175 | file = fdopen (fd, "w+"); |
| 2175 | TTY_NAME (tty) = xstrdup (name); | 2176 | TTY_NAME (tty) = xstrdup (name); |
| 2176 | TTY_INPUT (tty) = f; | 2177 | TTY_INPUT (tty) = file; |
| 2177 | TTY_OUTPUT (tty) = f; | 2178 | TTY_OUTPUT (tty) = file; |
| 2178 | } | 2179 | } |
| 2179 | else | 2180 | else |
| 2180 | { | 2181 | { |
| @@ -2185,8 +2186,6 @@ term_init (name, terminal_type) | |||
| 2185 | 2186 | ||
| 2186 | TTY_TYPE (tty) = xstrdup (terminal_type); | 2187 | TTY_TYPE (tty) = xstrdup (terminal_type); |
| 2187 | 2188 | ||
| 2188 | init_sys_modes (tty); | ||
| 2189 | |||
| 2190 | #ifdef WINDOWSNT | 2189 | #ifdef WINDOWSNT |
| 2191 | initialize_w32_display (); | 2190 | initialize_w32_display (); |
| 2192 | 2191 | ||
| @@ -2194,9 +2193,9 @@ term_init (name, terminal_type) | |||
| 2194 | 2193 | ||
| 2195 | area = (char *) xmalloc (2044); | 2194 | area = (char *) xmalloc (2044); |
| 2196 | 2195 | ||
| 2197 | FrameRows = FRAME_LINES (sf); | 2196 | FrameRows = FRAME_LINES (f); |
| 2198 | FrameCols = FRAME_COLS (sf); | 2197 | FrameCols = FRAME_COLS (f); |
| 2199 | specified_window = FRAME_LINES (sf); | 2198 | specified_window = FRAME_LINES (f); |
| 2200 | 2199 | ||
| 2201 | delete_in_insert_mode = 1; | 2200 | delete_in_insert_mode = 1; |
| 2202 | 2201 | ||
| @@ -2213,8 +2212,8 @@ term_init (name, terminal_type) | |||
| 2213 | 2212 | ||
| 2214 | baud_rate = 19200; | 2213 | baud_rate = 19200; |
| 2215 | 2214 | ||
| 2216 | FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0; | 2215 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; |
| 2217 | FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none; | 2216 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; |
| 2218 | TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ | 2217 | TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ |
| 2219 | 2218 | ||
| 2220 | return tty; | 2219 | return tty; |
| @@ -2229,6 +2228,7 @@ term_init (name, terminal_type) | |||
| 2229 | #ifdef TERMINFO | 2228 | #ifdef TERMINFO |
| 2230 | if (name) | 2229 | if (name) |
| 2231 | { | 2230 | { |
| 2231 | xfree (buffer); | ||
| 2232 | delete_tty (tty); | 2232 | delete_tty (tty); |
| 2233 | error ("Cannot open terminfo database file"); | 2233 | error ("Cannot open terminfo database file"); |
| 2234 | } | 2234 | } |
| @@ -2237,6 +2237,7 @@ term_init (name, terminal_type) | |||
| 2237 | #else | 2237 | #else |
| 2238 | if (name) | 2238 | if (name) |
| 2239 | { | 2239 | { |
| 2240 | xfree (buffer); | ||
| 2240 | delete_tty (tty); | 2241 | delete_tty (tty); |
| 2241 | error ("Cannot open termcap database file"); | 2242 | error ("Cannot open termcap database file"); |
| 2242 | } | 2243 | } |
| @@ -2249,12 +2250,13 @@ term_init (name, terminal_type) | |||
| 2249 | #ifdef TERMINFO | 2250 | #ifdef TERMINFO |
| 2250 | if (name) | 2251 | if (name) |
| 2251 | { | 2252 | { |
| 2253 | xfree (buffer); | ||
| 2252 | delete_tty (tty); | 2254 | delete_tty (tty); |
| 2253 | error ("Terminal type %s is not defined", terminal_type); | 2255 | error ("Terminal type %s is not defined", terminal_type); |
| 2254 | } | 2256 | } |
| 2255 | else | 2257 | else |
| 2256 | fatal ("Terminal type %s is not defined.\n\ | 2258 | fatal ("Terminal type %s is not defined.\n\ |
| 2257 | If that is not the actual type of terminal you have,\n \ | 2259 | If that is not the actual type of terminal you have,\n\ |
| 2258 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | 2260 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ |
| 2259 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ | 2261 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ |
| 2260 | to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", | 2262 | to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", |
| @@ -2262,12 +2264,13 @@ to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", | |||
| 2262 | #else | 2264 | #else |
| 2263 | if (name) | 2265 | if (name) |
| 2264 | { | 2266 | { |
| 2267 | xfree (buffer); | ||
| 2265 | delete_tty (tty); | 2268 | delete_tty (tty); |
| 2266 | error ("Terminal type %s is not defined", terminal_type); | 2269 | error ("Terminal type %s is not defined", terminal_type); |
| 2267 | } | 2270 | } |
| 2268 | else | 2271 | else |
| 2269 | fatal ("Terminal type %s is not defined.\n\ | 2272 | fatal ("Terminal type %s is not defined.\n\ |
| 2270 | If that is not the actual type of terminal you have,\n \ | 2273 | If that is not the actual type of terminal you have,\n\ |
| 2271 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | 2274 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ |
| 2272 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ | 2275 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ |
| 2273 | to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | 2276 | to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", |
| @@ -2401,21 +2404,29 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2401 | { | 2404 | { |
| 2402 | int height, width; | 2405 | int height, width; |
| 2403 | get_tty_size (tty, &width, &height); | 2406 | get_tty_size (tty, &width, &height); |
| 2404 | FRAME_COLS (sf) = width; | 2407 | FrameCols (tty) = width; |
| 2405 | FRAME_LINES (sf) = height; | 2408 | FrameRows (tty) = height; |
| 2406 | } | 2409 | } |
| 2407 | 2410 | ||
| 2408 | if (FRAME_COLS (sf) <= 0) | 2411 | if (FrameCols (tty) <= 0) |
| 2409 | SET_FRAME_COLS (sf, tgetnum ("co")); | 2412 | FrameCols (tty) = tgetnum ("co"); |
| 2410 | else | 2413 | if (FrameRows (tty) <= 0) |
| 2411 | /* Keep width and external_width consistent */ | 2414 | FrameRows (tty) = tgetnum ("li"); |
| 2412 | SET_FRAME_COLS (sf, FRAME_COLS (sf)); | ||
| 2413 | if (FRAME_LINES (sf) <= 0) | ||
| 2414 | FRAME_LINES (sf) = tgetnum ("li"); | ||
| 2415 | 2415 | ||
| 2416 | if (FRAME_LINES (sf) < 3 || FRAME_COLS (sf) < 3) | 2416 | if (FrameRows (tty) < 3 || FrameCols (tty) < 3) |
| 2417 | fatal ("Screen size %dx%d is too small", | 2417 | { |
| 2418 | FRAME_LINES (sf), FRAME_COLS (sf)); | 2418 | if (initialized) |
| 2419 | { | ||
| 2420 | delete_tty (tty); | ||
| 2421 | error ("Screen size %dx%d is too small", | ||
| 2422 | FrameCols (tty), FrameRows (tty)); | ||
| 2423 | } | ||
| 2424 | else | ||
| 2425 | { | ||
| 2426 | fatal ("Screen size %dx%d is too small", | ||
| 2427 | FrameCols (tty), FrameRows (tty)); | ||
| 2428 | } | ||
| 2429 | } | ||
| 2419 | 2430 | ||
| 2420 | #if 0 /* This is not used anywhere. */ | 2431 | #if 0 /* This is not used anywhere. */ |
| 2421 | TTY_MIN_PADDING_SPEED (tty) = tgetnum ("pb"); | 2432 | TTY_MIN_PADDING_SPEED (tty) = tgetnum ("pb"); |
| @@ -2541,15 +2552,14 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2541 | } | 2552 | } |
| 2542 | } | 2553 | } |
| 2543 | 2554 | ||
| 2544 | FrameRows (tty) = FRAME_LINES (sf); | 2555 | tty->specified_window = FrameRows (tty); |
| 2545 | FrameCols (tty) = FRAME_COLS (sf); | ||
| 2546 | tty->specified_window = FRAME_LINES (sf); | ||
| 2547 | 2556 | ||
| 2548 | if (Wcm_init (tty) == -1) /* can't do cursor motion */ | 2557 | if (Wcm_init (tty) == -1) /* can't do cursor motion */ |
| 2549 | if (name) | 2558 | if (name) |
| 2550 | { | 2559 | { |
| 2551 | delete_tty (tty); | 2560 | delete_tty (tty); |
| 2552 | error ("Terminal type \"%s\" is not powerful enough to run Emacs"); | 2561 | error ("Terminal type \"%s\" is not powerful enough to run Emacs", |
| 2562 | terminal_type); | ||
| 2553 | } | 2563 | } |
| 2554 | else { | 2564 | else { |
| 2555 | #ifdef VMS | 2565 | #ifdef VMS |
| @@ -2562,15 +2572,15 @@ or `define EMACS_TERM \"terminal type\"' for non-DEC terminals.", | |||
| 2562 | #else /* not VMS */ | 2572 | #else /* not VMS */ |
| 2563 | # ifdef TERMINFO | 2573 | # ifdef TERMINFO |
| 2564 | fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ | 2574 | fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ |
| 2565 | It lacks the ability to position the cursor.\n \ | 2575 | It lacks the ability to position the cursor.\n\ |
| 2566 | If that is not the actual type of terminal you have,\n \ | 2576 | If that is not the actual type of terminal you have,\n\ |
| 2567 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | 2577 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ |
| 2568 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ | 2578 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ |
| 2569 | to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", | 2579 | to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", |
| 2570 | terminal_type); | 2580 | terminal_type); |
| 2571 | # else /* TERMCAP */ | 2581 | # else /* TERMCAP */ |
| 2572 | fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ | 2582 | fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ |
| 2573 | It lacks the ability to position the cursor.\n \ | 2583 | It lacks the ability to position the cursor.\n\ |
| 2574 | If that is not the actual type of terminal you have,\n\ | 2584 | If that is not the actual type of terminal you have,\n\ |
| 2575 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ | 2585 | use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ |
| 2576 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ | 2586 | `setenv TERM ...') to specify the correct type. It may be necessary\n\ |
| @@ -2580,8 +2590,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2580 | #endif /*VMS */ | 2590 | #endif /*VMS */ |
| 2581 | } | 2591 | } |
| 2582 | 2592 | ||
| 2583 | if (FRAME_LINES (sf) <= 0 | 2593 | if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) |
| 2584 | || FRAME_COLS (sf) <= 0) | ||
| 2585 | { | 2594 | { |
| 2586 | if (name) | 2595 | if (name) |
| 2587 | { | 2596 | { |
| @@ -2619,20 +2628,29 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 2619 | 2628 | ||
| 2620 | TTY_FAST_CLEAR_END_OF_LINE (tty) = tty->TS_clr_line != 0; | 2629 | TTY_FAST_CLEAR_END_OF_LINE (tty) = tty->TS_clr_line != 0; |
| 2621 | 2630 | ||
| 2622 | init_baud_rate (); | 2631 | init_baud_rate (tty); |
| 2623 | if (read_socket_hook) /* Baudrate is somewhat | 2632 | if (read_socket_hook) /* Baudrate is somewhat |
| 2624 | meaningless in this case */ | 2633 | meaningless in this case */ |
| 2625 | baud_rate = 9600; | 2634 | baud_rate = 9600; |
| 2626 | 2635 | ||
| 2627 | FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0; | 2636 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; |
| 2628 | FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none; | 2637 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; |
| 2629 | #endif /* WINDOWSNT */ | ||
| 2630 | 2638 | ||
| 2631 | xfree (buffer); | 2639 | /* Don't do this. I think termcap may still need the buffer. */ |
| 2640 | /* xfree (buffer); */ | ||
| 2632 | 2641 | ||
| 2642 | tty->top_frame = frame; | ||
| 2643 | |||
| 2644 | tty->foreground_pixel = FACE_TTY_DEFAULT_FG_COLOR; | ||
| 2645 | tty->background_pixel = FACE_TTY_DEFAULT_BG_COLOR; | ||
| 2646 | |||
| 2647 | /* Init system terminal modes (RAW or CBREAK, etc.). */ | ||
| 2648 | init_sys_modes (tty); | ||
| 2649 | |||
| 2633 | tty_set_terminal_modes (tty); | 2650 | tty_set_terminal_modes (tty); |
| 2634 | 2651 | ||
| 2635 | return tty; | 2652 | return tty; |
| 2653 | #endif /* WINDOWSNT */ | ||
| 2636 | } | 2654 | } |
| 2637 | 2655 | ||
| 2638 | /* VARARGS 1 */ | 2656 | /* VARARGS 1 */ |
| @@ -2670,11 +2688,20 @@ The function should accept no arguments. */); | |||
| 2670 | Fprovide (intern ("multi-tty"), Qnil); | 2688 | Fprovide (intern ("multi-tty"), Qnil); |
| 2671 | } | 2689 | } |
| 2672 | 2690 | ||
| 2691 | static int deleting_tty = 0; | ||
| 2692 | |||
| 2673 | void | 2693 | void |
| 2674 | delete_tty (struct tty_output *tty) | 2694 | delete_tty (struct tty_output *tty) |
| 2675 | { | 2695 | { |
| 2676 | Lisp_Object tail, frame; | 2696 | Lisp_Object tail, frame; |
| 2697 | |||
| 2698 | if (deleting_tty) | ||
| 2699 | /* We get a recursive call when we delete the last frame on this | ||
| 2700 | tty. */ | ||
| 2701 | return; | ||
| 2677 | 2702 | ||
| 2703 | deleting_tty = 1; | ||
| 2704 | |||
| 2678 | if (tty == tty_list) | 2705 | if (tty == tty_list) |
| 2679 | tty_list = tty->next; | 2706 | tty_list = tty->next; |
| 2680 | else | 2707 | else |
| @@ -2687,7 +2714,8 @@ delete_tty (struct tty_output *tty) | |||
| 2687 | /* This should not happen. */ | 2714 | /* This should not happen. */ |
| 2688 | abort (); | 2715 | abort (); |
| 2689 | 2716 | ||
| 2690 | p->next = p->next->next; | 2717 | p->next = tty->next; |
| 2718 | tty->next = 0; | ||
| 2691 | } | 2719 | } |
| 2692 | 2720 | ||
| 2693 | FOR_EACH_FRAME (tail, frame) | 2721 | FOR_EACH_FRAME (tail, frame) |
| @@ -2700,46 +2728,31 @@ delete_tty (struct tty_output *tty) | |||
| 2700 | } | 2728 | } |
| 2701 | } | 2729 | } |
| 2702 | 2730 | ||
| 2703 | /* This hangs. */ | ||
| 2704 | /* | ||
| 2705 | reset_sys_modes (tty); | 2731 | reset_sys_modes (tty); |
| 2706 | 2732 | ||
| 2707 | if (tty->name) | 2733 | if (tty->name) |
| 2708 | xfree (tty->name); | 2734 | xfree (tty->name); |
| 2709 | if (tty->type) | 2735 | if (tty->type) |
| 2710 | xfree (tty->type); | 2736 | xfree (tty->type); |
| 2711 | */ | 2737 | |
| 2712 | if (tty->input) | 2738 | if (tty->input) |
| 2713 | fclose (tty->input); | 2739 | fclose (tty->input); |
| 2714 | if (tty->output) | 2740 | if (tty->output) |
| 2715 | fclose (tty->output); | 2741 | fclose (tty->output); |
| 2716 | if (tty->termscript) | 2742 | if (tty->termscript) |
| 2717 | fclose (tty->termscript); | 2743 | fclose (tty->termscript); |
| 2718 | |||
| 2719 | tty->input = 0; | ||
| 2720 | tty->output = 0; | ||
| 2721 | tty->termscript = 0; | ||
| 2722 | 2744 | ||
| 2723 | /* | ||
| 2724 | if (tty->old_tty) | 2745 | if (tty->old_tty) |
| 2725 | { | 2746 | xfree (tty->old_tty); |
| 2726 | memset (tty->old_tty, 'Z', sizeof (struct emacs_tty)); | ||
| 2727 | tty->old_tty = 0; | ||
| 2728 | } | ||
| 2729 | |||
| 2730 | |||
| 2731 | /* xfree (tty->old_tty); | ||
| 2732 | 2747 | ||
| 2733 | if (tty->Wcm) | 2748 | #if 0 /* XXX There is a dangling reference somewhere into this. */ |
| 2734 | { | 2749 | if (tty->Wcm) |
| 2735 | bzero (tty->Wcm, sizeof (struct cm)); | ||
| 2736 | } | ||
| 2737 | xfree (tty->Wcm); | 2750 | xfree (tty->Wcm); |
| 2751 | #endif | ||
| 2738 | 2752 | ||
| 2739 | bzero (tty, sizeof (struct tty_output)); | 2753 | bzero (tty, sizeof (struct tty_output)); |
| 2740 | |||
| 2741 | xfree (tty); | 2754 | xfree (tty); |
| 2742 | */ | 2755 | deleting_tty = 0; |
| 2743 | } | 2756 | } |
| 2744 | 2757 | ||
| 2745 | 2758 | ||