annotate lisp/device.el @ 318:afd57c14dfc8 r21-0b57

Import from CVS: tag r21-0b57
author cvs
date Mon, 13 Aug 2007 10:45:36 +0200
parents 558f606b08ae
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; device.el --- miscellaneous device functions not written in C
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994-5, 1997 Free Software Foundation, Inc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995, 1996 Ben Wing
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Keywords: internal, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19 ;; General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 (defun device-list ()
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 "Return a list of all devices."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36 (apply 'nconc (mapcar 'console-device-list (console-list))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38 (defun device-type (&optional device)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39 "Return the type of the specified device (e.g. `x' or `tty').
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 This is equivalent to the type of the device's console.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41 Value is `tty' for a tty device (a character-only terminal),
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 `x' for a device that is a screen on an X display,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43 `ns' for a device that is a NeXTstep connection (not yet implemented),
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 209
diff changeset
44 `mswindows' for a device that is a Windows or Windows NT connection,
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45 `pc' for a device that is a direct-write MS-DOS screen (not yet implemented),
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46 `stream' for a stream device (which acts like a stdio stream), and
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47 `dead' for a deleted device."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
48 (or device (setq device (selected-device)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49 (if (not (device-live-p device)) 'dead
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50 (console-type (device-console device))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52 (defun make-tty-device (&optional tty terminal-type controlling-process)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 "Create a new device on TTY.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 TTY should be the name of a tty device file (e.g. \"/dev/ttyp3\" under
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55 SunOS et al.), as returned by the `tty' command. A value of nil means
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56 use the stdin and stdout as passed to XEmacs from the shell.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57 If TERMINAL-TYPE is non-nil, it should be a string specifying the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 type of the terminal attached to the specified tty. If it is nil,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 the terminal type will be inferred from the TERM environment variable.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60 If CONTROLLING-PROCESS is non-nil, it should be an integer
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 specifying the process id of the process in control of the specified tty. If
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 it is nil, it is assumes to be the value returned by emacs-pid."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 (make-device 'tty tty (list 'terminal-type terminal-type
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 'controlling-process controlling-process)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
66 (defun device-pixel-width (&optional device)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
67 "Return the width in pixels of DEVICE, or nil if unknown."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
68 (let ((ds (device-system-metric device 'size-device)))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
69 (and ds (car ds))))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
70
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
71 (defun device-pixel-height (&optional device)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
72 "Return the height in pixels of DEVICE, or nil if unknown."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
73 (let ((ds (device-system-metric device 'size-device)))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
74 (and ds (cdr ds))))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
75
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
76 (defun device-mm-width (&optional device)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
77 "Return the width in millimeters of DEVICE, or nil if unknown."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
78 (let ((ds (device-system-metric device 'size-device-mm)))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
79 (and ds (car ds))))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
80
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
81 (defun device-mm-height (&optional device)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
82 "Return the height in millimeters of DEVICE, or nil if unknown."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
83 (let ((ds (device-system-metric device 'size-device-mm)))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
84 (and ds (cdr ds))))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
85
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
86 (defun device-bitplanes (&optional device)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
87 "Return the number of bitplanes of DEVICE, or nil if unknown."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
88 (device-system-metric device 'num-bit-planes))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
89
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
90 (defun device-color-cells (&optional device)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
91 "Return the number of color cells of DEVICE, or nil if unknown."
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 282
diff changeset
92 (device-system-metric device 'num-color-cells))
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 213
diff changeset
93
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 (defun make-x-device (&optional display)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95 "Create a new device connected to DISPLAY."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 (make-device 'x display))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 209
diff changeset
98 (defun make-mswindows-device ()
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 209
diff changeset
99 "Create a new mswindows device."
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 209
diff changeset
100 (make-device 'mswindows nil))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102 (defun device-on-window-system-p (&optional device)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103 "Return non-nil if DEVICE is on a window system.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 This generally means that there is support for the mouse, the menubar,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 the toolbar, glyphs, etc."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 (or device (setq device (selected-device)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 (console-on-window-system-p (device-console device)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 (defalias 'valid-device-type-p 'valid-console-type-p)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110 (defalias 'device-type-list 'console-type-list)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 (defalias 'device-pixel-depth 'device-bitplanes)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113 ;;; device.el ends here