home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / lisp / packages / vt100-led.el < prev    next >
Encoding:
Text File  |  1992-06-29  |  1.8 KB  |  62 lines

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