diff options
| author | Karoly Lorentey | 2003-12-31 05:09:29 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2003-12-31 05:09:29 +0000 |
| commit | 819b8f00ed7b8a9a2190efaa02376ed332ecf763 (patch) | |
| tree | c30ab72204225385c428db008580a9f67f5c215c /src | |
| parent | 16c290d8c16fb0fdb574c837c6b1badbc655efe2 (diff) | |
| download | emacs-819b8f00ed7b8a9a2190efaa02376ed332ecf763.tar.gz emacs-819b8f00ed7b8a9a2190efaa02376ed332ecf763.zip | |
A few more bugfixes and new features.
(Sigh.) I obviously need to remember to separate individual changes
to multiple commits.
src/emacsclient.c: Improved error handling.
(decode_options): Changed frame option (again) from -f to -t.
(print_help_and_exit): Ditto.
(copy_from_to): Check EINTR after write, not EAGAIN. Removed SIGIO hack.
(pty_conversation): Handle errors transmitted through the socket.
Handle pty errors by not reading from it anymore.
(main): Restore correct errno after socket_status failed. Send -tty
on -t, not -pty.
lisp/server.el (server-process-filter): Watch -tty, not -pty.
Use make-frame-on-tty instead of make-terminal-frame.
Don't set newframe to t if make-frame-on-tty failed.
Don't delete frames here. Print correct message when there are no
files to edit, but a new frame was requested.
(server-sentinel): Delete the frame after the process.
(server-handle-delete-frame): New function for delete-frame-functions.
(server-start): Add server-handle-delete-frame to delete-frame-functions.
(server-buffer-done): Don't delete frames here.
src/alloc.c (mark_ttys): Add prototype.
(Fgarbage_collect): Call mark_ttys.
src/emacs.c: (shut_down_emacs): Don't flush stdout before
reset_sys_modes().
src/process.c (add_keyboard_wait_descriptor_called_flag): Removed.
(add_keyboard_wait_descriptor): Removed stdin hack.
src/sysdep.c: Unconditionally include sysselect.h.
(old_fcntl_flags): Changed to an array.
(init_sigio, reset_sigio): Use it.
(narrow_foreground_group, widen_foreground_group): Use setpgid, not
setpgrp.
(old_fcntl_owner): Changed to an array.
(init_sys_modes, reset_sys_modes): Use it. Fix fsync() and reset_sigio() calls.
src/term.c (Qframe_tty_name, Qframe_tty_type): New variables.
(syms_of_term): Initialize them.
(Fframe_tty_name, Fframe_tty_type): New functions.
(term_init): Call add_keyboard_wait_descriptor().
(Fdelete_tty): New function.
(delete_tty): Call delete_keyboard_wait_descriptor().
(get_current_tty): Removed.
(mark_ttys): New function.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-28
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 2 | ||||
| -rw-r--r-- | src/emacs.c | 1 | ||||
| -rw-r--r-- | src/process.c | 14 | ||||
| -rw-r--r-- | src/sysdep.c | 39 | ||||
| -rw-r--r-- | src/term.c | 163 |
5 files changed, 160 insertions, 59 deletions
diff --git a/src/alloc.c b/src/alloc.c index 1835d2a59eb..700845ab6c5 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -256,6 +256,7 @@ EMACS_INT gcs_done; /* accumulated GCs */ | |||
| 256 | 256 | ||
| 257 | static void mark_buffer P_ ((Lisp_Object)); | 257 | static void mark_buffer P_ ((Lisp_Object)); |
| 258 | extern void mark_kboards P_ ((void)); | 258 | extern void mark_kboards P_ ((void)); |
| 259 | extern void mark_ttys P_ ((void)); | ||
| 259 | static void gc_sweep P_ ((void)); | 260 | static void gc_sweep P_ ((void)); |
| 260 | static void mark_glyph_matrix P_ ((struct glyph_matrix *)); | 261 | static void mark_glyph_matrix P_ ((struct glyph_matrix *)); |
| 261 | static void mark_face_cache P_ ((struct face_cache *)); | 262 | static void mark_face_cache P_ ((struct face_cache *)); |
| @@ -4441,6 +4442,7 @@ returns nil, because real GC can't be done. */) | |||
| 4441 | mark_object (backlist->args[i]); | 4442 | mark_object (backlist->args[i]); |
| 4442 | } | 4443 | } |
| 4443 | mark_kboards (); | 4444 | mark_kboards (); |
| 4445 | mark_ttys (); | ||
| 4444 | 4446 | ||
| 4445 | /* Look thru every buffer's undo list | 4447 | /* Look thru every buffer's undo list |
| 4446 | for elements that update markers that were not marked, | 4448 | for elements that update markers that were not marked, |
diff --git a/src/emacs.c b/src/emacs.c index 62b550a4e2c..d6f040f3f51 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -1990,7 +1990,6 @@ shut_down_emacs (sig, no_x, stuff) | |||
| 1990 | if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1 | 1990 | if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1 |
| 1991 | && tpgrp == pgrp) | 1991 | && tpgrp == pgrp) |
| 1992 | { | 1992 | { |
| 1993 | fflush (stdout); | ||
| 1994 | reset_all_sys_modes (); | 1993 | reset_all_sys_modes (); |
| 1995 | if (sig && sig != SIGTERM) | 1994 | if (sig && sig != SIGTERM) |
| 1996 | fprintf (stderr, "Fatal error (%d)", sig); | 1995 | fprintf (stderr, "Fatal error (%d)", sig); |
diff --git a/src/process.c b/src/process.c index ed0d5fe765b..3334f3258ae 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -275,11 +275,11 @@ extern int keyboard_bit_set P_ ((SELECT_TYPE *)); | |||
| 275 | 275 | ||
| 276 | static SELECT_TYPE input_wait_mask; | 276 | static SELECT_TYPE input_wait_mask; |
| 277 | 277 | ||
| 278 | /* Mask that excludes keyboard input descriptor (s). */ | 278 | /* Mask that excludes keyboard input descriptor(s). */ |
| 279 | 279 | ||
| 280 | static SELECT_TYPE non_keyboard_wait_mask; | 280 | static SELECT_TYPE non_keyboard_wait_mask; |
| 281 | 281 | ||
| 282 | /* Mask that excludes process input descriptor (s). */ | 282 | /* Mask that excludes process input descriptor(s). */ |
| 283 | 283 | ||
| 284 | static SELECT_TYPE non_process_wait_mask; | 284 | static SELECT_TYPE non_process_wait_mask; |
| 285 | 285 | ||
| @@ -6430,20 +6430,10 @@ DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p, | |||
| 6430 | 6430 | ||
| 6431 | 6431 | ||
| 6432 | 6432 | ||
| 6433 | /* The first time this is called, assume keyboard input comes from DESC | ||
| 6434 | instead of from where we used to expect it. | ||
| 6435 | Subsequent calls mean assume input keyboard can come from DESC | ||
| 6436 | in addition to other places. */ | ||
| 6437 | |||
| 6438 | static int add_keyboard_wait_descriptor_called_flag; | ||
| 6439 | |||
| 6440 | void | 6433 | void |
| 6441 | add_keyboard_wait_descriptor (desc) | 6434 | add_keyboard_wait_descriptor (desc) |
| 6442 | int desc; | 6435 | int desc; |
| 6443 | { | 6436 | { |
| 6444 | if (! add_keyboard_wait_descriptor_called_flag) | ||
| 6445 | FD_CLR (0, &input_wait_mask); | ||
| 6446 | add_keyboard_wait_descriptor_called_flag = 1; | ||
| 6447 | FD_SET (desc, &input_wait_mask); | 6437 | FD_SET (desc, &input_wait_mask); |
| 6448 | FD_SET (desc, &non_process_wait_mask); | 6438 | FD_SET (desc, &non_process_wait_mask); |
| 6449 | if (desc > max_keyboard_desc) | 6439 | if (desc > max_keyboard_desc) |
diff --git a/src/sysdep.c b/src/sysdep.c index 7453be6e3a7..98a671ddbdc 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -45,6 +45,8 @@ extern void srandom P_ ((unsigned int)); | |||
| 45 | #endif | 45 | #endif |
| 46 | #endif | 46 | #endif |
| 47 | 47 | ||
| 48 | #include "sysselect.h" | ||
| 49 | |||
| 48 | #include "blockinput.h" | 50 | #include "blockinput.h" |
| 49 | #undef NULL | 51 | #undef NULL |
| 50 | 52 | ||
| @@ -913,16 +915,15 @@ restore_signal_handlers (saved_handlers) | |||
| 913 | 915 | ||
| 914 | #ifdef F_SETFL | 916 | #ifdef F_SETFL |
| 915 | 917 | ||
| 916 | int old_fcntl_flags; | 918 | int old_fcntl_flags[MAXDESC]; |
| 917 | 919 | ||
| 918 | void | 920 | void |
| 919 | init_sigio (fd) | 921 | init_sigio (fd) |
| 920 | int fd; | 922 | int fd; |
| 921 | { | 923 | { |
| 922 | #ifdef FASYNC | 924 | #ifdef FASYNC |
| 923 | /* XXX What if we get called with more than one fds? */ | 925 | old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC; |
| 924 | old_fcntl_flags = fcntl (fd, F_GETFL, 0) & ~FASYNC; | 926 | fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC); |
| 925 | fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC); | ||
| 926 | #endif | 927 | #endif |
| 927 | interrupts_deferred = 0; | 928 | interrupts_deferred = 0; |
| 928 | } | 929 | } |
| @@ -931,7 +932,7 @@ void | |||
| 931 | reset_sigio (fd) | 932 | reset_sigio (fd) |
| 932 | int fd; | 933 | int fd; |
| 933 | { | 934 | { |
| 934 | fcntl (fd, F_SETFL, old_fcntl_flags); | 935 | fcntl (fd, F_SETFL, old_fcntl_flags[fd]); |
| 935 | } | 936 | } |
| 936 | 937 | ||
| 937 | #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ | 938 | #ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ |
| @@ -1086,11 +1087,12 @@ narrow_foreground_group (int fd) | |||
| 1086 | { | 1087 | { |
| 1087 | int me = getpid (); | 1088 | int me = getpid (); |
| 1088 | 1089 | ||
| 1089 | setpgrp (0, inherited_pgroup); | 1090 | if (! inherited_pgroup) |
| 1091 | inherited_pgroup = getpgid (0); | ||
| 1090 | /* XXX This only works on the controlling tty. */ | 1092 | /* XXX This only works on the controlling tty. */ |
| 1091 | if (inherited_pgroup != me) | 1093 | if (inherited_pgroup != me) |
| 1092 | EMACS_SET_TTY_PGRP (fd, &me); | 1094 | EMACS_SET_TTY_PGRP (fd, &me); |
| 1093 | setpgrp (0, me); | 1095 | setpgid (0, me); |
| 1094 | } | 1096 | } |
| 1095 | 1097 | ||
| 1096 | /* Set the tty to our original foreground group. */ | 1098 | /* Set the tty to our original foreground group. */ |
| @@ -1099,7 +1101,7 @@ widen_foreground_group (int fd) | |||
| 1099 | { | 1101 | { |
| 1100 | if (inherited_pgroup != getpid ()) | 1102 | if (inherited_pgroup != getpid ()) |
| 1101 | EMACS_SET_TTY_PGRP (fd, &inherited_pgroup); | 1103 | EMACS_SET_TTY_PGRP (fd, &inherited_pgroup); |
| 1102 | setpgrp (0, inherited_pgroup); | 1104 | setpgid (0, inherited_pgroup); |
| 1103 | } | 1105 | } |
| 1104 | 1106 | ||
| 1105 | #endif /* BSD_PGRPS */ | 1107 | #endif /* BSD_PGRPS */ |
| @@ -1265,7 +1267,7 @@ int lmode; | |||
| 1265 | 1267 | ||
| 1266 | #ifndef F_SETOWN_BUG | 1268 | #ifndef F_SETOWN_BUG |
| 1267 | #ifdef F_SETOWN | 1269 | #ifdef F_SETOWN |
| 1268 | int old_fcntl_owner; | 1270 | int old_fcntl_owner[MAXDESC]; |
| 1269 | #endif /* F_SETOWN */ | 1271 | #endif /* F_SETOWN */ |
| 1270 | #endif /* F_SETOWN_BUG */ | 1272 | #endif /* F_SETOWN_BUG */ |
| 1271 | 1273 | ||
| @@ -1614,7 +1616,8 @@ nil means don't delete them until `list-processes' is run. */); | |||
| 1614 | if (interrupt_input | 1616 | if (interrupt_input |
| 1615 | && ! read_socket_hook && EQ (Vwindow_system, Qnil)) | 1617 | && ! read_socket_hook && EQ (Vwindow_system, Qnil)) |
| 1616 | { | 1618 | { |
| 1617 | old_fcntl_owner = fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0); | 1619 | old_fcntl_owner[fileno (TTY_INPUT (tty_out))] = |
| 1620 | fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0); | ||
| 1618 | fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, getpid ()); | 1621 | fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, getpid ()); |
| 1619 | init_sigio (fileno (TTY_INPUT (tty_out))); | 1622 | init_sigio (fileno (TTY_INPUT (tty_out))); |
| 1620 | } | 1623 | } |
| @@ -1823,9 +1826,12 @@ reset_sys_modes (tty_out) | |||
| 1823 | ) | 1826 | ) |
| 1824 | return; | 1827 | return; |
| 1825 | #endif | 1828 | #endif |
| 1829 | |||
| 1826 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); | 1830 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
| 1827 | tty_clear_end_of_line (tty_out, FrameCols (tty_out)); | 1831 | tty_clear_end_of_line (tty_out, FrameCols (tty_out)); |
| 1828 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); | 1832 | cmgoto (tty_out, FrameRows (tty_out) - 1, 0); |
| 1833 | fflush (tty_out->output); | ||
| 1834 | |||
| 1829 | #if defined (IBMR2AIX) && defined (AIXHFT) | 1835 | #if defined (IBMR2AIX) && defined (AIXHFT) |
| 1830 | { | 1836 | { |
| 1831 | /* HFT devices normally use ^J as a LF/CR. We forced it to | 1837 | /* HFT devices normally use ^J as a LF/CR. We forced it to |
| @@ -1842,7 +1848,7 @@ reset_sys_modes (tty_out) | |||
| 1842 | #ifdef BSD_SYSTEM | 1848 | #ifdef BSD_SYSTEM |
| 1843 | #ifndef BSD4_1 | 1849 | #ifndef BSD4_1 |
| 1844 | /* Avoid possible loss of output when changing terminal modes. */ | 1850 | /* Avoid possible loss of output when changing terminal modes. */ |
| 1845 | fsync (TTY_OUTPUT (tty_out)); | 1851 | fsync (fileno (TTY_OUTPUT (tty_out))); |
| 1846 | #endif | 1852 | #endif |
| 1847 | #endif | 1853 | #endif |
| 1848 | 1854 | ||
| @@ -1851,8 +1857,9 @@ reset_sys_modes (tty_out) | |||
| 1851 | #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ | 1857 | #ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ |
| 1852 | if (interrupt_input) | 1858 | if (interrupt_input) |
| 1853 | { | 1859 | { |
| 1854 | reset_sigio (tty_out); | 1860 | reset_sigio (fileno (TTY_INPUT (tty_out))); |
| 1855 | fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, old_fcntl_owner); | 1861 | fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, |
| 1862 | old_fcntl_owner[fileno (TTY_INPUT (tty_out))]); | ||
| 1856 | } | 1863 | } |
| 1857 | #endif /* F_SETOWN */ | 1864 | #endif /* F_SETOWN */ |
| 1858 | #endif /* F_SETOWN_BUG */ | 1865 | #endif /* F_SETOWN_BUG */ |
| @@ -1863,7 +1870,7 @@ reset_sys_modes (tty_out) | |||
| 1863 | #endif /* F_SETFL */ | 1870 | #endif /* F_SETFL */ |
| 1864 | #ifdef BSD4_1 | 1871 | #ifdef BSD4_1 |
| 1865 | if (interrupt_input) | 1872 | if (interrupt_input) |
| 1866 | reset_sigio (tty_out); | 1873 | reset_sigio (fileno (TTY_INPUT (tty_out))); |
| 1867 | #endif /* BSD4_1 */ | 1874 | #endif /* BSD4_1 */ |
| 1868 | 1875 | ||
| 1869 | if (tty_out->old_tty) | 1876 | if (tty_out->old_tty) |
| @@ -2704,6 +2711,10 @@ read_input_waiting () | |||
| 2704 | } | 2711 | } |
| 2705 | } | 2712 | } |
| 2706 | 2713 | ||
| 2714 | #if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X) | ||
| 2715 | #define select sys_select | ||
| 2716 | #endif | ||
| 2717 | |||
| 2707 | #endif /* not HAVE_SELECT */ | 2718 | #endif /* not HAVE_SELECT */ |
| 2708 | #endif /* not VMS */ | 2719 | #endif /* not VMS */ |
| 2709 | #endif /* not MSDOS */ | 2720 | #endif /* not MSDOS */ |
diff --git a/src/term.c b/src/term.c index 72698ed3b2c..25f26e3c6e2 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -109,7 +109,9 @@ struct tty_output *tty_list; | |||
| 109 | pages, where one page is used for Emacs and another for all | 109 | pages, where one page is used for Emacs and another for all |
| 110 | else. */ | 110 | else. */ |
| 111 | int no_redraw_on_reenter; | 111 | int no_redraw_on_reenter; |
| 112 | 112 | ||
| 113 | Lisp_Object Qframe_tty_name, Qframe_tty_type; | ||
| 114 | |||
| 113 | /* Hook functions that you can set to snap out the functions in this file. | 115 | /* Hook functions that you can set to snap out the functions in this file. |
| 114 | These are all extern'd in termhooks.h */ | 116 | These are all extern'd in termhooks.h */ |
| 115 | 117 | ||
| @@ -2107,6 +2109,60 @@ get_named_tty (name) | |||
| 2107 | } | 2109 | } |
| 2108 | 2110 | ||
| 2109 | 2111 | ||
| 2112 | |||
| 2113 | DEFUN ("frame-tty-name", Fframe_tty_name, Sframe_tty_name, 0, 1, 0, | ||
| 2114 | doc: /* Return the name of the TTY device that FRAME is displayed on. */) | ||
| 2115 | (frame) | ||
| 2116 | Lisp_Object frame; | ||
| 2117 | { | ||
| 2118 | struct frame *f; | ||
| 2119 | |||
| 2120 | if (NILP (frame)) | ||
| 2121 | { | ||
| 2122 | f = XFRAME (selected_frame); | ||
| 2123 | } | ||
| 2124 | else | ||
| 2125 | { | ||
| 2126 | CHECK_LIVE_FRAME (frame); | ||
| 2127 | f = XFRAME (frame); | ||
| 2128 | } | ||
| 2129 | |||
| 2130 | if (f->output_method != output_termcap) | ||
| 2131 | wrong_type_argument (Qframe_tty_name, frame); | ||
| 2132 | |||
| 2133 | if (f->output_data.tty->name) | ||
| 2134 | return build_string (f->output_data.tty->name); | ||
| 2135 | else | ||
| 2136 | return Qnil; | ||
| 2137 | } | ||
| 2138 | |||
| 2139 | DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0, | ||
| 2140 | doc: /* Return the type of the TTY device that FRAME is displayed on. */) | ||
| 2141 | (frame) | ||
| 2142 | Lisp_Object frame; | ||
| 2143 | { | ||
| 2144 | struct frame *f; | ||
| 2145 | |||
| 2146 | if (NILP (frame)) | ||
| 2147 | { | ||
| 2148 | f = XFRAME (selected_frame); | ||
| 2149 | } | ||
| 2150 | else | ||
| 2151 | { | ||
| 2152 | CHECK_LIVE_FRAME (frame); | ||
| 2153 | f = XFRAME (frame); | ||
| 2154 | } | ||
| 2155 | |||
| 2156 | if (f->output_method != output_termcap) | ||
| 2157 | wrong_type_argument (Qframe_tty_type, frame); | ||
| 2158 | |||
| 2159 | if (f->output_data.tty->type) | ||
| 2160 | return build_string (f->output_data.tty->type); | ||
| 2161 | else | ||
| 2162 | return Qnil; | ||
| 2163 | } | ||
| 2164 | |||
| 2165 | |||
| 2110 | /*********************************************************************** | 2166 | /*********************************************************************** |
| 2111 | Initialization | 2167 | Initialization |
| 2112 | ***********************************************************************/ | 2168 | ***********************************************************************/ |
| @@ -2186,6 +2242,8 @@ term_init (Lisp_Object frame, char *name, char *terminal_type) | |||
| 2186 | 2242 | ||
| 2187 | TTY_TYPE (tty) = xstrdup (terminal_type); | 2243 | TTY_TYPE (tty) = xstrdup (terminal_type); |
| 2188 | 2244 | ||
| 2245 | add_keyboard_wait_descriptor (fileno (tty->input)); | ||
| 2246 | |||
| 2189 | #ifdef WINDOWSNT | 2247 | #ifdef WINDOWSNT |
| 2190 | initialize_w32_display (); | 2248 | initialize_w32_display (); |
| 2191 | 2249 | ||
| @@ -2665,27 +2723,31 @@ fatal (str, arg1, arg2) | |||
| 2665 | exit (1); | 2723 | exit (1); |
| 2666 | } | 2724 | } |
| 2667 | 2725 | ||
| 2668 | void | 2726 | |
| 2669 | syms_of_term () | 2727 | |
| 2728 | DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0, | ||
| 2729 | doc: /* Delete all frames on the terminal named TTY, and close the device. */) | ||
| 2730 | (tty) | ||
| 2731 | Lisp_Object tty; | ||
| 2670 | { | 2732 | { |
| 2671 | DEFVAR_BOOL ("system-uses-terminfo", &system_uses_terminfo, | 2733 | struct tty_output *t; |
| 2672 | doc: /* Non-nil means the system uses terminfo rather than termcap. | 2734 | char *name = 0; |
| 2673 | This variable can be used by terminal emulator packages. */); | ||
| 2674 | #ifdef TERMINFO | ||
| 2675 | system_uses_terminfo = 1; | ||
| 2676 | #else | ||
| 2677 | system_uses_terminfo = 0; | ||
| 2678 | #endif | ||
| 2679 | 2735 | ||
| 2680 | DEFVAR_LISP ("ring-bell-function", &Vring_bell_function, | 2736 | CHECK_STRING (tty); |
| 2681 | doc: /* Non-nil means call this function to ring the bell. | 2737 | |
| 2682 | The function should accept no arguments. */); | 2738 | if (SBYTES (tty) > 0) |
| 2683 | Vring_bell_function = Qnil; | 2739 | { |
| 2740 | name = (char *) alloca (SBYTES (tty) + 1); | ||
| 2741 | strncpy (name, SDATA (tty), SBYTES (tty)); | ||
| 2742 | name[SBYTES (tty)] = 0; | ||
| 2743 | } | ||
| 2684 | 2744 | ||
| 2685 | defsubr (&Stty_display_color_p); | 2745 | t = get_named_tty (name); |
| 2686 | defsubr (&Stty_display_color_cells); | ||
| 2687 | 2746 | ||
| 2688 | Fprovide (intern ("multi-tty"), Qnil); | 2747 | if (! t) |
| 2748 | error ("No such tty device: %s", name); | ||
| 2749 | |||
| 2750 | delete_tty (t); | ||
| 2689 | } | 2751 | } |
| 2690 | 2752 | ||
| 2691 | static int deleting_tty = 0; | 2753 | static int deleting_tty = 0; |
| @@ -2734,10 +2796,14 @@ delete_tty (struct tty_output *tty) | |||
| 2734 | xfree (tty->name); | 2796 | xfree (tty->name); |
| 2735 | if (tty->type) | 2797 | if (tty->type) |
| 2736 | xfree (tty->type); | 2798 | xfree (tty->type); |
| 2737 | 2799 | ||
| 2738 | if (tty->input) | 2800 | if (tty->input) |
| 2739 | fclose (tty->input); | 2801 | { |
| 2740 | if (tty->output && tty->output != tty->input) | 2802 | delete_keyboard_wait_descriptor (fileno (tty->input)); |
| 2803 | if (tty->input != stdin) | ||
| 2804 | fclose (tty->input); | ||
| 2805 | } | ||
| 2806 | if (tty->output && tty->output != stdout && tty->output != tty->input) | ||
| 2741 | fclose (tty->output); | 2807 | fclose (tty->output); |
| 2742 | if (tty->termscript) | 2808 | if (tty->termscript) |
| 2743 | fclose (tty->termscript); | 2809 | fclose (tty->termscript); |
| @@ -2754,24 +2820,57 @@ delete_tty (struct tty_output *tty) | |||
| 2754 | } | 2820 | } |
| 2755 | 2821 | ||
| 2756 | 2822 | ||
| 2757 | struct tty_output * | 2823 | |
| 2758 | get_current_tty () | ||
| 2759 | { | ||
| 2760 | return CURTTY(); | ||
| 2761 | } | ||
| 2762 | 2824 | ||
| 2825 | /* Mark the pointers in the tty_output objects. | ||
| 2826 | Called by the Fgarbage_collector. */ | ||
| 2763 | void | 2827 | void |
| 2764 | print_all_frames () | 2828 | mark_ttys () |
| 2765 | { | 2829 | { |
| 2766 | /* XXX Debug function. */ | 2830 | struct tty_output *tty; |
| 2767 | Lisp_Object frame, tail; | 2831 | Lisp_Object *p; |
| 2768 | FOR_EACH_FRAME (tail, frame) | 2832 | for (tty = tty_list; tty; tty = tty->next) |
| 2769 | { | 2833 | { |
| 2770 | fprintf (stderr, "Frame: %x\n", XFRAME (frame)); | 2834 | if (tty->top_frame) |
| 2771 | fflush (stderr); | 2835 | mark_object (tty->top_frame); |
| 2772 | } | 2836 | } |
| 2773 | } | 2837 | } |
| 2774 | 2838 | ||
| 2775 | 2839 | ||
| 2840 | |||
| 2841 | void | ||
| 2842 | syms_of_term () | ||
| 2843 | { | ||
| 2844 | DEFVAR_BOOL ("system-uses-terminfo", &system_uses_terminfo, | ||
| 2845 | doc: /* Non-nil means the system uses terminfo rather than termcap. | ||
| 2846 | This variable can be used by terminal emulator packages. */); | ||
| 2847 | #ifdef TERMINFO | ||
| 2848 | system_uses_terminfo = 1; | ||
| 2849 | #else | ||
| 2850 | system_uses_terminfo = 0; | ||
| 2851 | #endif | ||
| 2852 | |||
| 2853 | DEFVAR_LISP ("ring-bell-function", &Vring_bell_function, | ||
| 2854 | doc: /* Non-nil means call this function to ring the bell. | ||
| 2855 | The function should accept no arguments. */); | ||
| 2856 | Vring_bell_function = Qnil; | ||
| 2857 | |||
| 2858 | Qframe_tty_name = intern ("frame-tty-name"); | ||
| 2859 | staticpro (&Qframe_tty_name); | ||
| 2860 | |||
| 2861 | Qframe_tty_type = intern ("frame-tty-type"); | ||
| 2862 | staticpro (&Qframe_tty_type); | ||
| 2863 | |||
| 2864 | defsubr (&Stty_display_color_p); | ||
| 2865 | defsubr (&Stty_display_color_cells); | ||
| 2866 | defsubr (&Sframe_tty_name); | ||
| 2867 | defsubr (&Sframe_tty_type); | ||
| 2868 | defsubr (&Sdelete_tty); | ||
| 2869 | |||
| 2870 | Fprovide (intern ("multi-tty"), Qnil); | ||
| 2871 | } | ||
| 2872 | |||
| 2873 | |||
| 2874 | |||
| 2776 | /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 | 2875 | /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 |
| 2777 | (do not change this comment) */ | 2876 | (do not change this comment) */ |