annotate lisp/term/tty-init.el @ 23:0edd3412f124

Added tag r19-15b94 for changeset 8fc7fe29b841
author cvs
date Mon, 13 Aug 2007 08:50:31 +0200
parents 376386a54a3c
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; tty-init.el --- initialization code for tty's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996 Ben Wing <wing@666.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: various
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: terminals
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; XEmacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; XEmacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defvar pre-tty-win-initted nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; called both from init-tty-win and from the C code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defun init-pre-tty-win ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 "Initialize TTY at startup (pre). Don't call this."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (if (not pre-tty-win-initted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (let ((esc (char-to-string 27)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (register-tty-color "black" (concat esc "[30m") (concat esc "[40m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (register-tty-color "red" (concat esc "[31m") (concat esc "[41m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (register-tty-color "green" (concat esc "[32m") (concat esc "[42m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (register-tty-color "yellow" (concat esc "[33m") (concat esc "[43m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (register-tty-color "blue" (concat esc "[34m") (concat esc "[44m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (register-tty-color "magenta" (concat esc "[35m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (concat esc "[45m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (register-tty-color "cyan" (concat esc "[36m") (concat esc "[46m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (register-tty-color "white" (concat esc "[37m") (concat esc "[47m"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; define some additional tty colors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (register-tty-color "darkgrey" "\e[1;30m" "\e[1;40m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (register-tty-color "brightred" "\e[1;31m" "\e[1;41m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (register-tty-color "brightgreen" "\e[1;32m" "\e[1;42m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (register-tty-color "brightyellow" "\e[1;33m" "\e[1;43m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (register-tty-color "brightblue" "\e[1;34m" "\e[1;44m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (register-tty-color "brightmagenta" "\e[1;35m" "\e[1;45m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (register-tty-color "brightcyan" "\e[1;36m" "\e[1;46m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (register-tty-color "brightwhite" "\e[1;37m" "\e[1;47m")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setq pre-tty-win-initted t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; called both from init-tty-win and from the C code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; we have to do this for every created TTY console.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defun init-post-tty-win (console)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "Initialize TTY at console creation time (post). Don't call this."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; load the appropriate term-type-specific Lisp file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; we don't do this at startup here so that the user can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; override term-file-prefix. (startup.el does it after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; loading the init file.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (and init-file-loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; temporarily select the console so that the changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; to function-key-map are made for the right console.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (let ((foobar (selected-console)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (select-console console)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (load-terminal-library))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (select-console foobar)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (defvar tty-win-initted nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defun init-tty-win ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 "Initialize TTY at startup. Don't call this."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (not tty-win-initted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (init-pre-tty-win)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (make-tty-device nil nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (init-post-tty-win (selected-console))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq tty-win-initted t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defun make-frame-on-tty (tty &optional parms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "Create a frame on the TTY connection named TTY.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 TTY should be a TTY device such as \"/dev/ttyp3\" (as returned by the `tty'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 command in that TTY), or nil for the standard input/output of the running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 XEmacs process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 PROPS should be an plist of properties, as in the call to `make-frame'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 This function opens a connection to the TTY or reuses an existing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 connection.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 This function is a trivial wrapper around `make-frame-on-device'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (interactive "sMake frame on TTY: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (if (equal tty "") (setq tty nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (make-frame-on-device 'tty tty parms))