aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.multi-tty71
-rw-r--r--lisp/files.el6
-rw-r--r--lisp/frame.el22
-rw-r--r--lisp/server.el44
-rw-r--r--lisp/startup.el4
-rw-r--r--lisp/talk.el8
-rw-r--r--lisp/termdev.el8
-rw-r--r--lisp/xt-mouse.el6
-rw-r--r--src/alloc.c4
-rw-r--r--src/coding.c40
-rw-r--r--src/data.c28
-rw-r--r--src/dispextern.h19
-rw-r--r--src/dispnew.c42
-rw-r--r--src/frame.c157
-rw-r--r--src/frame.h16
-rw-r--r--src/keyboard.c127
-rw-r--r--src/keyboard.h7
-rw-r--r--src/lisp.h4
-rw-r--r--src/minibuf.c2
-rw-r--r--src/sysdep.c4
-rw-r--r--src/term.c395
-rw-r--r--src/termchar.h6
-rw-r--r--src/termhooks.h100
-rw-r--r--src/terminal.c367
-rw-r--r--src/xdisp.c32
-rw-r--r--src/xfns.c216
-rw-r--r--src/xselect.c2
-rw-r--r--src/xterm.c142
-rw-r--r--src/xterm.h4
29 files changed, 946 insertions, 937 deletions
diff --git a/README.multi-tty b/README.multi-tty
index 346d27102bf..f1a0cde7df4 100644
--- a/README.multi-tty
+++ b/README.multi-tty
@@ -9,7 +9,7 @@ Some use cases:
9Emacs is notoriously slow at startup, so most people use another 9Emacs is notoriously slow at startup, so most people use another
10editor or emacsclient for quick editing jobs from the console. 10editor or emacsclient for quick editing jobs from the console.
11Unfortunately, emacsclient was very awkward to use, because it did not 11Unfortunately, emacsclient was very awkward to use, because it did not
12support opening a new Emacs frame on the current virtual console. 12support opening a new Emacs frame on the current virtual tty.
13Now, with multi-tty support, it can do that. (Emacsclient starts up 13Now, with multi-tty support, it can do that. (Emacsclient starts up
14faster than vi!) 14faster than vi!)
15 15
@@ -86,7 +86,7 @@ major problems have been fixed, only a few minor issues remain. (It
86still needs to be ported to Windows/Mac/DOS, though.) Both multiple 86still needs to be ported to Windows/Mac/DOS, though.) Both multiple
87tty device support and simultaneous X and tty frame support works 87tty device support and simultaneous X and tty frame support works
88fine. Emacsclient has been extended to support opening new tty and X 88fine. Emacsclient has been extended to support opening new tty and X
89frames. It has been changed open new Emacs frames by default. 89frames. It has been changed to open new Emacs frames by default.
90 90
91The multi-tty branch has been scheduled for inclusion in the next 91The multi-tty branch has been scheduled for inclusion in the next
92major release of Emacs (version 23). I expect the merge into the 92major release of Emacs (version 23). I expect the merge into the
@@ -250,9 +250,8 @@ also works. Of course, you can create frames on more than two tty
250devices. 250devices.
251 251
252Creating new frames on the same tty with C-x 5 2 (make-frame-command) 252Creating new frames on the same tty with C-x 5 2 (make-frame-command)
253works, and they behave the same way as in previous Emacs versions. If 253works, and behaves the same way as in previous Emacs versions. If you
254you exit emacs, all terminals should be restored to their previous 254exit emacs, all terminals should be restored to their previous states.
255states.
256 255
257This is work in progress, and probably full of bugs. It is a good 256This is work in progress, and probably full of bugs. It is a good
258idea to run emacs from gdb, so that you'll have a live instance to 257idea to run emacs from gdb, so that you'll have a live instance to
@@ -350,49 +349,50 @@ NEWS
350 349
351For the NEWS file: (Needs much, much work) 350For the NEWS file: (Needs much, much work)
352 351
353** Support for multiple terminal devices has been added. 352** Support for multiple terminal devices and simultaneous graphical
353 and tty frames has been added. You can test for the presence of
354 this feature in your Lisp code by testing for the `multi-tty'
355 feature.
356
357*** The `window-system' variable has been made frame-local. The new
358 `initial-window-system' variable contains the `window-system'
359 value for the first frame.
354 360
355*** You can specify a terminal device (`tty' parameter) and a terminal 361*** You can specify a terminal device (`tty' parameter) and a terminal
356 type (`tty-type' parameter) to `make-terminal-frame'. 362 type (`tty-type' parameter) to `make-terminal-frame'.
357 363
358*** You can test for the presence of multiple terminal support by 364*** The new function `make-frame-on-tty' allows you to create a new
359 testing for the `multi-tty' feature. 365 frame on another tty device interactively.
366
367*** The function `make-frame-on-display' now works during a tty
368 session, and `make-frame-on-tty' works during a graphical session.
360 369
361*** Emacsclient has been extended to support opening a new terminal 370*** Emacsclient has been extended to support opening a new terminal
362 frame. Its behaviour has been changed to open a new Emacs frame by 371 frame. Its behaviour has been changed to open a new Emacs frame by
363 default. Use the -c option to get the old behavior of opening 372 default. Use the -c option to get the old behavior of opening
364 files in the currently selected Emacs frame. 373 files in the currently selected Emacs frame.
365 374
366*** A make-frame-on-tty function has been added to make it easier to 375*** C-z now invokes `suspend-frame', C-x C-c now invokes
367 create frames on new terminals. 376 `save-buffers-kill-terminal'.
368 377
369*** New functions: frame-tty-name, frame-tty-type, delete-tty, 378*** New functions: frame-tty-name, frame-tty-type, delete-tty,
370 terminal-local-value, set-terminal-local-value 379 suspend-tty, resume-tty, terminal-id, terminal-parameters,
380 terminal-parameter, set-terminal-parameter,
381 modify-terminal-parameters, environment, let-environment
371 382
372 terminal-id, terminal-parameters, terminal-parameter, 383*** New variables: local-key-translation-map, local-function-key-map
373 set-terminal-parameter
374 384
375*** New variables: global-key-translation-map 385*** The `keyboard-translate-table' variable and the terminal and
386 keyboard coding systems have been made terminal-local.
376 387
377*** The keymaps key-translation-map and function-key-map are now 388*** In addition to the global key-translation-map and
378 terminal-local. 389 function-key-map, Emacs has terminal-local
379 390 local-key-translation-map and local-function-key-map variables,
380** Support for simultaneous graphical and terminal frames has been 391 and uses them instead of the global keymaps to set up translations
381 added. 392 and function key sequences relevant to a specific terminal device.
382
383*** The function `make-frame-on-display' now works during a terminal
384 session, and `make-frame-on-tty' works during a graphical session.
385
386*** The `window-system' variable has been made frame-local.
387
388*** The new `initial-window-system' variable contains the
389 `window-system' value for the first frame.
390 393
391*** talk.el has been extended for multiple tty support. 394*** talk.el has been extended for multiple tty support.
392 395
393*** C-z now invokes `suspend-frame', C-x C-c now invokes
394 `save-buffers-kill-frame'.
395
396* * * 396* * *
397 397
398(The rest of this file consists of my development notes and as such it 398(The rest of this file consists of my development notes and as such it
@@ -518,15 +518,16 @@ THINGS TO DO
518 frames-on-display-list frames-on-terminal-list 518 frames-on-display-list frames-on-terminal-list
519 519
520 The following functions were introduced in the multi-tty branch, and 520 The following functions were introduced in the multi-tty branch, and
521 can be renamed without aliases: 521 were renamed without aliases:
522 522
523 display-controlling-tty-p terminal-controlling-tty-p 523 delete-display delete-terminal
524 display-controlling-tty-p controlling-tty-p
524 display-list terminal-list 525 display-list terminal-list
525 display-live-p terminal-live-p 526 display-live-p terminal-live-p
526 display-name terminal-name 527 display-name terminal-name
527 display-tty-type terminal-tty-type 528 display-tty-type tty-type
528 frame-display terminal-of-frame 529 frame-display frame-terminal
529 delete-display delete-terminal 530 selected-display selected-terminal
530 531
531** The single-keyboard mode of MULTI_KBOARD is extremely confusing 532** The single-keyboard mode of MULTI_KBOARD is extremely confusing
532 sometimes; Emacs does not respond to stimuli from other keyboards. 533 sometimes; Emacs does not respond to stimuli from other keyboards.
diff --git a/lisp/files.el b/lisp/files.el
index 8b8a1444ba6..12384543fe9 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4879,7 +4879,7 @@ With prefix arg, silently save all file-visiting buffers, then kill."
4879 (funcall confirm-kill-emacs "Really exit Emacs? ")) 4879 (funcall confirm-kill-emacs "Really exit Emacs? "))
4880 (kill-emacs))) 4880 (kill-emacs)))
4881 4881
4882(defun save-buffers-kill-display (&optional arg) 4882(defun save-buffers-kill-terminal (&optional arg)
4883 "Offer to save each buffer, then kill the current connection. 4883 "Offer to save each buffer, then kill the current connection.
4884If the current frame has no client, kill Emacs itself. 4884If the current frame has no client, kill Emacs itself.
4885 4885
@@ -4892,7 +4892,7 @@ only these files will be asked to be saved."
4892 (frame (selected-frame))) 4892 (frame (selected-frame)))
4893 (if (null proc) 4893 (if (null proc)
4894 (save-buffers-kill-emacs) 4894 (save-buffers-kill-emacs)
4895 (server-save-buffers-kill-display proc arg)))) 4895 (server-save-buffers-kill-terminal proc arg))))
4896 4896
4897 4897
4898;; We use /: as a prefix to "quote" a file name 4898;; We use /: as a prefix to "quote" a file name
@@ -4991,7 +4991,7 @@ only these files will be asked to be saved."
4991(define-key ctl-x-map "i" 'insert-file) 4991(define-key ctl-x-map "i" 'insert-file)
4992(define-key esc-map "~" 'not-modified) 4992(define-key esc-map "~" 'not-modified)
4993(define-key ctl-x-map "\C-d" 'list-directory) 4993(define-key ctl-x-map "\C-d" 'list-directory)
4994(define-key ctl-x-map "\C-c" 'save-buffers-kill-display) 4994(define-key ctl-x-map "\C-c" 'save-buffers-kill-terminal)
4995(define-key ctl-x-map "\C-q" 'toggle-read-only) 4995(define-key ctl-x-map "\C-q" 'toggle-read-only)
4996 4996
4997(define-key ctl-x-4-map "f" 'find-file-other-window) 4997(define-key ctl-x-4-map "f" 'find-file-other-window)
diff --git a/lisp/frame.el b/lisp/frame.el
index 339100bbff5..818bd9368e1 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -651,7 +651,7 @@ You cannot specify either `width' or `height', you must use neither or both.
651 (window-system . nil) The frame should be displayed on a terminal device. 651 (window-system . nil) The frame should be displayed on a terminal device.
652 (window-system . x) The frame should be displayed in an X window. 652 (window-system . x) The frame should be displayed in an X window.
653 653
654 (device . ID) The frame should use the display device identified by ID. 654 (terminal . ID) The frame should use the terminal identified by ID.
655 655
656Before the frame is created (via `frame-creation-function-alist'), functions on the 656Before the frame is created (via `frame-creation-function-alist'), functions on the
657hook `before-make-frame-hook' are run. After the frame is created, functions 657hook `before-make-frame-hook' are run. After the frame is created, functions
@@ -664,11 +664,11 @@ instance if the frame appears under the mouse pointer and your
664setup is for focus to follow the pointer." 664setup is for focus to follow the pointer."
665 (interactive) 665 (interactive)
666 (let* ((w (cond 666 (let* ((w (cond
667 ((assq 'device parameters) 667 ((assq 'terminal parameters)
668 (let ((type (display-live-p (cdr (assq 'device parameters))))) 668 (let ((type (terminal-live-p (cdr (assq 'terminal parameters)))))
669 (cond 669 (cond
670 ((eq type t) nil) 670 ((eq type t) nil)
671 ((eq type nil) (error "Display %s does not exist" (cdr (assq 'device parameters)))) 671 ((eq type nil) (error "Terminal %s does not exist" (cdr (assq 'terminal parameters))))
672 (t type)))) 672 (t type))))
673 ((assq 'window-system parameters) 673 ((assq 'window-system parameters)
674 (cdr (assq 'window-system parameters))) 674 (cdr (assq 'window-system parameters)))
@@ -682,7 +682,7 @@ setup is for focus to follow the pointer."
682 (setq frame (funcall frame-creation-function (append parameters (cdr (assq w window-system-default-frame-alist))))) 682 (setq frame (funcall frame-creation-function (append parameters (cdr (assq w window-system-default-frame-alist)))))
683 (normal-erase-is-backspace-setup-frame frame) 683 (normal-erase-is-backspace-setup-frame frame)
684 ;; Set up the frame-local environment, if needed. 684 ;; Set up the frame-local environment, if needed.
685 (when (eq (frame-display frame) (frame-display oldframe)) 685 (when (eq (frame-terminal frame) (frame-terminal oldframe))
686 (let ((env (frame-parameter oldframe 'environment))) 686 (let ((env (frame-parameter oldframe 'environment)))
687 (if (not (framep env)) 687 (if (not (framep env))
688 (setq env oldframe)) 688 (setq env oldframe))
@@ -718,7 +718,7 @@ If TERMINAL is omitted or nil, it defaults to the selected
718frame's terminal device." 718frame's terminal device."
719 (let* ((terminal (terminal-id terminal)) 719 (let* ((terminal (terminal-id terminal))
720 (func #'(lambda (frame) 720 (func #'(lambda (frame)
721 (eq (frame-display frame) terminal)))) 721 (eq (frame-terminal frame) terminal))))
722 (filtered-frame-list func))) 722 (filtered-frame-list func)))
723 723
724(defun framep-on-display (&optional terminal) 724(defun framep-on-display (&optional terminal)
@@ -727,7 +727,7 @@ TERMINAL may be a terminal id, a display name or a frame. If it
727is a frame, its type is returned. If TERMINAL is omitted or nil, 727is a frame, its type is returned. If TERMINAL is omitted or nil,
728it defaults to the selected frame's terminal device. All frames 728it defaults to the selected frame's terminal device. All frames
729on a given display are of the same type." 729on a given display are of the same type."
730 (or (display-live-p terminal) 730 (or (terminal-live-p terminal)
731 (framep terminal) 731 (framep terminal)
732 (framep (car (frames-on-display-list terminal))))) 732 (framep (car (frames-on-display-list terminal)))))
733 733
@@ -815,7 +815,7 @@ Calls `suspend-emacs' if invoked from the controlling tty device,
815 (cond 815 (cond
816 ((eq type 'x) (iconify-or-deiconify-frame)) 816 ((eq type 'x) (iconify-or-deiconify-frame))
817 ((eq type t) 817 ((eq type t)
818 (if (display-controlling-tty-p) 818 (if (controlling-tty-p)
819 (suspend-emacs) 819 (suspend-emacs)
820 (suspend-tty))) 820 (suspend-tty)))
821 (t (suspend-emacs))))) 821 (t (suspend-emacs)))))
@@ -1068,9 +1068,9 @@ bars (top, bottom, or nil)."
1068 (cons vert hor))) 1068 (cons vert hor)))
1069 1069
1070;;;; Frame/display capabilities. 1070;;;; Frame/display capabilities.
1071(defun selected-display () 1071(defun selected-terminal ()
1072 "Return the display that is now selected." 1072 "Return the terminal that is now selected."
1073 (frame-display (selected-frame))) 1073 (frame-terminal (selected-frame)))
1074 1074
1075(defun display-mouse-p (&optional display) 1075(defun display-mouse-p (&optional display)
1076 "Return non-nil if DISPLAY has a mouse available. 1076 "Return non-nil if DISPLAY has a mouse available.
diff --git a/lisp/server.el b/lisp/server.el
index f98be109c92..9de88d55896 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -247,7 +247,7 @@ ENV should be in the same format as `process-environment'."
247 (setenv (car ,pair) (cdr ,pair))))))) 247 (setenv (car ,pair) (cdr ,pair)))))))
248 248
249(defun server-delete-client (client &optional noframe) 249(defun server-delete-client (client &optional noframe)
250 "Delete CLIENT, including its buffers, devices and frames. 250 "Delete CLIENT, including its buffers, terminals and frames.
251If NOFRAME is non-nil, let the frames live. (To be used from 251If NOFRAME is non-nil, let the frames live. (To be used from
252`delete-frame-functions'." 252`delete-frame-functions'."
253 ;; Force a new lookup of client (prevents infinite recursion). 253 ;; Force a new lookup of client (prevents infinite recursion).
@@ -271,9 +271,9 @@ If NOFRAME is non-nil, let the frames live. (To be used from
271 (kill-buffer (current-buffer)))))) 271 (kill-buffer (current-buffer))))))
272 272
273 ;; Delete the client's tty. 273 ;; Delete the client's tty.
274 (let ((device (server-client-get client 'device))) 274 (let ((terminal (server-client-get client 'terminal)))
275 (when (eq (display-live-p device) t) 275 (when (eq (terminal-live-p terminal) t)
276 (delete-display device))) 276 (delete-terminal terminal)))
277 277
278 ;; Delete the client's frames. 278 ;; Delete the client's frames.
279 (unless noframe 279 (unless noframe
@@ -323,18 +323,18 @@ message."
323 ;; there are other frames on it. 323 ;; there are other frames on it.
324 (< 0 (let ((frame-num 0)) 324 (< 0 (let ((frame-num 0))
325 (mapc (lambda (f) 325 (mapc (lambda (f)
326 (when (eq (frame-display f) 326 (when (eq (frame-terminal f)
327 (frame-display frame)) 327 (frame-terminal frame))
328 (setq frame-num (1+ frame-num)))) 328 (setq frame-num (1+ frame-num))))
329 (frame-list)) 329 (frame-list))
330 frame-num)))) 330 frame-num))))
331 (server-log (format "server-handle-delete-frame, frame %s" frame) proc) 331 (server-log (format "server-handle-delete-frame, frame %s" frame) proc)
332 (server-delete-client proc 'noframe)))) ; Let delete-frame delete the frame later. 332 (server-delete-client proc 'noframe)))) ; Let delete-frame delete the frame later.
333 333
334(defun server-handle-suspend-tty (device) 334(defun server-handle-suspend-tty (terminal)
335 "Notify the emacsclient process to suspend itself when its tty device is suspended." 335 "Notify the emacsclient process to suspend itself when its tty device is suspended."
336 (dolist (proc (server-clients-with 'device device)) 336 (dolist (proc (server-clients-with 'terminal terminal))
337 (server-log (format "server-handle-suspend-tty, device %s" device) proc) 337 (server-log (format "server-handle-suspend-tty, terminal %s" terminal) proc)
338 (condition-case err 338 (condition-case err
339 (server-send-string proc "-suspend \n") 339 (server-send-string proc "-suspend \n")
340 (file-error (condition-case nil (server-delete-client proc) (error nil)))))) 340 (file-error (condition-case nil (server-delete-client proc) (error nil))))))
@@ -618,7 +618,7 @@ The following commands are accepted by the client:
618 ;; Flag frame as client-created, but use a dummy client. 618 ;; Flag frame as client-created, but use a dummy client.
619 ;; This will prevent the frame from being deleted when 619 ;; This will prevent the frame from being deleted when
620 ;; emacsclient quits while also preventing 620 ;; emacsclient quits while also preventing
621 ;; `server-save-buffers-kill-display' from unexpectedly 621 ;; `server-save-buffers-kill-terminal' from unexpectedly
622 ;; killing emacs on that frame. 622 ;; killing emacs on that frame.
623 (list (cons 'client 'nowait) (cons 'environment env)) 623 (list (cons 'client 'nowait) (cons 'environment env))
624 (list (cons 'client proc) (cons 'environment env))))) 624 (list (cons 'client proc) (cons 'environment env)))))
@@ -636,7 +636,7 @@ The following commands are accepted by the client:
636 (modify-frame-parameters frame params) 636 (modify-frame-parameters frame params)
637 (select-frame frame) 637 (select-frame frame)
638 (server-client-set client 'frame frame) 638 (server-client-set client 'frame frame)
639 (server-client-set client 'device (frame-display frame)) 639 (server-client-set client 'terminal (frame-terminal frame))
640 (setq dontkill t)) 640 (setq dontkill t))
641 ;; This emacs does not support X. 641 ;; This emacs does not support X.
642 (server-log "Window system unsupported" proc) 642 (server-log "Window system unsupported" proc)
@@ -645,19 +645,19 @@ The following commands are accepted by the client:
645 645
646 ;; -resume: Resume a suspended tty frame. 646 ;; -resume: Resume a suspended tty frame.
647 ((equal "-resume" arg) 647 ((equal "-resume" arg)
648 (let ((device (server-client-get client 'device))) 648 (let ((terminal (server-client-get client 'terminal)))
649 (setq dontkill t) 649 (setq dontkill t)
650 (when (eq (display-live-p device) t) 650 (when (eq (terminal-live-p terminal) t)
651 (resume-tty device)))) 651 (resume-tty terminal))))
652 652
653 ;; -suspend: Suspend the client's frame. (In case we 653 ;; -suspend: Suspend the client's frame. (In case we
654 ;; get out of sync, and a C-z sends a SIGTSTP to 654 ;; get out of sync, and a C-z sends a SIGTSTP to
655 ;; emacsclient.) 655 ;; emacsclient.)
656 ((equal "-suspend" arg) 656 ((equal "-suspend" arg)
657 (let ((device (server-client-get client 'device))) 657 (let ((terminal (server-client-get client 'terminal)))
658 (setq dontkill t) 658 (setq dontkill t)
659 (when (eq (display-live-p device) t) 659 (when (eq (terminal-live-p terminal) t)
660 (suspend-tty device)))) 660 (suspend-tty terminal))))
661 661
662 ;; -ignore COMMENT: Noop; useful for debugging emacsclient. 662 ;; -ignore COMMENT: Noop; useful for debugging emacsclient.
663 ;; (The given comment appears in the server log.) 663 ;; (The given comment appears in the server log.)
@@ -687,8 +687,8 @@ The following commands are accepted by the client:
687 (environment . ,env))))) 687 (environment . ,env)))))
688 (select-frame frame) 688 (select-frame frame)
689 (server-client-set client 'frame frame) 689 (server-client-set client 'frame frame)
690 (server-client-set client 'tty (display-name frame)) 690 (server-client-set client 'tty (terminal-name frame))
691 (server-client-set client 'device (frame-display frame)) 691 (server-client-set client 'terminal (frame-terminal frame))
692 692
693 ;; Reply with our pid. 693 ;; Reply with our pid.
694 (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n")) 694 (server-send-string proc (concat "-emacs-pid " (number-to-string (emacs-pid)) "\n"))
@@ -1037,8 +1037,8 @@ done that."
1037 (get-window-with-predicate 1037 (get-window-with-predicate
1038 (lambda (w) 1038 (lambda (w)
1039 (and (not (window-dedicated-p w)) 1039 (and (not (window-dedicated-p w))
1040 (equal (frame-parameter (window-frame w) 'device) 1040 (equal (frame-terminal (window-frame w))
1041 (frame-parameter (selected-frame) 'device)))) 1041 (frame-terminal (selected-frame)))))
1042 'nomini 'visible (selected-window)))) 1042 'nomini 'visible (selected-window))))
1043 (condition-case nil 1043 (condition-case nil
1044 (switch-to-buffer next-buffer) 1044 (switch-to-buffer next-buffer)
@@ -1047,7 +1047,7 @@ done that."
1047 (error (pop-to-buffer next-buffer))))))))) 1047 (error (pop-to-buffer next-buffer)))))))))
1048 1048
1049;;;###autoload 1049;;;###autoload
1050(defun server-save-buffers-kill-display (proc &optional arg) 1050(defun server-save-buffers-kill-terminal (proc &optional arg)
1051 "Offer to save each buffer, then kill PROC. 1051 "Offer to save each buffer, then kill PROC.
1052 1052
1053With prefix arg, silently save all file-visiting buffers, then kill. 1053With prefix arg, silently save all file-visiting buffers, then kill.
diff --git a/lisp/startup.el b/lisp/startup.el
index 155ef1d3e79..cef38411dc9 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1430,7 +1430,7 @@ Copyright (C) 2005 Free Software Foundation, Inc."))
1430 ;; use precomputed string to save lots of time. 1430 ;; use precomputed string to save lots of time.
1431 (if (and (eq (key-binding "\C-h") 'help-command) 1431 (if (and (eq (key-binding "\C-h") 'help-command)
1432 (eq (key-binding "\C-xu") 'advertised-undo) 1432 (eq (key-binding "\C-xu") 'advertised-undo)
1433 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-display) 1433 (eq (key-binding "\C-x\C-c") 'save-buffers-kill-terminal)
1434 (eq (key-binding "\C-ht") 'help-with-tutorial) 1434 (eq (key-binding "\C-ht") 'help-with-tutorial)
1435 (eq (key-binding "\C-hi") 'info) 1435 (eq (key-binding "\C-hi") 'info)
1436 (eq (key-binding "\C-hr") 'info-emacs-manual) 1436 (eq (key-binding "\C-hr") 'info-emacs-manual)
@@ -1447,7 +1447,7 @@ Browse manuals C-h i")
1447Get help %s 1447Get help %s
1448Emacs manual \\[info-emacs-manual] 1448Emacs manual \\[info-emacs-manual]
1449Emacs tutorial \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo] 1449Emacs tutorial \\[help-with-tutorial]\tUndo changes\t\\[advertised-undo]
1450Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-display] 1450Buy manuals \\[view-order-manuals]\tExit Emacs\t\\[save-buffers-kill-terminal]
1451Browse manuals \\[info]" 1451Browse manuals \\[info]"
1452 (let ((where (where-is-internal 1452 (let ((where (where-is-internal
1453 'help-command nil t))) 1453 'help-command nil t)))
diff --git a/lisp/talk.el b/lisp/talk.el
index a008a0ef3fd..0807e655703 100644
--- a/lisp/talk.el
+++ b/lisp/talk.el
@@ -50,22 +50,22 @@ Each element has the form (DISPLAY FRAME BUFFER).")
50 "Connect to the Emacs talk group from the current X display or tty frame." 50 "Connect to the Emacs talk group from the current X display or tty frame."
51 (interactive) 51 (interactive)
52 (let ((type (frame-live-p (selected-frame))) 52 (let ((type (frame-live-p (selected-frame)))
53 (display (frame-display (selected-frame)))) 53 (display (frame-terminal (selected-frame))))
54 (cond 54 (cond
55 ((eq type t) 55 ((eq type t)
56 (talk-add-display (selected-frame))) 56 (talk-add-display (selected-frame)))
57 ((eq type 'x) 57 ((eq type 'x)
58 (talk-add-display (frame-display (selected-frame)))) 58 (talk-add-display (frame-terminal (selected-frame))))
59 (t 59 (t
60 (error "Unknown frame type")))) 60 (error "Unknown frame type"))))
61 (talk-update-buffers)) 61 (talk-update-buffers))
62 62
63(defun talk-add-display (frame) 63(defun talk-add-display (frame)
64 (let* ((display (if (frame-live-p frame) 64 (let* ((display (if (frame-live-p frame)
65 (frame-display frame) 65 (frame-terminal frame)
66 frame)) 66 frame))
67 (elt (assoc display talk-display-alist)) 67 (elt (assoc display talk-display-alist))
68 (name (concat "*talk-" (display-name display) "*")) 68 (name (concat "*talk-" (terminal-name display) "*"))
69 buffer) 69 buffer)
70 (unless (frame-live-p frame) 70 (unless (frame-live-p frame)
71 (setq frame (make-frame-on-display display (list (cons 'name name))))) 71 (setq frame (make-frame-on-display display (list (cons 'name name)))))
diff --git a/lisp/termdev.el b/lisp/termdev.el
index 5e12740e11c..c73fe017046 100644
--- a/lisp/termdev.el
+++ b/lisp/termdev.el
@@ -34,17 +34,17 @@ TERMINAL may be the name of an X display
34device (HOST.SERVER.SCREEN) or a tty device file." 34device (HOST.SERVER.SCREEN) or a tty device file."
35 (cond 35 (cond
36 ((integerp terminal) 36 ((integerp terminal)
37 (if (display-live-p terminal) 37 (if (terminal-live-p terminal)
38 terminal 38 terminal
39 (signal 'wrong-type-argument (list 'display-live-p terminal)))) 39 (signal 'wrong-type-argument (list 'terminal-live-p terminal))))
40 ((or (null terminal) (framep terminal)) 40 ((or (null terminal) (framep terminal))
41 (frame-display terminal)) 41 (frame-terminal terminal))
42 ((stringp terminal) 42 ((stringp terminal)
43 (let ((f (car (filtered-frame-list (lambda (frame) 43 (let ((f (car (filtered-frame-list (lambda (frame)
44 (or (equal (frame-parameter frame 'display) terminal) 44 (or (equal (frame-parameter frame 'display) terminal)
45 (equal (frame-parameter frame 'tty) terminal))))))) 45 (equal (frame-parameter frame 'tty) terminal)))))))
46 (or f (error "Display %s does not exist" terminal)) 46 (or f (error "Display %s does not exist" terminal))
47 (frame-display f))) 47 (frame-terminal f)))
48 (t 48 (t
49 (error "Invalid argument %s in `terminal-id'" terminal)))) 49 (error "Invalid argument %s in `terminal-id'" terminal))))
50 50
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 1268994ba89..075ea879270 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -197,18 +197,18 @@ down the SHIFT key while pressing the mouse button."
197 197
198(defun turn-on-xterm-mouse-tracking-on-terminal (terminal) 198(defun turn-on-xterm-mouse-tracking-on-terminal (terminal)
199 "Enable xterm mouse tracking on TERMINAL." 199 "Enable xterm mouse tracking on TERMINAL."
200 (when (and xterm-mouse-mode (eq t (display-live-p terminal))) 200 (when (and xterm-mouse-mode (eq t (terminal-live-p terminal)))
201 (send-string-to-terminal "\e[?1000h" terminal))) 201 (send-string-to-terminal "\e[?1000h" terminal)))
202 202
203(defun turn-off-xterm-mouse-tracking-on-terminal (terminal) 203(defun turn-off-xterm-mouse-tracking-on-terminal (terminal)
204 "Disable xterm mouse tracking on TERMINAL." 204 "Disable xterm mouse tracking on TERMINAL."
205 (when (and xterm-mouse-mode (eq t (display-live-p terminal))) 205 (when (and xterm-mouse-mode (eq t (terminal-live-p terminal)))
206 (send-string-to-terminal "\e[?1000l" terminal))) 206 (send-string-to-terminal "\e[?1000l" terminal)))
207 207
208(defun xterm-mouse-handle-delete-frame (frame) 208(defun xterm-mouse-handle-delete-frame (frame)
209 "Turn off xterm mouse tracking if FRAME is the last frame on its device." 209 "Turn off xterm mouse tracking if FRAME is the last frame on its device."
210 (when (and (eq t (frame-live-p frame)) 210 (when (and (eq t (frame-live-p frame))
211 (<= 1 (length (frames-on-display-list (frame-display frame))))) 211 (<= 1 (length (frames-on-display-list (frame-terminal frame)))))
212 (turn-off-xterm-mouse-tracking-on-terminal frame))) 212 (turn-off-xterm-mouse-tracking-on-terminal frame)))
213 213
214;; Frame creation and deletion. 214;; Frame creation and deletion.
diff --git a/src/alloc.c b/src/alloc.c
index f8ba5f480ab..cf86c80deaf 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -324,7 +324,7 @@ Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */
324EMACS_INT gcs_done; /* accumulated GCs */ 324EMACS_INT gcs_done; /* accumulated GCs */
325 325
326static void mark_buffer P_ ((Lisp_Object)); 326static void mark_buffer P_ ((Lisp_Object));
327extern void mark_devices P_ ((void)); 327extern void mark_terminals P_ ((void));
328extern void mark_kboards P_ ((void)); 328extern void mark_kboards P_ ((void));
329extern void mark_ttys P_ ((void)); 329extern void mark_ttys P_ ((void));
330extern void mark_backtrace P_ ((void)); 330extern void mark_backtrace P_ ((void));
@@ -4938,7 +4938,7 @@ returns nil, because real GC can't be done. */)
4938 mark_object (bind->symbol); 4938 mark_object (bind->symbol);
4939 mark_object (bind->old_value); 4939 mark_object (bind->old_value);
4940 } 4940 }
4941 mark_devices (); 4941 mark_terminals ();
4942 mark_kboards (); 4942 mark_kboards ();
4943 mark_ttys (); 4943 mark_ttys ();
4944 4944
diff --git a/src/coding.c b/src/coding.c
index 759a97567c1..14f8fd33285 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -7351,11 +7351,11 @@ Return the corresponding character code in Big5. */)
7351DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal, 7351DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_internal,
7352 Sset_terminal_coding_system_internal, 1, 2, 0, 7352 Sset_terminal_coding_system_internal, 1, 2, 0,
7353 doc: /* Internal use only. */) 7353 doc: /* Internal use only. */)
7354 (coding_system, device) 7354 (coding_system, terminal)
7355 Lisp_Object coding_system; 7355 Lisp_Object coding_system;
7356 Lisp_Object device; 7356 Lisp_Object terminal;
7357{ 7357{
7358 struct coding_system *terminal_coding = DEVICE_TERMINAL_CODING (get_device (device, 1)); 7358 struct coding_system *terminal_coding = TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1));
7359 CHECK_SYMBOL (coding_system); 7359 CHECK_SYMBOL (coding_system);
7360 setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding); 7360 setup_coding_system (Fcheck_coding_system (coding_system), terminal_coding);
7361 /* We had better not send unsafe characters to terminal. */ 7361 /* We had better not send unsafe characters to terminal. */
@@ -7389,41 +7389,41 @@ DEFUN ("set-safe-terminal-coding-system-internal", Fset_safe_terminal_coding_sys
7389 7389
7390DEFUN ("terminal-coding-system", Fterminal_coding_system, 7390DEFUN ("terminal-coding-system", Fterminal_coding_system,
7391 Sterminal_coding_system, 0, 1, 0, 7391 Sterminal_coding_system, 0, 1, 0,
7392 doc: /* Return coding system specified for terminal output on the given device. 7392 doc: /* Return coding system specified for terminal output on the given terminal.
7393DEVICE may be a display device id, a frame, or nil for the selected 7393TERMINAL may be a terminal id, a frame, or nil for the selected
7394frame's display device. */) 7394frame's terminal device. */)
7395 (device) 7395 (terminal)
7396 Lisp_Object device; 7396 Lisp_Object terminal;
7397{ 7397{
7398 return DEVICE_TERMINAL_CODING (get_device (device, 1))->symbol; 7398 return TERMINAL_TERMINAL_CODING (get_terminal (terminal, 1))->symbol;
7399} 7399}
7400 7400
7401DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal, 7401DEFUN ("set-keyboard-coding-system-internal", Fset_keyboard_coding_system_internal,
7402 Sset_keyboard_coding_system_internal, 1, 2, 0, 7402 Sset_keyboard_coding_system_internal, 1, 2, 0,
7403 doc: /* Internal use only. */) 7403 doc: /* Internal use only. */)
7404 (coding_system, device) 7404 (coding_system, terminal)
7405 Lisp_Object coding_system; 7405 Lisp_Object coding_system;
7406 Lisp_Object device; 7406 Lisp_Object terminal;
7407{ 7407{
7408 struct device *d = get_device (device, 1); 7408 struct terminal *t = get_terminal (terminal, 1);
7409 CHECK_SYMBOL (coding_system); 7409 CHECK_SYMBOL (coding_system);
7410 7410
7411 setup_coding_system (Fcheck_coding_system (coding_system), 7411 setup_coding_system (Fcheck_coding_system (coding_system),
7412 DEVICE_KEYBOARD_CODING (d)); 7412 TERMINAL_KEYBOARD_CODING (t));
7413 /* Character composition should be disabled. */ 7413 /* Character composition should be disabled. */
7414 DEVICE_KEYBOARD_CODING (d)->composing = COMPOSITION_DISABLED; 7414 TERMINAL_KEYBOARD_CODING (t)->composing = COMPOSITION_DISABLED;
7415 return Qnil; 7415 return Qnil;
7416} 7416}
7417 7417
7418DEFUN ("keyboard-coding-system", Fkeyboard_coding_system, 7418DEFUN ("keyboard-coding-system", Fkeyboard_coding_system,
7419 Skeyboard_coding_system, 0, 1, 0, 7419 Skeyboard_coding_system, 0, 1, 0,
7420 doc: /* Return coding system for decoding keyboard input on DEVICE. 7420 doc: /* Return coding system for decoding keyboard input on TERMINAL.
7421DEVICE may be a display device id, a frame, or nil for the selected 7421TERMINAL may be a terminal id, a frame, or nil for the selected
7422frame's display device. */) 7422frame's terminal device. */)
7423 (device) 7423 (terminal)
7424 Lisp_Object device; 7424 Lisp_Object terminal;
7425{ 7425{
7426 return DEVICE_KEYBOARD_CODING (get_device (device, 1))->symbol; 7426 return TERMINAL_KEYBOARD_CODING (get_terminal (terminal, 1))->symbol;
7427} 7427}
7428 7428
7429 7429
diff --git a/src/data.c b/src/data.c
index bd08368c2fb..0b2036395da 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1900,41 +1900,41 @@ If the current binding is global (the default), the value is nil. */)
1900/* This code is disabled now that we use the selected frame to return 1900/* This code is disabled now that we use the selected frame to return
1901 keyboard-local-values. */ 1901 keyboard-local-values. */
1902#if 0 1902#if 0
1903extern struct device *get_device P_ ((Lisp_Object display, int)); 1903extern struct terminal *get_terminal P_ ((Lisp_Object display, int));
1904 1904
1905DEFUN ("terminal-local-value", Fterminal_local_value, Sterminal_local_value, 2, 2, 0, 1905DEFUN ("terminal-local-value", Fterminal_local_value, Sterminal_local_value, 2, 2, 0,
1906 doc: /* Return the terminal-local value of SYMBOL on DEVICE. 1906 doc: /* Return the terminal-local value of SYMBOL on TERMINAL.
1907If SYMBOL is not a terminal-local variable, then return its normal 1907If SYMBOL is not a terminal-local variable, then return its normal
1908value, like `symbol-value'. 1908value, like `symbol-value'.
1909 1909
1910DEVICE may be a display device id, a frame, or nil (meaning the 1910TERMINAL may be a terminal id, a frame, or nil (meaning the
1911selected frame's display device). */) 1911selected frame's terminal device). */)
1912 (symbol, device) 1912 (symbol, terminal)
1913 Lisp_Object symbol; 1913 Lisp_Object symbol;
1914 Lisp_Object device; 1914 Lisp_Object terminal;
1915{ 1915{
1916 Lisp_Object result; 1916 Lisp_Object result;
1917 struct device *d = get_device (device, 1); 1917 struct terminal *t = get_terminal (terminal, 1);
1918 push_kboard (d->kboard); 1918 push_kboard (t->kboard);
1919 result = Fsymbol_value (symbol); 1919 result = Fsymbol_value (symbol);
1920 pop_kboard (); 1920 pop_kboard ();
1921 return result; 1921 return result;
1922} 1922}
1923 1923
1924DEFUN ("set-terminal-local-value", Fset_terminal_local_value, Sset_terminal_local_value, 3, 3, 0, 1924DEFUN ("set-terminal-local-value", Fset_terminal_local_value, Sset_terminal_local_value, 3, 3, 0,
1925 doc: /* Set the terminal-local binding of SYMBOL on DEVICE to VALUE. 1925 doc: /* Set the terminal-local binding of SYMBOL on TERMINAL to VALUE.
1926If VARIABLE is not a terminal-local variable, then set its normal 1926If VARIABLE is not a terminal-local variable, then set its normal
1927binding, like `set'. 1927binding, like `set'.
1928 1928
1929DEVICE may be a display device id, a frame, or nil (meaning the 1929TERMINAL may be a terminal id, a frame, or nil (meaning the
1930selected frame's display device). */) 1930selected frame's terminal device). */)
1931 (symbol, device, value) 1931 (symbol, terminal, value)
1932 Lisp_Object symbol; 1932 Lisp_Object symbol;
1933 Lisp_Object device; 1933 Lisp_Object terminal;
1934 Lisp_Object value; 1934 Lisp_Object value;
1935{ 1935{
1936 Lisp_Object result; 1936 Lisp_Object result;
1937 struct device *d = get_device (device, 1); 1937 struct terminal *t = get_terminal (terminal, 1);
1938 push_kboard (d->kboard); 1938 push_kboard (d->kboard);
1939 result = Fset (symbol, value); 1939 result = Fset (symbol, value);
1940 pop_kboard (); 1940 pop_kboard ();
diff --git a/src/dispextern.h b/src/dispextern.h
index 2ae833d46c2..b5a6b21d539 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1350,7 +1350,7 @@ struct glyph_string
1350 DESCENT = FONT->descent 1350 DESCENT = FONT->descent
1351 HEIGHT = FONT_HEIGHT (FONT) 1351 HEIGHT = FONT_HEIGHT (FONT)
1352 F_DESCENT = (FRAME_FONT (F)->descent 1352 F_DESCENT = (FRAME_FONT (F)->descent
1353 - F->device->output_data.x->baseline_offset) 1353 - F->terminal->output_data.x->baseline_offset)
1354 F_HEIGHT = FRAME_LINE_HEIGHT (F) 1354 F_HEIGHT = FRAME_LINE_HEIGHT (F)
1355*/ 1355*/
1356 1356
@@ -2927,11 +2927,8 @@ extern void update_begin P_ ((struct frame *));
2927extern void update_end P_ ((struct frame *)); 2927extern void update_end P_ ((struct frame *));
2928extern void set_terminal_window P_ ((struct frame *, int)); 2928extern void set_terminal_window P_ ((struct frame *, int));
2929extern void cursor_to P_ ((struct frame *, int, int)); 2929extern void cursor_to P_ ((struct frame *, int, int));
2930
2931/* Was not declared before: */
2932extern void raw_cursor_to P_ ((struct frame *, int, int)); 2930extern void raw_cursor_to P_ ((struct frame *, int, int));
2933extern void clear_to_end P_ ((struct frame *)); 2931extern void clear_to_end P_ ((struct frame *));
2934
2935extern void clear_frame P_ ((struct frame *)); 2932extern void clear_frame P_ ((struct frame *));
2936extern void clear_end_of_line P_ ((struct frame *, int)); 2933extern void clear_end_of_line P_ ((struct frame *, int));
2937extern void write_glyphs P_ ((struct frame *, struct glyph *, int)); 2934extern void write_glyphs P_ ((struct frame *, struct glyph *, int));
@@ -2939,13 +2936,13 @@ extern void insert_glyphs P_ ((struct frame *, struct glyph *, int));
2939extern void delete_glyphs P_ ((struct frame *, int)); 2936extern void delete_glyphs P_ ((struct frame *, int));
2940extern void ins_del_lines P_ ((struct frame *, int, int)); 2937extern void ins_del_lines P_ ((struct frame *, int, int));
2941 2938
2942extern struct device *init_initial_device P_ ((void)); 2939extern struct terminal *init_initial_terminal P_ ((void));
2943 2940
2944 2941
2945/* Defined in term.c */ 2942/* Defined in term.c */
2946 2943
2947extern void tty_set_terminal_modes P_ ((struct device *)); 2944extern void tty_set_terminal_modes P_ ((struct terminal *));
2948extern void tty_reset_terminal_modes P_ ((struct device *)); 2945extern void tty_reset_terminal_modes P_ ((struct terminal *));
2949extern void tty_turn_off_insert P_ ((struct tty_display_info *)); 2946extern void tty_turn_off_insert P_ ((struct tty_display_info *));
2950extern void tty_turn_off_highlight P_ ((struct tty_display_info *)); 2947extern void tty_turn_off_highlight P_ ((struct tty_display_info *));
2951extern int string_cost P_ ((char *)); 2948extern int string_cost P_ ((char *));
@@ -2955,11 +2952,11 @@ extern void produce_glyphs P_ ((struct it *));
2955extern void produce_special_glyphs P_ ((struct it *, enum display_element_type)); 2952extern void produce_special_glyphs P_ ((struct it *, enum display_element_type));
2956extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long)); 2953extern int tty_capable_p P_ ((struct tty_display_info *, unsigned, unsigned long, unsigned long));
2957extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object)); 2954extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
2958extern struct device *get_tty_device P_ ((Lisp_Object terminal)); 2955extern struct terminal *get_tty_terminal P_ ((Lisp_Object terminal));
2959extern struct device *get_named_tty P_ ((char *)); 2956extern struct terminal *get_named_tty P_ ((char *));
2960EXFUN (Fdisplay_tty_type, 1); 2957EXFUN (Ftty_type, 1);
2961extern void create_tty_output P_ ((struct frame *)); 2958extern void create_tty_output P_ ((struct frame *));
2962extern struct device *init_tty P_ ((char *, char *, int)); 2959extern struct terminal *init_tty P_ ((char *, char *, int));
2963 2960
2964 2961
2965/* Defined in scroll.c */ 2962/* Defined in scroll.c */
diff --git a/src/dispnew.c b/src/dispnew.c
index c97e9ea9212..2f3deac5fcc 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -3345,7 +3345,7 @@ DEFUN ("redraw-frame", Fredraw_frame, Sredraw_frame, 1, 1, 0,
3345 update_begin (f); 3345 update_begin (f);
3346#ifdef MSDOS 3346#ifdef MSDOS
3347 if (FRAME_MSDOS_P (f)) 3347 if (FRAME_MSDOS_P (f))
3348 set_terminal_modes (FRAME_DEVICE (f)); 3348 set_terminal_modes (FRAME_TERMINAL (f));
3349#endif 3349#endif
3350 clear_frame (f); 3350 clear_frame (f);
3351 clear_current_matrices (f); 3351 clear_current_matrices (f);
@@ -6304,23 +6304,23 @@ DEFUN ("send-string-to-terminal", Fsend_string_to_terminal,
6304 doc: /* Send STRING to the terminal without alteration. 6304 doc: /* Send STRING to the terminal without alteration.
6305Control characters in STRING will have terminal-dependent effects. 6305Control characters in STRING will have terminal-dependent effects.
6306 6306
6307Optional parameter TERMINAL specifies the tty display device to use. 6307Optional parameter TERMINAL specifies the tty terminal device to use.
6308It may be a terminal id, a frame, or nil for the terminal used by the 6308It may be a terminal id, a frame, or nil for the terminal used by the
6309currently selected frame. */) 6309currently selected frame. */)
6310 (string, display) 6310 (string, terminal)
6311 Lisp_Object string; 6311 Lisp_Object string;
6312 Lisp_Object display; 6312 Lisp_Object terminal;
6313{ 6313{
6314 struct device *d = get_tty_device (display); 6314 struct terminal *t = get_tty_terminal (terminal);
6315 struct tty_display_info *tty; 6315 struct tty_display_info *tty;
6316 6316
6317 /* ??? Perhaps we should do something special for multibyte strings here. */ 6317 /* ??? Perhaps we should do something special for multibyte strings here. */
6318 CHECK_STRING (string); 6318 CHECK_STRING (string);
6319 6319
6320 if (!d) 6320 if (!t)
6321 error ("Unknown display device"); 6321 error ("Unknown terminal device");
6322 6322
6323 tty = d->display_info.tty; 6323 tty = t->display_info.tty;
6324 6324
6325 if (tty->termscript) 6325 if (tty->termscript)
6326 { 6326 {
@@ -6783,34 +6783,34 @@ For types not defined in VMS, use define emacs_term \"TYPE\".\n\
6783#endif /* VMS */ 6783#endif /* VMS */
6784 6784
6785 { 6785 {
6786 struct device *d; 6786 struct terminal *t;
6787 struct frame *f = XFRAME (selected_frame); 6787 struct frame *f = XFRAME (selected_frame);
6788 6788
6789 /* Open a display on the controlling tty. */ 6789 /* Open a display on the controlling tty. */
6790 d = init_tty (0, terminal_type, 1); /* Errors are fatal. */ 6790 t = init_tty (0, terminal_type, 1); /* Errors are fatal. */
6791 6791
6792 /* Convert the initial frame to use the new display. */ 6792 /* Convert the initial frame to use the new display. */
6793 if (f->output_method != output_initial) 6793 if (f->output_method != output_initial)
6794 abort (); 6794 abort ();
6795 f->output_method = d->type; 6795 f->output_method = t->type;
6796 f->device = d; 6796 f->terminal = t;
6797 6797
6798 d->reference_count++; 6798 t->reference_count++;
6799 d->display_info.tty->top_frame = selected_frame; 6799 t->display_info.tty->top_frame = selected_frame;
6800 change_frame_size (XFRAME (selected_frame), 6800 change_frame_size (XFRAME (selected_frame),
6801 FrameRows (d->display_info.tty), 6801 FrameRows (t->display_info.tty),
6802 FrameCols (d->display_info.tty), 0, 0, 1); 6802 FrameCols (t->display_info.tty), 0, 0, 1);
6803 6803
6804 /* Delete the initial display. */ 6804 /* Delete the initial terminal. */
6805 if (--initial_device->reference_count == 0 6805 if (--initial_terminal->reference_count == 0
6806 && initial_device->delete_device_hook) 6806 && initial_terminal->delete_terminal_hook)
6807 (*initial_device->delete_device_hook) (initial_device); 6807 (*initial_terminal->delete_terminal_hook) (initial_terminal);
6808 6808
6809 /* Update frame parameters to reflect the new type. */ 6809 /* Update frame parameters to reflect the new type. */
6810 Fmodify_frame_parameters (selected_frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil)); 6810 Fmodify_frame_parameters (selected_frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil));
6811 Fmodify_frame_parameters 6811 Fmodify_frame_parameters
6812 (selected_frame, Fcons (Fcons (Qtty_type, 6812 (selected_frame, Fcons (Fcons (Qtty_type,
6813 Fdisplay_tty_type (selected_frame)), Qnil)); 6813 Ftty_type (selected_frame)), Qnil));
6814 Fmodify_frame_parameters (selected_frame, Fcons (Fcons (Qtty, Qnil), Qnil)); 6814 Fmodify_frame_parameters (selected_frame, Fcons (Fcons (Qtty, Qnil), Qnil));
6815 } 6815 }
6816 6816
diff --git a/src/frame.c b/src/frame.c
index f0657975402..bc358c702b3 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -76,8 +76,8 @@ Lisp_Object Qinhibit_default_face_x_resources;
76 76
77Lisp_Object Qx_frame_parameter; 77Lisp_Object Qx_frame_parameter;
78Lisp_Object Qx_resource_name; 78Lisp_Object Qx_resource_name;
79Lisp_Object Qdevice; 79Lisp_Object Qterminal;
80Lisp_Object Qdisplay_live_p; 80Lisp_Object Qterminal_live_p;
81 81
82/* Frame parameters (set or reported). */ 82/* Frame parameters (set or reported). */
83 83
@@ -225,7 +225,7 @@ See also `frame-live-p'. */)
225DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0, 225DEFUN ("frame-live-p", Fframe_live_p, Sframe_live_p, 1, 1, 0,
226 doc: /* Return non-nil if OBJECT is a frame which has not been deleted. 226 doc: /* Return non-nil if OBJECT is a frame which has not been deleted.
227Value is nil if OBJECT is not a live frame. If object is a live 227Value is nil if OBJECT is not a live frame. If object is a live
228frame, the return value indicates what sort of output device it is 228frame, the return value indicates what sort of terminal device it is
229displayed on. See the documentation of `framep' for possible 229displayed on. See the documentation of `framep' for possible
230return values. */) 230return values. */)
231 (object) 231 (object)
@@ -424,8 +424,8 @@ make_frame_without_minibuffer (mini_window, kb, display)
424 424
425#ifdef MULTI_KBOARD 425#ifdef MULTI_KBOARD
426 if (!NILP (mini_window) 426 if (!NILP (mini_window)
427 && XFRAME (XWINDOW (mini_window)->frame)->device->kboard != kb) 427 && FRAME_KBOARD (XFRAME (XWINDOW (mini_window)->frame)) != kb)
428 error ("Frame and minibuffer must be on the same display"); 428 error ("Frame and minibuffer must be on the same terminal");
429#endif 429#endif
430 430
431 /* Make a frame containing just a root window. */ 431 /* Make a frame containing just a root window. */
@@ -503,13 +503,13 @@ make_minibuffer_frame ()
503 503
504/* Construct a frame that refers to a terminal. */ 504/* Construct a frame that refers to a terminal. */
505 505
506static int terminal_frame_count; 506static int tty_frame_count;
507 507
508struct frame * 508struct frame *
509make_initial_frame (void) 509make_initial_frame (void)
510{ 510{
511 struct frame *f; 511 struct frame *f;
512 struct device *device; 512 struct terminal *terminal;
513 Lisp_Object frame; 513 Lisp_Object frame;
514 514
515#ifdef MULTI_KBOARD 515#ifdef MULTI_KBOARD
@@ -527,22 +527,22 @@ make_initial_frame (void)
527 if (! (NILP (Vframe_list) || CONSP (Vframe_list))) 527 if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
528 Vframe_list = Qnil; 528 Vframe_list = Qnil;
529 529
530 device = init_initial_device (); 530 terminal = init_initial_terminal ();
531 531
532 f = make_frame (1); 532 f = make_frame (1);
533 XSETFRAME (frame, f); 533 XSETFRAME (frame, f);
534 534
535 Vframe_list = Fcons (frame, Vframe_list); 535 Vframe_list = Fcons (frame, Vframe_list);
536 536
537 terminal_frame_count = 1; 537 tty_frame_count = 1;
538 f->name = build_string ("F1"); 538 f->name = build_string ("F1");
539 539
540 f->visible = 1; 540 f->visible = 1;
541 f->async_visible = 1; 541 f->async_visible = 1;
542 542
543 f->output_method = device->type; 543 f->output_method = terminal->type;
544 f->device = device; 544 f->terminal = terminal;
545 f->device->reference_count++; 545 f->terminal->reference_count++;
546 f->output_data.nothing = 0; 546 f->output_data.nothing = 0;
547 547
548 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; 548 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
@@ -556,7 +556,7 @@ make_initial_frame (void)
556 556
557 557
558struct frame * 558struct frame *
559make_terminal_frame (struct device *device) 559make_terminal_frame (struct terminal *terminal)
560{ 560{
561 register struct frame *f; 561 register struct frame *f;
562 Lisp_Object frame; 562 Lisp_Object frame;
@@ -567,8 +567,8 @@ make_terminal_frame (struct device *device)
567 XSETFRAME (frame, f); 567 XSETFRAME (frame, f);
568 Vframe_list = Fcons (frame, Vframe_list); 568 Vframe_list = Fcons (frame, Vframe_list);
569 569
570 terminal_frame_count++; 570 tty_frame_count++;
571 sprintf (name, "F%d", terminal_frame_count); 571 sprintf (name, "F%d", tty_frame_count);
572 f->name = build_string (name); 572 f->name = build_string (name);
573 573
574 f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */ 574 f->visible = 1; /* FRAME_SET_VISIBLE wd set frame_garbaged. */
@@ -607,8 +607,8 @@ make_terminal_frame (struct device *device)
607#else 607#else
608 { 608 {
609 f->output_method = output_termcap; 609 f->output_method = output_termcap;
610 f->device = device; 610 f->terminal = terminal;
611 f->device->reference_count++; 611 f->terminal->reference_count++;
612 create_tty_output (f); 612 create_tty_output (f);
613 613
614 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR; 614 FRAME_FOREGROUND_PIXEL (f) = FACE_TTY_DEFAULT_FG_COLOR;
@@ -687,7 +687,7 @@ affects all frames on the same terminal device. */)
687 Lisp_Object parms; 687 Lisp_Object parms;
688{ 688{
689 struct frame *f; 689 struct frame *f;
690 struct device *d = NULL; 690 struct terminal *t = NULL;
691 Lisp_Object frame, tem; 691 Lisp_Object frame, tem;
692 struct frame *sf = SELECTED_FRAME (); 692 struct frame *sf = SELECTED_FRAME ();
693 693
@@ -709,18 +709,17 @@ affects all frames on the same terminal device. */)
709#endif /* not MSDOS */ 709#endif /* not MSDOS */
710 710
711 { 711 {
712 Lisp_Object display_device; 712 Lisp_Object terminal;
713 713
714 display_device = Fassq (Qdevice, parms); 714 terminal = Fassq (Qterminal, parms);
715 if (!NILP (display_device)) 715 if (!NILP (terminal))
716 { 716 {
717 display_device = XCDR (display_device); 717 terminal = XCDR (terminal);
718 CHECK_NUMBER (display_device); 718 t = get_terminal (terminal, 1);
719 d = get_device (XINT (display_device), 1);
720 } 719 }
721 } 720 }
722 721
723 if (!d) 722 if (!t)
724 { 723 {
725 char *name = 0, *type = 0; 724 char *name = 0, *type = 0;
726 Lisp_Object tty, tty_type; 725 Lisp_Object tty, tty_type;
@@ -747,10 +746,10 @@ affects all frames on the same terminal device. */)
747 type[SBYTES (tty_type)] = 0; 746 type[SBYTES (tty_type)] = 0;
748 } 747 }
749 748
750 d = init_tty (name, type, 0); /* Errors are not fatal. */ 749 t = init_tty (name, type, 0); /* Errors are not fatal. */
751 } 750 }
752 751
753 f = make_terminal_frame (d); 752 f = make_terminal_frame (t);
754 753
755 { 754 {
756 int width, height; 755 int width, height;
@@ -765,10 +764,10 @@ affects all frames on the same terminal device. */)
765 Fmodify_frame_parameters (frame, parms); 764 Fmodify_frame_parameters (frame, parms);
766 Fmodify_frame_parameters (frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil)); 765 Fmodify_frame_parameters (frame, Fcons (Fcons (Qwindow_system, Qnil), Qnil));
767 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty_type, 766 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty_type,
768 build_string (d->display_info.tty->type)), 767 build_string (t->display_info.tty->type)),
769 Qnil)); 768 Qnil));
770 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty, 769 Fmodify_frame_parameters (frame, Fcons (Fcons (Qtty,
771 build_string (d->display_info.tty->name)), 770 build_string (t->display_info.tty->name)),
772 Qnil)); 771 Qnil));
773 772
774 /* Make the frame face alist be frame-specific, so that each 773 /* Make the frame face alist be frame-specific, so that each
@@ -793,7 +792,7 @@ affects all frames on the same terminal device. */)
793 frame's focus to FRAME instead. 792 frame's focus to FRAME instead.
794 793
795 FOR_DELETION non-zero means that the selected frame is being 794 FOR_DELETION non-zero means that the selected frame is being
796 deleted, which includes the possibility that the frame's display 795 deleted, which includes the possibility that the frame's terminal
797 is dead. */ 796 is dead. */
798 797
799Lisp_Object 798Lisp_Object
@@ -1060,30 +1059,6 @@ If FRAME is the selected frame, this makes WINDOW the selected window. */)
1060 1059
1061 return XFRAME (frame)->selected_window = window; 1060 return XFRAME (frame)->selected_window = window;
1062} 1061}
1063
1064
1065DEFUN ("frame-display", Fframe_display, Sframe_display, 0, 1, 0,
1066 doc: /* Return the display device that FRAME is displayed on.
1067If FRAME is nil, the selected frame is used.
1068
1069The display device is represented by its integer identifier. */)
1070 (frame)
1071 Lisp_Object frame;
1072{
1073 struct device *d;
1074
1075 if (NILP (frame))
1076 frame = selected_frame;
1077
1078 CHECK_LIVE_FRAME (frame);
1079
1080 d = get_device (frame, 0);
1081
1082 if (!d)
1083 return Qnil;
1084 else
1085 return make_number (d->id);
1086}
1087 1062
1088 1063
1089DEFUN ("frame-list", Fframe_list, Sframe_list, 1064DEFUN ("frame-list", Fframe_list, Sframe_list,
@@ -1532,32 +1507,33 @@ The functions are run with one arg, the frame to be deleted. */)
1532 xfree (FRAME_MESSAGE_BUF (f)); 1507 xfree (FRAME_MESSAGE_BUF (f));
1533 1508
1534 /* Since some events are handled at the interrupt level, we may get 1509 /* Since some events are handled at the interrupt level, we may get
1535 an event for f at any time; if we zero out the frame's display 1510 an event for f at any time; if we zero out the frame's terminal
1536 now, then we may trip up the event-handling code. Instead, we'll 1511 now, then we may trip up the event-handling code. Instead, we'll
1537 promise that the display of the frame must be valid until we have 1512 promise that the terminal of the frame must be valid until we
1538 called the window-system-dependent frame destruction routine. */ 1513 have called the window-system-dependent frame destruction
1514 routine. */
1539 1515
1540 if (FRAME_DEVICE (f)->delete_frame_hook) 1516 if (FRAME_TERMINAL (f)->delete_frame_hook)
1541 (*FRAME_DEVICE (f)->delete_frame_hook) (f); 1517 (*FRAME_TERMINAL (f)->delete_frame_hook) (f);
1542 1518
1543 { 1519 {
1544 struct device *device = FRAME_DEVICE (f); 1520 struct terminal *terminal = FRAME_TERMINAL (f);
1545 f->output_data.nothing = 0; 1521 f->output_data.nothing = 0;
1546 f->device = 0; /* Now the frame is dead. */ 1522 f->terminal = 0; /* Now the frame is dead. */
1547 1523
1548 /* If needed, delete the device that this frame was on. 1524 /* If needed, delete the terminal that this frame was on.
1549 (This must be done after the frame is killed.) */ 1525 (This must be done after the frame is killed.) */
1550 device->reference_count--; 1526 terminal->reference_count--;
1551 if (device->reference_count == 0) 1527 if (terminal->reference_count == 0)
1552 { 1528 {
1553 kb = NULL; 1529 kb = NULL;
1554 if (device->delete_device_hook) 1530 if (terminal->delete_terminal_hook)
1555 (*device->delete_device_hook) (device); 1531 (*terminal->delete_terminal_hook) (terminal);
1556 else 1532 else
1557 delete_device (device); 1533 delete_terminal (terminal);
1558 } 1534 }
1559 else 1535 else
1560 kb = device->kboard; 1536 kb = terminal->kboard;
1561 } 1537 }
1562 1538
1563 /* If we've deleted the last_nonminibuf_frame, then try to find 1539 /* If we've deleted the last_nonminibuf_frame, then try to find
@@ -1704,11 +1680,11 @@ and returns whatever that function returns. */)
1704 1680
1705#ifdef HAVE_MOUSE 1681#ifdef HAVE_MOUSE
1706 /* It's okay for the hook to refrain from storing anything. */ 1682 /* It's okay for the hook to refrain from storing anything. */
1707 if (FRAME_DEVICE (f)->mouse_position_hook) 1683 if (FRAME_TERMINAL (f)->mouse_position_hook)
1708 (*FRAME_DEVICE (f)->mouse_position_hook) (&f, -1, 1684 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
1709 &lispy_dummy, &party_dummy, 1685 &lispy_dummy, &party_dummy,
1710 &x, &y, 1686 &x, &y,
1711 &long_dummy); 1687 &long_dummy);
1712 if (! NILP (x)) 1688 if (! NILP (x))
1713 { 1689 {
1714 col = XINT (x); 1690 col = XINT (x);
@@ -1747,11 +1723,11 @@ and nil for X and Y. */)
1747 1723
1748#ifdef HAVE_MOUSE 1724#ifdef HAVE_MOUSE
1749 /* It's okay for the hook to refrain from storing anything. */ 1725 /* It's okay for the hook to refrain from storing anything. */
1750 if (FRAME_DEVICE (f)->mouse_position_hook) 1726 if (FRAME_TERMINAL (f)->mouse_position_hook)
1751 (*FRAME_DEVICE (f)->mouse_position_hook) (&f, -1, 1727 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, -1,
1752 &lispy_dummy, &party_dummy, 1728 &lispy_dummy, &party_dummy,
1753 &x, &y, 1729 &x, &y,
1754 &long_dummy); 1730 &long_dummy);
1755#endif 1731#endif
1756 XSETFRAME (lispy_dummy, f); 1732 XSETFRAME (lispy_dummy, f);
1757 return Fcons (lispy_dummy, Fcons (x, y)); 1733 return Fcons (lispy_dummy, Fcons (x, y));
@@ -2028,8 +2004,8 @@ doesn't support multiple overlapping frames, this function does nothing. */)
2028 /* Do like the documentation says. */ 2004 /* Do like the documentation says. */
2029 Fmake_frame_visible (frame); 2005 Fmake_frame_visible (frame);
2030 2006
2031 if (FRAME_DEVICE (f)->frame_raise_lower_hook) 2007 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
2032 (*FRAME_DEVICE (f)->frame_raise_lower_hook) (f, 1); 2008 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1);
2033 2009
2034 return Qnil; 2010 return Qnil;
2035} 2011}
@@ -2052,8 +2028,8 @@ doesn't support multiple overlapping frames, this function does nothing. */)
2052 2028
2053 f = XFRAME (frame); 2029 f = XFRAME (frame);
2054 2030
2055 if (FRAME_DEVICE (f)->frame_raise_lower_hook) 2031 if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
2056 (*FRAME_DEVICE (f)->frame_raise_lower_hook) (f, 0); 2032 (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
2057 2033
2058 return Qnil; 2034 return Qnil;
2059} 2035}
@@ -2101,8 +2077,8 @@ The redirection lasts until `redirect-frame-focus' is called to change it. */)
2101 2077
2102 f->focus_frame = focus_frame; 2078 f->focus_frame = focus_frame;
2103 2079
2104 if (FRAME_DEVICE (f)->frame_rehighlight_hook) 2080 if (FRAME_TERMINAL (f)->frame_rehighlight_hook)
2105 (*FRAME_DEVICE (f)->frame_rehighlight_hook) (f); 2081 (*FRAME_TERMINAL (f)->frame_rehighlight_hook) (f);
2106 2082
2107 return Qnil; 2083 return Qnil;
2108} 2084}
@@ -2236,8 +2212,8 @@ set_term_frame_name (f, name)
2236 SBYTES (f->name))) 2212 SBYTES (f->name)))
2237 return; 2213 return;
2238 2214
2239 terminal_frame_count++; 2215 tty_frame_count++;
2240 sprintf (namebuf, "F%d", terminal_frame_count); 2216 sprintf (namebuf, "F%d", tty_frame_count);
2241 name = build_string (namebuf); 2217 name = build_string (namebuf);
2242 } 2218 }
2243 else 2219 else
@@ -4306,10 +4282,10 @@ syms_of_frame ()
4306 Qx_frame_parameter = intern ("x-frame-parameter"); 4282 Qx_frame_parameter = intern ("x-frame-parameter");
4307 staticpro (&Qx_frame_parameter); 4283 staticpro (&Qx_frame_parameter);
4308 4284
4309 Qdevice = intern ("device"); 4285 Qterminal = intern ("terminal");
4310 staticpro (&Qdevice); 4286 staticpro (&Qterminal);
4311 Qdisplay_live_p = intern ("display-live-p"); 4287 Qterminal_live_p = intern ("terminal-live-p");
4312 staticpro (&Qdisplay_live_p); 4288 staticpro (&Qterminal_live_p);
4313 4289
4314 { 4290 {
4315 int i; 4291 int i;
@@ -4449,7 +4425,6 @@ This variable is local to the current terminal and cannot be buffer-local. */);
4449 defsubr (&Sframe_first_window); 4425 defsubr (&Sframe_first_window);
4450 defsubr (&Sframe_selected_window); 4426 defsubr (&Sframe_selected_window);
4451 defsubr (&Sset_frame_selected_window); 4427 defsubr (&Sset_frame_selected_window);
4452 defsubr (&Sframe_display);
4453 defsubr (&Sframe_list); 4428 defsubr (&Sframe_list);
4454 defsubr (&Snext_frame); 4429 defsubr (&Snext_frame);
4455 defsubr (&Sprevious_frame); 4430 defsubr (&Sprevious_frame);
diff --git a/src/frame.h b/src/frame.h
index 6c54c328923..cf0e50ed623 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -70,7 +70,7 @@ enum text_cursor_kinds
70#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel) 70#define FRAME_FOREGROUND_PIXEL(f) ((f)->foreground_pixel)
71#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel) 71#define FRAME_BACKGROUND_PIXEL(f) ((f)->background_pixel)
72 72
73struct device; 73struct terminal;
74 74
75struct frame 75struct frame
76{ 76{
@@ -267,12 +267,12 @@ struct frame
267 267
268 /* The output method says how the contents of this frame are 268 /* The output method says how the contents of this frame are
269 displayed. It could be using termcap, or using an X window. 269 displayed. It could be using termcap, or using an X window.
270 This must be the same as the device->type. */ 270 This must be the same as the terminal->type. */
271 enum output_method output_method; 271 enum output_method output_method;
272 272
273 /* The display device that this frame uses. If this is NULL, then 273 /* The terminal device that this frame uses. If this is NULL, then
274 the frame has been deleted. */ 274 the frame has been deleted. */
275 struct device *device; 275 struct terminal *terminal;
276 276
277 /* Device-dependent, frame-local auxiliary data used for displaying 277 /* Device-dependent, frame-local auxiliary data used for displaying
278 the contents. When the frame is deleted, this data is deleted as 278 the contents. When the frame is deleted, this data is deleted as
@@ -458,7 +458,7 @@ struct frame
458}; 458};
459 459
460#ifdef MULTI_KBOARD 460#ifdef MULTI_KBOARD
461#define FRAME_KBOARD(f) ((f)->device->kboard) 461#define FRAME_KBOARD(f) ((f)->terminal->kboard)
462#else 462#else
463#define FRAME_KBOARD(f) (&the_only_kboard) 463#define FRAME_KBOARD(f) (&the_only_kboard)
464#endif 464#endif
@@ -496,7 +496,7 @@ typedef struct frame *FRAME_PTR;
496#endif 496#endif
497 497
498/* Nonzero if frame F is still alive (not deleted). */ 498/* Nonzero if frame F is still alive (not deleted). */
499#define FRAME_LIVE_P(f) ((f)->device != 0) 499#define FRAME_LIVE_P(f) ((f)->terminal != 0)
500 500
501/* Nonzero if frame F is a minibuffer-only frame. */ 501/* Nonzero if frame F is a minibuffer-only frame. */
502#define FRAME_MINIBUF_ONLY_P(f) \ 502#define FRAME_MINIBUF_ONLY_P(f) \
@@ -780,13 +780,13 @@ typedef struct frame *FRAME_PTR;
780 780
781extern Lisp_Object Qframep, Qframe_live_p; 781extern Lisp_Object Qframep, Qframe_live_p;
782extern Lisp_Object Qtty, Qtty_type; 782extern Lisp_Object Qtty, Qtty_type;
783extern Lisp_Object Qdevice, Qdisplay_live_p; 783extern Lisp_Object Qterminal, Qterminal_live_p;
784extern Lisp_Object Qenvironment; 784extern Lisp_Object Qenvironment;
785 785
786extern struct frame *last_nonminibuf_frame; 786extern struct frame *last_nonminibuf_frame;
787 787
788extern struct frame *make_initial_frame P_ ((void)); 788extern struct frame *make_initial_frame P_ ((void));
789extern struct frame *make_terminal_frame P_ ((struct device *)); 789extern struct frame *make_terminal_frame P_ ((struct terminal *));
790extern struct frame *make_frame P_ ((int)); 790extern struct frame *make_frame P_ ((int));
791#ifdef HAVE_WINDOW_SYSTEM 791#ifdef HAVE_WINDOW_SYSTEM
792extern struct frame *make_minibuffer_frame P_ ((void)); 792extern struct frame *make_minibuffer_frame P_ ((void));
diff --git a/src/keyboard.c b/src/keyboard.c
index c47fda8223c..8cfa4b34371 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1130,19 +1130,19 @@ void
1130push_frame_kboard (f) 1130push_frame_kboard (f)
1131 FRAME_PTR f; 1131 FRAME_PTR f;
1132{ 1132{
1133 push_kboard (f->device->kboard); 1133 push_kboard (f->terminal->kboard);
1134} 1134}
1135 1135
1136void 1136void
1137pop_kboard () 1137pop_kboard ()
1138{ 1138{
1139#ifdef MULTI_KBOARD 1139#ifdef MULTI_KBOARD
1140 struct device *d; 1140 struct terminal *t;
1141 struct kboard_stack *p = kboard_stack; 1141 struct kboard_stack *p = kboard_stack;
1142 current_kboard = NULL; 1142 current_kboard = NULL;
1143 for (d = device_list; d; d = d->next_device) 1143 for (t = terminal_list; t; t = t->next_terminal)
1144 { 1144 {
1145 if (d->kboard == p->kboard) 1145 if (t->kboard == p->kboard)
1146 { 1146 {
1147 current_kboard = p->kboard; 1147 current_kboard = p->kboard;
1148 break; 1148 break;
@@ -1150,7 +1150,7 @@ pop_kboard ()
1150 } 1150 }
1151 if (current_kboard == NULL) 1151 if (current_kboard == NULL)
1152 { 1152 {
1153 /* The display we remembered has been deleted. */ 1153 /* The terminal we remembered has been deleted. */
1154 current_kboard = FRAME_KBOARD (SELECTED_FRAME ()); 1154 current_kboard = FRAME_KBOARD (SELECTED_FRAME ());
1155 } 1155 }
1156 kboard_stack = p->next; 1156 kboard_stack = p->next;
@@ -4205,15 +4205,15 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
4205 unsigned long time; 4205 unsigned long time;
4206 4206
4207 *kbp = current_kboard; 4207 *kbp = current_kboard;
4208 /* Note that this uses F to determine which display to look at. 4208 /* Note that this uses F to determine which terminal to look at.
4209 If there is no valid info, it does not store anything 4209 If there is no valid info, it does not store anything
4210 so x remains nil. */ 4210 so x remains nil. */
4211 x = Qnil; 4211 x = Qnil;
4212 4212
4213 /* XXX Can f or mouse_position_hook be NULL here? */ 4213 /* XXX Can f or mouse_position_hook be NULL here? */
4214 if (f && FRAME_DEVICE (f)->mouse_position_hook) 4214 if (f && FRAME_TERMINAL (f)->mouse_position_hook)
4215 (*FRAME_DEVICE (f)->mouse_position_hook) (&f, 0, &bar_window, 4215 (*FRAME_TERMINAL (f)->mouse_position_hook) (&f, 0, &bar_window,
4216 &part, &x, &y, &time); 4216 &part, &x, &y, &time);
4217 4217
4218 obj = Qnil; 4218 obj = Qnil;
4219 4219
@@ -6749,15 +6749,15 @@ read_avail_input (expected)
6749{ 6749{
6750 int nread = 0; 6750 int nread = 0;
6751 int err = 0; 6751 int err = 0;
6752 struct device *d; 6752 struct terminal *t;
6753 6753
6754 /* Loop through the available devices, and call their input hooks. */ 6754 /* Loop through the available terminals, and call their input hooks. */
6755 d = device_list; 6755 t = terminal_list;
6756 while (d) 6756 while (t)
6757 { 6757 {
6758 struct device *next = d->next_device; 6758 struct terminal *next = t->next_terminal;
6759 6759
6760 if (d->read_socket_hook) 6760 if (t->read_socket_hook)
6761 { 6761 {
6762 int nr; 6762 int nr;
6763 struct input_event hold_quit; 6763 struct input_event hold_quit;
@@ -6766,7 +6766,7 @@ read_avail_input (expected)
6766 hold_quit.kind = NO_EVENT; 6766 hold_quit.kind = NO_EVENT;
6767 6767
6768 /* No need for FIONREAD or fcntl; just say don't wait. */ 6768 /* No need for FIONREAD or fcntl; just say don't wait. */
6769 while (nr = (*d->read_socket_hook) (d, expected, &hold_quit), nr > 0) 6769 while (nr = (*t->read_socket_hook) (t, expected, &hold_quit), nr > 0)
6770 { 6770 {
6771 nread += nr; 6771 nread += nr;
6772 expected = 0; 6772 expected = 0;
@@ -6778,10 +6778,10 @@ read_avail_input (expected)
6778 } 6778 }
6779 else if (nr == -2) /* Non-transient error. */ 6779 else if (nr == -2) /* Non-transient error. */
6780 { 6780 {
6781 /* The display device terminated; it should be closed. */ 6781 /* The terminal device terminated; it should be closed. */
6782 6782
6783 /* Kill Emacs if this was our last display. */ 6783 /* Kill Emacs if this was our last terminal. */
6784 if (! device_list->next_device) 6784 if (!terminal_list->next_terminal)
6785 /* Formerly simply reported no input, but that 6785 /* Formerly simply reported no input, but that
6786 sometimes led to a failure of Emacs to terminate. 6786 sometimes led to a failure of Emacs to terminate.
6787 SIGHUP seems appropriate if we can't reach the 6787 SIGHUP seems appropriate if we can't reach the
@@ -6792,18 +6792,18 @@ read_avail_input (expected)
6792 alone in its group. */ 6792 alone in its group. */
6793 kill (getpid (), SIGHUP); 6793 kill (getpid (), SIGHUP);
6794 6794
6795 /* XXX Is calling delete_device safe here? It calls Fdelete_frame. */ 6795 /* XXX Is calling delete_terminal safe here? It calls Fdelete_frame. */
6796 if (d->delete_device_hook) 6796 if (t->delete_terminal_hook)
6797 (*d->delete_device_hook) (d); 6797 (*t->delete_terminal_hook) (t);
6798 else 6798 else
6799 delete_device (d); 6799 delete_terminal (t);
6800 } 6800 }
6801 6801
6802 if (hold_quit.kind != NO_EVENT) 6802 if (hold_quit.kind != NO_EVENT)
6803 kbd_buffer_store_event (&hold_quit); 6803 kbd_buffer_store_event (&hold_quit);
6804 } 6804 }
6805 6805
6806 d = next; 6806 t = next;
6807 } 6807 }
6808 6808
6809 if (err && !nread) 6809 if (err && !nread)
@@ -6814,12 +6814,12 @@ read_avail_input (expected)
6814 6814
6815/* This is the tty way of reading available input. 6815/* This is the tty way of reading available input.
6816 6816
6817 Note that each terminal device has its own `struct device' object, 6817 Note that each terminal device has its own `struct terminal' object,
6818 and so this function is called once for each individual termcap 6818 and so this function is called once for each individual termcap
6819 display. The first parameter indicates which device to read from. */ 6819 terminal. The first parameter indicates which terminal to read from. */
6820 6820
6821int 6821int
6822tty_read_avail_input (struct device *device, 6822tty_read_avail_input (struct terminal *terminal,
6823 int expected, 6823 int expected,
6824 struct input_event *hold_quit) 6824 struct input_event *hold_quit)
6825{ 6825{
@@ -6828,10 +6828,10 @@ tty_read_avail_input (struct device *device,
6828 of characters on some systems when input is stuffed at us. */ 6828 of characters on some systems when input is stuffed at us. */
6829 unsigned char cbuf[KBD_BUFFER_SIZE - 1]; 6829 unsigned char cbuf[KBD_BUFFER_SIZE - 1];
6830 int n_to_read, i; 6830 int n_to_read, i;
6831 struct tty_display_info *tty = device->display_info.tty; 6831 struct tty_display_info *tty = terminal->display_info.tty;
6832 int nread = 0; 6832 int nread = 0;
6833 6833
6834 if (device->type != output_termcap) 6834 if (terminal->type != output_termcap)
6835 abort (); 6835 abort ();
6836 6836
6837 /* XXX I think the following code should be moved to separate hook 6837 /* XXX I think the following code should be moved to separate hook
@@ -6861,7 +6861,7 @@ tty_read_avail_input (struct device *device,
6861 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0) 6861 if (ioctl (fileno (tty->input), FIONREAD, &n_to_read) < 0)
6862 { 6862 {
6863 if (! noninteractive) 6863 if (! noninteractive)
6864 return -2; /* Close this device. */ 6864 return -2; /* Close this terminal. */
6865 else 6865 else
6866 n_to_read = 0; 6866 n_to_read = 0;
6867 } 6867 }
@@ -6890,14 +6890,14 @@ tty_read_avail_input (struct device *device,
6890 when the control tty is taken away. 6890 when the control tty is taken away.
6891 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */ 6891 Jeffrey Honig <jch@bsdi.com> says this is generally safe. */
6892 if (nread == -1 && errno == EIO) 6892 if (nread == -1 && errno == EIO)
6893 return -2; /* Close this device. */ 6893 return -2; /* Close this terminal. */
6894#if defined (AIX) && (! defined (aix386) && defined (_BSD)) 6894#if defined (AIX) && (! defined (aix386) && defined (_BSD))
6895 /* The kernel sometimes fails to deliver SIGHUP for ptys. 6895 /* The kernel sometimes fails to deliver SIGHUP for ptys.
6896 This looks incorrect, but it isn't, because _BSD causes 6896 This looks incorrect, but it isn't, because _BSD causes
6897 O_NDELAY to be defined in fcntl.h as O_NONBLOCK, 6897 O_NDELAY to be defined in fcntl.h as O_NONBLOCK,
6898 and that causes a value other than 0 when there is no input. */ 6898 and that causes a value other than 0 when there is no input. */
6899 if (nread == 0) 6899 if (nread == 0)
6900 return -2; /* Close this device. */ 6900 return -2; /* Close this terminal. */
6901#endif 6901#endif
6902 } 6902 }
6903 while ( 6903 while (
@@ -10440,7 +10440,7 @@ interrupt_signal (signalnum) /* If we don't have an argument, */
10440{ 10440{
10441 /* Must preserve main program's value of errno. */ 10441 /* Must preserve main program's value of errno. */
10442 int old_errno = errno; 10442 int old_errno = errno;
10443 struct device *device; 10443 struct terminal *terminal;
10444 10444
10445#if defined (USG) && !defined (POSIX_SIGNALS) 10445#if defined (USG) && !defined (POSIX_SIGNALS)
10446 /* USG systems forget handlers when they are used; 10446 /* USG systems forget handlers when they are used;
@@ -10451,9 +10451,9 @@ interrupt_signal (signalnum) /* If we don't have an argument, */
10451 10451
10452 SIGNAL_THREAD_CHECK (signalnum); 10452 SIGNAL_THREAD_CHECK (signalnum);
10453 10453
10454 /* See if we have an active display on our controlling terminal. */ 10454 /* See if we have an active terminal on our controlling tty. */
10455 device = get_named_tty (NULL); 10455 terminal = get_named_tty (NULL);
10456 if (!device) 10456 if (!terminal)
10457 { 10457 {
10458 /* If there are no frames there, let's pretend that we are a 10458 /* If there are no frames there, let's pretend that we are a
10459 well-behaving UN*X program and quit. */ 10459 well-behaving UN*X program and quit. */
@@ -10467,7 +10467,7 @@ interrupt_signal (signalnum) /* If we don't have an argument, */
10467 controlling tty, if we have a frame there. We disable the 10467 controlling tty, if we have a frame there. We disable the
10468 interrupt key on secondary ttys, so the SIGINT must have come 10468 interrupt key on secondary ttys, so the SIGINT must have come
10469 from the controlling tty. */ 10469 from the controlling tty. */
10470 internal_last_event_frame = device->display_info.tty->top_frame; 10470 internal_last_event_frame = terminal->display_info.tty->top_frame;
10471 10471
10472 handle_interrupt (); 10472 handle_interrupt ();
10473 } 10473 }
@@ -10710,18 +10710,18 @@ DEFUN ("set-output-flow-control", Fset_output_flow_control, Sset_output_flow_con
10710If FLOW is non-nil, flow control is enabled and you cannot use C-s or 10710If FLOW is non-nil, flow control is enabled and you cannot use C-s or
10711C-q in key sequences. 10711C-q in key sequences.
10712 10712
10713This setting only has an effect on tty display devices and only when 10713This setting only has an effect on tty terminals and only when
10714Emacs reads input in CBREAK mode; see `set-input-interrupt-mode'. 10714Emacs reads input in CBREAK mode; see `set-input-interrupt-mode'.
10715 10715
10716See also `current-input-mode'. */) 10716See also `current-input-mode'. */)
10717 (flow, terminal) 10717 (flow, terminal)
10718 Lisp_Object flow, terminal; 10718 Lisp_Object flow, terminal;
10719{ 10719{
10720 struct device *d = get_device (terminal, 1); 10720 struct terminal *t = get_terminal (terminal, 1);
10721 struct tty_display_info *tty; 10721 struct tty_display_info *tty;
10722 if (d == NULL || d->type != output_termcap) 10722 if (t == NULL || t->type != output_termcap)
10723 return Qnil; 10723 return Qnil;
10724 tty = d->display_info.tty; 10724 tty = t->display_info.tty;
10725 10725
10726 if (tty->flow_control != !NILP (flow)) 10726 if (tty->flow_control != !NILP (flow))
10727 { 10727 {
@@ -10750,9 +10750,9 @@ parity.
10750Otherwise, Emacs will accept and pass through 8-bit input without 10750Otherwise, Emacs will accept and pass through 8-bit input without
10751specially interpreting the top bit. 10751specially interpreting the top bit.
10752 10752
10753This setting only has an effect on tty display devices. 10753This setting only has an effect on tty terminal devices.
10754 10754
10755Optional parameter TERMINAL specifies the tty display device to use. 10755Optional parameter TERMINAL specifies the tty terminal device to use.
10756It may be a terminal id, a frame, or nil for the terminal used by the 10756It may be a terminal id, a frame, or nil for the terminal used by the
10757currently selected frame. 10757currently selected frame.
10758 10758
@@ -10760,13 +10760,13 @@ See also `current-input-mode'. */)
10760 (meta, terminal) 10760 (meta, terminal)
10761 Lisp_Object meta, terminal; 10761 Lisp_Object meta, terminal;
10762{ 10762{
10763 struct device *d = get_device (terminal, 1); 10763 struct terminal *t = get_terminal (terminal, 1);
10764 struct tty_display_info *tty; 10764 struct tty_display_info *tty;
10765 int new_meta; 10765 int new_meta;
10766 10766
10767 if (d == NULL || d->type != output_termcap) 10767 if (t == NULL || t->type != output_termcap)
10768 return Qnil; 10768 return Qnil;
10769 tty = d->display_info.tty; 10769 tty = t->display_info.tty;
10770 10770
10771 if (NILP (meta)) 10771 if (NILP (meta))
10772 new_meta = 0; 10772 new_meta = 0;
@@ -10795,18 +10795,18 @@ DEFUN ("set-quit-char", Fset_quit_char, Sset_quit_char, 1, 1, 0,
10795 doc: /* Specify character used for quitting. 10795 doc: /* Specify character used for quitting.
10796QUIT must be an ASCII character. 10796QUIT must be an ASCII character.
10797 10797
10798This function only has an effect on the tty display on the controlling 10798This function only has an effect on the terminal on the controlling
10799tty of the Emacs process. 10799tty of the Emacs process.
10800 10800
10801See also `current-input-mode'. */) 10801See also `current-input-mode'. */)
10802 (quit) 10802 (quit)
10803 Lisp_Object quit; 10803 Lisp_Object quit;
10804{ 10804{
10805 struct device *d = get_named_tty (NULL); 10805 struct terminal *t = get_named_tty (NULL);
10806 struct tty_display_info *tty; 10806 struct tty_display_info *tty;
10807 if (d == NULL || d->type != output_termcap) 10807 if (t == NULL || t->type != output_termcap)
10808 return Qnil; 10808 return Qnil;
10809 tty = d->display_info.tty; 10809 tty = t->display_info.tty;
10810 10810
10811#ifndef DOS_NT 10811#ifndef DOS_NT
10812 /* this causes startup screen to be restored and messes with the mouse */ 10812 /* this causes startup screen to be restored and messes with the mouse */
@@ -11025,7 +11025,7 @@ delete_kboard (kb)
11025 && FRAMEP (selected_frame) 11025 && FRAMEP (selected_frame)
11026 && FRAME_LIVE_P (XFRAME (selected_frame))) 11026 && FRAME_LIVE_P (XFRAME (selected_frame)))
11027 { 11027 {
11028 current_kboard = XFRAME (selected_frame)->device->kboard; 11028 current_kboard = XFRAME (selected_frame)->terminal->kboard;
11029 if (current_kboard == kb) 11029 if (current_kboard == kb)
11030 abort (); 11030 abort ();
11031 } 11031 }
@@ -11463,7 +11463,7 @@ command exit.
11463The value `kill-region' is special; it means that the previous command 11463The value `kill-region' is special; it means that the previous command
11464was a kill command. 11464was a kill command.
11465 11465
11466`last-command' has a separate binding for each display device. 11466`last-command' has a separate binding for each terminal device.
11467See Info node `(elisp)Multiple displays'. */); 11467See Info node `(elisp)Multiple displays'. */);
11468 11468
11469 DEFVAR_KBOARD ("real-last-command", Vreal_last_command, 11469 DEFVAR_KBOARD ("real-last-command", Vreal_last_command,
@@ -11589,8 +11589,8 @@ untranslated. In a vector, an element which is nil means "no translation".
11589This is applied to the characters supplied to input methods, not their 11589This is applied to the characters supplied to input methods, not their
11590output. See also `translation-table-for-input'. 11590output. See also `translation-table-for-input'.
11591 11591
11592`local-keyboard-translate-table' has a separate binding for each 11592This variable has a separate binding for each terminal. See Info node
11593terminal. See Info node `(elisp)Multiple displays'. */); 11593`(elisp)Multiple displays'. */);
11594 11594
11595 DEFVAR_BOOL ("cannot-suspend", &cannot_suspend, 11595 DEFVAR_BOOL ("cannot-suspend", &cannot_suspend,
11596 doc: /* Non-nil means to always spawn a subshell instead of suspending. 11596 doc: /* Non-nil means to always spawn a subshell instead of suspending.
@@ -11677,7 +11677,8 @@ It also replaces `overriding-local-map'.
11677This variable is intended to let commands such as `universal-argument' 11677This variable is intended to let commands such as `universal-argument'
11678set up a different keymap for reading the next command. 11678set up a different keymap for reading the next command.
11679 11679
11680`overriding-terminal-local-map' has a separate binding for each display device. 11680`overriding-terminal-local-map' has a separate binding for each
11681terminal device.
11681See Info node `(elisp)Multiple displays'. */); 11682See Info node `(elisp)Multiple displays'. */);
11682 11683
11683 DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map, 11684 DEFVAR_LISP ("overriding-local-map", &Voverriding_local_map,
@@ -11705,7 +11706,7 @@ Each element should have the form (N . SYMBOL) where N is the
11705numeric keysym code (sans the \"system-specific\" bit 1<<28) 11706numeric keysym code (sans the \"system-specific\" bit 1<<28)
11706and SYMBOL is its name. 11707and SYMBOL is its name.
11707 11708
11708`system-key-alist' has a separate binding for each display device. 11709`system-key-alist' has a separate binding for each terminal device.
11709See Info node `(elisp)Multiple displays'. */); 11710See Info node `(elisp)Multiple displays'. */);
11710 11711
11711 DEFVAR_KBOARD ("local-function-key-map", Vlocal_function_key_map, 11712 DEFVAR_KBOARD ("local-function-key-map", Vlocal_function_key_map,
@@ -11731,15 +11732,15 @@ Typing `ESC O P' to `read-key-sequence' would return [f1]. Typing
11731`C-x ESC O P' would return [?\\C-x f1]. If [f1] were a prefix key, 11732`C-x ESC O P' would return [?\\C-x f1]. If [f1] were a prefix key,
11732typing `ESC O P x' would return [f1 x]. 11733typing `ESC O P x' would return [f1 x].
11733 11734
11734`local-function-key-map' has a separate binding for each display 11735`local-function-key-map' has a separate binding for each terminal
11735device. See Info node `(elisp)Multiple displays'. If you need to 11736device. See Info node `(elisp)Multiple displays'. If you need to
11736define a binding on all display devices, change `function-key-map' 11737define a binding on all terminals, change `function-key-map'
11737instead. Initially, `local-function-key-map' is an empty keymap that 11738instead. Initially, `local-function-key-map' is an empty keymap that
11738has `function-key-map' as its parent on all display devices. */); 11739has `function-key-map' as its parent on all terminal devices. */);
11739 11740
11740 DEFVAR_LISP ("function-key-map", &Vfunction_key_map, 11741 DEFVAR_LISP ("function-key-map", &Vfunction_key_map,
11741 doc: /* The parent keymap of all `local-function-key-map' instances. 11742 doc: /* The parent keymap of all `local-function-key-map' instances.
11742Function key definitions that apply to all display devices should go 11743Function key definitions that apply to all terminal devices should go
11743here. If a mapping is defined in both the current 11744here. If a mapping is defined in both the current
11744`local-function-key-map' binding and this variable, then the local 11745`local-function-key-map' binding and this variable, then the local
11745definition will take precendence. */); 11746definition will take precendence. */);
@@ -11750,13 +11751,13 @@ definition will take precendence. */);
11750This keymap works like `function-key-map', but comes after that, 11751This keymap works like `function-key-map', but comes after that,
11751and its non-prefix bindings override ordinary bindings. 11752and its non-prefix bindings override ordinary bindings.
11752 11753
11753`key-translation-map' has a separate binding for each display device. 11754`key-translation-map' has a separate binding for each terminal device.
11754(See Info node `(elisp)Multiple displays'.) If you need to set a key 11755(See Info node `(elisp)Multiple displays'.) If you need to set a key
11755translation on all devices, change `global-key-translation-map' instead. */); 11756translation on all terminals, change `global-key-translation-map' instead. */);
11756 11757
11757 DEFVAR_LISP ("key-translation-map", &Vkey_translation_map, 11758 DEFVAR_LISP ("key-translation-map", &Vkey_translation_map,
11758 doc: /* The parent keymap of all `local-key-translation-map' instances. 11759 doc: /* The parent keymap of all `local-key-translation-map' instances.
11759Key translations that apply to all display devices should go here. */); 11760Key translations that apply to all terminal devices should go here. */);
11760 Vkey_translation_map = Fmake_sparse_keymap (Qnil); 11761 Vkey_translation_map = Fmake_sparse_keymap (Qnil);
11761 11762
11762 DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list, 11763 DEFVAR_LISP ("deferred-action-list", &Vdeferred_action_list,
diff --git a/src/keyboard.h b/src/keyboard.h
index 45dbd495d28..6c320a4fad8 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -21,8 +21,9 @@ Boston, MA 02110-1301, USA. */
21 21
22/* Length of echobuf field in each KBOARD. */ 22/* Length of echobuf field in each KBOARD. */
23 23
24/* Each KBOARD represents one logical input stream from which Emacs gets input. 24/* Each KBOARD represents one logical input stream from which Emacs
25 If we are using ordinary terminals, it has one KBOARD object for each terminal device. 25 gets input. If we are using ordinary terminals, it has one KBOARD
26 object for each terminal device.
26 Usually each X display screen has its own KBOARD, 27 Usually each X display screen has its own KBOARD,
27 but when two of them are on the same X server, 28 but when two of them are on the same X server,
28 we assume they share a keyboard and give them one KBOARD in common. 29 we assume they share a keyboard and give them one KBOARD in common.
@@ -356,7 +357,7 @@ extern void kbd_buffer_store_help_event P_ ((Lisp_Object, Lisp_Object));
356extern Lisp_Object menu_item_eval_property P_ ((Lisp_Object)); 357extern Lisp_Object menu_item_eval_property P_ ((Lisp_Object));
357extern int kbd_buffer_events_waiting P_ ((int)); 358extern int kbd_buffer_events_waiting P_ ((int));
358 359
359extern int tty_read_avail_input P_ ((struct device *, int, 360extern int tty_read_avail_input P_ ((struct terminal *, int,
360 struct input_event *)); 361 struct input_event *));
361 362
362/* arch-tag: 769cbade-1ba9-4950-b886-db265b061aa3 363/* arch-tag: 769cbade-1ba9-4950-b886-db265b061aa3
diff --git a/src/lisp.h b/src/lisp.h
index 0aa2d7cb510..f04d29808d1 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3064,7 +3064,7 @@ EXFUN (Fcall_process, MANY);
3064extern int child_setup P_ ((int, int, int, char **, int, Lisp_Object)); 3064extern int child_setup P_ ((int, int, int, char **, int, Lisp_Object));
3065extern void init_callproc_1 P_ ((void)); 3065extern void init_callproc_1 P_ ((void));
3066extern void init_callproc P_ ((void)); 3066extern void init_callproc P_ ((void));
3067extern void set_process_environment P_ ((void)); 3067extern void set_global_environment P_ ((void));
3068extern void syms_of_callproc P_ ((void)); 3068extern void syms_of_callproc P_ ((void));
3069 3069
3070/* defined in doc.c */ 3070/* defined in doc.c */
@@ -3130,7 +3130,7 @@ extern void syms_of_xmenu P_ ((void));
3130struct tty_display_info; 3130struct tty_display_info;
3131 3131
3132/* defined in termhooks.h */ 3132/* defined in termhooks.h */
3133struct device; 3133struct terminal;
3134 3134
3135/* defined in sysdep.c */ 3135/* defined in sysdep.c */
3136#ifndef HAVE_GET_CURRENT_DIR_NAME 3136#ifndef HAVE_GET_CURRENT_DIR_NAME
diff --git a/src/minibuf.c b/src/minibuf.c
index 4025226574d..795acb1988c 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -552,7 +552,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
552 if (minibuffer_auto_raise) 552 if (minibuffer_auto_raise)
553 Fraise_frame (mini_frame); 553 Fraise_frame (mini_frame);
554 554
555 temporarily_switch_to_single_kboard (XFRAME (mini_frame)->device->kboard); 555 temporarily_switch_to_single_kboard (XFRAME (mini_frame)->terminal->kboard);
556 556
557 /* We have to do this after saving the window configuration 557 /* We have to do this after saving the window configuration
558 since that is what restores the current buffer. */ 558 since that is what restores the current buffer. */
diff --git a/src/sysdep.c b/src/sysdep.c
index 7f9d189d79a..956323f3a3b 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1782,7 +1782,7 @@ nil means don't delete them until `list-processes' is run. */);
1782 setbuf (tty_out->output, (char *) _sobuf); 1782 setbuf (tty_out->output, (char *) _sobuf);
1783#endif 1783#endif
1784 1784
1785 tty_set_terminal_modes (tty_out->device); 1785 tty_set_terminal_modes (tty_out->terminal);
1786 1786
1787 if (!tty_out->term_initted) 1787 if (!tty_out->term_initted)
1788 { 1788 {
@@ -1994,7 +1994,7 @@ reset_sys_modes (tty_out)
1994 } 1994 }
1995#endif 1995#endif
1996 1996
1997 tty_reset_terminal_modes (tty_out->device); 1997 tty_reset_terminal_modes (tty_out->terminal);
1998 1998
1999#ifdef BSD_SYSTEM 1999#ifdef BSD_SYSTEM
2000#ifndef BSD4_1 2000#ifndef BSD4_1
diff --git a/src/term.c b/src/term.c
index b599e1b97fe..49356348545 100644
--- a/src/term.c
+++ b/src/term.c
@@ -87,7 +87,7 @@ static void tty_show_cursor P_ ((struct tty_display_info *));
87static void tty_hide_cursor P_ ((struct tty_display_info *)); 87static void tty_hide_cursor P_ ((struct tty_display_info *));
88static void tty_background_highlight P_ ((struct tty_display_info *tty)); 88static void tty_background_highlight P_ ((struct tty_display_info *tty));
89static void dissociate_if_controlling_tty P_ ((int fd)); 89static void dissociate_if_controlling_tty P_ ((int fd));
90static void delete_tty P_ ((struct device *)); 90static void delete_tty P_ ((struct terminal *));
91 91
92#define OUTPUT(tty, a) \ 92#define OUTPUT(tty, a) \
93 emacs_tputs ((tty), a, \ 93 emacs_tputs ((tty), a, \
@@ -198,9 +198,9 @@ tty_ring_bell (struct frame *f)
198/* Set up termcap modes for Emacs. */ 198/* Set up termcap modes for Emacs. */
199 199
200void 200void
201tty_set_terminal_modes (struct device *display) 201tty_set_terminal_modes (struct terminal *terminal)
202{ 202{
203 struct tty_display_info *tty = display->display_info.tty; 203 struct tty_display_info *tty = terminal->display_info.tty;
204 204
205 if (tty->output) 205 if (tty->output)
206 { 206 {
@@ -227,9 +227,9 @@ tty_set_terminal_modes (struct device *display)
227/* Reset termcap modes before exiting Emacs. */ 227/* Reset termcap modes before exiting Emacs. */
228 228
229void 229void
230tty_reset_terminal_modes (struct device *display) 230tty_reset_terminal_modes (struct terminal *terminal)
231{ 231{
232 struct tty_display_info *tty = display->display_info.tty; 232 struct tty_display_info *tty = terminal->display_info.tty;
233 233
234 if (tty->output) 234 if (tty->output)
235 { 235 {
@@ -246,7 +246,7 @@ tty_reset_terminal_modes (struct device *display)
246 } 246 }
247} 247}
248 248
249/* Flag the end of a display update on a termcap display. */ 249/* Flag the end of a display update on a termcap terminal. */
250 250
251static void 251static void
252tty_update_end (struct frame *f) 252tty_update_end (struct frame *f)
@@ -1809,30 +1809,37 @@ tty_capable_p (tty, caps, fg, bg)
1809 1809
1810DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p, 1810DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
1811 0, 1, 0, 1811 0, 1, 0,
1812 doc: /* Return non-nil if the display device DEVICE can display colors. 1812 doc: /* Return non-nil if the tty device TERMINAL can display colors.
1813DEVICE must be a tty device. */) 1813
1814 (device) 1814TERMINAL can be a terminal id, a frame or nil (meaning the selected
1815 Lisp_Object device; 1815frame's terminal). This function always returns nil if TERMINAL
1816is not on a tty device. */)
1817 (terminal)
1818 Lisp_Object terminal;
1816{ 1819{
1817 struct device *d = get_tty_device (device); 1820 struct terminal *t = get_tty_terminal (terminal);
1818 if (!d) 1821 if (!t)
1819 return Qnil; 1822 return Qnil;
1820 else 1823 else
1821 return d->display_info.tty->TN_max_colors > 0 ? Qt : Qnil; 1824 return t->display_info.tty->TN_max_colors > 0 ? Qt : Qnil;
1822} 1825}
1823 1826
1824/* Return the number of supported colors. */ 1827/* Return the number of supported colors. */
1825DEFUN ("tty-display-color-cells", Ftty_display_color_cells, 1828DEFUN ("tty-display-color-cells", Ftty_display_color_cells,
1826 Stty_display_color_cells, 0, 1, 0, 1829 Stty_display_color_cells, 0, 1, 0,
1827 doc: /* Return the number of colors supported by the tty device DEVICE. */) 1830 doc: /* Return the number of colors supported by the tty device TERMINAL.
1828 (device) 1831
1829 Lisp_Object device; 1832TERMINAL can be a terminal id, a frame or nil (meaning the selected
1833frame's terminal). This function always returns nil if TERMINAL
1834is not on a tty device. */)
1835 (terminal)
1836 Lisp_Object terminal;
1830{ 1837{
1831 struct device *d = get_tty_device (device); 1838 struct terminal *t = get_tty_terminal (terminal);
1832 if (!d) 1839 if (!t)
1833 return make_number (0); 1840 return make_number (0);
1834 else 1841 else
1835 return make_number (d->display_info.tty->TN_max_colors); 1842 return make_number (t->display_info.tty->TN_max_colors);
1836} 1843}
1837 1844
1838#ifndef WINDOWSNT 1845#ifndef WINDOWSNT
@@ -1974,20 +1981,20 @@ set_tty_color_mode (f, val)
1974 1981
1975 1982
1976 1983
1977/* Return the tty display object specified by DEVICE. */ 1984/* Return the tty display object specified by TERMINAL. */
1978 1985
1979struct device * 1986struct terminal *
1980get_tty_device (Lisp_Object terminal) 1987get_tty_terminal (Lisp_Object terminal)
1981{ 1988{
1982 struct device *d = get_device (terminal, 0); 1989 struct terminal *t = get_terminal (terminal, 0);
1983 1990
1984 if (d && d->type == output_initial) 1991 if (t && t->type == output_initial)
1985 d = NULL; 1992 t = NULL;
1986 1993
1987 if (d && d->type != output_termcap) 1994 if (t && t->type != output_termcap)
1988 error ("Device %d is not a termcap display device", d->id); 1995 error ("Device %d is not a termcap terminal device", t->id);
1989 1996
1990 return d; 1997 return t;
1991} 1998}
1992 1999
1993/* Return the active termcap device that uses the tty device with the 2000/* Return the active termcap device that uses the tty device with the
@@ -1998,75 +2005,77 @@ get_tty_device (Lisp_Object terminal)
1998 2005
1999 Returns NULL if the named terminal device is not opened. */ 2006 Returns NULL if the named terminal device is not opened. */
2000 2007
2001struct device * 2008struct terminal *
2002get_named_tty (name) 2009get_named_tty (name)
2003 char *name; 2010 char *name;
2004{ 2011{
2005 struct device *d; 2012 struct terminal *t;
2006 2013
2007 for (d = device_list; d; d = d->next_device) { 2014 for (t = terminal_list; t; t = t->next_terminal) {
2008 if (d->type == output_termcap 2015 if (t->type == output_termcap
2009 && ((d->display_info.tty->name == 0 && name == 0) 2016 && ((t->display_info.tty->name == 0 && name == 0)
2010 || (name && d->display_info.tty->name 2017 || (name && t->display_info.tty->name
2011 && !strcmp (d->display_info.tty->name, name))) 2018 && !strcmp (t->display_info.tty->name, name)))
2012 && DEVICE_ACTIVE_P (d)) 2019 && TERMINAL_ACTIVE_P (t))
2013 return d; 2020 return t;
2014 }; 2021 };
2015 2022
2016 return 0; 2023 return 0;
2017} 2024}
2018 2025
2019 2026
2020DEFUN ("display-tty-type", Fdisplay_tty_type, Sdisplay_tty_type, 0, 1, 0, 2027DEFUN ("tty-type", Ftty_type, Stty_type, 0, 1, 0,
2021 doc: /* Return the type of the tty device that DEVICE uses. 2028 doc: /* Return the type of the tty device that TERMINAL uses.
2022 2029
2023DEVICE may be a display device id, a frame, or nil (meaning the 2030TERMINAL can be a terminal id, a frame or nil (meaning the selected
2024selected frame's display device). */) 2031frame's terminal). */)
2025 (device) 2032 (terminal)
2026 Lisp_Object device; 2033 Lisp_Object terminal;
2027{ 2034{
2028 struct device *d = get_device (device, 1); 2035 struct terminal *t = get_terminal (terminal, 1);
2029 2036
2030 if (d->type != output_termcap) 2037 if (t->type != output_termcap)
2031 error ("Display %d is not a termcap display", d->id); 2038 error ("Terminal %d is not a termcap terminal", t->id);
2032 2039
2033 if (d->display_info.tty->type) 2040 if (t->display_info.tty->type)
2034 return build_string (d->display_info.tty->type); 2041 return build_string (t->display_info.tty->type);
2035 else 2042 else
2036 return Qnil; 2043 return Qnil;
2037} 2044}
2038 2045
2039DEFUN ("display-controlling-tty-p", Fdisplay_controlling_tty_p, Sdisplay_controlling_tty_p, 0, 1, 0, 2046DEFUN ("controlling-tty-p", Fcontrolling_tty_p, Scontrolling_tty_p, 0, 1, 0,
2040 doc: /* Return non-nil if DEVICE is on the controlling tty of the Emacs process. 2047 doc: /* Return non-nil if TERMINAL is on the controlling tty of the Emacs process.
2041 2048
2042DEVICE may be a display device id, a frame, or nil (meaning the 2049TERMINAL can be a terminal id, a frame or nil (meaning the selected
2043selected frame's display device). */) 2050frame's terminal). This function always returns nil if TERMINAL
2044 (device) 2051is not on a tty device. */)
2045 Lisp_Object device; 2052 (terminal)
2053 Lisp_Object terminal;
2046{ 2054{
2047 struct device *d = get_device (device, 1); 2055 struct terminal *t = get_terminal (terminal, 1);
2048 2056
2049 if (d->type != output_termcap || d->display_info.tty->name) 2057 if (t->type != output_termcap || t->display_info.tty->name)
2050 return Qnil; 2058 return Qnil;
2051 else 2059 else
2052 return Qt; 2060 return Qt;
2053} 2061}
2054 2062
2055DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0, 2063DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0,
2056 doc: /* Declare that the tty used by DEVICE does not handle underlining. 2064 doc: /* Declare that the tty used by TERMINAL does not handle underlining.
2057This is used to override the terminfo data, for certain terminals that 2065This is used to override the terminfo data, for certain terminals that
2058do not really do underlining, but say that they do. This function has 2066do not really do underlining, but say that they do. This function has
2059no effect if used on a non-tty display. 2067no effect if used on a non-tty terminal.
2060 2068
2061DEVICE may be a display device id, a frame, or nil (meaning the 2069TERMINAL can be a terminal id, a frame or nil (meaning the selected
2062selected frame's display device). */) 2070frame's terminal). This function always returns nil if TERMINAL
2063 (device) 2071is not on a tty device. */)
2064 Lisp_Object device; 2072 (terminal)
2073 Lisp_Object terminal;
2065{ 2074{
2066 struct device *d = get_device (device, 1); 2075 struct terminal *t = get_terminal (terminal, 1);
2067 2076
2068 if (d->type == output_termcap) 2077 if (t->type == output_termcap)
2069 d->display_info.tty->TS_enter_underline_mode = 0; 2078 t->display_info.tty->TS_enter_underline_mode = 0;
2070 return Qnil; 2079 return Qnil;
2071} 2080}
2072 2081
@@ -2094,36 +2103,36 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
2094 (tty) 2103 (tty)
2095 Lisp_Object tty; 2104 Lisp_Object tty;
2096{ 2105{
2097 struct device *d = get_tty_device (tty); 2106 struct terminal *t = get_tty_terminal (tty);
2098 FILE *f; 2107 FILE *f;
2099 2108
2100 if (!d) 2109 if (!t)
2101 error ("Unknown tty device"); 2110 error ("Unknown tty device");
2102 2111
2103 f = d->display_info.tty->input; 2112 f = t->display_info.tty->input;
2104 2113
2105 if (f) 2114 if (f)
2106 { 2115 {
2107 reset_sys_modes (d->display_info.tty); 2116 reset_sys_modes (t->display_info.tty);
2108 2117
2109 delete_keyboard_wait_descriptor (fileno (f)); 2118 delete_keyboard_wait_descriptor (fileno (f));
2110 2119
2111 fclose (f); 2120 fclose (f);
2112 if (f != d->display_info.tty->output) 2121 if (f != t->display_info.tty->output)
2113 fclose (d->display_info.tty->output); 2122 fclose (t->display_info.tty->output);
2114 2123
2115 d->display_info.tty->input = 0; 2124 t->display_info.tty->input = 0;
2116 d->display_info.tty->output = 0; 2125 t->display_info.tty->output = 0;
2117 2126
2118 if (FRAMEP (d->display_info.tty->top_frame)) 2127 if (FRAMEP (t->display_info.tty->top_frame))
2119 FRAME_SET_VISIBLE (XFRAME (d->display_info.tty->top_frame), 0); 2128 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0);
2120 2129
2121 /* Run `suspend-tty-functions'. */ 2130 /* Run `suspend-tty-functions'. */
2122 if (!NILP (Vrun_hooks)) 2131 if (!NILP (Vrun_hooks))
2123 { 2132 {
2124 Lisp_Object args[2]; 2133 Lisp_Object args[2];
2125 args[0] = intern ("suspend-tty-functions"); 2134 args[0] = intern ("suspend-tty-functions");
2126 args[1] = make_number (d->id); 2135 args[1] = make_number (t->id);
2127 Frun_hook_with_args (2, args); 2136 Frun_hook_with_args (2, args);
2128 } 2137 }
2129 } 2138 }
@@ -2134,56 +2143,56 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
2134DEFUN ("resume-tty", Fresume_tty, Sresume_tty, 0, 1, 0, 2143DEFUN ("resume-tty", Fresume_tty, Sresume_tty, 0, 1, 0,
2135 doc: /* Resume the previously suspended terminal device TTY. 2144 doc: /* Resume the previously suspended terminal device TTY.
2136The terminal is opened and reinitialized. Frames that are on the 2145The terminal is opened and reinitialized. Frames that are on the
2137suspended display are revived. 2146suspended terminal are revived.
2138 2147
2139It is an error to resume a display while another display is active on 2148It is an error to resume a terminal while another terminal is active
2140the same device. 2149on the same device.
2141 2150
2142This function runs `resume-tty-functions' after resuming the device. 2151This function runs `resume-tty-functions' after resuming the terminal.
2143The functions are run with one arg, the id of the resumed display 2152The functions are run with one arg, the id of the resumed terminal
2144device. 2153device.
2145 2154
2146`resume-tty' does nothing if it is called on a device that is not 2155`resume-tty' does nothing if it is called on a device that is not
2147suspended. 2156suspended.
2148 2157
2149TTY may be a display device id, a frame, or nil for the display device 2158TTY may be a terminal id, a frame, or nil for the terminal device of
2150of the currently selected frame. */) 2159the currently selected frame. */)
2151 (tty) 2160 (tty)
2152 Lisp_Object tty; 2161 Lisp_Object tty;
2153{ 2162{
2154 struct device *d = get_tty_device (tty); 2163 struct terminal *t = get_tty_terminal (tty);
2155 int fd; 2164 int fd;
2156 2165
2157 if (!d) 2166 if (!t)
2158 error ("Unknown tty device"); 2167 error ("Unknown tty device");
2159 2168
2160 if (!d->display_info.tty->input) 2169 if (!t->display_info.tty->input)
2161 { 2170 {
2162 if (get_named_tty (d->display_info.tty->name)) 2171 if (get_named_tty (t->display_info.tty->name))
2163 error ("Cannot resume display while another display is active on the same device"); 2172 error ("Cannot resume display while another display is active on the same device");
2164 2173
2165 fd = emacs_open (d->display_info.tty->name, O_RDWR | O_NOCTTY, 0); 2174 fd = emacs_open (t->display_info.tty->name, O_RDWR | O_NOCTTY, 0);
2166 2175
2167 /* XXX What if open fails? */ 2176 /* XXX What if open fails? */
2168 2177
2169 dissociate_if_controlling_tty (fd); 2178 dissociate_if_controlling_tty (fd);
2170 2179
2171 d->display_info.tty->output = fdopen (fd, "w+"); 2180 t->display_info.tty->output = fdopen (fd, "w+");
2172 d->display_info.tty->input = d->display_info.tty->output; 2181 t->display_info.tty->input = t->display_info.tty->output;
2173 2182
2174 add_keyboard_wait_descriptor (fd); 2183 add_keyboard_wait_descriptor (fd);
2175 2184
2176 if (FRAMEP (d->display_info.tty->top_frame)) 2185 if (FRAMEP (t->display_info.tty->top_frame))
2177 FRAME_SET_VISIBLE (XFRAME (d->display_info.tty->top_frame), 1); 2186 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
2178 2187
2179 init_sys_modes (d->display_info.tty); 2188 init_sys_modes (t->display_info.tty);
2180 2189
2181 /* Run `suspend-tty-functions'. */ 2190 /* Run `suspend-tty-functions'. */
2182 if (!NILP (Vrun_hooks)) 2191 if (!NILP (Vrun_hooks))
2183 { 2192 {
2184 Lisp_Object args[2]; 2193 Lisp_Object args[2];
2185 args[0] = intern ("resume-tty-functions"); 2194 args[0] = intern ("resume-tty-functions");
2186 args[1] = make_number (d->id); 2195 args[1] = make_number (t->id);
2187 Frun_hook_with_args (2, args); 2196 Frun_hook_with_args (2, args);
2188 } 2197 }
2189 } 2198 }
@@ -2210,7 +2219,7 @@ create_tty_output (struct frame *f)
2210 t = xmalloc (sizeof (struct tty_output)); 2219 t = xmalloc (sizeof (struct tty_output));
2211 bzero (t, sizeof (struct tty_output)); 2220 bzero (t, sizeof (struct tty_output));
2212 2221
2213 t->display_info = FRAME_DEVICE (f)->display_info.tty; 2222 t->display_info = FRAME_TERMINAL (f)->display_info.tty;
2214 2223
2215 f->output_data.tty = t; 2224 f->output_data.tty = t;
2216} 2225}
@@ -2271,7 +2280,7 @@ static void maybe_fatal();
2271 2280
2272 If MUST_SUCCEED is true, then all errors are fatal. */ 2281 If MUST_SUCCEED is true, then all errors are fatal. */
2273 2282
2274struct device * 2283struct terminal *
2275init_tty (char *name, char *terminal_type, int must_succeed) 2284init_tty (char *name, char *terminal_type, int must_succeed)
2276{ 2285{
2277 char *area; 2286 char *area;
@@ -2281,72 +2290,72 @@ init_tty (char *name, char *terminal_type, int must_succeed)
2281 register char *p; 2290 register char *p;
2282 int status; 2291 int status;
2283 struct tty_display_info *tty; 2292 struct tty_display_info *tty;
2284 struct device *device; 2293 struct terminal *terminal;
2285 2294
2286 if (!terminal_type) 2295 if (!terminal_type)
2287 maybe_fatal (must_succeed, 0, 0, 2296 maybe_fatal (must_succeed, 0, 0,
2288 "Unknown terminal type", 2297 "Unknown terminal type",
2289 "Unknown terminal type"); 2298 "Unknown terminal type");
2290 2299
2291 /* If we already have a display on the given device, use that. If 2300 /* If we already have a terminal on the given device, use that. If
2292 all such displays are suspended, create a new one instead. */ 2301 all such terminals are suspended, create a new one instead. */
2293 /* XXX Perhaps this should be made explicit by having init_tty 2302 /* XXX Perhaps this should be made explicit by having init_tty
2294 always create a new display and separating device and frame 2303 always create a new terminal and separating terminal and frame
2295 creation on Lisp level. */ 2304 creation on Lisp level. */
2296 device = get_named_tty (name); 2305 terminal = get_named_tty (name);
2297 if (device) 2306 if (terminal)
2298 return device; 2307 return terminal;
2299 2308
2300 device = create_device (); 2309 terminal = create_terminal ();
2301 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); 2310 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
2302 bzero (tty, sizeof (struct tty_display_info)); 2311 bzero (tty, sizeof (struct tty_display_info));
2303 tty->next = tty_list; 2312 tty->next = tty_list;
2304 tty_list = tty; 2313 tty_list = tty;
2305 2314
2306 device->type = output_termcap; 2315 terminal->type = output_termcap;
2307 device->display_info.tty = tty; 2316 terminal->display_info.tty = tty;
2308 tty->device = device; 2317 tty->terminal = terminal;
2309 2318
2310 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); 2319 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
2311 Wcm_clear (tty); 2320 Wcm_clear (tty);
2312 2321
2313 device->rif = 0; /* ttys don't support window-based redisplay. */ 2322 terminal->rif = 0; /* ttys don't support window-based redisplay. */
2314 2323
2315 device->cursor_to_hook = &tty_cursor_to; 2324 terminal->cursor_to_hook = &tty_cursor_to;
2316 device->raw_cursor_to_hook = &tty_raw_cursor_to; 2325 terminal->raw_cursor_to_hook = &tty_raw_cursor_to;
2317 2326
2318 device->clear_to_end_hook = &tty_clear_to_end; 2327 terminal->clear_to_end_hook = &tty_clear_to_end;
2319 device->clear_frame_hook = &tty_clear_frame; 2328 terminal->clear_frame_hook = &tty_clear_frame;
2320 device->clear_end_of_line_hook = &tty_clear_end_of_line; 2329 terminal->clear_end_of_line_hook = &tty_clear_end_of_line;
2321 2330
2322 device->ins_del_lines_hook = &tty_ins_del_lines; 2331 terminal->ins_del_lines_hook = &tty_ins_del_lines;
2323 2332
2324 device->insert_glyphs_hook = &tty_insert_glyphs; 2333 terminal->insert_glyphs_hook = &tty_insert_glyphs;
2325 device->write_glyphs_hook = &tty_write_glyphs; 2334 terminal->write_glyphs_hook = &tty_write_glyphs;
2326 device->delete_glyphs_hook = &tty_delete_glyphs; 2335 terminal->delete_glyphs_hook = &tty_delete_glyphs;
2327 2336
2328 device->ring_bell_hook = &tty_ring_bell; 2337 terminal->ring_bell_hook = &tty_ring_bell;
2329 2338
2330 device->reset_terminal_modes_hook = &tty_reset_terminal_modes; 2339 terminal->reset_terminal_modes_hook = &tty_reset_terminal_modes;
2331 device->set_terminal_modes_hook = &tty_set_terminal_modes; 2340 terminal->set_terminal_modes_hook = &tty_set_terminal_modes;
2332 device->update_begin_hook = 0; /* Not needed. */ 2341 terminal->update_begin_hook = 0; /* Not needed. */
2333 device->update_end_hook = &tty_update_end; 2342 terminal->update_end_hook = &tty_update_end;
2334 device->set_terminal_window_hook = &tty_set_terminal_window; 2343 terminal->set_terminal_window_hook = &tty_set_terminal_window;
2335 2344
2336 device->mouse_position_hook = 0; /* Not needed. */ 2345 terminal->mouse_position_hook = 0; /* Not needed. */
2337 device->frame_rehighlight_hook = 0; /* Not needed. */ 2346 terminal->frame_rehighlight_hook = 0; /* Not needed. */
2338 device->frame_raise_lower_hook = 0; /* Not needed. */ 2347 terminal->frame_raise_lower_hook = 0; /* Not needed. */
2339 2348
2340 device->set_vertical_scroll_bar_hook = 0; /* Not needed. */ 2349 terminal->set_vertical_scroll_bar_hook = 0; /* Not needed. */
2341 device->condemn_scroll_bars_hook = 0; /* Not needed. */ 2350 terminal->condemn_scroll_bars_hook = 0; /* Not needed. */
2342 device->redeem_scroll_bar_hook = 0; /* Not needed. */ 2351 terminal->redeem_scroll_bar_hook = 0; /* Not needed. */
2343 device->judge_scroll_bars_hook = 0; /* Not needed. */ 2352 terminal->judge_scroll_bars_hook = 0; /* Not needed. */
2344 2353
2345 device->read_socket_hook = &tty_read_avail_input; /* keyboard.c */ 2354 terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
2346 device->frame_up_to_date_hook = 0; /* Not needed. */ 2355 terminal->frame_up_to_date_hook = 0; /* Not needed. */
2347 2356
2348 device->delete_frame_hook = &delete_tty_output; 2357 terminal->delete_frame_hook = &delete_tty_output;
2349 device->delete_device_hook = &delete_tty; 2358 terminal->delete_terminal_hook = &delete_tty;
2350 2359
2351 if (name) 2360 if (name)
2352 { 2361 {
@@ -2370,7 +2379,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
2370 2379
2371 if (fd < 0) 2380 if (fd < 0)
2372 { 2381 {
2373 delete_tty (device); 2382 delete_tty (terminal);
2374 error ("Could not open file: %s", name); 2383 error ("Could not open file: %s", name);
2375 } 2384 }
2376 if (!isatty (fd)) 2385 if (!isatty (fd))
@@ -2383,7 +2392,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
2383 2392
2384 file = fdopen (fd, "w+"); 2393 file = fdopen (fd, "w+");
2385 tty->name = xstrdup (name); 2394 tty->name = xstrdup (name);
2386 device->name = xstrdup (name); 2395 terminal->name = xstrdup (name);
2387 tty->input = file; 2396 tty->input = file;
2388 tty->output = file; 2397 tty->output = file;
2389 } 2398 }
@@ -2396,7 +2405,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
2396 error ("There is no controlling terminal any more"); 2405 error ("There is no controlling terminal any more");
2397 } 2406 }
2398 tty->name = 0; 2407 tty->name = 0;
2399 device->name = xstrdup (ttyname (0)); 2408 terminal->name = xstrdup (ttyname (0));
2400 tty->input = stdin; 2409 tty->input = stdin;
2401 tty->output = stdout; 2410 tty->output = stdout;
2402 } 2411 }
@@ -2418,16 +2427,16 @@ init_tty (char *name, char *terminal_type, int must_succeed)
2418 FrameCols (tty) = FRAME_COLS (f); /* XXX */ 2427 FrameCols (tty) = FRAME_COLS (f); /* XXX */
2419 tty->specified_window = FRAME_LINES (f); /* XXX */ 2428 tty->specified_window = FRAME_LINES (f); /* XXX */
2420 2429
2421 tty->device->delete_in_insert_mode = 1; 2430 tty->terminal->delete_in_insert_mode = 1;
2422 2431
2423 UseTabs (tty) = 0; 2432 UseTabs (tty) = 0;
2424 device->scroll_region_ok = 0; 2433 terminal->scroll_region_ok = 0;
2425 2434
2426 /* Seems to insert lines when it's not supposed to, messing up the 2435 /* Seems to insert lines when it's not supposed to, messing up the
2427 device. In doing a trace, it didn't seem to be called much, so I 2436 display. In doing a trace, it didn't seem to be called much, so I
2428 don't think we're losing anything by turning it off. */ 2437 don't think we're losing anything by turning it off. */
2429 device->line_ins_del_ok = 0; 2438 terminal->line_ins_del_ok = 0;
2430 device->char_ins_del_ok = 1; 2439 terminal->char_ins_del_ok = 1;
2431 2440
2432 baud_rate = 19200; 2441 baud_rate = 19200;
2433 2442
@@ -2435,7 +2444,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
2435 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; /* XXX */ 2444 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; /* XXX */
2436 TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ 2445 TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
2437 2446
2438 return device; 2447 return terminal;
2439#else /* not WINDOWSNT */ 2448#else /* not WINDOWSNT */
2440 2449
2441 Wcm_clear (tty); 2450 Wcm_clear (tty);
@@ -2451,11 +2460,11 @@ init_tty (char *name, char *terminal_type, int must_succeed)
2451 if (status < 0) 2460 if (status < 0)
2452 { 2461 {
2453#ifdef TERMINFO 2462#ifdef TERMINFO
2454 maybe_fatal (must_succeed, buffer, device, 2463 maybe_fatal (must_succeed, buffer, terminal,
2455 "Cannot open terminfo database file", 2464 "Cannot open terminfo database file",
2456 "Cannot open terminfo database file"); 2465 "Cannot open terminfo database file");
2457#else 2466#else
2458 maybe_fatal (must_succeed, buffer, device, 2467 maybe_fatal (must_succeed, buffer, terminal,
2459 "Cannot open termcap database file", 2468 "Cannot open termcap database file",
2460 "Cannot open termcap database file"); 2469 "Cannot open termcap database file");
2461#endif 2470#endif
@@ -2463,7 +2472,7 @@ init_tty (char *name, char *terminal_type, int must_succeed)
2463 if (status == 0) 2472 if (status == 0)
2464 { 2473 {
2465#ifdef TERMINFO 2474#ifdef TERMINFO
2466 maybe_fatal (must_succeed, buffer, device, 2475 maybe_fatal (must_succeed, buffer, terminal,
2467 "Terminal type %s is not defined", 2476 "Terminal type %s is not defined",
2468 "Terminal type %s is not defined.\n\ 2477 "Terminal type %s is not defined.\n\
2469If that is not the actual type of terminal you have,\n\ 2478If that is not the actual type of terminal you have,\n\
@@ -2472,7 +2481,7 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
2472to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", 2481to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.",
2473 terminal_type); 2482 terminal_type);
2474#else 2483#else
2475 maybe_fatal (must_succeed, buffer, device, 2484 maybe_fatal (must_succeed, buffer, terminal,
2476 "Terminal type %s is not defined", 2485 "Terminal type %s is not defined",
2477 "Terminal type %s is not defined.\n\ 2486 "Terminal type %s is not defined.\n\
2478If that is not the actual type of terminal you have,\n\ 2487If that is not the actual type of terminal you have,\n\
@@ -2594,9 +2603,9 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2594 /* Since we make MagicWrap terminals look like AutoWrap, we need to have 2603 /* Since we make MagicWrap terminals look like AutoWrap, we need to have
2595 the former flag imply the latter. */ 2604 the former flag imply the latter. */
2596 AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am"); 2605 AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am");
2597 device->memory_below_frame = tgetflag ("db"); 2606 terminal->memory_below_frame = tgetflag ("db");
2598 tty->TF_hazeltine = tgetflag ("hz"); 2607 tty->TF_hazeltine = tgetflag ("hz");
2599 device->must_write_spaces = tgetflag ("in"); 2608 terminal->must_write_spaces = tgetflag ("in");
2600 tty->meta_key = tgetflag ("km") || tgetflag ("MT"); 2609 tty->meta_key = tgetflag ("km") || tgetflag ("MT");
2601 tty->TF_insmode_motion = tgetflag ("mi"); 2610 tty->TF_insmode_motion = tgetflag ("mi");
2602 tty->TF_standout_motion = tgetflag ("ms"); 2611 tty->TF_standout_motion = tgetflag ("ms");
@@ -2604,19 +2613,19 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2604 tty->TF_teleray = tgetflag ("xt"); 2613 tty->TF_teleray = tgetflag ("xt");
2605 2614
2606#ifdef MULTI_KBOARD 2615#ifdef MULTI_KBOARD
2607 device->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 2616 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
2608 init_kboard (device->kboard); 2617 init_kboard (terminal->kboard);
2609 device->kboard->next_kboard = all_kboards; 2618 terminal->kboard->next_kboard = all_kboards;
2610 all_kboards = device->kboard; 2619 all_kboards = terminal->kboard;
2611 device->kboard->reference_count++; 2620 terminal->kboard->reference_count++;
2612 /* Don't let the initial kboard remain current longer than necessary. 2621 /* Don't let the initial kboard remain current longer than necessary.
2613 That would cause problems if a file loaded on startup tries to 2622 That would cause problems if a file loaded on startup tries to
2614 prompt in the mini-buffer. */ 2623 prompt in the mini-buffer. */
2615 if (current_kboard == initial_kboard) 2624 if (current_kboard == initial_kboard)
2616 current_kboard = device->kboard; 2625 current_kboard = terminal->kboard;
2617#endif 2626#endif
2618 2627
2619 term_get_fkeys (address, device->kboard); 2628 term_get_fkeys (address, terminal->kboard);
2620 2629
2621 /* Get frame size from system, or else from termcap. */ 2630 /* Get frame size from system, or else from termcap. */
2622 { 2631 {
@@ -2632,13 +2641,13 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2632 FrameRows (tty) = tgetnum ("li"); 2641 FrameRows (tty) = tgetnum ("li");
2633 2642
2634 if (FrameRows (tty) < 3 || FrameCols (tty) < 3) 2643 if (FrameRows (tty) < 3 || FrameCols (tty) < 3)
2635 maybe_fatal (must_succeed, NULL, device, 2644 maybe_fatal (must_succeed, NULL, terminal,
2636 "Screen size %dx%d is too small" 2645 "Screen size %dx%d is too small"
2637 "Screen size %dx%d is too small", 2646 "Screen size %dx%d is too small",
2638 FrameCols (tty), FrameRows (tty)); 2647 FrameCols (tty), FrameRows (tty));
2639 2648
2640#if 0 /* This is not used anywhere. */ 2649#if 0 /* This is not used anywhere. */
2641 tty->device->min_padding_speed = tgetnum ("pb"); 2650 tty->terminal->min_padding_speed = tgetnum ("pb");
2642#endif 2651#endif
2643 2652
2644 TabWidth (tty) = tgetnum ("tw"); 2653 TabWidth (tty) = tgetnum ("tw");
@@ -2716,7 +2725,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2716 2725
2717 if (!strcmp (terminal_type, "supdup")) 2726 if (!strcmp (terminal_type, "supdup"))
2718 { 2727 {
2719 device->memory_below_frame = 1; 2728 terminal->memory_below_frame = 1;
2720 tty->Wcm->cm_losewrap = 1; 2729 tty->Wcm->cm_losewrap = 1;
2721 } 2730 }
2722 if (!strncmp (terminal_type, "c10", 3) 2731 if (!strncmp (terminal_type, "c10", 3)
@@ -2743,7 +2752,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2743 tty->TS_set_window = "\033v%C %C %C %C "; 2752 tty->TS_set_window = "\033v%C %C %C %C ";
2744 } 2753 }
2745 /* Termcap entry often fails to have :in: flag */ 2754 /* Termcap entry often fails to have :in: flag */
2746 device->must_write_spaces = 1; 2755 terminal->must_write_spaces = 1;
2747 /* :ti string typically fails to have \E^G! in it */ 2756 /* :ti string typically fails to have \E^G! in it */
2748 /* This limits scope of insert-char to one line. */ 2757 /* This limits scope of insert-char to one line. */
2749 strcpy (area, tty->TS_termcap_modes); 2758 strcpy (area, tty->TS_termcap_modes);
@@ -2765,7 +2774,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2765 2774
2766 if (Wcm_init (tty) == -1) /* can't do cursor motion */ 2775 if (Wcm_init (tty) == -1) /* can't do cursor motion */
2767 { 2776 {
2768 maybe_fatal (must_succeed, NULL, device, 2777 maybe_fatal (must_succeed, NULL, terminal,
2769 "Terminal type \"%s\" is not powerful enough to run Emacs", 2778 "Terminal type \"%s\" is not powerful enough to run Emacs",
2770#ifdef VMS 2779#ifdef VMS
2771 "Terminal type \"%s\" is not powerful enough to run Emacs.\n\ 2780 "Terminal type \"%s\" is not powerful enough to run Emacs.\n\
@@ -2794,7 +2803,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2794 } 2803 }
2795 2804
2796 if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) 2805 if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0)
2797 maybe_fatal (must_succeed, NULL, device, 2806 maybe_fatal (must_succeed, NULL, terminal,
2798 "Could not determine the frame size", 2807 "Could not determine the frame size",
2799 "Could not determine the frame size"); 2808 "Could not determine the frame size");
2800 2809
@@ -2808,30 +2817,30 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2808 2817
2809 UseTabs (tty) = tabs_safe_p (fileno (tty->input)) && TabWidth (tty) == 8; 2818 UseTabs (tty) = tabs_safe_p (fileno (tty->input)) && TabWidth (tty) == 8;
2810 2819
2811 device->scroll_region_ok 2820 terminal->scroll_region_ok
2812 = (tty->Wcm->cm_abs 2821 = (tty->Wcm->cm_abs
2813 && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1)); 2822 && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1));
2814 2823
2815 device->line_ins_del_ok 2824 terminal->line_ins_del_ok
2816 = (((tty->TS_ins_line || tty->TS_ins_multi_lines) 2825 = (((tty->TS_ins_line || tty->TS_ins_multi_lines)
2817 && (tty->TS_del_line || tty->TS_del_multi_lines)) 2826 && (tty->TS_del_line || tty->TS_del_multi_lines))
2818 || (device->scroll_region_ok 2827 || (terminal->scroll_region_ok
2819 && tty->TS_fwd_scroll && tty->TS_rev_scroll)); 2828 && tty->TS_fwd_scroll && tty->TS_rev_scroll));
2820 2829
2821 device->char_ins_del_ok 2830 terminal->char_ins_del_ok
2822 = ((tty->TS_ins_char || tty->TS_insert_mode 2831 = ((tty->TS_ins_char || tty->TS_insert_mode
2823 || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars) 2832 || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars)
2824 && (tty->TS_del_char || tty->TS_del_multi_chars)); 2833 && (tty->TS_del_char || tty->TS_del_multi_chars));
2825 2834
2826 device->fast_clear_end_of_line = tty->TS_clr_line != 0; 2835 terminal->fast_clear_end_of_line = tty->TS_clr_line != 0;
2827 2836
2828 init_baud_rate (fileno (tty->input)); 2837 init_baud_rate (fileno (tty->input));
2829 2838
2830#ifdef AIXHFT 2839#ifdef AIXHFT
2831 /* The HFT system on AIX doesn't optimize for scrolling, so it's 2840 /* The HFT system on AIX doesn't optimize for scrolling, so it's
2832 really ugly at times. */ 2841 really ugly at times. */
2833 device->line_ins_del_ok = 0; 2842 terminal->line_ins_del_ok = 0;
2834 device->char_ins_del_ok = 0; 2843 terminal->char_ins_del_ok = 0;
2835#endif 2844#endif
2836 2845
2837 /* Don't do this. I think termcap may still need the buffer. */ 2846 /* Don't do this. I think termcap may still need the buffer. */
@@ -2840,26 +2849,26 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2840 /* Init system terminal modes (RAW or CBREAK, etc.). */ 2849 /* Init system terminal modes (RAW or CBREAK, etc.). */
2841 init_sys_modes (tty); 2850 init_sys_modes (tty);
2842 2851
2843 return device; 2852 return terminal;
2844#endif /* not WINDOWSNT */ 2853#endif /* not WINDOWSNT */
2845} 2854}
2846 2855
2847/* Auxiliary error-handling function for init_tty. 2856/* Auxiliary error-handling function for init_tty.
2848 Free BUFFER and delete DEVICE, then call error or fatal 2857 Free BUFFER and delete TERMINAL, then call error or fatal
2849 with str1 or str2, respectively, according to MUST_SUCCEED. */ 2858 with str1 or str2, respectively, according to MUST_SUCCEED. */
2850 2859
2851static void 2860static void
2852maybe_fatal (must_succeed, buffer, device, str1, str2, arg1, arg2) 2861maybe_fatal (must_succeed, buffer, terminal, str1, str2, arg1, arg2)
2853 int must_succeed; 2862 int must_succeed;
2854 char *buffer; 2863 char *buffer;
2855 struct device *device; 2864 struct terminal *terminal;
2856 char *str1, *str2, *arg1, *arg2; 2865 char *str1, *str2, *arg1, *arg2;
2857{ 2866{
2858 if (buffer) 2867 if (buffer)
2859 xfree (buffer); 2868 xfree (buffer);
2860 2869
2861 if (device) 2870 if (terminal)
2862 delete_tty (device); 2871 delete_tty (terminal);
2863 2872
2864 if (must_succeed) 2873 if (must_succeed)
2865 fatal (str2, arg1, arg2); 2874 fatal (str2, arg1, arg2);
@@ -2886,38 +2895,38 @@ fatal (str, arg1, arg2)
2886static int deleting_tty = 0; 2895static int deleting_tty = 0;
2887 2896
2888 2897
2889/* Delete the given terminal device, closing all frames on it. */ 2898/* Delete the given tty terminal, closing all frames on it. */
2890 2899
2891static void 2900static void
2892delete_tty (struct device *device) 2901delete_tty (struct terminal *terminal)
2893{ 2902{
2894 struct tty_display_info *tty; 2903 struct tty_display_info *tty;
2895 Lisp_Object tail, frame; 2904 Lisp_Object tail, frame;
2896 char *tty_name; 2905 char *tty_name;
2897 int last_device; 2906 int last_terminal;
2898 2907
2899 if (deleting_tty) 2908 if (deleting_tty)
2900 /* We get a recursive call when we delete the last frame on this 2909 /* We get a recursive call when we delete the last frame on this
2901 device. */ 2910 terminal. */
2902 return; 2911 return;
2903 2912
2904 if (device->type != output_termcap) 2913 if (terminal->type != output_termcap)
2905 abort (); 2914 abort ();
2906 2915
2907 tty = device->display_info.tty; 2916 tty = terminal->display_info.tty;
2908 2917
2909 last_device = 1; 2918 last_terminal = 1;
2910 FOR_EACH_FRAME (tail, frame) 2919 FOR_EACH_FRAME (tail, frame)
2911 { 2920 {
2912 struct frame *f = XFRAME (frame); 2921 struct frame *f = XFRAME (frame);
2913 if (FRAME_LIVE_P (f) && (!FRAME_TERMCAP_P (f) || FRAME_TTY (f) != tty)) 2922 if (FRAME_LIVE_P (f) && (!FRAME_TERMCAP_P (f) || FRAME_TTY (f) != tty))
2914 { 2923 {
2915 last_device = 0; 2924 last_terminal = 0;
2916 break; 2925 break;
2917 } 2926 }
2918 } 2927 }
2919 if (last_device) 2928 if (last_terminal)
2920 error ("Attempt to delete the sole display device with live frames"); 2929 error ("Attempt to delete the sole terminal device with live frames");
2921 2930
2922 if (tty == tty_list) 2931 if (tty == tty_list)
2923 tty_list = tty->next; 2932 tty_list = tty->next;
@@ -2947,10 +2956,10 @@ delete_tty (struct device *device)
2947 } 2956 }
2948 2957
2949 /* reset_sys_modes needs a valid device, so this call needs to be 2958 /* reset_sys_modes needs a valid device, so this call needs to be
2950 before delete_device. */ 2959 before delete_terminal. */
2951 reset_sys_modes (tty); 2960 reset_sys_modes (tty);
2952 2961
2953 delete_device (device); 2962 delete_terminal (terminal);
2954 2963
2955 tty_name = tty->name; 2964 tty_name = tty->name;
2956 if (tty->type) 2965 if (tty->type)
@@ -3025,8 +3034,8 @@ See `resume-tty'. */);
3025 defsubr (&Stty_display_color_p); 3034 defsubr (&Stty_display_color_p);
3026 defsubr (&Stty_display_color_cells); 3035 defsubr (&Stty_display_color_cells);
3027 defsubr (&Stty_no_underline); 3036 defsubr (&Stty_no_underline);
3028 defsubr (&Sdisplay_tty_type); 3037 defsubr (&Stty_type);
3029 defsubr (&Sdisplay_controlling_tty_p); 3038 defsubr (&Scontrolling_tty_p);
3030 defsubr (&Ssuspend_tty); 3039 defsubr (&Ssuspend_tty);
3031 defsubr (&Sresume_tty); 3040 defsubr (&Sresume_tty);
3032} 3041}
diff --git a/src/termchar.h b/src/termchar.h
index 87072136317..f4b58f105b0 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -58,9 +58,9 @@ struct tty_display_info
58 58
59 int reference_count; /* Number of frames that are on this display. */ 59 int reference_count; /* Number of frames that are on this display. */
60 60
61 struct device *device; /* Points back to the generic display device 61 struct terminal *terminal; /* Points back to the generic terminal
62 structure. This is sometimes handy. */ 62 structure. This is sometimes handy. */
63 63
64 /* Info on cursor positioning. */ 64 /* Info on cursor positioning. */
65 struct cm *Wcm; 65 struct cm *Wcm;
66 66
@@ -194,7 +194,7 @@ extern struct tty_display_info *tty_list;
194 194
195#define FRAME_TTY(f) \ 195#define FRAME_TTY(f) \
196 ((f)->output_method == output_termcap \ 196 ((f)->output_method == output_termcap \
197 ? (f)->device->display_info.tty \ 197 ? (f)->terminal->display_info.tty \
198 : (abort(), (struct tty_display_info *) 0)) 198 : (abort(), (struct tty_display_info *) 0))
199 199
200#define CURTTY() FRAME_TTY (SELECTED_FRAME()) 200#define CURTTY() FRAME_TTY (SELECTED_FRAME())
diff --git a/src/termhooks.h b/src/termhooks.h
index c925a85b484..7045d6ee1e3 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -1,4 +1,4 @@
1/* Parameters and display hooks for output devices. 1/* Parameters and display hooks for terminal devices.
2 Copyright (C) 1985, 1986, 1993, 1994, 2002, 2003, 2004, 2 Copyright (C) 1985, 1986, 1993, 1994, 2002, 2003, 2004,
3 2005 Free Software Foundation, Inc. 3 2005 Free Software Foundation, Inc.
4 4
@@ -288,30 +288,30 @@ enum {
288#endif /* CONSP */ 288#endif /* CONSP */
289 289
290 290
291/* Device-local parameters. */ 291/* Terminal-local parameters. */
292struct device 292struct terminal
293{ 293{
294 /* Chain of all display devices. */ 294 /* Chain of all terminal devices. */
295 struct device *next_device; 295 struct terminal *next_terminal;
296 296
297 /* Unique id for this display device. */ 297 /* Unique id for this terminal device. */
298 int id; 298 int id;
299 299
300 /* The number of frames that are on this device. */ 300 /* The number of frames that are on this terminal. */
301 int reference_count; 301 int reference_count;
302 302
303 /* The type of the display device. */ 303 /* The type of the terminal device. */
304 enum output_method type; 304 enum output_method type;
305 305
306 /* The name of the display device. Do not use this to identify the device. */ 306 /* The name of the terminal device. Do not use this to identify the device. */
307 char *name; 307 char *name;
308 308
309#ifdef MULTI_KBOARD 309#ifdef MULTI_KBOARD
310 /* The device's keyboard object. */ 310 /* The terminal's keyboard object. */
311 struct kboard *kboard; 311 struct kboard *kboard;
312#endif 312#endif
313 313
314 /* Device-type dependent data shared amongst all frames on this display. */ 314 /* Device-type dependent data shared amongst all frames on this terminal. */
315 union display_info 315 union display_info
316 { 316 {
317 struct tty_display_info *tty; /* termchar.h */ 317 struct tty_display_info *tty; /* termchar.h */
@@ -381,8 +381,8 @@ struct device
381 381
382 void (*ring_bell_hook) P_ ((struct frame *f)); 382 void (*ring_bell_hook) P_ ((struct frame *f));
383 383
384 void (*reset_terminal_modes_hook) P_ ((struct device *)); 384 void (*reset_terminal_modes_hook) P_ ((struct terminal *));
385 void (*set_terminal_modes_hook) P_ ((struct device *)); 385 void (*set_terminal_modes_hook) P_ ((struct terminal *));
386 386
387 void (*update_begin_hook) P_ ((struct frame *)); 387 void (*update_begin_hook) P_ ((struct frame *));
388 void (*update_end_hook) P_ ((struct frame *)); 388 void (*update_end_hook) P_ ((struct frame *));
@@ -428,7 +428,7 @@ struct device
428 /* If we're displaying frames using a window system that can stack 428 /* If we're displaying frames using a window system that can stack
429 frames on top of each other, this hook allows you to bring a frame 429 frames on top of each other, this hook allows you to bring a frame
430 to the front, or bury it behind all the other windows. If this 430 to the front, or bury it behind all the other windows. If this
431 hook is zero, that means the device we're displaying on doesn't 431 hook is zero, that means the terminal we're displaying on doesn't
432 support overlapping frames, so there's no need to raise or lower 432 support overlapping frames, so there's no need to raise or lower
433 anything. 433 anything.
434 434
@@ -512,10 +512,10 @@ struct device
512 512
513 /* Called to read input events. 513 /* Called to read input events.
514 514
515 DEVICE indicates which display device to read from. Input events 515 TERMINAL indicates which terminal device to read from. Input
516 should be read into BUF, the size of which is given in SIZE. 516 events should be read into BUF, the size of which is given in
517 EXPECTED is non-zero if the caller suspects that new input is 517 SIZE. EXPECTED is non-zero if the caller suspects that new input
518 available. 518 is available.
519 519
520 A positive return value indicates that that many input events 520 A positive return value indicates that that many input events
521 where read into BUF. 521 where read into BUF.
@@ -525,11 +525,11 @@ struct device
525 525
526 XXX Please note that a non-zero value of EXPECTED only means that 526 XXX Please note that a non-zero value of EXPECTED only means that
527 there is available input on at least one of the currently opened 527 there is available input on at least one of the currently opened
528 display devices -- but not necessarily on this device. 528 terminal devices -- but not necessarily on this device.
529 Therefore, in most cases EXPECTED should be simply ignored. 529 Therefore, in most cases EXPECTED should be simply ignored.
530 530
531 XXX This documentation needs to be updated. */ 531 XXX This documentation needs to be updated. */
532 int (*read_socket_hook) P_ ((struct device *device, 532 int (*read_socket_hook) P_ ((struct terminal *terminal,
533 int expected, 533 int expected,
534 struct input_event *hold_quit)); 534 struct input_event *hold_quit));
535 535
@@ -538,43 +538,43 @@ struct device
538 538
539 539
540 /* Called to delete the device-specific portions of a frame that is 540 /* Called to delete the device-specific portions of a frame that is
541 on this display device. */ 541 on this terminal device. */
542 void (*delete_frame_hook) P_ ((struct frame *)); 542 void (*delete_frame_hook) P_ ((struct frame *));
543 543
544 /* Called after the last frame on this device is deleted, or when 544 /* Called after the last frame on this terminal is deleted, or when
545 the display device was closed (hangup). 545 the display device was closed (hangup).
546 546
547 If this is NULL, then the generic delete_device is called 547 If this is NULL, then the generic delete_terminal is called
548 instead. Otherwise the hook must call delete_device itself. 548 instead. Otherwise the hook must call delete_terminal itself.
549 549
550 The hook must check for and close any live frames that are still 550 The hook must check for and close any live frames that are still
551 on the device. Fdelete_frame ensures that there are no live 551 on the terminal. Fdelete_frame ensures that there are no live
552 frames on the device when it calls this hook, so infinite 552 frames on the terminal when it calls this hook, so infinite
553 recursion is prevented. */ 553 recursion is prevented. */
554 void (*delete_device_hook) P_ ((struct device *)); 554 void (*delete_terminal_hook) P_ ((struct terminal *));
555}; 555};
556 556
557 557
558/* Chain of all display devices currently in use. */ 558/* Chain of all terminal devices currently in use. */
559extern struct device *device_list; 559extern struct terminal *terminal_list;
560 560
561#define FRAME_MUST_WRITE_SPACES(f) ((f)->device->must_write_spaces) 561#define FRAME_MUST_WRITE_SPACES(f) ((f)->terminal->must_write_spaces)
562#define FRAME_FAST_CLEAR_END_OF_LINE(f) ((f)->device->fast_clear_end_of_line) 562#define FRAME_FAST_CLEAR_END_OF_LINE(f) ((f)->terminal->fast_clear_end_of_line)
563#define FRAME_LINE_INS_DEL_OK(f) ((f)->device->line_ins_del_ok) 563#define FRAME_LINE_INS_DEL_OK(f) ((f)->terminal->line_ins_del_ok)
564#define FRAME_CHAR_INS_DEL_OK(f) ((f)->device->char_ins_del_ok) 564#define FRAME_CHAR_INS_DEL_OK(f) ((f)->terminal->char_ins_del_ok)
565#define FRAME_SCROLL_REGION_OK(f) ((f)->device->scroll_region_ok) 565#define FRAME_SCROLL_REGION_OK(f) ((f)->terminal->scroll_region_ok)
566#define FRAME_SCROLL_REGION_COST(f) ((f)->device->scroll_region_cost) 566#define FRAME_SCROLL_REGION_COST(f) ((f)->terminal->scroll_region_cost)
567#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->device->memory_below_frame) 567#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->terminal->memory_below_frame)
568 568
569#define FRAME_TERMINAL_CODING(f) ((f)->device->terminal_coding) 569#define FRAME_TERMINAL_CODING(f) ((f)->terminal->terminal_coding)
570#define FRAME_KEYBOARD_CODING(f) ((f)->device->keyboard_coding) 570#define FRAME_KEYBOARD_CODING(f) ((f)->terminal->keyboard_coding)
571 571
572#define DEVICE_TERMINAL_CODING(d) ((d)->terminal_coding) 572#define TERMINAL_TERMINAL_CODING(d) ((d)->terminal_coding)
573#define DEVICE_KEYBOARD_CODING(d) ((d)->keyboard_coding) 573#define TERMINAL_KEYBOARD_CODING(d) ((d)->keyboard_coding)
574 574
575#define FRAME_RIF(f) ((f)->device->rif) 575#define FRAME_RIF(f) ((f)->terminal->rif)
576 576
577#define FRAME_DEVICE(f) ((f)->device) 577#define FRAME_TERMINAL(f) ((f)->terminal)
578 578
579/* FRAME_WINDOW_P tests whether the frame is a window, and is 579/* FRAME_WINDOW_P tests whether the frame is a window, and is
580 defined to be the predicate for the window system being used. */ 580 defined to be the predicate for the window system being used. */
@@ -592,16 +592,16 @@ extern struct device *device_list;
592#define FRAME_WINDOW_P(f) (0) 592#define FRAME_WINDOW_P(f) (0)
593#endif 593#endif
594 594
595/* Return true if the display device is not suspended. */ 595/* Return true if the terminal device is not suspended. */
596#define DEVICE_ACTIVE_P(d) ((d)->type != output_termcap || (d)->display_info.tty->input) 596#define TERMINAL_ACTIVE_P(d) ((d)->type != output_termcap || (d)->display_info.tty->input)
597 597
598extern Lisp_Object get_terminal_param P_ ((struct device *, Lisp_Object)); 598extern Lisp_Object get_terminal_param P_ ((struct terminal *, Lisp_Object));
599extern struct device *get_device P_ ((Lisp_Object display, int)); 599extern struct terminal *get_terminal P_ ((Lisp_Object terminal, int));
600extern struct device *create_device P_ ((void)); 600extern struct terminal *create_terminal P_ ((void));
601extern void delete_device P_ ((struct device *)); 601extern void delete_terminal P_ ((struct terminal *));
602 602
603/* The initial display device, created by initial_term_init. */ 603/* The initial terminal device, created by initial_term_init. */
604extern struct device *initial_device; 604extern struct terminal *initial_terminal;
605 605
606/* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d 606/* arch-tag: 33a00ecc-52b5-4186-a410-8801ac9f087d
607 (do not change this comment) */ 607 (do not change this comment) */
diff --git a/src/terminal.c b/src/terminal.c
index 83879a43afa..084318b893f 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -28,19 +28,19 @@ Boston, MA 02110-1301, USA. */
28#include "coding.h" 28#include "coding.h"
29#include "keyboard.h" 29#include "keyboard.h"
30 30
31/* Chain of all displays currently in use. */ 31/* Chain of all terminals currently in use. */
32struct device *device_list; 32struct terminal *terminal_list;
33 33
34/* The first unallocated display id. */ 34/* The first unallocated terminal id. */
35static int next_device_id; 35static int next_terminal_id;
36 36
37/* The initial display device, created by initial_term_init. */ 37/* The initial terminal device, created by initial_term_init. */
38struct device *initial_device; 38struct terminal *initial_terminal;
39 39
40/* Function to use to ring the bell. */ 40/* Function to use to ring the bell. */
41Lisp_Object Vring_bell_function; 41Lisp_Object Vring_bell_function;
42 42
43void delete_initial_device P_ ((struct device *)); 43static void delete_initial_terminal P_ ((struct terminal *));
44 44
45 45
46 46
@@ -66,22 +66,22 @@ ring_bell (struct frame *f)
66 66
67 Vring_bell_function = function; 67 Vring_bell_function = function;
68 } 68 }
69 else if (FRAME_DEVICE (f)->ring_bell_hook) 69 else if (FRAME_TERMINAL (f)->ring_bell_hook)
70 (*FRAME_DEVICE (f)->ring_bell_hook) (f); 70 (*FRAME_TERMINAL (f)->ring_bell_hook) (f);
71} 71}
72 72
73void 73void
74update_begin (struct frame *f) 74update_begin (struct frame *f)
75{ 75{
76 if (FRAME_DEVICE (f)->update_begin_hook) 76 if (FRAME_TERMINAL (f)->update_begin_hook)
77 (*FRAME_DEVICE (f)->update_begin_hook) (f); 77 (*FRAME_TERMINAL (f)->update_begin_hook) (f);
78} 78}
79 79
80void 80void
81update_end (struct frame *f) 81update_end (struct frame *f)
82{ 82{
83 if (FRAME_DEVICE (f)->update_end_hook) 83 if (FRAME_TERMINAL (f)->update_end_hook)
84 (*FRAME_DEVICE (f)->update_end_hook) (f); 84 (*FRAME_TERMINAL (f)->update_end_hook) (f);
85} 85}
86 86
87/* Specify how many text lines, from the top of the window, 87/* Specify how many text lines, from the top of the window,
@@ -92,8 +92,8 @@ update_end (struct frame *f)
92void 92void
93set_terminal_window (struct frame *f, int size) 93set_terminal_window (struct frame *f, int size)
94{ 94{
95 if (FRAME_DEVICE (f)->set_terminal_window_hook) 95 if (FRAME_TERMINAL (f)->set_terminal_window_hook)
96 (*FRAME_DEVICE (f)->set_terminal_window_hook) (f, size); 96 (*FRAME_TERMINAL (f)->set_terminal_window_hook) (f, size);
97} 97}
98 98
99/* Move cursor to row/column position VPOS/HPOS. HPOS/VPOS are 99/* Move cursor to row/column position VPOS/HPOS. HPOS/VPOS are
@@ -102,8 +102,8 @@ set_terminal_window (struct frame *f, int size)
102void 102void
103cursor_to (struct frame *f, int vpos, int hpos) 103cursor_to (struct frame *f, int vpos, int hpos)
104{ 104{
105 if (FRAME_DEVICE (f)->cursor_to_hook) 105 if (FRAME_TERMINAL (f)->cursor_to_hook)
106 (*FRAME_DEVICE (f)->cursor_to_hook) (f, vpos, hpos); 106 (*FRAME_TERMINAL (f)->cursor_to_hook) (f, vpos, hpos);
107} 107}
108 108
109/* Similar but don't take any account of the wasted characters. */ 109/* Similar but don't take any account of the wasted characters. */
@@ -111,8 +111,8 @@ cursor_to (struct frame *f, int vpos, int hpos)
111void 111void
112raw_cursor_to (struct frame *f, int row, int col) 112raw_cursor_to (struct frame *f, int row, int col)
113{ 113{
114 if (FRAME_DEVICE (f)->raw_cursor_to_hook) 114 if (FRAME_TERMINAL (f)->raw_cursor_to_hook)
115 (*FRAME_DEVICE (f)->raw_cursor_to_hook) (f, row, col); 115 (*FRAME_TERMINAL (f)->raw_cursor_to_hook) (f, row, col);
116} 116}
117 117
118/* Erase operations */ 118/* Erase operations */
@@ -121,8 +121,8 @@ raw_cursor_to (struct frame *f, int row, int col)
121void 121void
122clear_to_end (struct frame *f) 122clear_to_end (struct frame *f)
123{ 123{
124 if (FRAME_DEVICE (f)->clear_to_end_hook) 124 if (FRAME_TERMINAL (f)->clear_to_end_hook)
125 (*FRAME_DEVICE (f)->clear_to_end_hook) (f); 125 (*FRAME_TERMINAL (f)->clear_to_end_hook) (f);
126} 126}
127 127
128/* Clear entire frame */ 128/* Clear entire frame */
@@ -130,8 +130,8 @@ clear_to_end (struct frame *f)
130void 130void
131clear_frame (struct frame *f) 131clear_frame (struct frame *f)
132{ 132{
133 if (FRAME_DEVICE (f)->clear_frame_hook) 133 if (FRAME_TERMINAL (f)->clear_frame_hook)
134 (*FRAME_DEVICE (f)->clear_frame_hook) (f); 134 (*FRAME_TERMINAL (f)->clear_frame_hook) (f);
135} 135}
136 136
137/* Clear from cursor to end of line. 137/* Clear from cursor to end of line.
@@ -142,8 +142,8 @@ clear_frame (struct frame *f)
142void 142void
143clear_end_of_line (struct frame *f, int first_unused_hpos) 143clear_end_of_line (struct frame *f, int first_unused_hpos)
144{ 144{
145 if (FRAME_DEVICE (f)->clear_end_of_line_hook) 145 if (FRAME_TERMINAL (f)->clear_end_of_line_hook)
146 (*FRAME_DEVICE (f)->clear_end_of_line_hook) (f, first_unused_hpos); 146 (*FRAME_TERMINAL (f)->clear_end_of_line_hook) (f, first_unused_hpos);
147} 147}
148 148
149/* Output LEN glyphs starting at STRING at the nominal cursor position. 149/* Output LEN glyphs starting at STRING at the nominal cursor position.
@@ -152,8 +152,8 @@ clear_end_of_line (struct frame *f, int first_unused_hpos)
152void 152void
153write_glyphs (struct frame *f, struct glyph *string, int len) 153write_glyphs (struct frame *f, struct glyph *string, int len)
154{ 154{
155 if (FRAME_DEVICE (f)->write_glyphs_hook) 155 if (FRAME_TERMINAL (f)->write_glyphs_hook)
156 (*FRAME_DEVICE (f)->write_glyphs_hook) (f, string, len); 156 (*FRAME_TERMINAL (f)->write_glyphs_hook) (f, string, len);
157} 157}
158 158
159/* Insert LEN glyphs from START at the nominal cursor position. 159/* Insert LEN glyphs from START at the nominal cursor position.
@@ -166,8 +166,8 @@ insert_glyphs (struct frame *f, struct glyph *start, int len)
166 if (len <= 0) 166 if (len <= 0)
167 return; 167 return;
168 168
169 if (FRAME_DEVICE (f)->insert_glyphs_hook) 169 if (FRAME_TERMINAL (f)->insert_glyphs_hook)
170 (*FRAME_DEVICE (f)->insert_glyphs_hook) (f, start, len); 170 (*FRAME_TERMINAL (f)->insert_glyphs_hook) (f, start, len);
171} 171}
172 172
173/* Delete N glyphs at the nominal cursor position. */ 173/* Delete N glyphs at the nominal cursor position. */
@@ -175,8 +175,8 @@ insert_glyphs (struct frame *f, struct glyph *start, int len)
175void 175void
176delete_glyphs (struct frame *f, int n) 176delete_glyphs (struct frame *f, int n)
177{ 177{
178 if (FRAME_DEVICE (f)->delete_glyphs_hook) 178 if (FRAME_TERMINAL (f)->delete_glyphs_hook)
179 (*FRAME_DEVICE (f)->delete_glyphs_hook) (f, n); 179 (*FRAME_TERMINAL (f)->delete_glyphs_hook) (f, n);
180} 180}
181 181
182/* Insert N lines at vpos VPOS. If N is negative, delete -N lines. */ 182/* Insert N lines at vpos VPOS. If N is negative, delete -N lines. */
@@ -184,185 +184,209 @@ delete_glyphs (struct frame *f, int n)
184void 184void
185ins_del_lines (struct frame *f, int vpos, int n) 185ins_del_lines (struct frame *f, int vpos, int n)
186{ 186{
187 if (FRAME_DEVICE (f)->ins_del_lines_hook) 187 if (FRAME_TERMINAL (f)->ins_del_lines_hook)
188 (*FRAME_DEVICE (f)->ins_del_lines_hook) (f, vpos, n); 188 (*FRAME_TERMINAL (f)->ins_del_lines_hook) (f, vpos, n);
189} 189}
190 190
191 191
192 192
193 193
194/* Return the display object specified by DEVICE. DEVICE may be a 194/* Return the terminal object specified by TERMINAL. TERMINAL may be a
195 display id, a frame, or nil for the display device of the current 195 terminal id, a frame, or nil for the terminal device of the current
196 frame. If THROW is zero, return NULL for failure, otherwise throw 196 frame. If THROW is zero, return NULL for failure, otherwise throw
197 an error. */ 197 an error. */
198 198
199struct device * 199struct terminal *
200get_device (Lisp_Object device, int throw) 200get_terminal (Lisp_Object terminal, int throw)
201{ 201{
202 struct device *result = NULL; 202 struct terminal *result = NULL;
203 203
204 if (NILP (device)) 204 if (NILP (terminal))
205 device = selected_frame; 205 terminal = selected_frame;
206 206
207 if (INTEGERP (device)) 207 if (INTEGERP (terminal))
208 { 208 {
209 struct device *d; 209 struct terminal *t;
210 210
211 for (d = device_list; d; d = d->next_device) 211 for (t = terminal_list; t; t = t->next_terminal)
212 { 212 {
213 if (d->id == XINT (device)) 213 if (t->id == XINT (terminal))
214 { 214 {
215 result = d; 215 result = t;
216 break; 216 break;
217 } 217 }
218 } 218 }
219 } 219 }
220 else if (FRAMEP (device)) 220 else if (FRAMEP (terminal))
221 { 221 {
222 result = FRAME_DEVICE (XFRAME (device)); 222 result = FRAME_TERMINAL (XFRAME (terminal));
223 } 223 }
224 224
225 if (result == NULL && throw) 225 if (result == NULL && throw)
226 wrong_type_argument (Qdisplay_live_p, device); 226 wrong_type_argument (Qterminal_live_p, terminal);
227 227
228 return result; 228 return result;
229} 229}
230 230
231 231
232 232
233/* Create a new device object and add it to the device list. */ 233/* Create a new terminal object and add it to the terminal list. */
234 234
235struct device * 235struct terminal *
236create_device (void) 236create_terminal (void)
237{ 237{
238 struct device *device = (struct device *) xmalloc (sizeof (struct device)); 238 struct terminal *terminal = (struct terminal *) xmalloc (sizeof (struct terminal));
239 239
240 bzero (device, sizeof (struct device)); 240 bzero (terminal, sizeof (struct terminal));
241 device->next_device = device_list; 241 terminal->next_terminal = terminal_list;
242 device_list = device; 242 terminal_list = terminal;
243 243
244 device->id = next_device_id++; 244 terminal->id = next_terminal_id++;
245 245
246 device->keyboard_coding = 246 terminal->keyboard_coding =
247 (struct coding_system *) xmalloc (sizeof (struct coding_system)); 247 (struct coding_system *) xmalloc (sizeof (struct coding_system));
248 device->terminal_coding = 248 terminal->terminal_coding =
249 (struct coding_system *) xmalloc (sizeof (struct coding_system)); 249 (struct coding_system *) xmalloc (sizeof (struct coding_system));
250 250
251 setup_coding_system (Qnil, device->keyboard_coding); 251 setup_coding_system (Qnil, terminal->keyboard_coding);
252 setup_coding_system (Qnil, device->terminal_coding); 252 setup_coding_system (Qnil, terminal->terminal_coding);
253 253
254 device->param_alist = Qnil; 254 terminal->param_alist = Qnil;
255 return device; 255 return terminal;
256} 256}
257 257
258/* Mark the Lisp pointers in the terminal objects. 258/* Mark the Lisp pointers in the terminal objects.
259 Called by the Fgarbage_collector. */ 259 Called by the Fgarbage_collector. */
260 260
261void 261void
262mark_devices (void) 262mark_terminals (void)
263{ 263{
264 struct device *d; 264 struct terminal *t;
265 for (d = device_list; d; d = d->next_device) 265 for (t = terminal_list; t; t = t->next_terminal)
266 { 266 {
267 mark_object (d->param_alist); 267 mark_object (t->param_alist);
268 } 268 }
269} 269}
270 270
271 271
272/* Remove a device from the device list and free its memory. */ 272/* Remove a terminal from the terminal list and free its memory. */
273 273
274void 274void
275delete_device (struct device *device) 275delete_terminal (struct terminal *terminal)
276{ 276{
277 struct device **dp; 277 struct terminal **tp;
278 Lisp_Object tail, frame; 278 Lisp_Object tail, frame;
279 279
280 /* Check for and close live frames that are still on this 280 /* Check for and close live frames that are still on this
281 device. */ 281 terminal. */
282 FOR_EACH_FRAME (tail, frame) 282 FOR_EACH_FRAME (tail, frame)
283 { 283 {
284 struct frame *f = XFRAME (frame); 284 struct frame *f = XFRAME (frame);
285 if (FRAME_LIVE_P (f) && f->device == device) 285 if (FRAME_LIVE_P (f) && f->terminal == terminal)
286 { 286 {
287 Fdelete_frame (frame, Qt); 287 Fdelete_frame (frame, Qt);
288 } 288 }
289 } 289 }
290 290
291 for (dp = &device_list; *dp != device; dp = &(*dp)->next_device) 291 for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal)
292 if (! *dp) 292 if (! *tp)
293 abort (); 293 abort ();
294 *dp = device->next_device; 294 *tp = terminal->next_terminal;
295 295
296 if (device->keyboard_coding) 296 if (terminal->keyboard_coding)
297 xfree (device->keyboard_coding); 297 xfree (terminal->keyboard_coding);
298 if (device->terminal_coding) 298 if (terminal->terminal_coding)
299 xfree (device->terminal_coding); 299 xfree (terminal->terminal_coding);
300 if (device->name) 300 if (terminal->name)
301 xfree (device->name); 301 xfree (terminal->name);
302 302
303#ifdef MULTI_KBOARD 303#ifdef MULTI_KBOARD
304 if (device->kboard && --device->kboard->reference_count == 0) 304 if (terminal->kboard && --terminal->kboard->reference_count == 0)
305 delete_kboard (device->kboard); 305 delete_kboard (terminal->kboard);
306#endif 306#endif
307 307
308 bzero (device, sizeof (struct device)); 308 bzero (terminal, sizeof (struct terminal));
309 xfree (device); 309 xfree (terminal);
310} 310}
311 311
312DEFUN ("delete-display", Fdelete_display, Sdelete_display, 0, 2, 0, 312DEFUN ("delete-terminal", Fdelete_terminal, Sdelete_terminal, 0, 2, 0,
313 doc: /* Delete DEVICE by deleting all frames on it and closing the device. 313 doc: /* Delete TERMINAL by deleting all frames on it and closing the terminal.
314DEVICE may be a display device id, a frame, or nil (meaning the 314TERMINAL may be a terminal id, a frame, or nil (meaning the selected
315selected frame's display device). 315frame's terminal).
316 316
317Normally, you may not delete a display if all other displays are suspended, 317Normally, you may not delete a display if all other displays are suspended,
318but if the second argument FORCE is non-nil, you may do so. */) 318but if the second argument FORCE is non-nil, you may do so. */)
319 (device, force) 319 (terminal, force)
320 Lisp_Object device, force; 320 Lisp_Object terminal, force;
321{ 321{
322 struct device *d, *p; 322 struct terminal *t, *p;
323 323
324 d = get_device (device, 0); 324 t = get_terminal (terminal, 0);
325 325
326 if (!d) 326 if (!t)
327 return Qnil; 327 return Qnil;
328 328
329 p = device_list; 329 p = terminal_list;
330 while (p && (p == d || !DEVICE_ACTIVE_P (p))) 330 while (p && (p == t || !TERMINAL_ACTIVE_P (p)))
331 p = p->next_device; 331 p = p->next_terminal;
332 332
333 if (NILP (force) && !p) 333 if (NILP (force) && !p)
334 error ("Attempt to delete the sole active display device"); 334 error ("Attempt to delete the sole active display terminal");
335 335
336 if (d->delete_device_hook) 336 if (t->delete_terminal_hook)
337 (*d->delete_device_hook) (d); 337 (*t->delete_terminal_hook) (t);
338 else 338 else
339 delete_device (d); 339 delete_terminal (t);
340 340
341 return Qnil; 341 return Qnil;
342} 342}
343 343
344DEFUN ("display-live-p", Fdisplay_live_p, Sdisplay_live_p, 1, 1, 0, 344
345 doc: /* Return non-nil if OBJECT is a device which has not been deleted. 345DEFUN ("frame-terminal", Fframe_terminal, Sframe_terminal, 0, 1, 0,
346Value is nil if OBJECT is not a live display device. 346 doc: /* Return the terminal that FRAME is displayed on.
347If object is a live display device, the return value indicates what 347If FRAME is nil, the selected frame is used.
348sort of output device it uses. See the documentation of `framep' for 348
349The terminal device is represented by its integer identifier. */)
350 (frame)
351 Lisp_Object frame;
352{
353 struct terminal *t;
354
355 if (NILP (frame))
356 frame = selected_frame;
357
358 CHECK_LIVE_FRAME (frame);
359
360 t = get_terminal (frame, 0);
361
362 if (!t)
363 return Qnil;
364 else
365 return make_number (t->id);
366}
367
368DEFUN ("terminal-live-p", Fterminal_live_p, Sterminal_live_p, 1, 1, 0,
369 doc: /* Return non-nil if OBJECT is a terminal which has not been deleted.
370Value is nil if OBJECT is not a live display terminal.
371If object is a live display terminal, the return value indicates what
372sort of output terminal it uses. See the documentation of `framep' for
349possible return values. 373possible return values.
350 374
351Display devices are represented by their integer identifiers. */) 375Display terminals are represented by their integer identifiers. */)
352 (object) 376 (object)
353 Lisp_Object object; 377 Lisp_Object object;
354{ 378{
355 struct device *d; 379 struct terminal *t;
356 380
357 if (!INTEGERP (object)) 381 if (!INTEGERP (object))
358 return Qnil; 382 return Qnil;
359 383
360 d = get_device (object, 0); 384 t = get_terminal (object, 0);
361 385
362 if (!d) 386 if (!t)
363 return Qnil; 387 return Qnil;
364 388
365 switch (d->type) 389 switch (t->type)
366 { 390 {
367 case output_initial: /* The initial frame is like a termcap frame. */ 391 case output_initial: /* The initial frame is like a termcap frame. */
368 case output_termcap: 392 case output_termcap:
@@ -380,64 +404,64 @@ Display devices are represented by their integer identifiers. */)
380 } 404 }
381} 405}
382 406
383DEFUN ("display-list", Fdisplay_list, Sdisplay_list, 0, 0, 0, 407DEFUN ("terminal-list", Fterminal_list, Sterminal_list, 0, 0, 0,
384 doc: /* Return a list of all display devices. 408 doc: /* Return a list of all terminal devices.
385Display devices are represented by their integer identifiers. */) 409Terminal devices are represented by their integer identifiers. */)
386 () 410 ()
387{ 411{
388 Lisp_Object devices = Qnil; 412 Lisp_Object terminals = Qnil;
389 struct device *d; 413 struct terminal *t;
390 414
391 for (d = device_list; d; d = d->next_device) 415 for (t = terminal_list; t; t = t->next_terminal)
392 devices = Fcons (make_number (d->id), devices); 416 terminals = Fcons (make_number (t->id), terminals);
393 417
394 return devices; 418 return terminals;
395} 419}
396 420
397DEFUN ("display-name", Fdisplay_name, Sdisplay_name, 0, 1, 0, 421DEFUN ("terminal-name", Fterminal_name, Sterminal_name, 0, 1, 0,
398 doc: /* Return the name of the display device DEVICE. 422 doc: /* Return the name of the terminal device TERMINAL.
399It is not guaranteed that the returned value is unique among opened devices. 423It is not guaranteed that the returned value is unique among opened devices.
400 424
401DEVICE may be a display device id, a frame, or nil (meaning the 425TERMINAL may be a terminal id, a frame, or nil (meaning the
402selected frame's display device). */) 426selected frame's terminal). */)
403 (device) 427 (terminal)
404 Lisp_Object device; 428 Lisp_Object terminal;
405{ 429{
406 struct device *d = get_device (device, 1); 430 struct terminal *t = get_terminal (terminal, 1);
407 431
408 if (d->name) 432 if (t->name)
409 return build_string (d->name); 433 return build_string (t->name);
410 else 434 else
411 return Qnil; 435 return Qnil;
412} 436}
413 437
414 438
415 439
416/* Return the value of terminal parameter PARAM in device D. */ 440/* Return the value of terminal parameter PARAM in terminal T. */
417Lisp_Object 441Lisp_Object
418get_terminal_param (d, param) 442get_terminal_param (t, param)
419 struct device *d; 443 struct terminal *t;
420 Lisp_Object param; 444 Lisp_Object param;
421{ 445{
422 Lisp_Object tem = Fassq (param, d->param_alist); 446 Lisp_Object tem = Fassq (param, t->param_alist);
423 if (EQ (tem, Qnil)) 447 if (EQ (tem, Qnil))
424 return tem; 448 return tem;
425 return Fcdr (tem); 449 return Fcdr (tem);
426} 450}
427 451
428/* Set the value of terminal parameter PARAMETER in device D to VALUE. 452/* Set the value of terminal parameter PARAMETER in terminal D to VALUE.
429 Return the previous value. */ 453 Return the previous value. */
430 454
431Lisp_Object 455Lisp_Object
432store_terminal_param (d, parameter, value) 456store_terminal_param (t, parameter, value)
433 struct device *d; 457 struct terminal *t;
434 Lisp_Object parameter; 458 Lisp_Object parameter;
435 Lisp_Object value; 459 Lisp_Object value;
436{ 460{
437 Lisp_Object old_alist_elt = Fassq (parameter, d->param_alist); 461 Lisp_Object old_alist_elt = Fassq (parameter, t->param_alist);
438 if (EQ (old_alist_elt, Qnil)) 462 if (EQ (old_alist_elt, Qnil))
439 { 463 {
440 d->param_alist = Fcons (Fcons (parameter, value), d->param_alist); 464 t->param_alist = Fcons (Fcons (parameter, value), t->param_alist);
441 return Qnil; 465 return Qnil;
442 } 466 }
443 else 467 else
@@ -454,27 +478,27 @@ DEFUN ("terminal-parameters", Fterminal_parameters, Sterminal_parameters, 0, 1,
454The value is a list of elements of the form (PARM . VALUE), where PARM 478The value is a list of elements of the form (PARM . VALUE), where PARM
455is a symbol. 479is a symbol.
456 480
457TERMINAL can be a terminal if, a frame or nil (meaning the selected 481TERMINAL can be a terminal id, a frame or nil (meaning the selected
458frame's terminal). */) 482frame's terminal). */)
459 (terminal) 483 (terminal)
460 Lisp_Object terminal; 484 Lisp_Object terminal;
461{ 485{
462 struct device *d = get_device (terminal, 1); 486 struct terminal *t = get_terminal (terminal, 1);
463 return Fcopy_alist (d->param_alist); 487 return Fcopy_alist (t->param_alist);
464} 488}
465 489
466DEFUN ("terminal-parameter", Fterminal_parameter, Sterminal_parameter, 2, 2, 0, 490DEFUN ("terminal-parameter", Fterminal_parameter, Sterminal_parameter, 2, 2, 0,
467 doc: /* Return TERMINAL's value for parameter PARAMETER. 491 doc: /* Return TERMINAL's value for parameter PARAMETER.
468TERMINAL can be a terminal if, a frame or nil (meaning the selected 492TERMINAL can be a terminal id, a frame or nil (meaning the selected
469frame's terminal). */) 493frame's terminal). */)
470 (terminal, parameter) 494 (terminal, parameter)
471 Lisp_Object terminal; 495 Lisp_Object terminal;
472 Lisp_Object parameter; 496 Lisp_Object parameter;
473{ 497{
474 Lisp_Object value; 498 Lisp_Object value;
475 struct device *d = get_device (terminal, 1); 499 struct terminal *t = get_terminal (terminal, 1);
476 CHECK_SYMBOL (parameter); 500 CHECK_SYMBOL (parameter);
477 value = Fcdr (Fassq (parameter, d->param_alist)); 501 value = Fcdr (Fassq (parameter, t->param_alist));
478 return value; 502 return value;
479} 503}
480 504
@@ -484,14 +508,14 @@ DEFUN ("modify-terminal-parameters", Fmodify_terminal_parameters,
484ALIST is an alist of parameters to change and their new values. 508ALIST is an alist of parameters to change and their new values.
485Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol. 509Each element of ALIST has the form (PARM . VALUE), where PARM is a symbol.
486 510
487TERMINAL can be a terminal if, a frame or nil (meaning the selected 511TERMINAL can be a terminal id, a frame or nil (meaning the selected
488frame's terminal). */) 512frame's terminal). */)
489 (terminal, alist) 513 (terminal, alist)
490 Lisp_Object terminal; 514 Lisp_Object terminal;
491 Lisp_Object alist; 515 Lisp_Object alist;
492{ 516{
493 Lisp_Object tail, prop, val; 517 Lisp_Object tail, prop, val;
494 struct device *d = get_device (terminal, 1); 518 struct terminal *t = get_terminal (terminal, 1);
495 int length = XINT (Fsafe_length (alist)); 519 int length = XINT (Fsafe_length (alist));
496 int i; 520 int i;
497 Lisp_Object *parms = (Lisp_Object *) alloca (length * sizeof (Lisp_Object)); 521 Lisp_Object *parms = (Lisp_Object *) alloca (length * sizeof (Lisp_Object));
@@ -515,7 +539,7 @@ frame's terminal). */)
515 { 539 {
516 prop = parms[i]; 540 prop = parms[i];
517 val = values[i]; 541 val = values[i];
518 store_terminal_param (d, prop, val); 542 store_terminal_param (t, prop, val);
519 } 543 }
520 return Qnil; 544 return Qnil;
521} 545}
@@ -525,50 +549,50 @@ DEFUN ("set-terminal-parameter", Fset_terminal_parameter,
525 doc: /* Set TERMINAL's value for parameter PARAMETER to VALUE. 549 doc: /* Set TERMINAL's value for parameter PARAMETER to VALUE.
526Return the previous value of PARAMETER. 550Return the previous value of PARAMETER.
527 551
528TERMINAL can be a terminal if, a frame or nil (meaning the selected 552TERMINAL can be a terminal id, a frame or nil (meaning the selected
529frame's terminal). */) 553frame's terminal). */)
530 (terminal, parameter, value) 554 (terminal, parameter, value)
531 Lisp_Object terminal; 555 Lisp_Object terminal;
532 Lisp_Object parameter; 556 Lisp_Object parameter;
533 Lisp_Object value; 557 Lisp_Object value;
534{ 558{
535 struct device *d = get_device (terminal, 1); 559 struct terminal *t = get_terminal (terminal, 1);
536 return store_terminal_param (d, parameter, value); 560 return store_terminal_param (t, parameter, value);
537} 561}
538 562
539 563
540 564
541/* Create the bootstrap display device for the initial frame. 565/* Create the bootstrap display terminal for the initial frame.
542 Returns a device of type output_initial. */ 566 Returns a terminal of type output_initial. */
543 567
544struct device * 568struct terminal *
545init_initial_device (void) 569init_initial_terminal (void)
546{ 570{
547 if (initialized || device_list || tty_list) 571 if (initialized || terminal_list || tty_list)
548 abort (); 572 abort ();
549 573
550 initial_device = create_device (); 574 initial_terminal = create_terminal ();
551 initial_device->type = output_initial; 575 initial_terminal->type = output_initial;
552 initial_device->name = xstrdup ("initial_device"); 576 initial_terminal->name = xstrdup ("initial_terminal");
553 initial_device->kboard = initial_kboard; 577 initial_terminal->kboard = initial_kboard;
554 578
555 initial_device->delete_device_hook = &delete_initial_device; 579 initial_terminal->delete_terminal_hook = &delete_initial_terminal;
556 /* All other hooks are NULL. */ 580 /* All other hooks are NULL. */
557 581
558 return initial_device; 582 return initial_terminal;
559} 583}
560 584
561/* Deletes the bootstrap display device. 585/* Deletes the bootstrap terminal device.
562 Called through delete_device_hook. */ 586 Called through delete_terminal_hook. */
563 587
564void 588static void
565delete_initial_device (struct device *device) 589delete_initial_terminal (struct terminal *terminal)
566{ 590{
567 if (device != initial_device) 591 if (terminal != initial_terminal)
568 abort (); 592 abort ();
569 593
570 delete_device (device); 594 delete_terminal (terminal);
571 initial_device = NULL; 595 initial_terminal = NULL;
572} 596}
573 597
574void 598void
@@ -580,10 +604,11 @@ syms_of_terminal ()
580The function should accept no arguments. */); 604The function should accept no arguments. */);
581 Vring_bell_function = Qnil; 605 Vring_bell_function = Qnil;
582 606
583 defsubr (&Sdelete_display); 607 defsubr (&Sdelete_terminal);
584 defsubr (&Sdisplay_live_p); 608 defsubr (&Sframe_terminal);
585 defsubr (&Sdisplay_list); 609 defsubr (&Sterminal_live_p);
586 defsubr (&Sdisplay_name); 610 defsubr (&Sterminal_list);
611 defsubr (&Sterminal_name);
587 defsubr (&Sterminal_parameters); 612 defsubr (&Sterminal_parameters);
588 defsubr (&Sterminal_parameter); 613 defsubr (&Sterminal_parameter);
589 defsubr (&Smodify_terminal_parameters); 614 defsubr (&Smodify_terminal_parameters);
diff --git a/src/xdisp.c b/src/xdisp.c
index 1f04b1eac27..df6bba2ef0b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -7304,8 +7304,8 @@ message2_nolog (m, nbytes, multibyte)
7304 do_pending_window_change (0); 7304 do_pending_window_change (0);
7305 echo_area_display (1); 7305 echo_area_display (1);
7306 do_pending_window_change (0); 7306 do_pending_window_change (0);
7307 if (FRAME_DEVICE (f)->frame_up_to_date_hook != 0 && ! gc_in_progress) 7307 if (FRAME_TERMINAL (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
7308 (*FRAME_DEVICE (f)->frame_up_to_date_hook) (f); 7308 (*FRAME_TERMINAL (f)->frame_up_to_date_hook) (f);
7309 } 7309 }
7310} 7310}
7311 7311
@@ -7408,8 +7408,8 @@ message3_nolog (m, nbytes, multibyte)
7408 do_pending_window_change (0); 7408 do_pending_window_change (0);
7409 echo_area_display (1); 7409 echo_area_display (1);
7410 do_pending_window_change (0); 7410 do_pending_window_change (0);
7411 if (FRAME_DEVICE (f)->frame_up_to_date_hook != 0 && ! gc_in_progress) 7411 if (FRAME_TERMINAL (f)->frame_up_to_date_hook != 0 && ! gc_in_progress)
7412 (*FRAME_DEVICE (f)->frame_up_to_date_hook) (f); 7412 (*FRAME_TERMINAL (f)->frame_up_to_date_hook) (f);
7413 } 7413 }
7414} 7414}
7415 7415
@@ -10940,16 +10940,16 @@ redisplay_internal (preserve_echo_area)
10940 10940
10941 /* Mark all the scroll bars to be removed; we'll redeem 10941 /* Mark all the scroll bars to be removed; we'll redeem
10942 the ones we want when we redisplay their windows. */ 10942 the ones we want when we redisplay their windows. */
10943 if (FRAME_DEVICE (f)->condemn_scroll_bars_hook) 10943 if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
10944 FRAME_DEVICE (f)->condemn_scroll_bars_hook (f); 10944 FRAME_TERMINAL (f)->condemn_scroll_bars_hook (f);
10945 10945
10946 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f)) 10946 if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
10947 redisplay_windows (FRAME_ROOT_WINDOW (f)); 10947 redisplay_windows (FRAME_ROOT_WINDOW (f));
10948 10948
10949 /* Any scroll bars which redisplay_windows should have 10949 /* Any scroll bars which redisplay_windows should have
10950 nuked should now go away. */ 10950 nuked should now go away. */
10951 if (FRAME_DEVICE (f)->judge_scroll_bars_hook) 10951 if (FRAME_TERMINAL (f)->judge_scroll_bars_hook)
10952 FRAME_DEVICE (f)->judge_scroll_bars_hook (f); 10952 FRAME_TERMINAL (f)->judge_scroll_bars_hook (f);
10953 10953
10954 /* If fonts changed, display again. */ 10954 /* If fonts changed, display again. */
10955 /* ??? rms: I suspect it is a mistake to jump all the way 10955 /* ??? rms: I suspect it is a mistake to jump all the way
@@ -10999,8 +10999,8 @@ redisplay_internal (preserve_echo_area)
10999 if (f->updated_p) 10999 if (f->updated_p)
11000 { 11000 {
11001 mark_window_display_accurate (f->root_window, 1); 11001 mark_window_display_accurate (f->root_window, 1);
11002 if (FRAME_DEVICE (f)->frame_up_to_date_hook) 11002 if (FRAME_TERMINAL (f)->frame_up_to_date_hook)
11003 FRAME_DEVICE (f)->frame_up_to_date_hook (f); 11003 FRAME_TERMINAL (f)->frame_up_to_date_hook (f);
11004 } 11004 }
11005 } 11005 }
11006 } 11006 }
@@ -11086,8 +11086,8 @@ redisplay_internal (preserve_echo_area)
11086 /* Say overlay arrows are up to date. */ 11086 /* Say overlay arrows are up to date. */
11087 update_overlay_arrows (1); 11087 update_overlay_arrows (1);
11088 11088
11089 if (FRAME_DEVICE (sf)->frame_up_to_date_hook != 0) 11089 if (FRAME_TERMINAL (sf)->frame_up_to_date_hook != 0)
11090 FRAME_DEVICE (sf)->frame_up_to_date_hook (sf); 11090 FRAME_TERMINAL (sf)->frame_up_to_date_hook (sf);
11091 } 11091 }
11092 11092
11093 update_mode_lines = 0; 11093 update_mode_lines = 0;
@@ -12343,8 +12343,8 @@ set_vertical_scroll_bar (w)
12343 start = end = whole = 0; 12343 start = end = whole = 0;
12344 12344
12345 /* Indicate what this scroll bar ought to be displaying now. */ 12345 /* Indicate what this scroll bar ought to be displaying now. */
12346 if (FRAME_DEVICE (XFRAME (w->frame))->set_vertical_scroll_bar_hook) 12346 if (FRAME_TERMINAL (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
12347 (*FRAME_DEVICE (XFRAME (w->frame))->set_vertical_scroll_bar_hook) 12347 (*FRAME_TERMINAL (XFRAME (w->frame))->set_vertical_scroll_bar_hook)
12348 (w, end - start, whole, start); 12348 (w, end - start, whole, start);
12349} 12349}
12350 12350
@@ -13083,8 +13083,8 @@ redisplay_window (window, just_this_one_p)
13083 13083
13084 /* Note that we actually used the scroll bar attached to this 13084 /* Note that we actually used the scroll bar attached to this
13085 window, so it shouldn't be deleted at the end of redisplay. */ 13085 window, so it shouldn't be deleted at the end of redisplay. */
13086 if (FRAME_DEVICE (f)->redeem_scroll_bar_hook) 13086 if (FRAME_TERMINAL (f)->redeem_scroll_bar_hook)
13087 (*FRAME_DEVICE (f)->redeem_scroll_bar_hook) (w); 13087 (*FRAME_TERMINAL (f)->redeem_scroll_bar_hook) (w);
13088 } 13088 }
13089 13089
13090 /* Restore current_buffer and value of point in it. */ 13090 /* Restore current_buffer and value of point in it. */
diff --git a/src/xfns.c b/src/xfns.c
index 7bf302594be..345ceebb34b 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -244,7 +244,7 @@ check_x_frame (frame)
244} 244}
245 245
246/* Let the user specify an X display with a Lisp object. 246/* Let the user specify an X display with a Lisp object.
247 OBJECT may be nil, a frame or a device id. 247 OBJECT may be nil, a frame or a terminal id.
248 nil stands for the selected frame--or, if that is not an X frame, 248 nil stands for the selected frame--or, if that is not an X frame,
249 the first X display on the list. */ 249 the first X display on the list. */
250 250
@@ -267,12 +267,12 @@ check_x_display_info (object)
267 } 267 }
268 else if (INTEGERP (object)) 268 else if (INTEGERP (object))
269 { 269 {
270 struct device *d = get_device (XINT (object), 1); 270 struct terminal *t = get_terminal (XINT (object), 1);
271 271
272 if (d->type != output_x_window) 272 if (t->type != output_x_window)
273 error ("Display %d is not an X display", XINT (object)); 273 error ("Terminal %d is not an X display", XINT (object));
274 274
275 dpyinfo = d->display_info.x; 275 dpyinfo = t->display_info.x;
276 } 276 }
277 else if (STRINGP (object)) 277 else if (STRINGP (object))
278 dpyinfo = x_display_info_for_name (object); 278 dpyinfo = x_display_info_for_name (object);
@@ -1463,10 +1463,10 @@ x_set_scroll_bar_foreground (f, value, oldval)
1463 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f)) 1463 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
1464 { 1464 {
1465 /* Remove all scroll bars because they have wrong colors. */ 1465 /* Remove all scroll bars because they have wrong colors. */
1466 if (FRAME_DEVICE (f)->condemn_scroll_bars_hook) 1466 if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
1467 (*FRAME_DEVICE (f)->condemn_scroll_bars_hook) (f); 1467 (*FRAME_TERMINAL (f)->condemn_scroll_bars_hook) (f);
1468 if (FRAME_DEVICE (f)->judge_scroll_bars_hook) 1468 if (FRAME_TERMINAL (f)->judge_scroll_bars_hook)
1469 (*FRAME_DEVICE (f)->judge_scroll_bars_hook) (f); 1469 (*FRAME_TERMINAL (f)->judge_scroll_bars_hook) (f);
1470 1470
1471 update_face_from_frame_parameter (f, Qscroll_bar_foreground, value); 1471 update_face_from_frame_parameter (f, Qscroll_bar_foreground, value);
1472 redraw_frame (f); 1472 redraw_frame (f);
@@ -1512,10 +1512,10 @@ x_set_scroll_bar_background (f, value, oldval)
1512 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f)) 1512 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
1513 { 1513 {
1514 /* Remove all scroll bars because they have wrong colors. */ 1514 /* Remove all scroll bars because they have wrong colors. */
1515 if (FRAME_DEVICE (f)->condemn_scroll_bars_hook) 1515 if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
1516 (*FRAME_DEVICE (f)->condemn_scroll_bars_hook) (f); 1516 (*FRAME_TERMINAL (f)->condemn_scroll_bars_hook) (f);
1517 if (FRAME_DEVICE (f)->judge_scroll_bars_hook) 1517 if (FRAME_TERMINAL (f)->judge_scroll_bars_hook)
1518 (*FRAME_DEVICE (f)->judge_scroll_bars_hook) (f); 1518 (*FRAME_TERMINAL (f)->judge_scroll_bars_hook) (f);
1519 1519
1520 update_face_from_frame_parameter (f, Qscroll_bar_background, value); 1520 update_face_from_frame_parameter (f, Qscroll_bar_background, value);
1521 redraw_frame (f); 1521 redraw_frame (f);
@@ -3025,14 +3025,14 @@ This function is an internal primitive--use `make-frame' instead. */)
3025 until we know if this frame has a specified name. */ 3025 until we know if this frame has a specified name. */
3026 Vx_resource_name = Vinvocation_name; 3026 Vx_resource_name = Vinvocation_name;
3027 3027
3028 display = x_get_arg (dpyinfo, parms, Qdevice, 0, 0, RES_TYPE_NUMBER); 3028 display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_NUMBER);
3029 if (EQ (display, Qunbound)) 3029 if (EQ (display, Qunbound))
3030 display = x_get_arg (dpyinfo, parms, Qdisplay, 0, 0, RES_TYPE_STRING); 3030 display = x_get_arg (dpyinfo, parms, Qdisplay, 0, 0, RES_TYPE_STRING);
3031 if (EQ (display, Qunbound)) 3031 if (EQ (display, Qunbound))
3032 display = Qnil; 3032 display = Qnil;
3033 dpyinfo = check_x_display_info (display); 3033 dpyinfo = check_x_display_info (display);
3034#ifdef MULTI_KBOARD 3034#ifdef MULTI_KBOARD
3035 kb = dpyinfo->device->kboard; 3035 kb = dpyinfo->terminal->kboard;
3036#else 3036#else
3037 kb = &the_only_kboard; 3037 kb = &the_only_kboard;
3038#endif 3038#endif
@@ -3077,8 +3077,8 @@ This function is an internal primitive--use `make-frame' instead. */)
3077 /* Note that X Windows does support scroll bars. */ 3077 /* Note that X Windows does support scroll bars. */
3078 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; 3078 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
3079 3079
3080 f->device = dpyinfo->device; 3080 f->terminal = dpyinfo->terminal;
3081 f->device->reference_count++; 3081 f->terminal->reference_count++;
3082 3082
3083 f->output_method = output_x_window; 3083 f->output_method = output_x_window;
3084 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); 3084 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
@@ -3395,7 +3395,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3395 } 3395 }
3396 3396
3397 /* Initialize `default-minibuffer-frame' in case this is the first 3397 /* Initialize `default-minibuffer-frame' in case this is the first
3398 frame on this display device. */ 3398 frame on this terminal. */
3399 if (FRAME_HAS_MINIBUF_P (f) 3399 if (FRAME_HAS_MINIBUF_P (f)
3400 && (!FRAMEP (kb->Vdefault_minibuffer_frame) 3400 && (!FRAMEP (kb->Vdefault_minibuffer_frame)
3401 || !FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame)))) 3401 || !FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame))))
@@ -3500,10 +3500,10 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
3500 3500
3501DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, 3501DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
3502 doc: /* Internal function called by `display-color-p', which see. */) 3502 doc: /* Internal function called by `display-color-p', which see. */)
3503 (device) 3503 (terminal)
3504 Lisp_Object device; 3504 Lisp_Object terminal;
3505{ 3505{
3506 struct x_display_info *dpyinfo = check_x_display_info (device); 3506 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3507 3507
3508 if (dpyinfo->n_planes <= 2) 3508 if (dpyinfo->n_planes <= 2)
3509 return Qnil; 3509 return Qnil;
@@ -3525,13 +3525,13 @@ DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
3525 0, 1, 0, 3525 0, 1, 0,
3526 doc: /* Return t if the X display supports shades of gray. 3526 doc: /* Return t if the X display supports shades of gray.
3527Note that color displays do support shades of gray. 3527Note that color displays do support shades of gray.
3528The optional argument DEVICE specifies which display to ask about. 3528The optional argument TERMINAL specifies which display to ask about.
3529DEVICE should be a device id, a frame or a display name (a string). 3529TERMINAL should be a terminal id, a frame or a display name (a string).
3530If omitted or nil, that stands for the selected frame's display device. */) 3530If omitted or nil, that stands for the selected frame's display. */)
3531 (device) 3531 (terminal)
3532 Lisp_Object device; 3532 Lisp_Object terminal;
3533{ 3533{
3534 struct x_display_info *dpyinfo = check_x_display_info (device); 3534 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3535 3535
3536 if (dpyinfo->n_planes <= 1) 3536 if (dpyinfo->n_planes <= 1)
3537 return Qnil; 3537 return Qnil;
@@ -3553,56 +3553,56 @@ If omitted or nil, that stands for the selected frame's display device. */)
3553 3553
3554DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 3554DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
3555 0, 1, 0, 3555 0, 1, 0,
3556 doc: /* Returns the width in pixels of the X display DEVICE. 3556 doc: /* Returns the width in pixels of the X display TERMINAL.
3557The optional argument DEVICE specifies which display to ask about. 3557The optional argument TERMINAL specifies which display to ask about.
3558DEVICE should be a device id, a frame or a display name (a string). 3558TERMINAL should be a terminal id, a frame or a display name (a string).
3559If omitted or nil, that stands for the selected frame's display. */) 3559If omitted or nil, that stands for the selected frame's display. */)
3560 (device) 3560 (terminal)
3561 Lisp_Object device; 3561 Lisp_Object terminal;
3562{ 3562{
3563 struct x_display_info *dpyinfo = check_x_display_info (device); 3563 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3564 3564
3565 return make_number (dpyinfo->width); 3565 return make_number (dpyinfo->width);
3566} 3566}
3567 3567
3568DEFUN ("x-display-pixel-height", Fx_display_pixel_height, 3568DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
3569 Sx_display_pixel_height, 0, 1, 0, 3569 Sx_display_pixel_height, 0, 1, 0,
3570 doc: /* Returns the height in pixels of the X display DEVICE. 3570 doc: /* Returns the height in pixels of the X display TERMINAL.
3571The optional argument DEVICE specifies which display to ask about. 3571The optional argument TERMINAL specifies which display to ask about.
3572DEVICE should be a device id, a frame or a display name (a string). 3572TERMINAL should be a terminal id, a frame or a display name (a string).
3573If omitted or nil, that stands for the selected frame's display. */) 3573If omitted or nil, that stands for the selected frame's display. */)
3574 (device) 3574 (terminal)
3575 Lisp_Object device; 3575 Lisp_Object terminal;
3576{ 3576{
3577 struct x_display_info *dpyinfo = check_x_display_info (device); 3577 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3578 3578
3579 return make_number (dpyinfo->height); 3579 return make_number (dpyinfo->height);
3580} 3580}
3581 3581
3582DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 3582DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
3583 0, 1, 0, 3583 0, 1, 0,
3584 doc: /* Returns the number of bitplanes of the X display DEVICE. 3584 doc: /* Returns the number of bitplanes of the X display TERMINAL.
3585The optional argument DEVICE specifies which display to ask about. 3585The optional argument TERMINAL specifies which display to ask about.
3586DEVICE should be a device id, a frame or a display name (a string). 3586TERMINAL should be a terminal id, a frame or a display name (a string).
3587If omitted or nil, that stands for the selected frame's display. */) 3587If omitted or nil, that stands for the selected frame's display. */)
3588 (device) 3588 (terminal)
3589 Lisp_Object device; 3589 Lisp_Object terminal;
3590{ 3590{
3591 struct x_display_info *dpyinfo = check_x_display_info (device); 3591 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3592 3592
3593 return make_number (dpyinfo->n_planes); 3593 return make_number (dpyinfo->n_planes);
3594} 3594}
3595 3595
3596DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 3596DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
3597 0, 1, 0, 3597 0, 1, 0,
3598 doc: /* Returns the number of color cells of the X display DEVICE. 3598 doc: /* Returns the number of color cells of the X display TERMINAL.
3599The optional argument DEVICE specifies which display to ask about. 3599The optional argument TERMINAL specifies which display to ask about.
3600DEVICE should be a device id, a frame or a display name (a string). 3600TERMINAL should be a terminal id, a frame or a display name (a string).
3601If omitted or nil, that stands for the selected frame's display. */) 3601If omitted or nil, that stands for the selected frame's display. */)
3602 (device) 3602 (terminal)
3603 Lisp_Object device; 3603 Lisp_Object terminal;
3604{ 3604{
3605 struct x_display_info *dpyinfo = check_x_display_info (device); 3605 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3606 3606
3607 int nr_planes = DisplayPlanes (dpyinfo->display, 3607 int nr_planes = DisplayPlanes (dpyinfo->display,
3608 XScreenNumberOfScreen (dpyinfo->screen)); 3608 XScreenNumberOfScreen (dpyinfo->screen));
@@ -3620,29 +3620,29 @@ If omitted or nil, that stands for the selected frame's display. */)
3620DEFUN ("x-server-max-request-size", Fx_server_max_request_size, 3620DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
3621 Sx_server_max_request_size, 3621 Sx_server_max_request_size,
3622 0, 1, 0, 3622 0, 1, 0,
3623 doc: /* Returns the maximum request size of the X server of display DEVICE. 3623 doc: /* Returns the maximum request size of the X server of display TERMINAL.
3624The optional argument DEVICE specifies which display to ask about. 3624The optional argument TERMINAL specifies which display to ask about.
3625DEVICE should be a device id, a frame or a display name (a string). 3625TERMINAL should be a terminal id, a frame or a display name (a string).
3626If omitted or nil, that stands for the selected frame's display. */) 3626If omitted or nil, that stands for the selected frame's display. */)
3627 (device) 3627 (terminal)
3628 Lisp_Object device; 3628 Lisp_Object terminal;
3629{ 3629{
3630 struct x_display_info *dpyinfo = check_x_display_info (device); 3630 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3631 3631
3632 return make_number (MAXREQUEST (dpyinfo->display)); 3632 return make_number (MAXREQUEST (dpyinfo->display));
3633} 3633}
3634 3634
3635DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, 3635DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
3636 doc: /* Returns the "vendor ID" string of the X server of display DEVICE. 3636 doc: /* Returns the "vendor ID" string of the X server of display TERMINAL.
3637\(Labelling every distributor as a "vendor" embodies the false assumption 3637\(Labelling every distributor as a "vendor" embodies the false assumption
3638that operating systems cannot be developed and distributed noncommercially.) 3638that operating systems cannot be developed and distributed noncommercially.)
3639The optional argument DEVICE specifies which display to ask about. 3639The optional argument TERMINAL specifies which display to ask about.
3640DEVICE should be a device id, a frame or a display name (a string). 3640TERMINAL should be a terminal id, a frame or a display name (a string).
3641If omitted or nil, that stands for the selected frame's display. */) 3641If omitted or nil, that stands for the selected frame's display. */)
3642 (device) 3642 (terminal)
3643 Lisp_Object device; 3643 Lisp_Object terminal;
3644{ 3644{
3645 struct x_display_info *dpyinfo = check_x_display_info (device); 3645 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3646 char *vendor = ServerVendor (dpyinfo->display); 3646 char *vendor = ServerVendor (dpyinfo->display);
3647 3647
3648 if (! vendor) vendor = ""; 3648 if (! vendor) vendor = "";
@@ -3650,18 +3650,18 @@ If omitted or nil, that stands for the selected frame's display. */)
3650} 3650}
3651 3651
3652DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, 3652DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
3653 doc: /* Returns the version numbers of the X server of display DEVICE. 3653 doc: /* Returns the version numbers of the X server of display TERMINAL.
3654The value is a list of three integers: the major and minor 3654The value is a list of three integers: the major and minor
3655version numbers of the X Protocol in use, and the distributor-specific release 3655version numbers of the X Protocol in use, and the distributor-specific release
3656number. See also the function `x-server-vendor'. 3656number. See also the function `x-server-vendor'.
3657 3657
3658The optional argument DEVICE specifies which display to ask about. 3658The optional argument TERMINAL specifies which display to ask about.
3659DEVICE should be a device id, a frame or a display name (a string). 3659TERMINAL should be a terminal id, a frame or a display name (a string).
3660If omitted or nil, that stands for the selected frame's display. */) 3660If omitted or nil, that stands for the selected frame's display. */)
3661 (device) 3661 (terminal)
3662 Lisp_Object device; 3662 Lisp_Object terminal;
3663{ 3663{
3664 struct x_display_info *dpyinfo = check_x_display_info (device); 3664 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3665 Display *dpy = dpyinfo->display; 3665 Display *dpy = dpyinfo->display;
3666 3666
3667 return Fcons (make_number (ProtocolVersion (dpy)), 3667 return Fcons (make_number (ProtocolVersion (dpy)),
@@ -3670,55 +3670,55 @@ If omitted or nil, that stands for the selected frame's display. */)
3670} 3670}
3671 3671
3672DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, 3672DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
3673 doc: /* Return the number of screens on the X server of display DEVICE. 3673 doc: /* Return the number of screens on the X server of display TERMINAL.
3674The optional argument DEVICE specifies which display to ask about. 3674The optional argument TERMINAL specifies which display to ask about.
3675DEVICE should be a device id, a frame or a display name (a string). 3675TERMINAL should be a terminal id, a frame or a display name (a string).
3676If omitted or nil, that stands for the selected frame's display. */) 3676If omitted or nil, that stands for the selected frame's display. */)
3677 (device) 3677 (terminal)
3678 Lisp_Object device; 3678 Lisp_Object terminal;
3679{ 3679{
3680 struct x_display_info *dpyinfo = check_x_display_info (device); 3680 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3681 3681
3682 return make_number (ScreenCount (dpyinfo->display)); 3682 return make_number (ScreenCount (dpyinfo->display));
3683} 3683}
3684 3684
3685DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0, 3685DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0,
3686 doc: /* Return the height in millimeters of the X display DEVICE. 3686 doc: /* Return the height in millimeters of the X display TERMINAL.
3687The optional argument DEVICE specifies which display to ask about. 3687The optional argument TERMINAL specifies which display to ask about.
3688DEVICE should be a device id, a frame or a display name (a string). 3688TERMINAL should be a terminal id, a frame or a display name (a string).
3689If omitted or nil, that stands for the selected frame's display. */) 3689If omitted or nil, that stands for the selected frame's display. */)
3690 (device) 3690 (terminal)
3691 Lisp_Object device; 3691 Lisp_Object terminal;
3692{ 3692{
3693 struct x_display_info *dpyinfo = check_x_display_info (device); 3693 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3694 3694
3695 return make_number (HeightMMOfScreen (dpyinfo->screen)); 3695 return make_number (HeightMMOfScreen (dpyinfo->screen));
3696} 3696}
3697 3697
3698DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, 3698DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
3699 doc: /* Return the width in millimeters of the X display DEVICE. 3699 doc: /* Return the width in millimeters of the X display TERMINAL.
3700The optional argument DEVICE specifies which display to ask about. 3700The optional argument TERMINAL specifies which display to ask about.
3701DEVICE should be a device id, a frame or a display name (a string). 3701TERMINAL should be a terminal id, a frame or a display name (a string).
3702If omitted or nil, that stands for the selected frame's display. */) 3702If omitted or nil, that stands for the selected frame's display. */)
3703 (device) 3703 (terminal)
3704 Lisp_Object device; 3704 Lisp_Object terminal;
3705{ 3705{
3706 struct x_display_info *dpyinfo = check_x_display_info (device); 3706 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3707 3707
3708 return make_number (WidthMMOfScreen (dpyinfo->screen)); 3708 return make_number (WidthMMOfScreen (dpyinfo->screen));
3709} 3709}
3710 3710
3711DEFUN ("x-display-backing-store", Fx_display_backing_store, 3711DEFUN ("x-display-backing-store", Fx_display_backing_store,
3712 Sx_display_backing_store, 0, 1, 0, 3712 Sx_display_backing_store, 0, 1, 0,
3713 doc: /* Returns an indication of whether X display DEVICE does backing store. 3713 doc: /* Returns an indication of whether X display TERMINAL does backing store.
3714The value may be `always', `when-mapped', or `not-useful'. 3714The value may be `always', `when-mapped', or `not-useful'.
3715The optional argument DEVICE specifies which display to ask about. 3715The optional argument TERMINAL specifies which display to ask about.
3716DEVICE should be a device id, a frame or a display name (a string). 3716TERMINAL should be a terminal id, a frame or a display name (a string).
3717If omitted or nil, that stands for the selected frame's display. */) 3717If omitted or nil, that stands for the selected frame's display. */)
3718 (device) 3718 (terminal)
3719 Lisp_Object device; 3719 Lisp_Object terminal;
3720{ 3720{
3721 struct x_display_info *dpyinfo = check_x_display_info (device); 3721 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3722 Lisp_Object result; 3722 Lisp_Object result;
3723 3723
3724 switch (DoesBackingStore (dpyinfo->screen)) 3724 switch (DoesBackingStore (dpyinfo->screen))
@@ -3745,17 +3745,17 @@ If omitted or nil, that stands for the selected frame's display. */)
3745 3745
3746DEFUN ("x-display-visual-class", Fx_display_visual_class, 3746DEFUN ("x-display-visual-class", Fx_display_visual_class,
3747 Sx_display_visual_class, 0, 1, 0, 3747 Sx_display_visual_class, 0, 1, 0,
3748 doc: /* Return the visual class of the X display DEVICE. 3748 doc: /* Return the visual class of the X display TERMINAL.
3749The value is one of the symbols `static-gray', `gray-scale', 3749The value is one of the symbols `static-gray', `gray-scale',
3750`static-color', `pseudo-color', `true-color', or `direct-color'. 3750`static-color', `pseudo-color', `true-color', or `direct-color'.
3751 3751
3752The optional argument DEVICE specifies which display to ask about. 3752The optional argument TERMINAL specifies which display to ask about.
3753DEVICE should a device id, a frame or a display name (a string). 3753TERMINAL should a terminal id, a frame or a display name (a string).
3754If omitted or nil, that stands for the selected frame's display. */) 3754If omitted or nil, that stands for the selected frame's display. */)
3755 (device) 3755 (terminal)
3756 Lisp_Object device; 3756 Lisp_Object terminal;
3757{ 3757{
3758 struct x_display_info *dpyinfo = check_x_display_info (device); 3758 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3759 Lisp_Object result; 3759 Lisp_Object result;
3760 3760
3761 switch (dpyinfo->visual->class) 3761 switch (dpyinfo->visual->class)
@@ -3788,14 +3788,14 @@ If omitted or nil, that stands for the selected frame's display. */)
3788 3788
3789DEFUN ("x-display-save-under", Fx_display_save_under, 3789DEFUN ("x-display-save-under", Fx_display_save_under,
3790 Sx_display_save_under, 0, 1, 0, 3790 Sx_display_save_under, 0, 1, 0,
3791 doc: /* Returns t if the X display DEVICE supports the save-under feature. 3791 doc: /* Returns t if the X display TERMINAL supports the save-under feature.
3792The optional argument DEVICE specifies which display to ask about. 3792The optional argument TERMINAL specifies which display to ask about.
3793DEVICE should be a device id, a frame or a display name (a string). 3793TERMINAL should be a terminal id, a frame or a display name (a string).
3794If omitted or nil, that stands for the selected frame's display. */) 3794If omitted or nil, that stands for the selected frame's display. */)
3795 (device) 3795 (terminal)
3796 Lisp_Object device; 3796 Lisp_Object terminal;
3797{ 3797{
3798 struct x_display_info *dpyinfo = check_x_display_info (device); 3798 struct x_display_info *dpyinfo = check_x_display_info (terminal);
3799 3799
3800 if (DoesSaveUnders (dpyinfo->screen) == True) 3800 if (DoesSaveUnders (dpyinfo->screen) == True)
3801 return Qt; 3801 return Qt;
@@ -4075,7 +4075,7 @@ If DISPLAY is nil, that stands for the selected frame's display. */)
4075 if (dpyinfo->reference_count > 0) 4075 if (dpyinfo->reference_count > 0)
4076 error ("Display still has frames on it"); 4076 error ("Display still has frames on it");
4077 4077
4078 x_delete_device (dpyinfo->device); 4078 x_delete_terminal (dpyinfo->terminal);
4079 4079
4080 return Qnil; 4080 return Qnil;
4081} 4081}
@@ -4652,8 +4652,8 @@ x_create_tip_frame (dpyinfo, parms, text)
4652 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; 4652 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
4653 record_unwind_protect (unwind_create_tip_frame, frame); 4653 record_unwind_protect (unwind_create_tip_frame, frame);
4654 4654
4655 f->device = dpyinfo->device; 4655 f->terminal = dpyinfo->terminal;
4656 f->device->reference_count++; 4656 f->terminal->reference_count++;
4657 4657
4658 /* By setting the output method, we're essentially saying that 4658 /* By setting the output method, we're essentially saying that
4659 the frame is live, as per FRAME_LIVE_P. If we get a signal 4659 the frame is live, as per FRAME_LIVE_P. If we get a signal
diff --git a/src/xselect.c b/src/xselect.c
index 16fb7187474..062336bc050 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1010,7 +1010,7 @@ x_handle_selection_clear (event)
1010 to see if this Emacs job now owns the selection 1010 to see if this Emacs job now owns the selection
1011 through that display. */ 1011 through that display. */
1012 for (t_dpyinfo = x_display_list; t_dpyinfo; t_dpyinfo = t_dpyinfo->next) 1012 for (t_dpyinfo = x_display_list; t_dpyinfo; t_dpyinfo = t_dpyinfo->next)
1013 if (t_dpyinfo->device->kboard == dpyinfo->device->kboard) 1013 if (t_dpyinfo->terminal->kboard == dpyinfo->terminal->kboard)
1014 { 1014 {
1015 Window owner_window 1015 Window owner_window
1016 = XGetSelectionOwner (t_dpyinfo->display, selection); 1016 = XGetSelectionOwner (t_dpyinfo->display, selection);
diff --git a/src/xterm.c b/src/xterm.c
index 5da3f422f80..b784b560fc4 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -338,15 +338,15 @@ void x_raise_frame P_ ((struct frame *));
338void x_set_window_size P_ ((struct frame *, int, int, int)); 338void x_set_window_size P_ ((struct frame *, int, int, int));
339void x_wm_set_window_state P_ ((struct frame *, int)); 339void x_wm_set_window_state P_ ((struct frame *, int));
340void x_wm_set_icon_pixmap P_ ((struct frame *, int)); 340void x_wm_set_icon_pixmap P_ ((struct frame *, int));
341struct device *x_create_device P_ ((struct x_display_info *)); 341static struct terminal *x_create_terminal P_ ((struct x_display_info *));
342void x_delete_device P_ ((struct device *)); 342void x_delete_terminal P_ ((struct terminal *));
343void x_initialize P_ ((void)); 343void x_initialize P_ ((void));
344static void x_font_min_bounds P_ ((XFontStruct *, int *, int *)); 344static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
345static int x_compute_min_glyph_bounds P_ ((struct frame *)); 345static int x_compute_min_glyph_bounds P_ ((struct frame *));
346static void x_update_end P_ ((struct frame *)); 346static void x_update_end P_ ((struct frame *));
347static void XTframe_up_to_date P_ ((struct frame *)); 347static void XTframe_up_to_date P_ ((struct frame *));
348static void XTset_terminal_modes P_ ((struct device *)); 348static void XTset_terminal_modes P_ ((struct terminal *));
349static void XTreset_terminal_modes P_ ((struct device *)); 349static void XTreset_terminal_modes P_ ((struct terminal *));
350static void x_clear_frame P_ ((struct frame *)); 350static void x_clear_frame P_ ((struct frame *));
351static void frame_highlight P_ ((struct frame *)); 351static void frame_highlight P_ ((struct frame *));
352static void frame_unhighlight P_ ((struct frame *)); 352static void frame_unhighlight P_ ((struct frame *));
@@ -806,7 +806,7 @@ x_draw_fringe_bitmap (w, row, p)
806 rarely happens). */ 806 rarely happens). */
807 807
808static void 808static void
809XTset_terminal_modes (struct device *device) 809XTset_terminal_modes (struct terminal *terminal)
810{ 810{
811} 811}
812 812
@@ -814,7 +814,7 @@ XTset_terminal_modes (struct device *device)
814 the X-windows go away, and suspending requires no action. */ 814 the X-windows go away, and suspending requires no action. */
815 815
816static void 816static void
817XTreset_terminal_modes (struct device *device) 817XTreset_terminal_modes (struct terminal *terminal)
818{ 818{
819} 819}
820 820
@@ -5673,7 +5673,7 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
5673 int count = 0; 5673 int count = 0;
5674 int do_help = 0; 5674 int do_help = 0;
5675 int nbytes = 0; 5675 int nbytes = 0;
5676 struct frame *f; 5676 struct frame *f = NULL;
5677 struct coding_system coding; 5677 struct coding_system coding;
5678 XEvent event = *eventp; 5678 XEvent event = *eventp;
5679 5679
@@ -6923,8 +6923,8 @@ x_dispatch_event (event, display)
6923 EXPECTED is nonzero if the caller knows input is available. */ 6923 EXPECTED is nonzero if the caller knows input is available. */
6924 6924
6925static int 6925static int
6926XTread_socket (device, expected, hold_quit) 6926XTread_socket (terminal, expected, hold_quit)
6927 struct device *device; 6927 struct terminal *terminal;
6928 int expected; 6928 int expected;
6929 struct input_event *hold_quit; 6929 struct input_event *hold_quit;
6930{ 6930{
@@ -6987,7 +6987,7 @@ XTread_socket (device, expected, hold_quit)
6987 6987
6988#ifdef HAVE_X_SM 6988#ifdef HAVE_X_SM
6989 /* Only check session manager input for the primary display. */ 6989 /* Only check session manager input for the primary display. */
6990 if (device->id == 1 && x_session_have_connection ()) 6990 if (terminal->id == 1 && x_session_have_connection ())
6991 { 6991 {
6992 struct input_event inev; 6992 struct input_event inev;
6993 BLOCK_INPUT; 6993 BLOCK_INPUT;
@@ -7656,7 +7656,7 @@ x_connection_closed (dpy, error_message)
7656 /* Protect display from being closed when we delete the last 7656 /* Protect display from being closed when we delete the last
7657 frame on it. */ 7657 frame on it. */
7658 dpyinfo->reference_count++; 7658 dpyinfo->reference_count++;
7659 dpyinfo->device->reference_count++; 7659 dpyinfo->terminal->reference_count++;
7660 } 7660 }
7661 7661
7662 /* First delete frames whose mini-buffers are on frames 7662 /* First delete frames whose mini-buffers are on frames
@@ -7724,7 +7724,7 @@ x_connection_closed (dpy, error_message)
7724 dpyinfo->display = 0; 7724 dpyinfo->display = 0;
7725 7725
7726 dpyinfo->reference_count--; 7726 dpyinfo->reference_count--;
7727 dpyinfo->device->reference_count--; 7727 dpyinfo->terminal->reference_count--;
7728 if (dpyinfo->reference_count != 0) 7728 if (dpyinfo->reference_count != 0)
7729 /* We have just closed all frames on this display. */ 7729 /* We have just closed all frames on this display. */
7730 abort (); 7730 abort ();
@@ -7734,7 +7734,7 @@ x_connection_closed (dpy, error_message)
7734 7734
7735 x_uncatch_errors (dpy, count); 7735 x_uncatch_errors (dpy, count);
7736 7736
7737 if (device_list == 0) 7737 if (terminal_list == 0)
7738 { 7738 {
7739 fprintf (stderr, "%s\n", error_msg); 7739 fprintf (stderr, "%s\n", error_msg);
7740 shut_down_emacs (0, 0, Qnil); 7740 shut_down_emacs (0, 0, Qnil);
@@ -10121,7 +10121,7 @@ x_term_init (display_name, xrm_option, resource_name)
10121{ 10121{
10122 int connection; 10122 int connection;
10123 Display *dpy; 10123 Display *dpy;
10124 struct device *device; 10124 struct terminal *terminal;
10125 struct x_display_info *dpyinfo; 10125 struct x_display_info *dpyinfo;
10126 XrmDatabase xrdb; 10126 XrmDatabase xrdb;
10127 10127
@@ -10268,7 +10268,7 @@ x_term_init (display_name, xrm_option, resource_name)
10268 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info)); 10268 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
10269 bzero (dpyinfo, sizeof *dpyinfo); 10269 bzero (dpyinfo, sizeof *dpyinfo);
10270 10270
10271 device = x_create_device (dpyinfo); 10271 terminal = x_create_terminal (dpyinfo);
10272 10272
10273#ifdef MULTI_KBOARD 10273#ifdef MULTI_KBOARD
10274 { 10274 {
@@ -10281,30 +10281,30 @@ x_term_init (display_name, xrm_option, resource_name)
10281 SDATA (display_name))) 10281 SDATA (display_name)))
10282 break; 10282 break;
10283 if (share) 10283 if (share)
10284 device->kboard = share->device->kboard; 10284 terminal->kboard = share->terminal->kboard;
10285 else 10285 else
10286 { 10286 {
10287 device->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); 10287 terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
10288 init_kboard (device->kboard); 10288 init_kboard (terminal->kboard);
10289 if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound)) 10289 if (!EQ (XSYMBOL (Qvendor_specific_keysyms)->function, Qunbound))
10290 { 10290 {
10291 char *vendor = ServerVendor (dpy); 10291 char *vendor = ServerVendor (dpy);
10292 UNBLOCK_INPUT; 10292 UNBLOCK_INPUT;
10293 device->kboard->Vsystem_key_alist 10293 terminal->kboard->Vsystem_key_alist
10294 = call1 (Qvendor_specific_keysyms, 10294 = call1 (Qvendor_specific_keysyms,
10295 build_string (vendor ? vendor : "")); 10295 build_string (vendor ? vendor : ""));
10296 BLOCK_INPUT; 10296 BLOCK_INPUT;
10297 } 10297 }
10298 10298
10299 device->kboard->next_kboard = all_kboards; 10299 terminal->kboard->next_kboard = all_kboards;
10300 all_kboards = device->kboard; 10300 all_kboards = terminal->kboard;
10301 /* Don't let the initial kboard remain current longer than necessary. 10301 /* Don't let the initial kboard remain current longer than necessary.
10302 That would cause problems if a file loaded on startup tries to 10302 That would cause problems if a file loaded on startup tries to
10303 prompt in the mini-buffer. */ 10303 prompt in the mini-buffer. */
10304 if (current_kboard == initial_kboard) 10304 if (current_kboard == initial_kboard)
10305 current_kboard = device->kboard; 10305 current_kboard = terminal->kboard;
10306 } 10306 }
10307 device->kboard->reference_count++; 10307 terminal->kboard->reference_count++;
10308 } 10308 }
10309#endif 10309#endif
10310 10310
@@ -10319,10 +10319,10 @@ x_term_init (display_name, xrm_option, resource_name)
10319 10319
10320 dpyinfo->display = dpy; 10320 dpyinfo->display = dpy;
10321 10321
10322 /* Set the name of the device. */ 10322 /* Set the name of the terminal. */
10323 device->name = (char *) xmalloc (SBYTES (display_name) + 1); 10323 terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
10324 strncpy (device->name, SDATA (display_name), SBYTES (display_name)); 10324 strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
10325 device->name[SBYTES (display_name)] = 0; 10325 terminal->name[SBYTES (display_name)] = 0;
10326 10326
10327#if 0 10327#if 0
10328 XSetAfterFunction (x_current_display, x_trace_wire); 10328 XSetAfterFunction (x_current_display, x_trace_wire);
@@ -10614,7 +10614,7 @@ x_term_init (display_name, xrm_option, resource_name)
10614 /* Only do this for the very first display in the Emacs session. 10614 /* Only do this for the very first display in the Emacs session.
10615 Ignore X session management when Emacs was first started on a 10615 Ignore X session management when Emacs was first started on a
10616 tty. */ 10616 tty. */
10617 if (device->id == 1) 10617 if (terminal->id == 1)
10618 x_session_initialize (dpyinfo); 10618 x_session_initialize (dpyinfo);
10619#endif 10619#endif
10620 10620
@@ -10631,17 +10631,17 @@ x_delete_display (dpyinfo)
10631 struct x_display_info *dpyinfo; 10631 struct x_display_info *dpyinfo;
10632{ 10632{
10633 int i; 10633 int i;
10634 struct device *d; 10634 struct terminal *t;
10635 10635
10636 /* Delete the generic struct device for this X display. */ 10636 /* Delete the generic struct terminal for this X display. */
10637 for (d = device_list; d; d = d->next_device) 10637 for (t = terminal_list; t; t = t->next_terminal)
10638 if (d->type == output_x_window && d->display_info.x == dpyinfo) 10638 if (t->type == output_x_window && t->display_info.x == dpyinfo)
10639 { 10639 {
10640 /* Close X session management when we close its display. */ 10640 /* Close X session management when we close its display. */
10641 if (d->id == 1 && x_session_have_connection ()) 10641 if (t->id == 1 && x_session_have_connection ())
10642 x_session_close(); 10642 x_session_close();
10643 10643
10644 delete_device (d); 10644 delete_terminal (t);
10645 break; 10645 break;
10646 } 10646 }
10647 10647
@@ -10776,9 +10776,9 @@ static struct redisplay_interface x_redisplay_interface =
10776 10776
10777/* This function is called when the last frame on a display is deleted. */ 10777/* This function is called when the last frame on a display is deleted. */
10778void 10778void
10779x_delete_device (struct device *device) 10779x_delete_terminal (struct terminal *terminal)
10780{ 10780{
10781 struct x_display_info *dpyinfo = device->display_info.x; 10781 struct x_display_info *dpyinfo = terminal->display_info.x;
10782 int i; 10782 int i;
10783 10783
10784 BLOCK_INPUT; 10784 BLOCK_INPUT;
@@ -10807,50 +10807,50 @@ x_delete_device (struct device *device)
10807} 10807}
10808 10808
10809 10809
10810struct device * 10810static struct terminal *
10811x_create_device (struct x_display_info *dpyinfo) 10811x_create_terminal (struct x_display_info *dpyinfo)
10812{ 10812{
10813 struct device *device; 10813 struct terminal *terminal;
10814 10814
10815 device = create_device (); 10815 terminal = create_terminal ();
10816 10816
10817 device->type = output_x_window; 10817 terminal->type = output_x_window;
10818 device->display_info.x = dpyinfo; 10818 terminal->display_info.x = dpyinfo;
10819 dpyinfo->device = device; 10819 dpyinfo->terminal = terminal;
10820 10820
10821 /* kboard is initialized in x_term_init. */ 10821 /* kboard is initialized in x_term_init. */
10822 10822
10823 device->clear_frame_hook = x_clear_frame; 10823 terminal->clear_frame_hook = x_clear_frame;
10824 device->ins_del_lines_hook = x_ins_del_lines; 10824 terminal->ins_del_lines_hook = x_ins_del_lines;
10825 device->delete_glyphs_hook = x_delete_glyphs; 10825 terminal->delete_glyphs_hook = x_delete_glyphs;
10826 device->ring_bell_hook = XTring_bell; 10826 terminal->ring_bell_hook = XTring_bell;
10827 device->reset_terminal_modes_hook = XTreset_terminal_modes; 10827 terminal->reset_terminal_modes_hook = XTreset_terminal_modes;
10828 device->set_terminal_modes_hook = XTset_terminal_modes; 10828 terminal->set_terminal_modes_hook = XTset_terminal_modes;
10829 device->update_begin_hook = x_update_begin; 10829 terminal->update_begin_hook = x_update_begin;
10830 device->update_end_hook = x_update_end; 10830 terminal->update_end_hook = x_update_end;
10831 device->set_terminal_window_hook = XTset_terminal_window; 10831 terminal->set_terminal_window_hook = XTset_terminal_window;
10832 device->read_socket_hook = XTread_socket; 10832 terminal->read_socket_hook = XTread_socket;
10833 device->frame_up_to_date_hook = XTframe_up_to_date; 10833 terminal->frame_up_to_date_hook = XTframe_up_to_date;
10834 device->mouse_position_hook = XTmouse_position; 10834 terminal->mouse_position_hook = XTmouse_position;
10835 device->frame_rehighlight_hook = XTframe_rehighlight; 10835 terminal->frame_rehighlight_hook = XTframe_rehighlight;
10836 device->frame_raise_lower_hook = XTframe_raise_lower; 10836 terminal->frame_raise_lower_hook = XTframe_raise_lower;
10837 device->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar; 10837 terminal->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
10838 device->condemn_scroll_bars_hook = XTcondemn_scroll_bars; 10838 terminal->condemn_scroll_bars_hook = XTcondemn_scroll_bars;
10839 device->redeem_scroll_bar_hook = XTredeem_scroll_bar; 10839 terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar;
10840 device->judge_scroll_bars_hook = XTjudge_scroll_bars; 10840 terminal->judge_scroll_bars_hook = XTjudge_scroll_bars;
10841 10841
10842 device->delete_frame_hook = x_destroy_window; 10842 terminal->delete_frame_hook = x_destroy_window;
10843 device->delete_device_hook = x_delete_device; 10843 terminal->delete_terminal_hook = x_delete_terminal;
10844 10844
10845 device->rif = &x_redisplay_interface; 10845 terminal->rif = &x_redisplay_interface;
10846 device->scroll_region_ok = 1; /* We'll scroll partial frames. */ 10846 terminal->scroll_region_ok = 1; /* We'll scroll partial frames. */
10847 device->char_ins_del_ok = 1; 10847 terminal->char_ins_del_ok = 1;
10848 device->line_ins_del_ok = 1; /* We'll just blt 'em. */ 10848 terminal->line_ins_del_ok = 1; /* We'll just blt 'em. */
10849 device->fast_clear_end_of_line = 1; /* X does this well. */ 10849 terminal->fast_clear_end_of_line = 1; /* X does this well. */
10850 device->memory_below_frame = 0; /* We don't remember what scrolls 10850 terminal->memory_below_frame = 0; /* We don't remember what scrolls
10851 off the bottom. */ 10851 off the bottom. */
10852 10852
10853 return device; 10853 return terminal;
10854} 10854}
10855 10855
10856void 10856void
diff --git a/src/xterm.h b/src/xterm.h
index b0464b6cbfa..dfb79d9d90f 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -388,7 +388,7 @@ struct x_display_info
388 } wm_type; 388 } wm_type;
389 389
390 /* The generic display parameters corresponding to this X display. */ 390 /* The generic display parameters corresponding to this X display. */
391 struct device *device; 391 struct terminal *terminal;
392}; 392};
393 393
394#ifdef HAVE_X_I18N 394#ifdef HAVE_X_I18N
@@ -995,7 +995,7 @@ extern void x_wm_set_size_hint P_ ((struct frame *, long, int));
995extern void x_wm_set_window_state P_ ((struct frame *, int)); 995extern void x_wm_set_window_state P_ ((struct frame *, int));
996extern void x_wm_set_icon_pixmap P_ ((struct frame *, int)); 996extern void x_wm_set_icon_pixmap P_ ((struct frame *, int));
997extern void x_delete_display P_ ((struct x_display_info *)); 997extern void x_delete_display P_ ((struct x_display_info *));
998extern void x_delete_device P_ ((struct device *device)); 998extern void x_delete_terminal P_ ((struct terminal *terminal));
999extern void x_initialize P_ ((void)); 999extern void x_initialize P_ ((void));
1000extern unsigned long x_copy_color P_ ((struct frame *, unsigned long)); 1000extern unsigned long x_copy_color P_ ((struct frame *, unsigned long));
1001#ifdef USE_X_TOOLKIT 1001#ifdef USE_X_TOOLKIT