diff src/term.c @ 83431:76396de7f50a

Rename `struct device' to `struct terminal'. Rename some terminal-related functions similarly. * src/termhooks.h (struct device): Rename to `terminal'. Rename member `next_device' to `next_terminal'. (device_list): Rename to `terminal_list'. (FRAME_DEVICE): Rename to `FRAME_TERMINAL'. (DEVICE_TERMINAL_CODING): Rename to `TERMINAL_TERMINAL_CODING'. (TERMINAL_KEYBOARD_CODING): Rename to `TERMINAL_KEYBOARD_CODING'. (DEVICE_ACTIVE_P): Rename to `TERMINAL_ACTIVE_P'. Update declarations and macro definitions. * src/termchar.h (tty_display_info): Rename member `device' to `terminal'. (FRAME_TTY): Update for renames. * src/xterm.h (x_display_info): Rename member `device' to `terminal'. * src/frame.h (frame): Rename `device' member to `terminal'. (FRAME_KBOARD, FRAME_LIVE_P, Qdevice, Qdisplay_live_p): Update for renames. * src/lisp.h (set_process_environment): Rename to `set_global_environment'. (device): Rename to `terminal'. * src/dispextern.h: Update declarations and macro definitions. * src/terminal.c (device_list): Rename to `terminal_list'. (next_device_id): Rename to `next_terminal_id'. (initial_device): Rename to `initial_terminal'. (get_device): Rename to `get_terminal'. (create_device): Rename to `create_terminal'. (mark_devices): Rename to `mark_terminals'. (delete_device): Rename to `delete_terminal'. (Fdelete_display): Rename to `Fdelete_terminal'. (Fframe_terminal): Move here from frame.c. (Fdisplay_live_p): Rename to `Fterminal_live_p'. (Fdisplay_list): Rename to `Fterminal_list'. (Fdisplay_name): Rename to `Fterminal_name'. (init_initial_device): Rename to `init_initial_terminal'. (delete_initial_device): Rename to `delete_initial_terminal'. (ring_bell, update_begin, update_end, set_terminal_window) (cursor_to, raw_cursor_to, clear_to_end, clear_frame) (clear_end_of_line, write_glyphs, insert_glyphs, delete_glyphs) (ins_del_lines, get_terminal_param, store_terminal_param) (Fterminal_parameters, Fterminal_parameter) (Fmodify_terminal_parameters, Fset_terminal_parameter) (syms_of_terminal): Update for renames. * src/term.c (get_tty_device): Rename to `get_tty_terminal'. Update. (Fdisplay_tty_type): Rename to `Ftty_type'. (Fdisplay_controlling_tty_p): Rename to `Fcontrolling_tty_p'. (delete_tty, tty_set_terminal_modes, tty_reset_terminal_modes) (Ftty_display_color_p, Ftty_display_color_cells, get_named_tty) (Ftty_no_underline, Fsuspend_tty, Fresume_tty, create_tty_output) (init_tty, maybe_fatal, delete_tty, syms_of_term): Update for rename. * src/frame.c (Qdevice): Rename to `Qterminal'. (Qdisplay_live_p): Rename to `Qterminal_live_p'. (terminal_frame_count): Rename to `tty_frame_count'. (Fframe_display): Move to terminal.c, rename to `Fframe_terminal'. (make_frame_without_minibuffer, make_initial_frame) (make_terminal_frame, Fmodify_frame_parameters) (do_switch_frame, Fdelete_frame, Fmouse_position) (Fmouse_pixel_position, Fraise_frame, Flower_frame) (Fredirect_frame_focus, set_term_frame_name, syms_of_frame): Update for renames. * src/xdisp.c (message2_nolog, message3_nolog, redisplay_internal) (set_vertical_scroll_bar, redisplay_window, check_x_display_info) (x_set_scroll_bar_foreground, x_set_scroll_bar_background) (Fx_create_frame, Fxw_display_color_p, Fx_display_grayscale_p) (Fx_display_pixel_width, Fx_display_pixel_height) (Fx_display_planes, Fx_display_color_cells) (Fx_server_max_request_size, Fx_server_vendor, Fx_server_version) (Fx_display_screens, Fx_display_mm_height, Fx_display_mm_width) (Fx_display_backing_store, Fx_display_visual_class) (Fx_display_save_under, Fx_close_connection, x_create_tip_frame): Update for renames. * xterm.c (handle_one_xevent): Initialize `f' to NULL. (x_delete_device): Rename to `x_delete_terminal'. (x_create_device): Rename to `x_create_terminal'. (XTset_terminal_modes, XTreset_terminal_modes) (XTread_socket, x_connection_closed, x_term_init) (x_term_init, x_delete_display): Update for renames. * src/dispnew.c (Fredraw_frame, Fsend_string_to_terminal) (Fsend_string_to_terminal, init_display): Update for renames. * src/keyboard.c (push_frame_kboard, pop_kboard, pop_kboard) (kbd_buffer_get_event, read_avail_input, tty_read_avail_input) (interrupt_signal, Fset_output_flow_control) (Fset_input_meta_mode, Fset_quit_char, delete_kboard) (syms_of_keyboard): Update for renames. * src/alloc.c (mark_devices): Update declaration. (Fgarbage_collect): Update for renames. * src/coding.c (Fset_terminal_coding_system_internal) (Fterminal_coding_system4) (Fset_keyboard_coding_system_internal) (Fkeyboard_coding_system): Update for renames. * src/data.c (Fterminal_local_value, Fset_terminal_local_value): Update for renames. * src/minibuf.c (read_minibuf): Update for renames. * src/sysdep.c (init_sys_modes, reset_sys_modes): Update for renames. * xselect.c (x_handle_selection_clear): Update for renames. * lisp/files.el (save-buffers-kill-display): Rename to `save-buffers-kill-terminal'. (save-buffers-kill-terminal, ctl-x-map): Update for renames. * frame.el (make-frame): Rename 'device frame parameter to 'terminal. Update. (frames-on-display-list, framep-on-display, suspend-frame): Update for renames. (selected-display): Rename to `selected-terminal'. * server.el (server-save-buffers-kill-display): Rename to `server-save-buffers-kill-terminal'. (server-delete-client, server-handle-delete-frame) (server-handle-suspend-tty, server-process-filter) (server-switch-buffer): Update for renames. * startup.el (normal-splash-screen, normal-splash-screen): Update for renames. * talk.el (talk): Update for renames. * termdev.el (terminal-id): Update for renames. * xt-mouse.el (turn-on-xterm-mouse-tracking-on-terminal) (turn-off-xterm-mouse-tracking-on-terminal) (xterm-mouse-handle-delete-frame): Update for renames. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-471
author Karoly Lorentey <lorentey@elte.hu>
date Thu, 29 Dec 2005 18:20:26 +0000
parents 521d3f18b3d1
children c69d44922688
line wrap: on
line diff
--- a/src/term.c	Thu Dec 29 04:57:14 2005 +0000
+++ b/src/term.c	Thu Dec 29 18:20:26 2005 +0000
@@ -87,7 +87,7 @@
 static void tty_hide_cursor P_ ((struct tty_display_info *));
 static void tty_background_highlight P_ ((struct tty_display_info *tty));
 static void dissociate_if_controlling_tty P_ ((int fd));
