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/term.c | |
| 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/term.c')
| -rw-r--r-- | src/term.c | 163 |
1 files changed, 131 insertions, 32 deletions
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) */ |