annotate lisp/vt100-led.el @ 617:cde1f15848c6

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Sun, 19 Apr 1992 08:53:55 +0000
parents 3c0c1cd8428a
children d74e65773062
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
583
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 ;; Functions for controlling the LEDs on VT-100 terminals & clones.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2 ;; Copyright (C) 1988 Free Software Foundation, Inc.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 ;; This file is part of GNU Emacs.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 ;; it under the terms of the GNU General Public License as published by
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;; the Free Software Foundation; either version 1, or (at your option)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;; any later version.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; GNU Emacs is distributed in the hope that it will be useful,
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; GNU General Public License for more details.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; You should have received a copy of the GNU General Public License
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; Written by Howard Gayle.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 (defvar led-state (make-vector 5 nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 "The internal state of the LEDs. Choices are nil, t, `flash.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 Element 0 is not used.")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 (defun led-flash (l)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 "Flash LED l."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 (aset led-state l 'flash)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 (led-update))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 (defun led-off (&optional l)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 "Turn off vt100 led number L. With no argument, turn them all off."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 (interactive "P")
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 (if l
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 (aset led-state (prefix-numeric-value l) nil)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 (fillarray led-state nil))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 (led-update))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 (defun led-on (l)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 "Turn on LED l."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 (aset led-state l t)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 (led-update))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 (defun led-update ()
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 "Update the terminal's LEDs to reflect the internal state."
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 (let ((f "\e[?0") ; String to flash.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 (o "\e[0") ; String for steady on.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 (l 1)) ; Current LED number.
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 (while (/= l 5)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 (let ((s (aref led-state l)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (cond
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 ((eq s 'flash)
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (setq f (concat f ";" (int-to-string l))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (s
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 (setq o (concat o ";" (int-to-string l))))))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (setq l (1+ l)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (setq o (concat o "q" f "t"))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (send-string-to-terminal o)))
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60
3c0c1cd8428a Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (provide 'vt100-led)