-static void delete_tty P_ ((struct device *));
+static void delete_tty P_ ((struct terminal *));
 
 #define OUTPUT(tty, a)                                          \
   emacs_tputs ((tty), a,                                        \
@@ -198,9 +198,9 @@
 /* Set up termcap modes for Emacs. */
 
 void
-tty_set_terminal_modes (struct device *display)
+tty_set_terminal_modes (struct terminal *terminal)
 {
-  struct tty_display_info *tty = display->display_info.tty;
+  struct tty_display_info *tty = terminal->display_info.tty;
   
   if (tty->output)
     {
@@ -227,9 +227,9 @@
 /* Reset termcap modes before exiting Emacs. */
 
 void
-tty_reset_terminal_modes (struct device *display)
+tty_reset_terminal_modes (struct terminal *terminal)
 {
-  struct tty_display_info *tty = display->display_info.tty;
+  struct tty_display_info *tty = terminal->display_info.tty;
 
   if (tty->output)
     {
@@ -246,7 +246,7 @@
     }
 }
 
-/* Flag the end of a display update on a termcap display. */
+/* Flag the end of a display update on a termcap terminal. */
 
 static void
 tty_update_end (struct frame *f)
@@ -1809,30 +1809,37 @@
 
 DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
        0, 1, 0,
-       doc: /* Return non-nil if the display device DEVICE can display colors.
-DEVICE must be a tty device.  */)
-     (device)
-     Lisp_Object device;
+       doc: /* Return non-nil if the tty device TERMINAL can display colors.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  This function always returns nil if TERMINAL
+is not on a tty device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_tty_device (device);
-  if (!d)
+  struct terminal *t = get_tty_terminal (terminal);
+  if (!t)
     return Qnil;
   else
-    return d->display_info.tty->TN_max_colors > 0 ? Qt : Qnil;
+    return t->display_info.tty->TN_max_colors > 0 ? Qt : Qnil;
 }
 
 /* Return the number of supported colors.  */
 DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
        Stty_display_color_cells, 0, 1, 0,
-       doc: /* Return the number of colors supported by the tty device DEVICE.  */)
-     (device)
-     Lisp_Object device;
+       doc: /* Return the number of colors supported by the tty device TERMINAL.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  This function always returns nil if TERMINAL
+is not on a tty device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_tty_device (device);
-  if (!d)
+  struct terminal *t = get_tty_terminal (terminal);
+  if (!t)
     return make_number (0);
   else
-    return make_number (d->display_info.tty->TN_max_colors);
+    return make_number (t->display_info.tty->TN_max_colors);
 }
 
 #ifndef WINDOWSNT
@@ -1974,20 +1981,20 @@
 
 
 
-/* Return the tty display object specified by DEVICE. */
-
-struct device *
-get_tty_device (Lisp_Object terminal)
+/* Return the tty display object specified by TERMINAL. */
+
+struct terminal *
+get_tty_terminal (Lisp_Object terminal)
 {
-  struct device *d = get_device (terminal, 0);
-
-  if (d && d->type == output_initial)
-    d = NULL;
-
-  if (d && d->type != output_termcap)
-    error ("Device %d is not a termcap display device", d->id);
-
-  return d;
+  struct terminal *t = get_terminal (terminal, 0);
+
+  if (t && t->type == output_initial)
+    t = NULL;
+
+  if (t && t->type != output_termcap)
+    error ("Device %d is not a termcap terminal device", t->id);
+
+  return t;
 }
 
 /* Return the active termcap device that uses the tty device with the
@@ -1998,75 +2005,77 @@
 
    Returns NULL if the named terminal device is not opened.  */
  
-struct device *
+struct terminal *
 get_named_tty (name)
      char *name;
 {
-  struct device *d;
-
-  for (d = device_list; d; d = d->next_device) {
-    if (d->type == output_termcap
-        && ((d->display_info.tty->name == 0 && name == 0)
-            || (name && d->display_info.tty->name
-                && !strcmp (d->display_info.tty->name, name)))
-        && DEVICE_ACTIVE_P (d))
-      return d;
+  struct terminal *t;
+
+  for (t = terminal_list; t; t = t->next_terminal) {
+    if (t->type == output_termcap
+        && ((t->display_info.tty->name == 0 && name == 0)
+            || (name && t->display_info.tty->name
+                && !strcmp (t->display_info.tty->name, name)))
+        && TERMINAL_ACTIVE_P (t))
+      return t;
   };
 
   return 0;
 }
 
 
-DEFUN ("display-tty-type", Fdisplay_tty_type, Sdisplay_tty_type, 0, 1, 0,
-       doc: /* Return the type of the tty device that DEVICE uses.
-
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device). */)
-  (device)
-     Lisp_Object device;
+DEFUN ("tty-type", Ftty_type, Stty_type, 0, 1, 0,
+       doc: /* Return the type of the tty device that TERMINAL uses.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_device (device, 1);
-
-  if (d->type != output_termcap)
-    error ("Display %d is not a termcap display", d->id);
+  struct terminal *t = get_terminal (terminal, 1);
+
+  if (t->type != output_termcap)
+    error ("Terminal %d is not a termcap terminal", t->id);
            
-  if (d->display_info.tty->type)
-    return build_string (d->display_info.tty->type);
+  if (t->display_info.tty->type)
+    return build_string (t->display_info.tty->type);
   else
     return Qnil;
 }
 
-DEFUN ("display-controlling-tty-p", Fdisplay_controlling_tty_p, Sdisplay_controlling_tty_p, 0, 1, 0,
-       doc: /* Return non-nil if DEVICE is on the controlling tty of the Emacs process.
-
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device).  */)
-  (device)
-     Lisp_Object device;
+DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0,
+       doc: /* Return non-nil if TERMINAL is on the controlling tty of the Emacs process.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  This function always returns nil if TERMINAL
+is not on a tty device.  */)
+     (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_device (device, 1);
-
-  if (d->type != output_termcap || d->display_info.tty->name)
+  struct terminal *t = get_terminal (terminal, 1);
+
+  if (t->type != output_termcap || t->display_info.tty->name)
     return Qnil;
   else
     return Qt;
 }
 
 DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0,
-       doc: /* Declare that the tty used by DEVICE does not handle underlining.
+       doc: /* Declare that the tty used by TERMINAL does not handle underlining.
 This is used to override the terminfo data, for certain terminals that
 do not really do underlining, but say that they do.  This function has
-no effect if used on a non-tty display.
-
-DEVICE may be a display device id, a frame, or nil (meaning the
-selected frame's display device).  */)
-  (device)
-     Lisp_Object device;
+no effect if used on a non-tty terminal.
+
+TERMINAL can be a terminal id, a frame or nil (meaning the selected
+frame's terminal).  This function always returns nil if TERMINAL
+is not on a tty device.  */)
+  (terminal)
+     Lisp_Object terminal;
 {
-  struct device *d = get_device (device, 1);
-
-  if (d->type == output_termcap)
-    d->display_info.tty->TS_enter_underline_mode = 0;
+  struct terminal *t = get_terminal (terminal, 1);
+
+  if (t->type == output_termcap)
+    t->display_info.tty->TS_enter_underline_mode = 0;
   return Qnil;
 }
 
