Separate frame-local, tty-dependent parameters from tty-local parameters.
authorKaroly Lorentey <lorentey@elte.hu>
Thu, 1 Jan 2004 17:55:53 +0000 (17:55 +0000)
committerKaroly Lorentey <lorentey@elte.hu>
Thu, 1 Jan 2004 17:55:53 +0000 (17:55 +0000)
src/termchar.h (struct tty_output): Redefined to contain frame-local
tty-dependent parameters.  (Currently there are no such parameters, so
it consists of the tty_display_info pointer.)
(struct tty_display_info): New structure, with reference_count.
(FRAME_TTY): Updated to reflect new termcap frame structure.

src/term.c: Update prototypes. Use tty_display_info instead of tty_output.

src/cm.c (current_tty, cmcheckmagic, cmcostinit, calccost, cmgoto, Wcm_clear)
(Wcm_init): Use tty_display_info instead of tty_output.

src/cm.h: Update prototypes.
src/dispextern.h: Ditto.

src/dispnew.c (window_change_signal, init_display, make_terminal_frame):
Use tty_display_info instead of tty_output.

src/frame.c (Fdelete_frame): Use tty_display_info instead of
tty_output.  Fix delete_tty check.
(make_terminal_frame): Allocate f->output_data.tty.  Increase
reference count of tty device.
(delete_frame): Free f->output_data.tty.  Use reference count to
decide if the tty should be closed.

src/frame.h (FRAME_FOREGROUND_PIXEL, FRAME_BACKGROUND_PIXEL): New,
unconditional definitions.
(struct device): New declaration (at the moment, it is defined as
empty in termhooks.h).
(struct frame): Added display, background_pixel, foreground_pixel member.

src/keyboard.c (read_avail_input): Use tty_display_info instead of tty_output.

src/lisp.h: Declare struct display.  Update prototypes.

src/sysdep.c: Update prototypes.
(discard_tty_input, init_all_sys_modes, init_sys_modes, reset_all_sys_modes)
(reset_sys_modes, hft_init, hft_reset): Use tty_display_info instead
of tty_output.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-29

13 files changed:
README.multi-tty
src/cm.c
src/cm.h
src/dispextern.h
src/dispnew.c
src/frame.c
src/frame.h
src/keyboard.c
src/lisp.h
src/sysdep.c
src/term.c
src/termchar.h
src/termhooks.h

index 4519be4..8003cef 100644 (file)
@@ -107,7 +107,7 @@ DIARY OF CHANGES
 -- Implement support for reading from multiple terminals.
 
    (Done, read_avail_input tries to read from each terminal, until one
-   succeeds.  MULTIKBOARD is not used.  Secondary terminals don't send
+   succeeds.  MULTI_KBOARD is not used.  Secondary terminals don't send
    SIGIO!)
 
    (Update: They do, now.)
@@ -306,7 +306,7 @@ THINGS TO DO
 ** Fix X support.
 
 ** Allow simultaneous X and tty frames.  (Handling input could be
-   tricky.)
+   tricky.  Or maybe not.)
 
 ** Implement support for starting an interactive Emacs session without
    an initial frame.  (The user would connect to it and open frames
@@ -332,8 +332,8 @@ THINGS TO DO
 ** Make sure C-g goes to the right frame.  This is hard, as SIGINT
    doesn't have a tty parameter. :-(
 
-** I have seen a case when Emacs with multiple ttys went ate 100% of
-   CPU time.  Strace showed this loop:
+** I have seen a case when Emacs with multiple ttys fell into a loop
+   eating 100% of CPU time.  Strace showed this loop:
 
 
        getpid()                                = 30284
index 1094e30..74f119d 100644 (file)
--- a/src/cm.c
+++ b/src/cm.c
@@ -62,7 +62,7 @@ evalcost (c)
 }
 
 /* The terminal to use for low-level output. */
-struct tty_output * current_tty;
+struct tty_display_info *current_tty;
 
 int
 cmputc (c)
@@ -135,7 +135,7 @@ addcol (tty, n) {
  * after we reach the last column; this takes us to a known state.
  */
 void
-cmcheckmagic (struct tty_output *tty)
+cmcheckmagic (struct tty_display_info *tty)
 {
   if (curX (tty) == FrameCols (tty))
     {
@@ -160,7 +160,7 @@ cmcheckmagic (struct tty_output *tty)
  */
 
 void
-cmcostinit (struct tty_output *tty)
+cmcostinit (struct tty_display_info *tty)
 {
     char *p;
 
@@ -200,7 +200,8 @@ cmcostinit (struct tty_output *tty)
  */
 
 static int
-calccost (struct tty_output *tty, int srcy, int srcx, int dsty, int dstx, int doit)
+calccost (struct tty_display_info *tty,
+          int srcy, int srcx, int dsty, int dstx, int doit)
 {
     register int    deltay,
                     deltax,
@@ -336,7 +337,7 @@ losecursor ()
 
 void
 cmgoto (tty, row, col)
-     struct tty_output *tty;
+     struct tty_display_info *tty;
      int row, col;
 {
     int     homecost,
@@ -441,7 +442,7 @@ cmgoto (tty, row, col)
  */
 
 void
-Wcm_clear (struct tty_output *tty)
+Wcm_clear (struct tty_display_info *tty)
 {
   bzero (tty->Wcm, sizeof (struct cm));
   UP = 0;
@@ -456,7 +457,7 @@ Wcm_clear (struct tty_output *tty)
  */
 
 int
-Wcm_init (struct tty_output *tty)
+Wcm_init (struct tty_display_info *tty)
 {
 #if 0
   if (tty->Wcm->cm_abs && !tty->Wcm->cm_ds)
index e71859c..1b6c952 100644 (file)
--- a/src/cm.h
+++ b/src/cm.h
@@ -163,13 +163,13 @@ extern int evalcost ();
 
 #define emacs_tputs(tty, str, affcnt, putc) (current_tty = (tty), tputs (str, affcnt, putc))
 
-extern struct tty_output *current_tty;
-extern void cmcheckmagic P_ ((struct tty_output *));
+extern struct tty_display_info *current_tty;
+extern void cmcheckmagic P_ ((struct tty_display_info *));
 extern int cmputc P_ ((int));
-extern void cmcostinit P_ ((struct tty_output *));
-extern void cmgoto P_ ((struct tty_output *, int, int));
-extern void Wcm_clear P_ ((struct tty_output *));
-extern int Wcm_init P_ ((struct tty_output *));
+extern void cmcostinit P_ ((struct tty_display_info *));
+extern void cmgoto P_ ((struct tty_display_info *, int, int));
+extern void Wcm_clear P_ ((struct tty_display_info *));
+extern int Wcm_init P_ ((struct tty_display_info *));
 
 /* arch-tag: acc1535a-7136-49d6-b22d-9bc85702251b
    (do not change this comment) */
index a486406..4b47aaf 100644 (file)
@@ -2738,25 +2738,25 @@ extern void update_begin P_ ((struct frame *));
 extern void update_end P_ ((struct frame *));
 extern void set_terminal_window P_ ((int));
 extern void set_scroll_region P_ ((int, int));
-extern void turn_off_insert P_ ((struct tty_output *));
-extern void turn_off_highlight P_ ((struct tty_output *));
-extern void background_highlight P_ ((struct tty_output *));
+extern void turn_off_insert P_ ((struct tty_display_info *));
+extern void turn_off_highlight P_ ((struct tty_display_info *));
+extern void background_highlight P_ ((struct tty_display_info *));
 extern void clear_frame P_ ((void));
 extern void clear_end_of_line P_ ((int));
 extern void clear_end_of_line_raw P_ ((int));
-extern void tty_clear_end_of_line P_ ((struct tty_output *, int));
+extern void tty_clear_end_of_line P_ ((struct tty_display_info *, int));
 extern void delete_glyphs P_ ((int));
 extern void ins_del_lines P_ ((int, int));
 extern int string_cost P_ ((char *));
 extern int per_line_cost P_ ((char *));
 extern void calculate_costs P_ ((struct frame *));
 extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
-extern void tty_setup_colors P_ ((struct tty_output *, int));
-extern struct tty_output *term_init P_ ((Lisp_Object, char *, char *));
-extern struct tty_output *term_dummy_init P_ ((void));
+extern void tty_setup_colors P_ ((struct tty_display_info *, int));
+extern struct tty_display_info *term_init P_ ((Lisp_Object, char *, char *));
+extern struct tty_display_info *term_dummy_init P_ ((void));
 extern void fatal P_ ((/* char *, ... */));
 void cursor_to P_ ((int, int));
-extern int tty_capable_p P_ ((struct tty_output *, unsigned, unsigned long, unsigned long));
+extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
 
 /* Defined in scroll.c */
 
index 593067e..4401e2d 100644 (file)
@@ -5916,7 +5916,7 @@ window_change_signal (signalnum) /* If we don't have an argument, */
 #endif
   int old_errno = errno;
 
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   
   /* The frame size change obviously applies to a single
      termcap-controlled terminal, but we can't decide which.
@@ -6625,7 +6625,7 @@ For types not defined in VMS, use  define emacs_term \"TYPE\".\n\
 #endif /* VMS */
 
   {
-    struct tty_output *tty;
+    struct tty_display_info *tty;
     
     tty = term_init (selected_frame, 0, terminal_type);
     change_frame_size (XFRAME (selected_frame), FrameRows (tty), FrameCols (tty), 0, 0, 0);
index f26bf9a..af2cd20 100644 (file)
@@ -544,20 +544,27 @@ make_terminal_frame (tty_name, tty_type)
   make_mac_terminal_frame (f);
 #else
   {
-    struct tty_output *tty;
+    struct tty_display_info *tty;
     f->output_method = output_termcap;
+
+    f->output_data.tty = (struct tty_output *) xmalloc (sizeof (struct tty_output));
+    bzero (f->output_data.tty, sizeof (struct tty_output));
+
+    FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
+    FRAME_BACKGROUND_PIXEL (f) = FACE_TTY_DEFAULT_BG_COLOR;
     
     if (initialized)
       {
         /* Note that term_init may signal an error, but then it is its
            responsibility to make sure this frame is deleted. */
-        f->output_data.tty = term_init (frame, tty_name, tty_type);
+        f->output_data.tty->display_info = term_init (frame, tty_name, tty_type);
       }
     else
       {
         /* init_display() will reinitialize the terminal with correct values after dump. */
-        f->output_data.tty = term_dummy_init ();
+        f->output_data.tty->display_info = term_dummy_init ();
       }
+    FRAME_TTY (f)->reference_count++;
   }
   
 #ifdef CANNOT_DUMP
@@ -1390,28 +1397,17 @@ The functions are run with one arg, the frame to be deleted.  */)
 
   if (FRAME_TERMCAP_P (f))
     {
-      Lisp_Object tail, frame1;
       int delete = 1;
-      struct tty_output *tty = FRAME_TTY (f);
+      struct tty_display_info *tty = FRAME_TTY (f);
 
-      /* delete_tty will call us recursively, so better kill the
-         frame now. */
-      f->output_data.nothing = 0;
-      
-      /* See if the terminal needs to be closed. */
-      FOR_EACH_FRAME (tail, frame1)
+      if (! --tty->reference_count)
         {
-          if (frame1 != frame
-              && FRAME_LIVE_P (XFRAME (frame1))
-              && FRAME_TERMCAP_P (XFRAME (frame1))
-              && FRAME_TTY (XFRAME (frame1)) == FRAME_TTY (f))
-            {
-              delete = 0;
-              break;
-            }
+          /* delete_tty would call us recursively if we don't kill the
+             frame now. */
+          xfree (f->output_data.tty);
+          f->output_data.nothing = 0;
+          delete_tty (tty);
         }
-      if (delete)
-        delete_tty (tty);
     }
   else
     {
index 06af557..5c46546 100644 (file)
@@ -65,34 +65,10 @@ enum text_cursor_kinds
   HBAR_CURSOR
 };
 
-#if !defined(MSDOS) && !defined(WINDOWSNT) && !defined(MAC_OS)
+#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
+#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
 
-#if !defined(HAVE_X_WINDOWS)
-
-#define PIX_TYPE unsigned long
-
-/* A (mostly empty) x_output structure definition for building Emacs
-   on Unix and GNU/Linux without X support.  */
-struct x_output
-{
-  PIX_TYPE background_pixel;
-  PIX_TYPE foreground_pixel;
-};
-
-#endif /* ! HAVE_X_WINDOWS */
-
-
-#define FRAME_FOREGROUND_PIXEL(f)             \
-  (((f)->output_method == output_termcap)     \
-   ? ((f)->output_data.tty->foreground_pixel) \
-   : ((f)->output_data.x->foreground_pixel))
-
-#define FRAME_BACKGROUND_PIXEL(f)             \
-  (((f)->output_method == output_termcap)     \
-   ? ((f)->output_data.tty->background_pixel) \
-   : ((f)->output_data.x->background_pixel))
-
-#endif /* ! MSDOS && ! WINDOWSNT && ! MAC_OS */
+struct device;
 
 struct frame
 {
@@ -280,12 +256,15 @@ struct frame
   /* Canonical Y unit.  Height of a line, in pixels.  */
   int line_height;
 
+  /* The display hooks to use with this frame. */
+  struct display *display;
+  
   /* The output method says how the contents of this frame
      are displayed.  It could be using termcap, or using an X window.  */
   enum output_method output_method;
 
   /* A structure of auxiliary data used for displaying the contents.
-     struct tty_output is used for terminal frames;
+     struct tty_output is used for termcap frames;
      it is defined in term.h.
      struct x_output is used for X window frames;
      it is defined in xterm.h.
@@ -457,6 +436,10 @@ struct frame
      Clear the frame in clear_garbaged_frames if set.  */
   unsigned resized_p : 1;
 
+  /* All display backends seem to need these two pixel values. */
+  unsigned long background_pixel;
+  unsigned long foreground_pixel;
+  
   /* Set to non-zero if the default face for the frame has been
      realized.  Reset to zero whenever the default face changes.
      Used to see the difference between a font change and face change.  */
index c9124f0..1751df6 100644 (file)
@@ -6612,7 +6612,7 @@ read_avail_input (expected)
         of characters on some systems when input is stuffed at us.  */
       unsigned char cbuf[KBD_BUFFER_SIZE - 1];
       int n_to_read;
-      struct tty_output *tty;
+      struct tty_display_info *tty;
       Lisp_Object frame;
       
 #ifdef WINDOWSNT
index 412c7d2..8c6374e 100644 (file)
@@ -2937,7 +2937,10 @@ EXFUN (Fx_popup_dialog, 2);
 extern void syms_of_xmenu P_ ((void));
 
 /* defined in termchar.h */
-struct tty_output;
+struct tty_display_info;
+
+/* defined in termhooks.h */
+struct display;
 
 /* defined in sysdep.c */
 extern void stuff_char P_ ((char c));
@@ -2945,8 +2948,8 @@ extern void init_sigio P_ ((int));
 extern void sys_subshell P_ ((void));
 extern void sys_suspend P_ ((void));
 extern void discard_tty_input P_ ((void));
-extern void init_sys_modes P_ ((struct tty_output *));
-extern void reset_sys_modes P_ ((struct tty_output *));
+extern void init_sys_modes P_ ((struct tty_display_info *));
+extern void reset_sys_modes P_ ((struct tty_display_info *));
 extern void init_all_sys_modes P_ ((void));
 extern void reset_all_sys_modes P_ ((void));
 extern void wait_for_termination P_ ((int));
index 98a671d..7710c2a 100644 (file)
@@ -252,8 +252,8 @@ int emacs_ospeed;
 void croak P_ ((char *));
 
 #ifdef AIXHFT
-void hft_init P_ ((struct tty_output *));
-void hft_reset P_ ((struct tty_output *));
+void hft_init P_ ((struct tty_display_info *));
+void hft_reset P_ ((struct tty_display_info *));
 #endif
 
 /* Temporary used by `sigblock' when defined in terms of signprocmask.  */
@@ -285,7 +285,7 @@ discard_tty_input ()
 #else /* not VMS */
 #ifdef APOLLO
   {
-    struct tty_output *tty;
+    struct tty_display_info *tty;
     for (tty = tty_list; tty; tty = tty->next)
       {
         int zero = 0;
@@ -298,7 +298,7 @@ discard_tty_input ()
     ;
 #else /* not MSDOS */
   {
-    struct tty_output *tty;
+    struct tty_display_info *tty;
     for (tty = tty_list; tty; tty = tty->next)
       {
         EMACS_GET_TTY (fileno (TTY_INPUT (tty)), &buf);
@@ -1295,14 +1295,14 @@ static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
 void
 init_all_sys_modes (void)
 {
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   for (tty = tty_list; tty; tty = tty->next)
     init_sys_modes (tty);
 }
 
 void
 init_sys_modes (tty_out)
-     struct tty_output *tty_out;
+     struct tty_display_info *tty_out;
 {
   struct emacs_tty tty;
 
@@ -1796,7 +1796,7 @@ set_window_size (fd, height, width)
 void
 reset_all_sys_modes (void)
 {
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   for (tty = tty_list; tty; tty = tty->next)
     reset_sys_modes (tty);
 }
@@ -1805,7 +1805,7 @@ reset_all_sys_modes (void)
    bottom of the frame, turn off interrupt-driven I/O, etc.  */
 void
 reset_sys_modes (tty_out)
-     struct tty_output *tty_out;
+     struct tty_display_info *tty_out;
 {
   if (noninteractive)
     {
@@ -5110,7 +5110,7 @@ srandom (seed)
 
 /* Called from init_sys_modes.  */
 void
-hft_init (struct tty_output *tty_out)
+hft_init (struct tty_display_info *tty_out)
 {
   int junk;
 
@@ -5165,7 +5165,7 @@ hft_init (struct tty_output *tty_out)
 /* Reset the rubout key to backspace.  */
 
 void
-hft_reset (struct tty_output *tty_out)
+hft_reset (struct tty_display_info *tty_out)
 {
   struct hfbuf buf;
   struct hfkeymap keymap;
index 25f26e3..cce411d 100644 (file)
@@ -69,11 +69,11 @@ extern int tgetnum P_ ((char *id));
 
 static void turn_on_face P_ ((struct frame *, int face_id));
 static void turn_off_face P_ ((struct frame *, int face_id));
-static void tty_show_cursor P_ ((struct tty_output *));
-static void tty_hide_cursor P_ ((struct tty_output *));
+static void tty_show_cursor P_ ((struct tty_display_info *));
+static void tty_hide_cursor P_ ((struct tty_display_info *));
 
-void delete_tty P_ ((struct tty_output *));
-static void delete_tty_1 P_ ((struct tty_output *));
+void delete_tty P_ ((struct tty_display_info *));
+static void delete_tty_1 P_ ((struct tty_display_info *));
 
 
 #define OUTPUT(tty, a)                                          \
@@ -102,7 +102,7 @@ Lisp_Object Vring_bell_function;
 
 /* Terminal characteristics that higher levels want to look at. */
 
-struct tty_output *tty_list;
+struct tty_display_info *tty_list;
 
 /* Nonzero means no need to redraw the entire frame on resuming a
    suspended Emacs.  This is useful on terminals with multiple
@@ -319,12 +319,12 @@ ring_bell ()
   else if (!FRAME_TERMCAP_P (f))
     (*ring_bell_hook) ();
   else {
-    struct tty_output *tty = FRAME_TTY (f);
+    struct tty_display_info *tty = FRAME_TTY (f);
     OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell);
   }
 }
 
-void tty_set_terminal_modes (struct tty_output *tty)
+void tty_set_terminal_modes (struct tty_display_info *tty)
 {
   OUTPUT_IF (tty, tty->TS_termcap_modes);
   OUTPUT_IF (tty, tty->TS_cursor_visible);
@@ -342,7 +342,7 @@ set_terminal_modes ()
     (*set_terminal_modes_hook) ();
 }
 
-void tty_reset_terminal_modes (struct tty_output *tty)
+void tty_reset_terminal_modes (struct tty_display_info *tty)
 {
   turn_off_highlight (tty);
   turn_off_insert (tty);
@@ -380,7 +380,7 @@ update_end (f)
 {
   if (FRAME_TERMCAP_P (f))
     {
-      struct tty_output *tty = FRAME_TTY (f);
+      struct tty_display_info *tty = FRAME_TTY (f);
       if (!XWINDOW (selected_window)->cursor_off_p)
        tty_show_cursor (tty);
       turn_off_insert (tty);
@@ -399,7 +399,7 @@ set_terminal_window (size)
   struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
   if (FRAME_TERMCAP_P (f))
     {
-      struct tty_output *tty = FRAME_TTY (f);
+      struct tty_display_info *tty = FRAME_TTY (f);
       tty->specified_window = size ? size : FRAME_LINES (f);
       if (TTY_SCROLL_REGION_OK (tty))
        set_scroll_region (0, tty->specified_window);
@@ -414,7 +414,7 @@ set_scroll_region (start, stop)
 {
   char *buf;
   struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-  struct tty_output *tty = FRAME_TTY (f);
+  struct tty_display_info *tty = FRAME_TTY (f);
 
   if (tty->TS_set_scroll_region)
     buf = tparam (tty->TS_set_scroll_region, 0, 0, start, stop - 1);
@@ -433,7 +433,7 @@ set_scroll_region (start, stop)
 
 \f
 static void
-turn_on_insert (struct tty_output *tty)
+turn_on_insert (struct tty_display_info *tty)
 {
   if (!tty->insert_mode)
     OUTPUT (tty, tty->TS_insert_mode);
@@ -441,7 +441,7 @@ turn_on_insert (struct tty_output *tty)
 }
 
 void
-turn_off_insert (struct tty_output *tty)
+turn_off_insert (struct tty_display_info *tty)
 {
   if (tty->insert_mode)
     OUTPUT (tty, tty->TS_end_insert_mode);
@@ -451,7 +451,7 @@ turn_off_insert (struct tty_output *tty)
 /* Handle highlighting.  */
 
 void
-turn_off_highlight (struct tty_output *tty)
+turn_off_highlight (struct tty_display_info *tty)
 {
   if (tty->standout_mode)
     OUTPUT_IF (tty, tty->TS_end_standout_mode);
@@ -459,7 +459,7 @@ turn_off_highlight (struct tty_output *tty)
 }
 
 static void
-turn_on_highlight (struct tty_output *tty)
+turn_on_highlight (struct tty_display_info *tty)
 {
   if (!tty->standout_mode)
     OUTPUT_IF (tty, tty->TS_standout_mode);
@@ -467,7 +467,7 @@ turn_on_highlight (struct tty_output *tty)
 }
 
 static void
-toggle_highlight (struct tty_output *tty)
+toggle_highlight (struct tty_display_info *tty)
 {
   if (tty->standout_mode)
     turn_off_highlight (tty);
@@ -479,7 +479,7 @@ toggle_highlight (struct tty_output *tty)
 /* Make cursor invisible.  */
 
 static void
-tty_hide_cursor (struct tty_output *tty)
+tty_hide_cursor (struct tty_display_info *tty)
 {
   if (tty->cursor_hidden == 0)
     {
@@ -492,7 +492,7 @@ tty_hide_cursor (struct tty_output *tty)
 /* Ensure that cursor is visible.  */
 
 static void
-tty_show_cursor (struct tty_output *tty)
+tty_show_cursor (struct tty_display_info *tty)
 {
   if (tty->cursor_hidden)
     {
@@ -508,7 +508,7 @@ tty_show_cursor (struct tty_output *tty)
    depends on the user option inverse-video.  */
 
 void
-background_highlight (struct tty_output *tty)
+background_highlight (struct tty_display_info *tty)
 {
   if (inverse_video)
     turn_on_highlight (tty);
@@ -519,7 +519,7 @@ background_highlight (struct tty_output *tty)
 /* Set standout mode to the mode specified for the text to be output.  */
 
 static void
-highlight_if_desired (struct tty_output *tty)
+highlight_if_desired (struct tty_display_info *tty)
 {
   if (inverse_video)
     turn_on_highlight (tty);
@@ -536,7 +536,7 @@ cursor_to (vpos, hpos)
      int vpos, hpos;
 {
   struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   
   if (! FRAME_TERMCAP_P (f) && cursor_to_hook)
     {
@@ -568,7 +568,7 @@ raw_cursor_to (row, col)
      int row, col;
 {
   struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   if (! FRAME_TERMCAP_P (f))
     {
       (*raw_cursor_to_hook) (row, col);
@@ -594,7 +594,7 @@ clear_to_end ()
   register int i;
 
   struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   
   if (clear_to_end_hook && ! FRAME_TERMCAP_P (f))
     {
@@ -623,7 +623,7 @@ void
 clear_frame ()
 {
   struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   
   if (clear_frame_hook && ! FRAME_TERMCAP_P (f))
     {
@@ -654,7 +654,7 @@ clear_end_of_line (first_unused_hpos)
      int first_unused_hpos;
 {
   struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   
   if (clear_end_of_line_hook
       && ! FRAME_TERMCAP_P (f))
@@ -667,7 +667,7 @@ clear_end_of_line (first_unused_hpos)
 }
 
 void
-tty_clear_end_of_line (struct tty_output *tty, int first_unused_hpos)
+tty_clear_end_of_line (struct tty_display_info *tty, int first_unused_hpos)
 {
   register int i;
   /* Detect the case where we are called from reset_sys_modes
@@ -818,7 +818,7 @@ write_glyphs (string, len)
 {
   int produced, consumed;
   struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   unsigned char conversion_buffer[1024];
   int conversion_buffer_size = sizeof conversion_buffer;
 
@@ -923,7 +923,7 @@ insert_glyphs (start, len)
   char *buf;
   struct glyph *glyph = NULL;
   struct frame *f;
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   
   if (len <= 0)
     return;
@@ -1016,7 +1016,7 @@ delete_glyphs (n)
   char *buf;
   register int i;
   struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame));
-  struct tty_output *tty = FRAME_TTY (f);
+  struct tty_display_info *tty = FRAME_TTY (f);
 
   if (delete_glyphs_hook && ! FRAME_TERMCAP_P (f))
     {
@@ -1062,7 +1062,7 @@ ins_del_lines (vpos, n)
     }
   else
     {
-      struct tty_output *tty = FRAME_TTY (f);
+      struct tty_display_info *tty = FRAME_TTY (f);
       char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines;
       char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line;
       char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll;
@@ -1181,7 +1181,7 @@ static void
 calculate_ins_del_char_costs (f)
      FRAME_PTR f;
 {
-  struct tty_output *tty = FRAME_TTY (f);
+  struct tty_display_info *tty = FRAME_TTY (f);
   int ins_startup_cost, del_startup_cost;
   int ins_cost_per_char, del_cost_per_char;
   register int i;
@@ -1243,7 +1243,7 @@ void
 calculate_costs (frame)
      FRAME_PTR frame;
 {
-  struct tty_output *tty = FRAME_TTY (frame);
+  struct tty_display_info *tty = FRAME_TTY (frame);
   register char *f = (tty->TS_set_scroll_region
                      ? tty->TS_set_scroll_region
                      : tty->TS_set_scroll_region_1);
@@ -1251,7 +1251,7 @@ calculate_costs (frame)
   FRAME_COST_BAUD_RATE (frame) = baud_rate;
 
   if (FRAME_TERMCAP_P (frame))
-    TTY_SCROLL_REGION_COST (frame->output_data.tty) = string_cost (f);
+    TTY_SCROLL_REGION_COST (FRAME_TTY (frame)) = string_cost (f);
 
   /* These variables are only used for terminal stuff.  They are allocated
      once for the terminal frame of X-windows emacs, but not used afterwards.
@@ -1761,7 +1761,7 @@ turn_on_face (f, face_id)
   struct face *face = FACE_FROM_ID (f, face_id);
   long fg = face->foreground;
   long bg = face->background;
-  struct tty_output *tty = FRAME_TTY (f);
+  struct tty_display_info *tty = FRAME_TTY (f);
 
   /* Do this first because TS_end_standout_mode may be the same
      as TS_exit_attribute_mode, which turns all appearances off. */
@@ -1859,7 +1859,7 @@ turn_off_face (f, face_id)
      int face_id;
 {
   struct face *face = FACE_FROM_ID (f, face_id);
-  struct tty_output *tty = FRAME_TTY (f);
+  struct tty_display_info *tty = FRAME_TTY (f);
 
   xassert (face != NULL);
 
@@ -1910,7 +1910,7 @@ turn_off_face (f, face_id)
 
 int
 tty_capable_p (tty, caps, fg, bg)
-     struct tty_output *tty;
+     struct tty_display_info *tty;
      unsigned caps;
      unsigned long fg, bg;
 {
@@ -1938,7 +1938,7 @@ DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
      (display)
      Lisp_Object display;
 {
-  struct tty_output *tty = FRAME_TTY (SELECTED_FRAME ());
+  struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ());
   return tty->TN_max_colors > 0 ? Qt : Qnil;
 }
 
@@ -1949,7 +1949,7 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
      (display)
      Lisp_Object display;
 {
-  struct tty_output *tty = FRAME_TTY (SELECTED_FRAME ());
+  struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ());
   return make_number (tty->TN_max_colors);
 }
 
@@ -1958,7 +1958,7 @@ DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
 /* Save or restore the default color-related capabilities of this
    terminal.  */
 static void
-tty_default_color_capabilities (struct tty_output *tty, int save)
+tty_default_color_capabilities (struct tty_display_info *tty, int save)
 {
   static char
     *default_orig_pair, *default_set_foreground, *default_set_background;
@@ -2000,7 +2000,7 @@ tty_default_color_capabilities (struct tty_output *tty, int save)
    support; zero means set up for the default capabilities, the ones
    we saw at term_init time; -1 means turn off color support.  */
 void
-tty_setup_colors (struct tty_output *tty, int mode)
+tty_setup_colors (struct tty_display_info *tty, int mode)
 {
   /* Canonicalize all negative values of MODE.  */
   if (mode < -1)
@@ -2092,11 +2092,11 @@ set_tty_color_mode (f, val)
 
 \f
 
-struct tty_output *
+struct tty_display_info *
 get_named_tty (name)
      char *name;
 {
-  struct tty_output *tty = tty_list;
+  struct tty_display_info *tty = tty_list;
 
   while (tty) {
     if ((tty->name == 0 && name == 0)
@@ -2130,8 +2130,8 @@ DEFUN ("frame-tty-name", Fframe_tty_name, Sframe_tty_name, 0, 1, 0,
   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);
+  if (FRAME_TTY (f)->name)
+    return build_string (FRAME_TTY (f)->name);
   else
     return Qnil;
 }
@@ -2156,8 +2156,8 @@ DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0,
   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);
+  if (FRAME_TTY (f)->type)
+    return build_string (FRAME_TTY (f)->type);
   else
     return Qnil;
 }
@@ -2167,22 +2167,22 @@ DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0,
                            Initialization
  ***********************************************************************/
 
-struct tty_output *
+struct tty_display_info *
 term_dummy_init (void)
 {
   if (initialized || tty_list)
     error ("tty already initialized");
 
-  tty_list = xmalloc (sizeof (struct tty_output));
-  bzero (tty_list, sizeof (struct tty_output));
-  TTY_NAME (tty_list) = 0;
-  TTY_INPUT (tty_list) = stdin;
-  TTY_OUTPUT (tty_list) = stdout;
+  tty_list = xmalloc (sizeof (struct tty_display_info));
+  bzero (tty_list, sizeof (struct tty_display_info));
+  tty_list->name = 0;
+  tty_list->input = stdin;
+  tty_list->input = stdout;
   return tty_list;
 }
 
 
-struct tty_output *
+struct tty_display_info *
 term_init (Lisp_Object frame, char *name, char *terminal_type)
 {
   char *area;
@@ -2192,7 +2192,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
   register char *p;
   int status;
   struct frame *f = XFRAME (frame);
-  struct tty_output *tty;
+  struct tty_display_info *tty;
 
   tty = get_named_tty (name);
   if (tty)
@@ -2204,8 +2204,8 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
     }
   else
     {
-      tty = (struct tty_output *) xmalloc (sizeof (struct tty_output));
-      bzero (tty, sizeof (struct tty_output));
+      tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
+      bzero (tty, sizeof (struct tty_display_info));
       tty->next = tty_list;
       tty_list = tty;
     }
@@ -2216,7 +2216,9 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
   /* Make sure the frame is live; if an error happens, it must be
      deleted. */
   f->output_method = output_termcap;
-  f->output_data.tty = tty;
+  if (! f->output_data.tty)
+    abort ();
+  f->output_data.tty->display_info = tty;
   
   if (name)
     {
@@ -2229,18 +2231,18 @@ term_init (Lisp_Object frame, char *name, char *terminal_type)
           error ("Could not open file: %s", name);
         }
       file = fdopen (fd, "w+");
-      TTY_NAME (tty) = xstrdup (name);
-      TTY_INPUT (tty) = file;
-      TTY_OUTPUT (tty) = file;
+      tty->name = xstrdup (name);
+      tty->input = file;
+      tty->output = file;
     }
   else
     {
-      TTY_NAME (tty) = 0;
-      TTY_INPUT (tty) = stdin;
-      TTY_OUTPUT (tty) = stdout;
+      tty->name = 0;
+      tty->input = stdin;
+      tty->output = stdout;
     }
 
-  TTY_TYPE (tty) = xstrdup (terminal_type);
+  tty->type = xstrdup (terminal_type);
 
   add_keyboard_wait_descriptor (fileno (tty->input));
   
@@ -2699,9 +2701,6 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
 
   tty->top_frame = frame;
   
-  tty->foreground_pixel = FACE_TTY_DEFAULT_FG_COLOR;
-  tty->background_pixel = FACE_TTY_DEFAULT_BG_COLOR;
-  
   /* Init system terminal modes (RAW or CBREAK, etc.).  */
   init_sys_modes (tty);
   
@@ -2730,7 +2729,7 @@ DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0,
   (tty)
      Lisp_Object tty;
 {
-  struct tty_output *t;
+  struct tty_display_info *t;
   char *name = 0;
 
   CHECK_STRING (tty);
@@ -2753,7 +2752,7 @@ DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0,
 static int deleting_tty = 0;
 
 void
-delete_tty (struct tty_output *tty)
+delete_tty (struct tty_display_info *tty)
 {
   Lisp_Object tail, frame;
   
@@ -2768,7 +2767,7 @@ delete_tty (struct tty_output *tty)
     tty_list = tty->next;
   else
     {
-      struct tty_output *p;
+      struct tty_display_info *p;
       for (p = tty_list; p && p->next != tty; p = p->next)
         ;
 
@@ -2814,7 +2813,7 @@ delete_tty (struct tty_output *tty)
   if (tty->Wcm)
     xfree (tty->Wcm); 
   
-  bzero (tty, sizeof (struct tty_output));
+  bzero (tty, sizeof (struct tty_display_info));
   xfree (tty);
   deleting_tty = 0;
 }
@@ -2822,12 +2821,12 @@ delete_tty (struct tty_output *tty)
 
 \f
 
-/* Mark the pointers in the tty_output objects.
+/* Mark the pointers in the tty_display_info objects.
    Called by the Fgarbage_collector.  */
 void
 mark_ttys ()
 {
-  struct tty_output *tty;
+  struct tty_display_info *tty;
   Lisp_Object *p;
   for (tty = tty_list; tty; tty = tty->next)
     {
index a9a74dd..49b1be8 100644 (file)
@@ -18,11 +18,22 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-/* Each termcap frame points to its own struct tty_output object in the
-   output_data.tty field.  The tty_output structure contains the information
-   that is specific to terminals. */
+/* Each termcap frame points to its own struct tty_output object in
+   the output_data.tty field.  The tty_output structure contains the
+   information that is specific to termcap frames. */
 struct tty_output
 {
+  /* The Emacs structure for the tty device this frame is on. */
+  struct tty_display_info *display_info;
+
+  /* There is nothing else here at the moment... */
+};
+
+/* Parameters that are shared between frames on the same tty device. */
+struct tty_display_info
+{
+  struct tty_display_info *next; /* Chain of all tty devices. */
+  
   char *name;                   /* The name of the device file or 0 if
                                    stdin/stdout. */
   char *type;                   /* The type of the tty. */
@@ -40,8 +51,9 @@ struct tty_output
   int term_initted;             /* 1 if we have been through init_sys_modes. */
 
 
-  /* Structure for info on cursor positioning.  */
-
+  int reference_count;          /* Number of frames that are on this display. */
+  
+  /* Info on cursor positioning.  */
   struct cm *Wcm;
 
   /* Redisplay. */
@@ -52,12 +64,6 @@ struct tty_output
   /* The previous terminal frame we displayed on this tty.  */
   struct frame *previous_terminal_frame;
 
-  /* Pixel values.
-     XXX What are these used for? */
-  
-  unsigned long background_pixel;
-  unsigned long foreground_pixel;
-
   /* Terminal characteristics. */
   
   int must_write_spaces;       /* Nonzero means spaces in the text must
@@ -192,22 +198,18 @@ struct tty_output
   /* Flag used in tty_show/hide_cursor.  */
 
   int cursor_hidden;
-
-
-  struct tty_output *next;
 };
 
-extern struct tty_output *tty_list;
+/* A chain of structures for all tty devices currently in use. */
+extern struct tty_display_info *tty_list;
 
 
-#define FRAME_TTY(f) \
-  ((f)->output_method == output_termcap \
-   ? (f)->output_data.tty : (abort(), (struct tty_output *) 0))
-  
-#define CURTTY() FRAME_TTY (SELECTED_FRAME())
+#define FRAME_TTY(f)                            \
+  ((f)->output_method == output_termcap         \
+   ? (f)->output_data.tty->display_info         \
+   : (abort(), (struct tty_display_info *) 0))
 
-#define TTY_NAME(t) ((t)->name)
-#define TTY_TYPE(t) ((t)->type)
+#define CURTTY() FRAME_TTY (SELECTED_FRAME())
 
 #define TTY_INPUT(t) ((t)->input)
 #define TTY_OUTPUT(t) ((t)->output)
@@ -221,11 +223,5 @@ extern struct tty_output *tty_list;
 #define TTY_SCROLL_REGION_COST(t) ((t)->scroll_region_cost)
 #define TTY_MEMORY_BELOW_FRAME(t) ((t)->memory_below_frame)
 
-#if 0
-/* These are not used anywhere. */
-#define TTY_MIN_PADDING_SPEED(t) ((t)->min_padding_speed)
-#define TTY_DONT_CALCULATE_COSTS(t) ((t)->dont_calculate_costs)
-#endif
-
 /* arch-tag: bf9f0d49-842b-42fb-9348-ec8759b27193
    (do not change this comment) */
index 0fc48a8..0802ec5 100644 (file)
@@ -30,6 +30,12 @@ struct frame;
 #define P_(X) ()
 #endif
 \f
+/* Device-local parameters. */
+struct device
+{
+  /* XXX Display hooks will go here. */
+};
+
 /* Text display hooks.  */
 
 extern void (*cursor_to_hook) P_ ((int vpos, int hpos));