From: Dan Nicolaescu <dann@ics.uci.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: read a reply from the terminal
Date: Sat, 14 Jul 2007 17:34:34 -0700 [thread overview]
Message-ID: <200707150034.l6F0YYxT013883@oogie-boogie.ics.uci.edu> (raw)
In-Reply-To: jwvmyxyn5fb.fsf-monnier+emacs@gnu.org
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> > I trying to do: (send-string-to-terminal "\e[>0c") and read the string
> > that the terminal sends back. Can this be done reliably in elisp?
>
> Something like
>
> (let ((coding-system-for-read 'binary))
> (read-event ...))
>
> should give you what you want,
Thanks, that seems to do it.
Here's a patch. It works for me correctly for all the terminals that I
tried it on.
Any objection to putting this in?
*** xterm.el 13 Jun 2007 16:19:48 -0700 1.39
--- xterm.el 14 Jul 2007 17:06:05 -0700
***************
*** 400,406 ****
;; Do it!
(xterm-register-default-colors)
;; This recomputes all the default faces given the colors we've just set up.
! (tty-set-up-initial-frame-faces)))
;; Set up colors, for those versions of xterm that support it.
(defvar xterm-standard-colors
--- 400,436 ----
;; Do it!
(xterm-register-default-colors)
;; This recomputes all the default faces given the colors we've just set up.
! (tty-set-up-initial-frame-faces)
!
! ;; Try to turn on the modifyOtherKeys feature on modern xterms.
! ;; When it is turned on much more key bindings work: things like
! ;; C-. C-, etc.
! ;; To do that we need to find out if the current terminal supports
! ;; modifyOtherKeys. At this time only xterm does.
! (let ((coding-system-for-read 'binary)
! (chr nil)
! (str nil))
! ;; Try to find out the type of terminal by sending a "Secondary
! ;; Device Attributes (DA)" query.
! (send-string-to-terminal "\e[>0c")
!
! ;; The reply should be of the form: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c
! (when (equal (read-event) ?\e)
! (when (equal (read-event) 91)
! (while (not (equal (setq chr (read-event)) ?c))
! (setq str (concat str (string chr))))
! (when (string-match ">[0-9]+;\\([0-9]+\\);[0-9]+" str)
! ;; NUMBER2 is the xterm version number, look for something
! ;; greater than 216, the version when modifyOtherKeys was
! ;; introduced.
! (when (>= (string-to-number
! (substring str (match-beginning 1) (match-end 1))) 216)
! ;; Make sure that the modifyOtherKeys state is restored when
! ;; suspending, resuming and exiting.
! (add-hook 'suspend-hook 'xterm-turn-off-modifyOtherKeys)
! (add-hook 'suspend-resume-hook 'xterm-turn-on-modifyOtherKeys)
! (add-hook 'kill-emacs-hook 'xterm-turn-off-modifyOtherKeys)
! (xterm-turn-on-modifyOtherKeys))))))))
;; Set up colors, for those versions of xterm that support it.
(defvar xterm-standard-colors
***************
*** 518,522 ****
--- 548,560 ----
;; right colors, so clear them.
(clear-face-cache)))
+ (defun xterm-turn-on-modifyOtherKeys ()
+ "Turn on the modifyOtherKeys feature of xterm."
+ (send-string-to-terminal "\e[>4;1m"))
+
+ (defun xterm-turn-off-modifyOtherKeys ()
+ "Turn off the modifyOtherKeys feature of xterm."
+ (send-string-to-terminal "\e[>4m"))
+
;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a
;;; xterm.el ends here
next prev parent reply other threads:[~2007-07-15 0:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-14 2:42 read a reply from the terminal Dan Nicolaescu
2007-07-14 10:39 ` Eli Zaretskii
2007-07-15 13:49 ` Johan Bockgård
2007-07-15 17:19 ` Eli Zaretskii
2007-07-15 22:04 ` Johan Bockgård
2007-07-16 3:11 ` Eli Zaretskii
2007-07-16 19:46 ` Johan Bockgård
2007-07-14 19:37 ` Stefan Monnier
2007-07-15 0:34 ` Dan Nicolaescu [this message]
2007-07-15 1:33 ` Stefan Monnier
2007-07-15 8:18 ` Andreas Schwab
2007-07-15 15:30 ` Dan Nicolaescu
2007-07-15 17:30 ` Eli Zaretskii
2007-07-15 20:42 ` Dan Nicolaescu
2007-08-03 21:54 ` Davis Herring
2007-08-03 22:23 ` Dan Nicolaescu
2007-08-04 1:00 ` Stefan Monnier
2007-07-15 22:53 ` Richard Stallman
2007-07-16 0:56 ` Dan Nicolaescu
2007-07-14 22:16 ` Johan Bockgård
2007-07-14 22:35 ` Eli Zaretskii
2007-07-15 0:24 ` Johan Bockgård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200707150034.l6F0YYxT013883@oogie-boogie.ics.uci.edu \
--to=dann@ics.uci.edu \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.