Created
December 19, 2012 12:27
-
-
Save saitoha/4336343 to your computer and use it in GitHub Desktop.
Get DA2/CPR response from emacs-lisp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun get-da2 () | |
| (let ((str "")) | |
| (send-string-to-terminal "\e[>c") | |
| (while (not (equal (setq chr (read-event nil nil 2)) 99)) | |
| (setq str (concat str (string chr)))) | |
| (if (string-match ">\\([0-9;]+\\)$" str) | |
| (setq params (match-string 1 str))))) | |
| (defun get-cpr () | |
| (let ((str "")) | |
| (send-string-to-terminal "\e[6n") | |
| (while (not (equal (setq chr (read-event nil nil 2)) 82)) | |
| (setq str (concat str (string chr)))) | |
| (if (string-match "\\([0-9;]+\\)$" str) | |
| (setq params (match-string 1 str))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment