123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- (defvar led-state (make-vector 5 nil)
- "The internal state of the LEDs. Choices are nil, t, `flash'.
- Element 0 is not used.")
- (defun led-flash (l)
- "Flash LED l."
- (aset led-state l 'flash)
- (led-update))
- (defun led-off (&optional l)
- "Turn off vt100 led number L. With no argument, turn them all off."
- (interactive "P")
- (if l
- (aset led-state (prefix-numeric-value l) nil)
- (fillarray led-state nil))
- (led-update))
- (defun led-on (l)
- "Turn on LED L."
- (aset led-state l t)
- (led-update))
- (defun led-update ()
- "Update the terminal's LEDs to reflect the internal state."
- (let ((f "\e[?0")
- (o "\e[0")
- (l 1))
- (while (/= l 5)
- (let ((s (aref led-state l)))
- (cond
- ((eq s 'flash)
- (setq f (concat f ";" (int-to-string l))))
- (s
- (setq o (concat o ";" (int-to-string l))))))
- (setq l (1+ l)))
- (setq o (concat o "q" f "t"))
- (send-string-to-terminal o)))
- (provide 'vt100-led)
|