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 | |
| 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')
| -rw-r--r-- | src/Makefile.in | 2 | ||||
| -rw-r--r-- | src/dispextern.h | 5 | ||||
| -rw-r--r-- | src/dispnew.c | 14 | ||||
| -rw-r--r-- | src/emacs.c | 23 | ||||
| -rw-r--r-- | src/frame.c | 49 | ||||
| -rw-r--r-- | src/keyboard.c | 12 | ||||
| -rw-r--r-- | src/lisp.h | 3 | ||||
| -rw-r--r-- | src/msdos.c | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 67 | ||||
| -rw-r--r-- | src/term.c | 169 |
10 files changed, 190 insertions, 156 deletions
diff --git a/src/Makefile.in b/src/Makefile.in index 467ad5156bd..e42c5099830 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -1119,7 +1119,7 @@ syntax.o: syntax.c syntax.h buffer.h commands.h category.h charset.h \ | |||
| 1119 | composite.h $(config_h) | 1119 | composite.h $(config_h) |
| 1120 | sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \ | 1120 | sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \ |
| 1121 | process.h dispextern.h termhooks.h termchar.h termopts.h \ | 1121 | process.h dispextern.h termhooks.h termchar.h termopts.h \ |
| 1122 | frame.h atimer.h window.h msdos.h dosfns.h keyboard.h $(config_h) | 1122 | frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h $(config_h) |
| 1123 | term.o: term.c systty.h termchar.h termhooks.h termopts.h $(config_h) cm.h frame.h \ | 1123 | term.o: term.c systty.h termchar.h termhooks.h termopts.h $(config_h) cm.h frame.h \ |
| 1124 | disptab.h dispextern.h keyboard.h charset.h coding.h ccl.h msdos.h | 1124 | disptab.h dispextern.h keyboard.h charset.h coding.h ccl.h msdos.h |
| 1125 | termcap.o: termcap.c $(config_h) | 1125 | termcap.o: termcap.c $(config_h) |
diff --git a/src/dispextern.h b/src/dispextern.h index 06b52cf9ee4..cb0a7a7d91d 100644 --- a/src/dispextern.h +++ b/src/dispextern.h | |||
| @@ -2566,7 +2566,7 @@ void get_tty_size P_ ((struct tty_output *, int *, int *)); | |||
| 2566 | void request_sigio P_ ((void)); | 2566 | void request_sigio P_ ((void)); |
| 2567 | void unrequest_sigio P_ ((void)); | 2567 | void unrequest_sigio P_ ((void)); |
| 2568 | int tabs_safe_p P_ ((struct tty_output *)); | 2568 | int tabs_safe_p P_ ((struct tty_output *)); |
| 2569 | void init_baud_rate P_ ((void)); | 2569 | void init_baud_rate P_ ((struct tty_output *)); |
| 2570 | void init_sigio P_ ((int)); | 2570 | void init_sigio P_ ((int)); |
| 2571 | 2571 | ||
| 2572 | /* Defined in xfaces.c */ | 2572 | /* Defined in xfaces.c */ |
| @@ -2743,6 +2743,7 @@ extern void background_highlight P_ ((struct tty_output *)); | |||
| 2743 | extern void clear_frame P_ ((void)); | 2743 | extern void clear_frame P_ ((void)); |
| 2744 | extern void clear_end_of_line P_ ((int)); | 2744 | extern void clear_end_of_line P_ ((int)); |
| 2745 | extern void clear_end_of_line_raw P_ ((int)); | 2745 | extern void clear_end_of_line_raw P_ ((int)); |
| 2746 | extern void tty_clear_end_of_line P_ ((struct tty_output *, int)); | ||
| 2746 | extern void delete_glyphs P_ ((int)); | 2747 | extern void delete_glyphs P_ ((int)); |
| 2747 | extern void ins_del_lines P_ ((int, int)); | 2748 | extern void ins_del_lines P_ ((int, int)); |
| 2748 | extern int string_cost P_ ((char *)); | 2749 | extern int string_cost P_ ((char *)); |
| @@ -2750,7 +2751,7 @@ extern int per_line_cost P_ ((char *)); | |||
| 2750 | extern void calculate_costs P_ ((struct frame *)); | 2751 | extern void calculate_costs P_ ((struct frame *)); |
| 2751 | extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); | 2752 | extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); |
| 2752 | extern void tty_setup_colors P_ ((struct tty_output *, int)); | 2753 | extern void tty_setup_colors P_ ((struct tty_output *, int)); |
| 2753 | extern struct tty_output *term_init P_ ((char *, char *)); | 2754 | extern struct tty_output *term_init P_ ((Lisp_Object, char *, char *)); |
| 2754 | extern struct tty_output *term_dummy_init P_ ((void)); | 2755 | extern struct tty_output *term_dummy_init P_ ((void)); |
| 2755 | extern void fatal P_ ((/* char *, ... */)); | 2756 | extern void fatal P_ ((/* char *, ... */)); |
| 2756 | void cursor_to P_ ((int, int)); | 2757 | void cursor_to P_ ((int, int)); |
diff --git a/src/dispnew.c b/src/dispnew.c index afde7bd80e6..3cf15deeab6 100644 --- a/src/dispnew.c +++ b/src/dispnew.c | |||
| @@ -5921,11 +5921,12 @@ window_change_signal (signalnum) /* If we don't have an argument, */ | |||
| 5921 | /* The frame size change obviously applies to a single | 5921 | /* The frame size change obviously applies to a single |
| 5922 | termcap-controlled terminal, but we can't decide which. | 5922 | termcap-controlled terminal, but we can't decide which. |
| 5923 | Therefore, we resize the frames corresponding to each tty. | 5923 | Therefore, we resize the frames corresponding to each tty. |
| 5924 | |||
| 5925 | XXX In fact we only get the signal for the initial terminal. | ||
| 5926 | */ | 5924 | */ |
| 5927 | for (tty = tty_list; tty; tty = tty->next) { | 5925 | for (tty = tty_list; tty; tty = tty->next) { |
| 5928 | 5926 | ||
| 5927 | if (! tty->term_initted) | ||
| 5928 | continue; | ||
| 5929 | |||
| 5929 | get_tty_size (tty, &width, &height); | 5930 | get_tty_size (tty, &width, &height); |
| 5930 | 5931 | ||
| 5931 | { | 5932 | { |
| @@ -6623,8 +6624,13 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\ | |||
| 6623 | } | 6624 | } |
| 6624 | #endif /* VMS */ | 6625 | #endif /* VMS */ |
| 6625 | 6626 | ||
| 6626 | term_init (0, terminal_type); | 6627 | { |
| 6627 | 6628 | struct tty_output *tty; | |
| 6629 | |||
| 6630 | tty = term_init (selected_frame, 0, terminal_type); | ||
| 6631 | change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 0); | ||
| 6632 | } | ||
| 6633 | |||
| 6628 | { | 6634 | { |
| 6629 | struct frame *sf = SELECTED_FRAME (); | 6635 | struct frame *sf = SELECTED_FRAME (); |
| 6630 | int width = FRAME_TOTAL_COLS (sf); | 6636 | int width = FRAME_TOTAL_COLS (sf); |
diff --git a/src/emacs.c b/src/emacs.c index 4f6d5168c6d..62b550a4e2c 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1561,13 +1561,6 @@ main (argc, argv | |||
| 1561 | #endif /* end #ifdef HAVE_NTGUI */ | 1561 | #endif /* end #ifdef HAVE_NTGUI */ |
| 1562 | } | 1562 | } |
| 1563 | 1563 | ||
| 1564 | if (!noninteractive) | ||
| 1565 | { | ||
| 1566 | #ifdef VMS | ||
| 1567 | init_vms_input ();/* init_display calls get_tty_size, that needs this. */ | ||
| 1568 | #endif /* VMS */ | ||
| 1569 | init_display (); /* Determine terminal type. Calls init_sys_modes. */ | ||
| 1570 | } | ||
| 1571 | #ifndef MAC_OS8 | 1564 | #ifndef MAC_OS8 |
| 1572 | /* Called before init_window_once for Mac OS Classic. */ | 1565 | /* Called before init_window_once for Mac OS Classic. */ |
| 1573 | init_keyboard (); /* This too must precede init_sys_modes. */ | 1566 | init_keyboard (); /* This too must precede init_sys_modes. */ |
| @@ -1575,7 +1568,13 @@ main (argc, argv | |||
| 1575 | #ifdef VMS | 1568 | #ifdef VMS |
| 1576 | init_vmsproc (); /* And this too. */ | 1569 | init_vmsproc (); /* And this too. */ |
| 1577 | #endif /* VMS */ | 1570 | #endif /* VMS */ |
| 1578 | /* init_sys_modes (); */ /* Init system terminal modes (RAW or CBREAK, etc.). */ | 1571 | if (!noninteractive) |
| 1572 | { | ||
| 1573 | #ifdef VMS | ||
| 1574 | init_vms_input ();/* init_display calls get_tty_size, that needs this. */ | ||
| 1575 | #endif /* VMS */ | ||
| 1576 | init_display (); /* Determine terminal type. Calls init_sys_modes. */ | ||
| 1577 | } | ||
| 1579 | #if defined (HAVE_X_WINDOWS) || defined (WINDOWSNT) | 1578 | #if defined (HAVE_X_WINDOWS) || defined (WINDOWSNT) |
| 1580 | init_xfns (); | 1579 | init_xfns (); |
| 1581 | #endif /* HAVE_X_WINDOWS */ | 1580 | #endif /* HAVE_X_WINDOWS */ |
| @@ -1910,9 +1909,9 @@ sort_args (argc, argv) | |||
| 1910 | 1909 | ||
| 1911 | bcopy (new, argv, sizeof (char *) * argc); | 1910 | bcopy (new, argv, sizeof (char *) * argc); |
| 1912 | 1911 | ||
| 1913 | free (options); | 1912 | xfree (options); |
| 1914 | free (new); | 1913 | xfree (new); |
| 1915 | free (priority); | 1914 | xfree (priority); |
| 1916 | } | 1915 | } |
| 1917 | 1916 | ||
| 1918 | DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", | 1917 | DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P", |
| @@ -1999,7 +1998,7 @@ shut_down_emacs (sig, no_x, stuff) | |||
| 1999 | } | 1998 | } |
| 2000 | #else | 1999 | #else |
| 2001 | fflush (stdout); | 2000 | fflush (stdout); |
| 2002 | reset_sys_modes (); | 2001 | reset_all_sys_modes (); |
| 2003 | #endif | 2002 | #endif |
| 2004 | 2003 | ||
| 2005 | stuff_buffered_input (stuff); | 2004 | stuff_buffered_input (stuff); |
diff --git a/src/frame.c b/src/frame.c index 8f8dea8fa75..9a532bfdd2d 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -485,13 +485,6 @@ make_terminal_frame (tty_name, tty_type) | |||
| 485 | register struct frame *f; | 485 | register struct frame *f; |
| 486 | Lisp_Object frame; | 486 | Lisp_Object frame; |
| 487 | char name[20]; | 487 | char name[20]; |
| 488 | struct tty_output *tty; | ||
| 489 | |||
| 490 | /* init_term may throw an error, so create the tty first. */ | ||
| 491 | if (initialized) | ||
| 492 | tty = term_init (tty_name, tty_type); | ||
| 493 | else | ||
| 494 | tty = term_dummy_init (); | ||
| 495 | 488 | ||
| 496 | #ifdef MULTI_KBOARD | 489 | #ifdef MULTI_KBOARD |
| 497 | if (!initial_kboard) | 490 | if (!initial_kboard) |
| @@ -550,9 +543,23 @@ make_terminal_frame (tty_name, tty_type) | |||
| 550 | #ifdef MAC_OS8 | 543 | #ifdef MAC_OS8 |
| 551 | make_mac_terminal_frame (f); | 544 | make_mac_terminal_frame (f); |
| 552 | #else | 545 | #else |
| 553 | f->output_method = output_termcap; | 546 | { |
| 554 | f->output_data.tty = tty; | 547 | struct tty_output *tty; |
| 555 | f->output_data.tty->top_frame = frame; | 548 | f->output_method = output_termcap; |
| 549 | |||
| 550 | if (initialized) | ||
| 551 | { | ||
| 552 | /* Note that term_init may signal an error, but then it is its | ||
| 553 | responsibility to make sure this frame is deleted. */ | ||
| 554 | f->output_data.tty = term_init (frame, tty_name, tty_type); | ||
| 555 | } | ||
| 556 | else | ||
| 557 | { | ||
| 558 | /* init_display() will reinitialize the terminal with correct values after dump. */ | ||
| 559 | f->output_data.tty = term_dummy_init (); | ||
| 560 | } | ||
| 561 | } | ||
| 562 | |||
| 556 | #ifdef CANNOT_DUMP | 563 | #ifdef CANNOT_DUMP |
| 557 | FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR; | 564 | FRAME_FOREGROUND_PIXEL(f) = FACE_TTY_DEFAULT_FG_COLOR; |
| 558 | FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR; | 565 | FRAME_BACKGROUND_PIXEL(f) = FACE_TTY_DEFAULT_BG_COLOR; |
| @@ -1383,25 +1390,33 @@ The functions are run with one arg, the frame to be deleted. */) | |||
| 1383 | 1390 | ||
| 1384 | if (FRAME_TERMCAP_P (f)) | 1391 | if (FRAME_TERMCAP_P (f)) |
| 1385 | { | 1392 | { |
| 1386 | /* See if the terminal needs to be closed. */ | ||
| 1387 | Lisp_Object tail, frame1; | 1393 | Lisp_Object tail, frame1; |
| 1388 | int delete = 1; | 1394 | int delete = 1; |
| 1395 | struct tty_output *tty = FRAME_TTY (f); | ||
| 1396 | |||
| 1397 | /* delete_tty will call us recursively, so better kill the | ||
| 1398 | frame now. */ | ||
| 1399 | f->output_data.nothing = 0; | ||
| 1389 | 1400 | ||
| 1401 | /* See if the terminal needs to be closed. */ | ||
| 1390 | FOR_EACH_FRAME (tail, frame1) | 1402 | FOR_EACH_FRAME (tail, frame1) |
| 1391 | { | 1403 | { |
| 1392 | if (!FRAME_LIVE_P (XFRAME (frame1)) && | 1404 | if (frame1 != frame |
| 1393 | FRAME_TERMCAP_P (XFRAME (frame1)) && | 1405 | && FRAME_LIVE_P (XFRAME (frame1)) |
| 1394 | FRAME_TTY (XFRAME (frame1)) == FRAME_TTY (f)) | 1406 | && FRAME_TERMCAP_P (XFRAME (frame1)) |
| 1407 | && FRAME_TTY (XFRAME (frame1)) == FRAME_TTY (f)) | ||
| 1395 | { | 1408 | { |
| 1396 | delete = 0; | 1409 | delete = 0; |
| 1397 | break; | 1410 | break; |
| 1398 | } | 1411 | } |
| 1399 | } | 1412 | } |
| 1400 | if (delete) | 1413 | if (delete) |
| 1401 | delete_tty (FRAME_TTY (f)); | 1414 | delete_tty (tty); |
| 1415 | } | ||
| 1416 | else | ||
| 1417 | { | ||
| 1418 | f->output_data.nothing = 0; | ||
| 1402 | } | 1419 | } |
| 1403 | |||
| 1404 | f->output_data.nothing = 0; | ||
| 1405 | 1420 | ||
| 1406 | /* If we've deleted the last_nonminibuf_frame, then try to find | 1421 | /* If we've deleted the last_nonminibuf_frame, then try to find |
| 1407 | another one. */ | 1422 | another one. */ |
diff --git a/src/keyboard.c b/src/keyboard.c index 20b7242cbcb..217cc290464 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -10433,7 +10433,7 @@ See also `current-input-mode'. */) | |||
| 10433 | 10433 | ||
| 10434 | #ifndef DOS_NT | 10434 | #ifndef DOS_NT |
| 10435 | /* this causes startup screen to be restored and messes with the mouse */ | 10435 | /* this causes startup screen to be restored and messes with the mouse */ |
| 10436 | reset_all_sys_modes (); | 10436 | reset_sys_modes (CURTTY ()); |
| 10437 | #endif | 10437 | #endif |
| 10438 | 10438 | ||
| 10439 | #ifdef SIGIO | 10439 | #ifdef SIGIO |
| @@ -10461,17 +10461,17 @@ See also `current-input-mode'. */) | |||
| 10461 | 10461 | ||
| 10462 | flow_control = !NILP (flow); | 10462 | flow_control = !NILP (flow); |
| 10463 | if (NILP (meta)) | 10463 | if (NILP (meta)) |
| 10464 | FRAME_TTY (SELECTED_FRAME ())->meta_key = 0; | 10464 | CURTTY ()->meta_key = 0; |
| 10465 | else if (EQ (meta, Qt)) | 10465 | else if (EQ (meta, Qt)) |
| 10466 | FRAME_TTY (SELECTED_FRAME ())->meta_key = 1; | 10466 | CURTTY ()->meta_key = 1; |
| 10467 | else | 10467 | else |
| 10468 | FRAME_TTY (SELECTED_FRAME ())->meta_key = 2; | 10468 | CURTTY ()->meta_key = 2; |
| 10469 | if (!NILP (quit)) | 10469 | if (!NILP (quit)) |
| 10470 | /* Don't let this value be out of range. */ | 10470 | /* Don't let this value be out of range. */ |
| 10471 | quit_char = XINT (quit) & (FRAME_TTY (SELECTED_FRAME ())->meta_key ? 0377 : 0177); | 10471 | quit_char = XINT (quit) & (CURTTY ()->meta_key ? 0377 : 0177); |
| 10472 | 10472 | ||
| 10473 | #ifndef DOS_NT | 10473 | #ifndef DOS_NT |
| 10474 | init_all_sys_modes (); | 10474 | init_sys_modes (CURTTY ()); |
| 10475 | #endif | 10475 | #endif |
| 10476 | 10476 | ||
| 10477 | #ifdef POLL_FOR_INPUT | 10477 | #ifdef POLL_FOR_INPUT |
diff --git a/src/lisp.h b/src/lisp.h index c7a4065a96c..412c7d25e46 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -2942,8 +2942,6 @@ struct tty_output; | |||
| 2942 | /* defined in sysdep.c */ | 2942 | /* defined in sysdep.c */ |
| 2943 | extern void stuff_char P_ ((char c)); | 2943 | extern void stuff_char P_ ((char c)); |
| 2944 | extern void init_sigio P_ ((int)); | 2944 | extern void init_sigio P_ ((int)); |
| 2945 | extern void request_sigio P_ ((void)); | ||
| 2946 | extern void unrequest_sigio P_ ((void)); | ||
| 2947 | extern void sys_subshell P_ ((void)); | 2945 | extern void sys_subshell P_ ((void)); |
| 2948 | extern void sys_suspend P_ ((void)); | 2946 | extern void sys_suspend P_ ((void)); |
| 2949 | extern void discard_tty_input P_ ((void)); | 2947 | extern void discard_tty_input P_ ((void)); |
| @@ -2957,7 +2955,6 @@ extern void child_setup_tty P_ ((int)); | |||
| 2957 | extern void setup_pty P_ ((int)); | 2955 | extern void setup_pty P_ ((int)); |
| 2958 | extern int set_window_size P_ ((int, int, int)); | 2956 | extern int set_window_size P_ ((int, int, int)); |
| 2959 | extern void create_process P_ ((Lisp_Object, char **, Lisp_Object)); | 2957 | extern void create_process P_ ((Lisp_Object, char **, Lisp_Object)); |
| 2960 | extern void init_baud_rate P_ ((void)); | ||
| 2961 | extern int emacs_open P_ ((const char *, int, int)); | 2958 | extern int emacs_open P_ ((const char *, int, int)); |
| 2962 | extern int emacs_close P_ ((int)); | 2959 | extern int emacs_close P_ ((int)); |
| 2963 | extern int emacs_read P_ ((int, char *, unsigned int)); | 2960 | extern int emacs_read P_ ((int, char *, unsigned int)); |
diff --git a/src/msdos.c b/src/msdos.c index da6bfef0659..e73f284fa4d 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -4858,7 +4858,7 @@ croak (badfunc) | |||
| 4858 | char *badfunc; | 4858 | char *badfunc; |
| 4859 | { | 4859 | { |
| 4860 | fprintf (stderr, "%s not yet implemented\r\n", badfunc); | 4860 | fprintf (stderr, "%s not yet implemented\r\n", badfunc); |
| 4861 | reset_sys_modes (); | 4861 | reset_all_sys_modes (); |
| 4862 | exit (1); | 4862 | exit (1); |
| 4863 | } | 4863 | } |
| 4864 | 4864 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index ad8b5c518b1..81299b37516 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -184,6 +184,7 @@ extern int quit_char; | |||
| 184 | #include "termopts.h" | 184 | #include "termopts.h" |
| 185 | #include "dispextern.h" | 185 | #include "dispextern.h" |
| 186 | #include "process.h" | 186 | #include "process.h" |
| 187 | #include "cm.h" /* for reset_sys_modes */ | ||
| 187 | 188 | ||
| 188 | #ifdef WINDOWSNT | 189 | #ifdef WINDOWSNT |
| 189 | #include <direct.h> | 190 | #include <direct.h> |
| @@ -330,7 +331,7 @@ stuff_char (char c) | |||
| 330 | #endif /* SIGTSTP */ | 331 | #endif /* SIGTSTP */ |
| 331 | 332 | ||
| 332 | void | 333 | void |
| 333 | init_baud_rate () | 334 | init_baud_rate (struct tty_output *tty) |
| 334 | { | 335 | { |
| 335 | if (noninteractive) | 336 | if (noninteractive) |
| 336 | emacs_ospeed = 0; | 337 | emacs_ospeed = 0; |
| @@ -345,7 +346,7 @@ init_baud_rate () | |||
| 345 | #ifdef VMS | 346 | #ifdef VMS |
| 346 | struct sensemode sg; | 347 | struct sensemode sg; |
| 347 | 348 | ||
| 348 | SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_SENSEMODE, &sg, 0, 0, | 349 | SYS$QIOW (0, fileno (TTY_INPUT (tty)), IO$_SENSEMODE, &sg, 0, 0, |
| 349 | &sg.class, 12, 0, 0, 0, 0 ); | 350 | &sg.class, 12, 0, 0, 0, 0 ); |
| 350 | emacs_ospeed = sg.xmit_baud; | 351 | emacs_ospeed = sg.xmit_baud; |
| 351 | #else /* not VMS */ | 352 | #else /* not VMS */ |
| @@ -353,7 +354,7 @@ init_baud_rate () | |||
| 353 | struct termios sg; | 354 | struct termios sg; |
| 354 | 355 | ||
| 355 | sg.c_cflag = B9600; | 356 | sg.c_cflag = B9600; |
| 356 | tcgetattr (fileno (TTY_INPUT (CURTTY())), &sg); | 357 | tcgetattr (fileno (TTY_INPUT (tty)), &sg); |
| 357 | emacs_ospeed = cfgetospeed (&sg); | 358 | emacs_ospeed = cfgetospeed (&sg); |
| 358 | #if defined (USE_GETOBAUD) && defined (getobaud) | 359 | #if defined (USE_GETOBAUD) && defined (getobaud) |
| 359 | /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ | 360 | /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ |
| @@ -366,16 +367,16 @@ init_baud_rate () | |||
| 366 | 367 | ||
| 367 | sg.c_cflag = B9600; | 368 | sg.c_cflag = B9600; |
| 368 | #ifdef HAVE_TCATTR | 369 | #ifdef HAVE_TCATTR |
| 369 | tcgetattr (fileno (TTY_INPUT (CURTTY())), &sg); | 370 | tcgetattr (fileno (TTY_INPUT (tty)), &sg); |
| 370 | #else | 371 | #else |
| 371 | ioctl (fileno (TTY_INPUT (CURTTY())), TCGETA, &sg); | 372 | ioctl (fileno (TTY_INPUT (tty)), TCGETA, &sg); |
| 372 | #endif | 373 | #endif |
| 373 | emacs_ospeed = sg.c_cflag & CBAUD; | 374 | emacs_ospeed = sg.c_cflag & CBAUD; |
| 374 | #else /* neither VMS nor TERMIOS nor TERMIO */ | 375 | #else /* neither VMS nor TERMIOS nor TERMIO */ |
| 375 | struct sgttyb sg; | 376 | struct sgttyb sg; |
| 376 | 377 | ||
| 377 | sg.sg_ospeed = B9600; | 378 | sg.sg_ospeed = B9600; |
| 378 | if (ioctl (fileno (TTY_INPUT (CURTTY())), TIOCGETP, &sg) < 0) | 379 | if (ioctl (fileno (TTY_INPUT (tty)), TIOCGETP, &sg) < 0) |
| 379 | abort (); | 380 | abort (); |
| 380 | emacs_ospeed = sg.sg_ospeed; | 381 | emacs_ospeed = sg.sg_ospeed; |
| 381 | #endif /* not HAVE_TERMIO */ | 382 | #endif /* not HAVE_TERMIO */ |
| @@ -649,7 +650,7 @@ child_setup_tty (out) | |||
| 649 | 650 | ||
| 650 | #ifdef BSD4_1 | 651 | #ifdef BSD4_1 |
| 651 | if (interrupt_input) | 652 | if (interrupt_input) |
| 652 | reset_sigio (); | 653 | reset_sigio (0); |
| 653 | #endif /* BSD4_1 */ | 654 | #endif /* BSD4_1 */ |
| 654 | #ifdef RTU | 655 | #ifdef RTU |
| 655 | { | 656 | { |
| @@ -915,6 +916,7 @@ init_sigio (fd) | |||
| 915 | int fd; | 916 | int fd; |
| 916 | { | 917 | { |
| 917 | #ifdef FASYNC | 918 | #ifdef FASYNC |
| 919 | /* XXX What if we get called with more than one fds? */ | ||
| 918 | old_fcntl_flags = fcntl (fd, F_GETFL, 0) & ~FASYNC; | 920 | old_fcntl_flags = fcntl (fd, F_GETFL, 0) & ~FASYNC; |
| 919 | fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC); | 921 | fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC); |
| 920 | #endif | 922 | #endif |
| @@ -922,9 +924,10 @@ init_sigio (fd) | |||
| 922 | } | 924 | } |
| 923 | 925 | ||
| 924 | void | 926 | void |
| 925 | reset_sigio () | 927 | reset_sigio (fd) |
| 928 | int fd; | ||
| 926 | { | 929 | { |
| 927 | unrequest_sigio (); | 930 | fcntl (fd, F_SETFL, old_fcntl_flags); |
| 928 | } | 931 | } |
| 929 | 932 | ||
| 930 | #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ | 933 | #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ |
| @@ -938,13 +941,13 @@ request_sigio () | |||
| 938 | #ifdef SIGWINCH | 941 | #ifdef SIGWINCH |
| 939 | sigunblock (sigmask (SIGWINCH)); | 942 | sigunblock (sigmask (SIGWINCH)); |
| 940 | #endif | 943 | #endif |
| 941 | fcntl (fileno (TTY_INPUT (CURTTY())), F_SETFL, old_fcntl_flags | FASYNC); | 944 | sigunblock (sigmask (SIGIO)); |
| 942 | 945 | ||
| 943 | interrupts_deferred = 0; | 946 | interrupts_deferred = 0; |
| 944 | } | 947 | } |
| 945 | 948 | ||
| 946 | void | 949 | void |
| 947 | unrequest_sigio () | 950 | unrequest_sigio (void) |
| 948 | { | 951 | { |
| 949 | if (read_socket_hook) | 952 | if (read_socket_hook) |
| 950 | return; | 953 | return; |
| @@ -952,7 +955,7 @@ unrequest_sigio () | |||
| 952 | #ifdef SIGWINCH | 955 | #ifdef SIGWINCH |
| 953 | sigblock (sigmask (SIGWINCH)); | 956 | sigblock (sigmask (SIGWINCH)); |
| 954 | #endif | 957 | #endif |
| 955 | fcntl (fileno (TTY_INPUT (CURTTY())), F_SETFL, old_fcntl_flags); | 958 | sigblock (sigmask (SIGIO)); |
| 956 | interrupts_deferred = 1; | 959 | interrupts_deferred = 1; |
| 957 | } | 960 | } |
| 958 | 961 | ||
| @@ -967,19 +970,21 @@ request_sigio () | |||
| 967 | if (read_socket_hook) | 970 | if (read_socket_hook) |
| 968 | return; | 971 | return; |
| 969 | 972 | ||
| 970 | ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &on); | 973 | /* XXX CURTTY() is bogus here. */ |
| 974 | ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &on); | ||
| 971 | interrupts_deferred = 0; | 975 | interrupts_deferred = 0; |
| 972 | } | 976 | } |
| 973 | 977 | ||
| 974 | void | 978 | void |
| 975 | unrequest_sigio () | 979 | unrequest_sigio (struct tty_output *tty) |
| 976 | { | 980 | { |
| 977 | int off = 0; | 981 | int off = 0; |
| 978 | 982 | ||
| 979 | if (read_socket_hook) | 983 | if (read_socket_hook) |
| 980 | return; | 984 | return; |
| 981 | 985 | ||
| 982 | ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &off); | 986 | /* XXX CURTTY() is bogus here. */ |
| 987 | ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &off); | ||
| 983 | interrupts_deferred = 1; | 988 | interrupts_deferred = 1; |
| 984 | } | 989 | } |
| 985 | 990 | ||
| @@ -1000,7 +1005,7 @@ request_sigio () | |||
| 1000 | 1005 | ||
| 1001 | sigemptyset (&st); | 1006 | sigemptyset (&st); |
| 1002 | sigaddset (&st, SIGIO); | 1007 | sigaddset (&st, SIGIO); |
| 1003 | ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &on); | 1008 | ioctl (0, FIOASYNC, &on); /* XXX This fails for multiple ttys. */ |
| 1004 | interrupts_deferred = 0; | 1009 | interrupts_deferred = 0; |
| 1005 | sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0); | 1010 | sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0); |
| 1006 | } | 1011 | } |
| @@ -1013,7 +1018,7 @@ unrequest_sigio () | |||
| 1013 | if (read_socket_hook) | 1018 | if (read_socket_hook) |
| 1014 | return; | 1019 | return; |
| 1015 | 1020 | ||
| 1016 | ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &off); | 1021 | ioctl (0, FIOASYNC, &off); /* XXX This fails for multiple ttys. */ |
| 1017 | interrupts_deferred = 1; | 1022 | interrupts_deferred = 1; |
| 1018 | } | 1023 | } |
| 1019 | 1024 | ||
| @@ -1728,7 +1733,7 @@ get_tty_size (tty_out, widthp, heightp) | |||
| 1728 | 1733 | ||
| 1729 | struct sensemode tty; | 1734 | struct sensemode tty; |
| 1730 | 1735 | ||
| 1731 | SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_SENSEMODE, &tty, 0, 0, | 1736 | SYS$QIOW (0, fileno (TTY_INPUT (tty_out)), IO$_SENSEMODE, &tty, 0, 0, |
| 1732 | &tty.class, 12, 0, 0, 0, 0); | 1737 | &tty.class, 12, 0, 0, 0, 0); |
| 1733 | *widthp = tty.scr_wid; | 1738 | *widthp = tty.scr_wid; |
| 1734 | *heightp = tty.scr_len; | 1739 | *heightp = tty.scr_len; |
| @@ -1795,14 +1800,12 @@ reset_all_sys_modes (void) | |||
| 1795 | } | 1800 | } |
| 1796 | } | 1801 | } |
| 1797 | 1802 | ||
| 1798 | /* Prepare the terminal for exiting Emacs; move the cursor to the | 1803 | /* Prepare the terminal for closing it; move the cursor to the |
| 1799 | bottom of the frame, turn off interrupt-driven I/O, etc. */ | 1804 | bottom of the frame, turn off interrupt-driven I/O, etc. */ |
| 1800 | void | 1805 | void |
| 1801 | reset_sys_modes (tty_out) | 1806 | reset_sys_modes (tty_out) |
| 1802 | struct tty_output *tty_out; | 1807 | struct tty_output *tty_out; |
| 1803 | { | 1808 | { |
| 1804 | struct frame *sf; | ||
| 1805 | |||
| 1806 | if (noninteractive) | 1809 | if (noninteractive) |
| 1807 | { | 1810 | { |
| 1808 | fflush (stdout); | 1811 | fflush (stdout); |
| @@ -1822,11 +1825,9 @@ reset_sys_modes (tty_out) | |||
| 1822 | ) | 1825 | ) |
| 1823 | return; | 1826 | return; |
| 1824 | #endif | 1827 | #endif |
| 1825 | sf = SELECTED_FRAME (); | 1828 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
| 1826 | cursor_to (FRAME_LINES (sf) - 1, 0); | 1829 | tty_clear_end_of_line (tty_out, FrameCols (tty_out)); |
| 1827 | clear_end_of_line (FRAME_COLS (sf)); | 1830 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
| 1828 | /* clear_end_of_line may move the cursor */ | ||
| 1829 | cursor_to (FRAME_LINES (sf) - 1, 0); | ||
| 1830 | #if defined (IBMR2AIX) && defined (AIXHFT) | 1831 | #if defined (IBMR2AIX) && defined (AIXHFT) |
| 1831 | { | 1832 | { |
| 1832 | /* HFT devices normally use ^J as a LF/CR. We forced it to | 1833 | /* HFT devices normally use ^J as a LF/CR. We forced it to |
| @@ -1852,7 +1853,7 @@ reset_sys_modes (tty_out) | |||
| 1852 | #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ | 1853 | #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ |
| 1853 | if (interrupt_input) | 1854 | if (interrupt_input) |
| 1854 | { | 1855 | { |
| 1855 | reset_sigio (); | 1856 | reset_sigio (tty_out); |
| 1856 | fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, old_fcntl_owner); | 1857 | fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, old_fcntl_owner); |
| 1857 | } | 1858 | } |
| 1858 | #endif /* F_SETOWN */ | 1859 | #endif /* F_SETOWN */ |
| @@ -1864,7 +1865,7 @@ reset_sys_modes (tty_out) | |||
| 1864 | #endif /* F_SETFL */ | 1865 | #endif /* F_SETFL */ |
| 1865 | #ifdef BSD4_1 | 1866 | #ifdef BSD4_1 |
| 1866 | if (interrupt_input) | 1867 | if (interrupt_input) |
| 1867 | reset_sigio (); | 1868 | reset_sigio (tty_out); |
| 1868 | #endif /* BSD4_1 */ | 1869 | #endif /* BSD4_1 */ |
| 1869 | 1870 | ||
| 1870 | if (tty_out->old_tty) | 1871 | if (tty_out->old_tty) |
| @@ -2170,7 +2171,8 @@ init_sigio (fd) | |||
| 2170 | request_sigio (); | 2171 | request_sigio (); |
| 2171 | } | 2172 | } |
| 2172 | 2173 | ||
| 2173 | reset_sigio () | 2174 | reset_sigio (fd) |
| 2175 | int fd; | ||
| 2174 | { | 2176 | { |
| 2175 | unrequest_sigio (); | 2177 | unrequest_sigio (); |
| 2176 | } | 2178 | } |
| @@ -2720,12 +2722,13 @@ init_sigio (fd) | |||
| 2720 | } | 2722 | } |
| 2721 | 2723 | ||
| 2722 | void | 2724 | void |
| 2723 | reset_sigio () | 2725 | reset_sigio (fd) |
| 2726 | int fd; | ||
| 2724 | { | 2727 | { |
| 2725 | if (noninteractive) | 2728 | if (noninteractive) |
| 2726 | return; | 2729 | return; |
| 2727 | lmode = ~LINTRUP & lmode; | 2730 | lmode = ~LINTRUP & lmode; |
| 2728 | ioctl (0, TIOCLSET, &lmode); | 2731 | ioctl (fd, TIOCLSET, &lmode); |
| 2729 | } | 2732 | } |
| 2730 | 2733 | ||
| 2731 | void | 2734 | void |
| @@ -3173,7 +3176,7 @@ sys_getenv (name) | |||
| 3173 | #undef abort | 3176 | #undef abort |
| 3174 | sys_abort () | 3177 | sys_abort () |
| 3175 | { | 3178 | { |
| 3176 | reset_sys_modes (); | 3179 | reset_all_sys_modes (); |
| 3177 | LIB$SIGNAL (SS$_DEBUG); | 3180 | LIB$SIGNAL (SS$_DEBUG); |
| 3178 | } | 3181 | } |
| 3179 | #endif /* abort */ | 3182 | #endif /* abort */ |
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 | ||