@@ -2094,36 +2103,36 @@
      (tty)
      Lisp_Object tty;
 {
-  struct device *d = get_tty_device (tty);
+  struct terminal *t = get_tty_terminal (tty);
   FILE *f;
   
-  if (!d)
+  if (!t)
     error ("Unknown tty device");
 
-  f = d->display_info.tty->input;
+  f = t->display_info.tty->input;
   
   if (f)
     {
-      reset_sys_modes (d->display_info.tty);
+      reset_sys_modes (t->display_info.tty);
 
       delete_keyboard_wait_descriptor (fileno (f));
       
       fclose (f);
-      if (f != d->display_info.tty->output)
-        fclose (d->display_info.tty->output);
+      if (f != t->display_info.tty->output)
+        fclose (t->display_info.tty->output);
       
-      d->display_info.tty->input = 0;
-      d->display_info.tty->output = 0;
-
-      if (FRAMEP (d->display_info.tty->top_frame))
-        FRAME_SET_VISIBLE (XFRAME (d->display_info.tty->top_frame), 0);
+      t->display_info.tty->input = 0;
+      t->display_info.tty->output = 0;
+
+      if (FRAMEP (t->display_info.tty->top_frame))
+        FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0);
       
       /* Run `suspend-tty-functions'.  */
       if (!NILP (Vrun_hooks))
         {
           Lisp_Object args[2];
           args[0] = intern ("suspend-tty-functions");
-          args[1] = make_number (d->id);
+          args[1] = make_number (t->id);
           Frun_hook_with_args (2, args);
         }
     }
