Mercurial > emacs
comparison lisp/term/xterm.el @ 81901:7e6412eabecf
(xterm-turn-on-modify-other-keys)
(xterm-turn-off-modify-other-keys): New functions.
(terminal-init-xterm): Enable the modifyOtherKeys feature if the
terminal supports it.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Mon, 16 Jul 2007 04:05:08 +0000 |
parents | 3049bd99b03e |
children | b98604865ea0 fd5b4a865d1d a1be62cbd32a |
comparison
equal
deleted
inserted
replaced
81900:39d8b226d67f | 81901:7e6412eabecf |
---|---|
398 (set-keymap-parent function-key-map map)) | 398 (set-keymap-parent function-key-map map)) |
399 | 399 |
400 ;; Do it! | 400 ;; Do it! |
401 (xterm-register-default-colors) | 401 (xterm-register-default-colors) |
402 ;; This recomputes all the default faces given the colors we've just set up. | 402 ;; This recomputes all the default faces given the colors we've just set up. |
403 (tty-set-up-initial-frame-faces))) | 403 (tty-set-up-initial-frame-faces) |
404 | |
405 ;; Try to turn on the modifyOtherKeys feature on modern xterms. | |
406 ;; When it is turned on much more key bindings work: things like | |
407 ;; C-. C-, etc. | |
408 ;; To do that we need to find out if the current terminal supports | |
409 ;; modifyOtherKeys. At this time only xterm does. | |
410 (let ((coding-system-for-read 'binary) | |
411 (chr nil) | |
412 (str nil)) | |
413 ;; Try to find out the type of terminal by sending a "Secondary | |
414 ;; Device Attributes (DA)" query. | |
415 (send-string-to-terminal "\e[>0c") | |
416 | |
417 ;; The reply should be of the form: \e [ > NUMBER1 ; NUMBER2 ; NUMBER3 c | |
418 (when (equal (read-event nil nil 0.1) ?\e) | |
419 (when (equal (read-event nil nil 0.1) ?\[) | |
420 (while (not (equal (setq chr (read-event nil nil 0.1)) ?c)) | |
421 (setq str (concat str (string chr)))) | |
422 (when (string-match ">0;\\([0-9]+\\);0" str) | |
423 ;; NUMBER2 is the xterm version number, look for something | |
424 ;; greater than 216, the version when modifyOtherKeys was | |
425 ;; introduced. | |
426 (when (>= (string-to-number | |
427 (substring str (match-beginning 1) (match-end 1))) 216) | |
428 ;; Make sure that the modifyOtherKeys state is restored when | |
429 ;; suspending, resuming and exiting. | |
430 (add-hook 'suspend-hook 'xterm-turn-off-modify-other-keys) | |
431 (add-hook 'suspend-resume-hook 'xterm-turn-on-modify-other-keys) | |
432 (add-hook 'kill-emacs-hook 'xterm-turn-off-modify-other-keys) | |
433 (xterm-turn-on-modify-other-keys)))))))) | |
404 | 434 |
405 ;; Set up colors, for those versions of xterm that support it. | 435 ;; Set up colors, for those versions of xterm that support it. |
406 (defvar xterm-standard-colors | 436 (defvar xterm-standard-colors |
407 ;; The names in the comments taken from XTerm-col.ad in the xterm | 437 ;; The names in the comments taken from XTerm-col.ad in the xterm |
408 ;; distribution, see ftp://dickey.his.com/xterm/. RGB values are | 438 ;; distribution, see ftp://dickey.his.com/xterm/. RGB values are |
516 (t (error "Unsupported number of xterm colors (%d)" (+ 16 ncolors))))) | 546 (t (error "Unsupported number of xterm colors (%d)" (+ 16 ncolors))))) |
517 ;; Modifying color mappings means realized faces don't use the | 547 ;; Modifying color mappings means realized faces don't use the |
518 ;; right colors, so clear them. | 548 ;; right colors, so clear them. |
519 (clear-face-cache))) | 549 (clear-face-cache))) |
520 | 550 |
551 (defun xterm-turn-on-modify-other-keys () | |
552 "Turn on the modifyOtherKeys feature of xterm." | |
553 (send-string-to-terminal "\e[>4;1m")) | |
554 | |
555 (defun xterm-turn-off-modify-other-keys () | |
556 "Turn off the modifyOtherKeys feature of xterm." | |
557 (send-string-to-terminal "\e[>4m")) | |
558 | |
521 ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a | 559 ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a |
522 ;;; xterm.el ends here | 560 ;;; xterm.el ends here |