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