@@ -2134,56 +2143,56 @@
 DEFUN ("resume-tty", Fresume_tty, Sresume_tty, 0, 1, 0,
        doc: /* Resume the previously suspended terminal device TTY.
 The terminal is opened and reinitialized.  Frames that are on the
-suspended display are revived.
-
-It is an error to resume a display while another display is active on
-the same device.
-
-This function runs `resume-tty-functions' after resuming the device.
-The functions are run with one arg, the id of the resumed display
+suspended terminal are revived.
+
+It is an error to resume a terminal while another terminal is active
+on the same device.
+
+This function runs `resume-tty-functions' after resuming the terminal.
+The functions are run with one arg, the id of the resumed terminal
 device.
 
 `resume-tty' does nothing if it is called on a device that is not
 suspended.
 
-TTY may be a display device id, a frame, or nil for the display device
-of the currently selected frame. */)
+TTY may be a terminal id, a frame, or nil for the terminal device of
+the currently selected frame. */)
      (tty)
      Lisp_Object tty;
 {
-  struct device *d = get_tty_device (tty);
+  struct terminal *t = get_tty_terminal (tty);
   int fd;
 
-  if (!d)
+  if (!t)
     error ("Unknown tty device");
 
-  if (!d->display_info.tty->input)
+  if (!t->display_info.tty->input)
     {
-      if (get_named_tty (d->display_info.tty->name))
+      if (get_named_tty (t->display_info.tty->name))
         error ("Cannot resume display while another display is active on the same device");
 
-      fd = emacs_open (d->display_info.tty->name, O_RDWR | O_NOCTTY, 0);
+      fd = emacs_open (t->display_info.tty->name, O_RDWR | O_NOCTTY, 0);
 
       /* XXX What if open fails? */
 
       dissociate_if_controlling_tty (fd);
       
-      d->display_info.tty->output = fdopen (fd, "w+");
-      d->display_info.tty->input = d->display_info.tty->output;
+      t->display_info.tty->output = fdopen (fd, "w+");
+      t->display_info.tty->input = t->display_info.tty->output;
     
       add_keyboard_wait_descriptor (fd);
 
-      if (FRAMEP (d->display_info.tty->top_frame))
-        FRAME_SET_VISIBLE (XFRAME (d->display_info.tty->top_frame), 1);
-
-      init_sys_modes (d->display_info.tty);
+      if (FRAMEP (t->display_info.tty->top_frame))
+        FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
+
+      init_sys_modes (t->display_info.tty);
 
       /* Run `suspend-tty-functions'.  */
       if (!NILP (Vrun_hooks))
         {
           Lisp_Object args[2];
           args[0] = intern ("resume-tty-functions");
-          args[1] = make_number (d->id);
+          args[1] = make_number (t->id);
           Frun_hook_with_args (2, args);
         }
     }
@@ -2210,7 +2219,7 @@
   t = xmalloc (sizeof (struct tty_output));
   bzero (t, sizeof (struct tty_output));
 
-  t->display_info = FRAME_DEVICE (f)->display_info.tty;
+  t->display_info = FRAME_TERMINAL (f)->display_info.tty;
 
   f->output_data.tty = t;
 }
@@ -2271,7 +2280,7 @@
 
    If MUST_SUCCEED is true, then all errors are fatal. */
 
-struct device *
+struct terminal *
 init_tty (char *name, char *terminal_type, int must_succeed)
 {
   char *area;
@@ -2281,72 +2290,72 @@
   register char *p;
   int status;
   struct tty_display_info *tty;
-  struct device *device;
+  struct terminal *terminal;
 
   if (!terminal_type)
     maybe_fatal (must_succeed, 0, 0,
                  "Unknown terminal type",
                  "Unknown terminal type");
 
-  /* If we already have a display on the given device, use that.  If
-     all such displays are suspended, create a new one instead.  */
+  /* If we already have a terminal on the given device, use that.  If
+     all such terminals are suspended, create a new one instead.  */
   /* XXX Perhaps this should be made explicit by having init_tty
-     always create a new display and separating device and frame
+     always create a new terminal and separating terminal and frame
      creation on Lisp level.  */
-  device = get_named_tty (name);
-  if (device)
-    return device;
-
-  device = create_device ();
+  terminal = get_named_tty (name);
+  if (terminal)
+    return terminal;
+
+  terminal = create_terminal ();
   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;
 
-  device->type = output_termcap;
-  device->display_info.tty = tty;
-  tty->device = device;
+  terminal->type = output_termcap;
+  terminal->display_info.tty = tty;
+  tty->terminal = terminal;
 
   tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
   Wcm_clear (tty);
 
-  device->rif = 0; /* ttys don't support window-based redisplay. */
-
-  device->cursor_to_hook = &tty_cursor_to;
-  device->raw_cursor_to_hook = &tty_raw_cursor_to;
-
-  device->clear_to_end_hook = &tty_clear_to_end;
-  device->clear_frame_hook = &tty_clear_frame;
-  device->clear_end_of_line_hook = &tty_clear_end_of_line;
-
-  device->ins_del_lines_hook = &tty_ins_del_lines;
-
-  device->insert_glyphs_hook = &tty_insert_glyphs;
-  device->write_glyphs_hook = &tty_write_glyphs;
-  device->delete_glyphs_hook = &tty_delete_glyphs;
-
-  device->ring_bell_hook = &tty_ring_bell;
+  terminal->rif = 0; /* ttys don't support window-based redisplay. */
+
+  terminal->cursor_to_hook = &tty_cursor_to;
+  terminal->raw_cursor_to_hook = &tty_raw_cursor_to;
+
+  terminal->clear_to_end_hook = &tty_clear_to_end;
+  terminal->clear_frame_hook = &tty_clear_frame;
+  terminal->clear_end_of_line_hook = &tty_clear_end_of_line;
+
+  terminal->ins_del_lines_hook = &tty_ins_del_lines;
+
+  terminal->insert_glyphs_hook = &tty_insert_glyphs;
+  terminal->write_glyphs_hook = &tty_write_glyphs;
+  terminal->delete_glyphs_hook = &tty_delete_glyphs;
+
+  terminal->ring_bell_hook = &tty_ring_bell;
   
-  device->reset_terminal_modes_hook = &tty_reset_terminal_modes;
-  device->set_terminal_modes_hook = &tty_set_terminal_modes;
-  device->update_begin_hook = 0; /* Not needed. */
-  device->update_end_hook = &tty_update_end;
-  device->set_terminal_window_hook = &tty_set_terminal_window;
-
-  device->mouse_position_hook = 0; /* Not needed. */
-  device->frame_rehighlight_hook = 0; /* Not needed. */
-  device->frame_raise_lower_hook = 0; /* Not needed. */
-
-  device->set_vertical_scroll_bar_hook = 0; /* Not needed. */
-  device->condemn_scroll_bars_hook = 0; /* Not needed. */
-  device->redeem_scroll_bar_hook = 0; /* Not needed. */
-  device->judge_scroll_bars_hook = 0; /* Not needed. */
-
-  device->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
-  device->frame_up_to_date_hook = 0; /* Not needed. */
+  terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes;
+  terminal->set_terminal_modes_hook = &tty_set_terminal_modes;
+  terminal->update_begin_hook = 0; /* Not needed. */
+  terminal->update_end_hook = &tty_update_end;
+  terminal->set_terminal_window_hook = &tty_set_terminal_window;
+
+  terminal->mouse_position_hook = 0; /* Not needed. */
+  terminal->frame_rehighlight_hook = 0; /* Not needed. */
+  terminal->frame_raise_lower_hook = 0; /* Not needed. */
+
+  terminal->set_vertical_scroll_bar_hook = 0; /* Not needed. */
+  terminal->condemn_scroll_bars_hook = 0; /* Not needed. */
+  terminal->redeem_scroll_bar_hook = 0; /* Not needed. */
+  terminal->judge_scroll_bars_hook = 0; /* Not needed. */
+
+  terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
+  terminal->frame_up_to_date_hook = 0; /* Not needed. */
   
-  device->delete_frame_hook = &delete_tty_output;
-  device->delete_device_hook = &delete_tty;
+  terminal->delete_frame_hook = &delete_tty_output;
+  terminal->delete_terminal_hook = &delete_tty;
   
   if (name)
     {
@@ -2370,7 +2379,7 @@
 
       if (fd < 0)
         {
-          delete_tty (device);
+          delete_tty (terminal);
           error ("Could not open file: %s", name);
         }
       if (!isatty (fd))
@@ -2383,7 +2392,7 @@
       
       file = fdopen (fd, "w+");
       tty->name = xstrdup (name);
-      device->name = xstrdup (name);
+      terminal->name = xstrdup (name);
       tty->input = file;
       tty->output = file;
     }
@@ -2396,7 +2405,7 @@
           error ("There is no controlling terminal any more");
         }
       tty->name = 0;
-      device->name = xstrdup (ttyname (0));
+      terminal->name = xstrdup (ttyname (0));
       tty->input = stdin;
       tty->output = stdout;
     }
@@ -2418,16 +2427,16 @@
   FrameCols (tty) = FRAME_COLS (f);  /* XXX */
   tty->specified_window = FRAME_LINES (f); /* XXX */
 
-  tty->device->delete_in_insert_mode = 1;
+  tty->terminal->delete_in_insert_mode = 1;
 
   UseTabs (tty) = 0;
-  device->scroll_region_ok = 0;
+  terminal->scroll_region_ok = 0;
 
   /* Seems to insert lines when it's not supposed to, messing up the
-     device.  In doing a trace, it didn't seem to be called much, so I
+     display.  In doing a trace, it didn't seem to be called much, so I
      don't think we're losing anything by turning it off.  */
-  device->line_ins_del_ok = 0;
-  device->char_ins_del_ok = 1;
+  terminal->line_ins_del_ok = 0;
+  terminal->char_ins_del_ok = 1;
 
   baud_rate = 19200;
 
@@ -2435,7 +2444,7 @@
   FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; /* XXX */
   TN_max_colors = 16;  /* Required to be non-zero for tty-display-color-p */
 
-  return device;
+  return terminal;
 #else  /* not WINDOWSNT */
 
   Wcm_clear (tty);
@@ -2451,11 +2460,11 @@
   if (status < 0)
     {
 #ifdef TERMINFO
-      maybe_fatal (must_succeed, buffer, device,
+      maybe_fatal (must_succeed, buffer, terminal,
                    "Cannot open terminfo database file",
                    "Cannot open terminfo database file");
 #else
-      maybe_fatal (must_succeed, buffer, device,
+      maybe_fatal (must_succeed, buffer, terminal,
                    "Cannot open termcap database file",
                    "Cannot open termcap database file");
 #endif
@@ -2463,7 +2472,7 @@
   if (status == 0)
     {
 #ifdef TERMINFO
-      maybe_fatal (must_succeed, buffer, device,
+      maybe_fatal (must_succeed, buffer, terminal,
                    "Terminal type %s is not defined",
                    "Terminal type %s is not defined.\n\
 If that is not the actual type of terminal you have,\n\
@@ -2472,7 +2481,7 @@
 to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
                    terminal_type);
 #else
-      maybe_fatal (must_succeed, buffer, device,
+      maybe_fatal (must_succeed, buffer, terminal,
                    "Terminal type %s is not defined",
                    "Terminal type %s is not defined.\n\
 If that is not the actual type of terminal you have,\n\
@@ -2594,9 +2603,9 @@
   /* Since we make MagicWrap terminals look like AutoWrap, we need to have
      the former flag imply the latter.  */
   AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am");
-  device->memory_below_frame = tgetflag ("db");
+  terminal->memory_below_frame = tgetflag ("db");
   tty->TF_hazeltine = tgetflag ("hz");
-  device->must_write_spaces = tgetflag ("in");
+  terminal->must_write_spaces = tgetflag ("in");
   tty->meta_key = tgetflag ("km") || tgetflag ("MT");
   tty->TF_insmode_motion = tgetflag ("mi");
   tty->TF_standout_motion = tgetflag ("ms");
@@ -2604,19 +2613,19 @@
   tty->TF_teleray = tgetflag ("xt");
 
 #ifdef MULTI_KBOARD
-  device->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
-  init_kboard (device->kboard);
-  device->kboard->next_kboard = all_kboards;
-  all_kboards = device->kboard;
-  device->kboard->reference_count++;
+  terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+  init_kboard (terminal->kboard);
+  terminal->kboard->next_kboard = all_kboards;
+  all_kboards = terminal->kboard;
+  terminal->kboard->reference_count++;
   /* Don't let the initial kboard remain current longer than necessary.
      That would cause problems if a file loaded on startup tries to
      prompt in the mini-buffer.  */
   if (current_kboard == initial_kboard)
-    current_kboard = device->kboard;
+    current_kboard = terminal->kboard;
 #endif
 
-  term_get_fkeys (address, device->kboard);
+  term_get_fkeys (address, terminal->kboard);
 
   /* Get frame size from system, or else from termcap.  */
   {
@@ -2632,13 +2641,13 @@
     FrameRows (tty) = tgetnum ("li");
 
   if (FrameRows (tty) < 3 || FrameCols (tty) < 3)
-    maybe_fatal (must_succeed, NULL, device,
+    maybe_fatal (must_succeed, NULL, terminal,
                  "Screen size %dx%d is too small"
                  "Screen size %dx%d is too small",
                  FrameCols (tty), FrameRows (tty));
 
 #if 0  /* This is not used anywhere. */
-  tty->device->min_padding_speed = tgetnum ("pb");
+  tty->terminal->min_padding_speed = tgetnum ("pb");
 #endif
 
   TabWidth (tty) = tgetnum ("tw");
@@ -2716,7 +2725,7 @@
 
   if (!strcmp (terminal_type, "supdup"))
     {
-      device->memory_below_frame = 1;
+      terminal->memory_below_frame = 1;
       tty->Wcm->cm_losewrap = 1;
     }
   if (!strncmp (terminal_type, "c10", 3)
@@ -2743,7 +2752,7 @@
 	    tty->TS_set_window = "\033v%C %C %C %C ";
 	}
       /* Termcap entry often fails to have :in: flag */
-      device->must_write_spaces = 1;
+      terminal->must_write_spaces = 1;
       /* :ti string typically fails to have \E^G! in it */
       /* This limits scope of insert-char to one line.  */
       strcpy (area, tty->TS_termcap_modes);
@@ -2765,7 +2774,7 @@
 
   if (Wcm_init (tty) == -1)	/* can't do cursor motion */
     {
-      maybe_fatal (must_succeed, NULL, device,
+      maybe_fatal (must_succeed, NULL, terminal,
                    "Terminal type \"%s\" is not powerful enough to run Emacs",
 #ifdef VMS
                    "Terminal type \"%s\" is not powerful enough to run Emacs.\n\
@@ -2794,7 +2803,7 @@
     }
 
   if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0)
-    maybe_fatal (must_succeed, NULL, device,
+    maybe_fatal (must_succeed, NULL, terminal,
                  "Could not determine the frame size",
                  "Could not determine the frame size");
 
@@ -2808,30 +2817,30 @@
 
   UseTabs (tty) = tabs_safe_p (fileno (tty->input)) && TabWidth (tty) == 8;
 
-  device->scroll_region_ok
+  terminal->scroll_region_ok
     = (tty->Wcm->cm_abs
        && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1));
 
-  device->line_ins_del_ok
+  terminal->line_ins_del_ok
     = (((tty->TS_ins_line || tty->TS_ins_multi_lines)
         && (tty->TS_del_line || tty->TS_del_multi_lines))
-       || (device->scroll_region_ok
+       || (terminal->scroll_region_ok
            && tty->TS_fwd_scroll && tty->TS_rev_scroll));
 
-  device->char_ins_del_ok
+  terminal->char_ins_del_ok
     = ((tty->TS_ins_char || tty->TS_insert_mode
         || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars)
        && (tty->TS_del_char || tty->TS_del_multi_chars));
 
-  device->fast_clear_end_of_line = tty->TS_clr_line != 0;
+  terminal->fast_clear_end_of_line = tty->TS_clr_line != 0;
 
   init_baud_rate (fileno (tty->input));
 
 #ifdef AIXHFT
   /* The HFT system on AIX doesn't optimize for scrolling, so it's
      really ugly at times.  */
-  device->line_ins_del_ok = 0;
-  device->char_ins_del_ok = 0;
+  terminal->line_ins_del_ok = 0;
+  terminal->char_ins_del_ok = 0;
 #endif
 
   /* Don't do this.  I think termcap may still need the buffer. */
@@ -2840,26 +2849,26 @@
   /* Init system terminal modes (RAW or CBREAK, etc.).  */
   init_sys_modes (tty);
 
-  return device;
+  return terminal;
 #endif /* not WINDOWSNT */
 }
 
 /* Auxiliary error-handling function for init_tty.
-   Free BUFFER and delete DEVICE, then call error or fatal
+   Free BUFFER and delete TERMINAL, then call error or fatal
    with str1 or str2, respectively, according to MUST_SUCCEED.  */
 
 static void
-maybe_fatal (must_succeed, buffer, device, str1, str2, arg1, arg2)
+maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
      int must_succeed;
      char *buffer;
-     struct device *device;
+     struct terminal *terminal;
      char *str1, *str2, *arg1, *arg2;
 {
   if (buffer)
     xfree (buffer);
 
-  if (device)
-    delete_tty (device);
+  if (terminal)
+    delete_tty (terminal);
   
   if (must_succeed)
     fatal (str2, arg1, arg2);
@@ -2886,38 +2895,38 @@
 static int deleting_tty = 0;
 
 
-/* Delete the given terminal device, closing all frames on it. */
+/* Delete the given tty terminal, closing all frames on it. */
 
 static void
-delete_tty (struct device *device)
+delete_tty (struct terminal *terminal)
 {
   struct tty_display_info *tty;
   Lisp_Object tail, frame;
   char *tty_name;
-  int last_device;
+  int last_terminal;
   
   if (deleting_tty)
     /* We get a recursive call when we delete the last frame on this
-       device. */
+       terminal. */
     return;
 
-  if (device->type != output_termcap)
+  if (terminal->type != output_termcap)
     abort ();
 
-  tty = device->display_info.tty;
+  tty = terminal->display_info.tty;
   
-  last_device = 1;
+  last_terminal = 1;
   FOR_EACH_FRAME (tail, frame)
     {
       struct frame *f = XFRAME (frame);
       if (FRAME_LIVE_P (f) && (!FRAME_TERMCAP_P (f) || FRAME_TTY (f) != tty))
         {
-          last_device = 0;
+          last_terminal = 0;
           break;
         }
     }
-  if (last_device)
-      error ("Attempt to delete the sole display device with live frames");
+  if (last_terminal)
+      error ("Attempt to delete the sole terminal device with live frames");
   
   if (tty == tty_list)
     tty_list = tty->next;
@@ -2947,10 +2956,10 @@
     }
 
   /* reset_sys_modes needs a valid device, so this call needs to be
-     before delete_device. */
+     before delete_terminal. */
   reset_sys_modes (tty);
 
-  delete_device (device);
+  delete_terminal (terminal);
 
   tty_name = tty->name;
   if (tty->type)
@@ -3025,8 +3034,8 @@
   defsubr (&Stty_display_color_p);
   defsubr (&Stty_display_color_cells);
   defsubr (&Stty_no_underline);
-  defsubr (&Sdisplay_tty_type);
-  defsubr (&Sdisplay_controlling_tty_p);
+  defsubr (&Stty_type);
+  defsubr (&Scontrolling_tty_p);
   defsubr (&Ssuspend_tty);
   defsubr (&Sresume_tty);
 }