*** empty log message ***
[emacs.git] / lisp / vt100-led.el
blob2a096a7311b77c2bfca12ff7cb65c75884daf2ac
1 ;;; vt100-led.el --- functions for LED control on VT-100 terminals & clones.
3 ;; Copyright (C) 1988 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 1, or (at your option)
10 ;; any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 ;; Written by Howard Gayle.
24 (defvar led-state (make-vector 5 nil)
25 "The internal state of the LEDs. Choices are nil, t, `flash.
26 Element 0 is not used.")
28 (defun led-flash (l)
29 "Flash LED l."
30 (aset led-state l 'flash)
31 (led-update))
33 (defun led-off (&optional l)
34 "Turn off vt100 led number L. With no argument, turn them all off."
35 (interactive "P")
36 (if l
37 (aset led-state (prefix-numeric-value l) nil)
38 (fillarray led-state nil))
39 (led-update))
41 (defun led-on (l)
42 "Turn on LED l."
43 (aset led-state l t)
44 (led-update))
46 (defun led-update ()
47 "Update the terminal's LEDs to reflect the internal state."
48 (let ((f "\e[?0") ; String to flash.
49 (o "\e[0") ; String for steady on.
50 (l 1)) ; Current LED number.
51 (while (/= l 5)
52 (let ((s (aref led-state l)))
53 (cond
54 ((eq s 'flash)
55 (setq f (concat f ";" (int-to-string l))))
57 (setq o (concat o ";" (int-to-string l))))))
58 (setq l (1+ l)))
59 (setq o (concat o "q" f "t"))
60 (send-string-to-terminal o)))
62 (provide 'vt100-led)
64 ;;; vt100-led.el ends here