Mercurial > emacs
diff src/term.c @ 82988:f82e3a6f5ccb
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
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Wed, 31 Dec 2003 05:09:29 +0000 |
parents | 1682917e56b4 |
children | f3845715a5f6 |
line wrap: on
line diff
--- a/src/term.c Tue Dec 30 19:27:57 2003 +0000 +++ b/src/term.c Wed Dec 31 05:09:29 2003 +0000 @@ -109,7 +109,9 @@ pages, where one page is used for Emacs and another for all else. */ int no_redraw_on_reenter; - + +Lisp_Object Qframe_tty_name, Qframe_tty_type; + /* Hook functions that you can set to snap out the functions in this file. These are all extern'd in termhooks.h */ @@ -2107,6 +2109,60 @@ } + +DEFUN ("frame-tty-name", Fframe_tty_name, Sframe_tty_name, 0, 1, 0, + doc: /* Return the name of the TTY device that FRAME is displayed on. */) + (frame) + Lisp_Object frame; +{ + struct frame *f; + + if (NILP (frame)) + { + f = XFRAME (selected_frame); + } + else + { + CHECK_LIVE_FRAME (frame); + f = XFRAME (frame); + } + + if (f->output_method != output_termcap) + wrong_type_argument (Qframe_tty_name, frame); + + if (f->output_data.tty->name) + return build_string (f->output_data.tty->name); + else + return Qnil; +} + +DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0, + doc: /* Return the type of the TTY device that FRAME is displayed on. */) + (frame) + Lisp_Object frame; +{ + struct frame *f; + + if (NILP (frame)) + { + f = XFRAME (selected_frame); + } + else + { + CHECK_LIVE_FRAME (frame); + f = XFRAME (frame); + } + + if (f->output_method != output_termcap) + wrong_type_argument (Qframe_tty_type, frame); + + if (f->output_data.tty->type) + return build_string (f->output_data.tty->type); + else + return Qnil; +} + + /*********************************************************************** Initialization ***********************************************************************/ @@ -2186,6 +2242,8 @@ TTY_TYPE (tty) = xstrdup (terminal_type); + add_keyboard_wait_descriptor (fileno (tty->input)); + #ifdef WINDOWSNT initialize_w32_display (); @@ -2665,27 +2723,31 @@ exit (1); } -void -syms_of_term () + + +DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0, + doc: /* Delete all frames on the terminal named TTY, and close the device. */) + (tty) + Lisp_Object tty; { - DEFVAR_BOOL ("system-uses-terminfo", &system_uses_terminfo, - doc: /* Non-nil means the system uses terminfo rather than termcap. -This variable can be used by terminal emulator packages. */); -#ifdef TERMINFO - system_uses_terminfo = 1; -#else - system_uses_terminfo = 0; -#endif - - DEFVAR_LISP ("ring-bell-function", &Vring_bell_function, - doc: /* Non-nil means call this function to ring the bell. -The function should accept no arguments. */); - Vring_bell_function = Qnil; - - defsubr (&Stty_display_color_p); - defsubr (&Stty_display_color_cells); - - Fprovide (intern ("multi-tty"), Qnil); + struct tty_output *t; + char *name = 0; + + CHECK_STRING (tty); + + if (SBYTES (tty) > 0) + { + name = (char *) alloca (SBYTES (tty) + 1); + strncpy (name, SDATA (tty), SBYTES (tty)); + name[SBYTES (tty)] = 0; + } + + t = get_named_tty (name); + + if (! t) + error ("No such tty device: %s", name); + + delete_tty (t); } static int deleting_tty = 0; @@ -2734,10 +2796,14 @@ xfree (tty->name); if (tty->type) xfree (tty->type); - + if (tty->input) - fclose (tty->input); - if (tty->output && tty->output != tty->input) + { + delete_keyboard_wait_descriptor (fileno (tty->input)); + if (tty->input != stdin) + fclose (tty->input); + } + if (tty->output && tty->output != stdout && tty->output != tty->input) fclose (tty->output); if (tty->termscript) fclose (tty->termscript); @@ -2754,24 +2820,57 @@ } -struct tty_output * -get_current_tty () -{ - return CURTTY(); -} - + + +/* Mark the pointers in the tty_output objects. + Called by the Fgarbage_collector. */ void -print_all_frames () +mark_ttys () { - /* XXX Debug function. */ - Lisp_Object frame, tail; - FOR_EACH_FRAME (tail, frame) + struct tty_output *tty; + Lisp_Object *p; + for (tty = tty_list; tty; tty = tty->next) { - fprintf (stderr, "Frame: %x\n", XFRAME (frame)); - fflush (stderr); + if (tty->top_frame) + mark_object (tty->top_frame); } } + +void +syms_of_term () +{ + DEFVAR_BOOL ("system-uses-terminfo", &system_uses_terminfo, + doc: /* Non-nil means the system uses terminfo rather than termcap. +This variable can be used by terminal emulator packages. */); +#ifdef TERMINFO + system_uses_terminfo = 1; +#else + system_uses_terminfo = 0; +#endif + + DEFVAR_LISP ("ring-bell-function", &Vring_bell_function, + doc: /* Non-nil means call this function to ring the bell. +The function should accept no arguments. */); + Vring_bell_function = Qnil; + + Qframe_tty_name = intern ("frame-tty-name"); + staticpro (&Qframe_tty_name); + + Qframe_tty_type = intern ("frame-tty-type"); + staticpro (&Qframe_tty_type); + + defsubr (&Stty_display_color_p); + defsubr (&Stty_display_color_cells); + defsubr (&Sframe_tty_name); + defsubr (&Sframe_tty_type); + defsubr (&Sdelete_tty); + + Fprovide (intern ("multi-tty"), Qnil); +} + + + /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 (do not change this comment) */