diff options
| author | Daniel Colascione | 2014-04-17 00:54:23 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2014-04-17 00:54:23 -0700 |
| commit | bfc30790686607fac1b7667d3a73d0f46b80e85f (patch) | |
| tree | d492a6b10405b75ad5341d1e5509b86ad09e75f8 | |
| parent | a3f989d4c430f4788352b2bad801ba99ccf2bb21 (diff) | |
| download | emacs-bfc30790686607fac1b7667d3a73d0f46b80e85f.tar.gz emacs-bfc30790686607fac1b7667d3a73d0f46b80e85f.zip | |
2014-04-17 Daniel Colascione <dancol@dancol.org>
Add support for bracketed paste mode; add infrastructure for
managing terminal mode enabling and disabling automatically.
* xt-mouse.el:
(xterm-mouse-mode): Simplify.
(xterm-mouse-tracking-enable-sequence)
(xterm-mouse-tracking-disable-sequence): New constants.
(turn-on-xterm-mouse-tracking-on-terminal)
(turn-off-xterm-mouse-tracking-on-terminal): Use
tty-mode-set-strings and tty-mode-reset-strings terminal
parameters instead of random hooks.
(turn-on-xterm-mouse-tracking)
(turn-off-xterm-mouse-tracking): Delete.
* term/xterm.el (xterm-extra-capabilities): Fix bitrotted comment.
(xterm-paste-ending-sequence): New constant.
(xterm-paste): New command used for bracketed paste support.
(xterm-modify-other-keys-terminal-list): Delete obsolete variable.
(terminal-init-xterm-bracketed-paste-mode): New function.
(terminal-init-xterm): Call it.
(terminal-init-xterm-modify-other-keys): Use tty-mode-set-strings
and tty-mode-reset-strings instead of random hooks.
(xterm-turn-on-modify-other-keys)
(xterm-turn-off-modify-other-keys)
(xterm-remove-modify-other-keys): Delete obsolete functions.
* term/screen.el: Rewrite to just use the xterm code. Add
copyright notice. Mention tmux.
| -rw-r--r-- | doc/lispref/ChangeLog | 6 | ||||
| -rw-r--r-- | doc/lispref/frames.texi | 12 | ||||
| -rw-r--r-- | etc/ChangeLog | 4 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/ChangeLog | 32 | ||||
| -rw-r--r-- | lisp/term/screen.el | 11 | ||||
| -rw-r--r-- | lisp/term/xterm.el | 82 | ||||
| -rw-r--r-- | lisp/xt-mouse.el | 61 | ||||
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/term.c | 31 |
10 files changed, 178 insertions, 77 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 8adbabc36bb..7c368c126cd 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-04-17 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | * frames.texi (Terminal Parameters): Document new | ||
| 4 | tty-mode-set-strings and tty-mode-reset-strings terminal | ||
| 5 | parameters. | ||
| 6 | |||
| 1 | 2014-04-17 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2014-04-17 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | * Makefile.in (infoclean): Be consistent about reporting failures. | 9 | * Makefile.in (infoclean): Be consistent about reporting failures. |
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index b6513426909..b95a5ccdb92 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi | |||
| @@ -1334,6 +1334,18 @@ terminal. @xref{DEL Does Not Delete,,, emacs, The Emacs Manual}. | |||
| 1334 | @item terminal-initted | 1334 | @item terminal-initted |
| 1335 | After the terminal is initialized, this is set to the | 1335 | After the terminal is initialized, this is set to the |
| 1336 | terminal-specific initialization function. | 1336 | terminal-specific initialization function. |
| 1337 | @item tty-mode-set-strings | ||
| 1338 | When present, a list of strings containing escape sequences that Emacs | ||
| 1339 | will output while configuring a tty for rendering. Emacs emits these | ||
| 1340 | strings only when configuring a terminal: if you want to enable a mode | ||
| 1341 | on a terminal that is already active (for example, while in | ||
| 1342 | @code{tty-setup-hook}), explicitly output the necessary escape | ||
| 1343 | sequence using @code{send-string-to-terminal} in addition to adding | ||
| 1344 | the sequence to @code{tty-mode-set-strings}. | ||
| 1345 | @item tty-mode-reset-strings | ||
| 1346 | When present, a list of strings that undo the effects of the strings | ||
| 1347 | in @code{tty-mode-set-strings}. Emacs emits these strings when | ||
| 1348 | exiting, deleting a terminal, or suspending itself. | ||
| 1337 | @end table | 1349 | @end table |
| 1338 | 1350 | ||
| 1339 | @node Frame Titles | 1351 | @node Frame Titles |
diff --git a/etc/ChangeLog b/etc/ChangeLog index 38693a70f17..1672b0f06ac 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2014-04-17 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | * NEWS: Mention bracketed paste support. | ||
| 4 | |||
| 1 | 2014-04-11 Glenn Morris <rgm@gnu.org> | 5 | 2014-04-11 Glenn Morris <rgm@gnu.org> |
| 2 | 6 | ||
| 3 | * refcards/cs-dired-ref.tex, refcards/cs-refcard.tex: | 7 | * refcards/cs-dired-ref.tex, refcards/cs-refcard.tex: |
| @@ -56,6 +56,13 @@ for use in Emacs bug reports. | |||
| 56 | 56 | ||
| 57 | * Editing Changes in Emacs 24.5 | 57 | * Editing Changes in Emacs 24.5 |
| 58 | 58 | ||
| 59 | Emacs now supports "bracketed paste mode" when running on a terminal | ||
| 60 | that supports it. This facility allows Emacs to understand pasted | ||
| 61 | chunks of text as strings to be inserted instead of interpreting each | ||
| 62 | character in the pasted text as actual user input, resulting in a | ||
| 63 | paste experience similar to that under a window system and significant | ||
| 64 | performance improvements when pasting large amounts of text. | ||
| 65 | |||
| 59 | 66 | ||
| 60 | * Changes in Specialized Modes and Packages in Emacs 24.5 | 67 | * Changes in Specialized Modes and Packages in Emacs 24.5 |
| 61 | 68 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a811b876e3c..ab9240c8f82 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,35 @@ | |||
| 1 | 2014-04-17 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | Add support for bracketed paste mode; add infrastructure for | ||
| 4 | managing terminal mode enabling and disabling automatically. | ||
| 5 | |||
| 6 | * xt-mouse.el: | ||
| 7 | (xterm-mouse-mode): Simplify. | ||
| 8 | (xterm-mouse-tracking-enable-sequence) | ||
| 9 | (xterm-mouse-tracking-disable-sequence): New constants. | ||
| 10 | (turn-on-xterm-mouse-tracking-on-terminal) | ||
| 11 | (turn-off-xterm-mouse-tracking-on-terminal): Use | ||
| 12 | tty-mode-set-strings and tty-mode-reset-strings terminal | ||
| 13 | parameters instead of random hooks. | ||
| 14 | (turn-on-xterm-mouse-tracking) | ||
| 15 | (turn-off-xterm-mouse-tracking): Delete. | ||
| 16 | |||
| 17 | * term/xterm.el (xterm-extra-capabilities): Fix bitrotted comment. | ||
| 18 | (xterm-paste-ending-sequence): New constant. | ||
| 19 | (xterm-paste): New command used for bracketed paste support. | ||
| 20 | |||
| 21 | (xterm-modify-other-keys-terminal-list): Delete obsolete variable. | ||
| 22 | (terminal-init-xterm-bracketed-paste-mode): New function. | ||
| 23 | (terminal-init-xterm): Call it. | ||
| 24 | (terminal-init-xterm-modify-other-keys): Use tty-mode-set-strings | ||
| 25 | and tty-mode-reset-strings instead of random hooks. | ||
| 26 | (xterm-turn-on-modify-other-keys) | ||
| 27 | (xterm-turn-off-modify-other-keys) | ||
| 28 | (xterm-remove-modify-other-keys): Delete obsolete functions. | ||
| 29 | |||
| 30 | * term/screen.el: Rewrite to just use the xterm code. Add | ||
| 31 | copyright notice. Mention tmux. | ||
| 32 | |||
| 1 | 2014-04-17 Ian D <dunni@gnu.org> (tiny change) | 33 | 2014-04-17 Ian D <dunni@gnu.org> (tiny change) |
| 2 | 34 | ||
| 3 | * image-mode.el (image-mode-window-put): Also update the property of | 35 | * image-mode.el (image-mode-window-put): Also update the property of |
diff --git a/lisp/term/screen.el b/lisp/term/screen.el index d37a695086a..69ddda80983 100644 --- a/lisp/term/screen.el +++ b/lisp/term/screen.el | |||
| @@ -1,12 +1,9 @@ | |||
| 1 | ;; Treat a screen terminal similar to an xterm. | 1 | ;;; screen.el --- terminal initialization for screen and tmux -*- lexical-binding: t -*- |
| 2 | (load "term/xterm") | 2 | ;; Copyright (C) 1995, 2001-2014 Free Software Foundation, Inc. |
| 3 | |||
| 4 | (declare-function xterm-register-default-colors "xterm" ()) | ||
| 5 | 3 | ||
| 6 | (defun terminal-init-screen () | 4 | (defun terminal-init-screen () |
| 7 | "Terminal initialization function for screen." | 5 | "Terminal initialization function for screen." |
| 8 | ;; Use the xterm color initialization code. | 6 | ;; Treat a screen terminal similar to an xterm. |
| 9 | (xterm-register-default-colors) | 7 | (tty-run-terminal-initialization (selected-frame) "xterm")) |
| 10 | (tty-set-up-initial-frame-faces)) | ||
| 11 | 8 | ||
| 12 | ;; screen.el ends here | 9 | ;; screen.el ends here |
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index eac40141979..33eb61dac1e 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el | |||
| @@ -43,10 +43,35 @@ The relevant features are: | |||
| 43 | :type '(choice (const :tag "No" nil) | 43 | :type '(choice (const :tag "No" nil) |
| 44 | (const :tag "Check" check) | 44 | (const :tag "Check" check) |
| 45 | ;; NOTE: If you add entries here, make sure to update | 45 | ;; NOTE: If you add entries here, make sure to update |
| 46 | ;; `tocheck-capabilities' in `terminal-init-xterm' as well. | 46 | ;; `terminal-init-xterm' as well. |
| 47 | (set (const :tag "modifyOtherKeys support" modifyOtherKeys) | 47 | (set (const :tag "modifyOtherKeys support" modifyOtherKeys) |
| 48 | (const :tag "report background" reportBackground)))) | 48 | (const :tag "report background" reportBackground)))) |
| 49 | 49 | ||
| 50 | (defconst xterm-paste-ending-sequence "\e[201~" | ||
| 51 | "Characters send by the terminal to end a bracketed paste.") | ||
| 52 | |||
| 53 | (defun xterm-paste () | ||
| 54 | "Handle the start of a terminal paste operation." | ||
| 55 | (interactive) | ||
| 56 | (let* ((end-marker-length (length xterm-paste-ending-sequence)) | ||
| 57 | (pasted-text (with-temp-buffer | ||
| 58 | (set-buffer-multibyte nil) | ||
| 59 | (while (not (search-backward | ||
| 60 | xterm-paste-ending-sequence | ||
| 61 | (- (point) end-marker-length) t)) | ||
| 62 | (let ((event (read-event))) | ||
| 63 | (when (eql event ?\r) | ||
| 64 | (setf event ?\n)) | ||
| 65 | (insert event))) | ||
| 66 | (let ((last-coding-system-used)) | ||
| 67 | (decode-coding-region | ||
| 68 | (point-min) (point) | ||
| 69 | (keyboard-coding-system) t)))) | ||
| 70 | (interprogram-paste-function (lambda () pasted-text))) | ||
| 71 | (yank))) | ||
| 72 | |||
| 73 | (define-key global-map [xterm-paste] #'xterm-paste) | ||
| 74 | |||
| 50 | (defvar xterm-function-map | 75 | (defvar xterm-function-map |
| 51 | (let ((map (make-sparse-keymap))) | 76 | (let ((map (make-sparse-keymap))) |
| 52 | 77 | ||
| @@ -394,6 +419,11 @@ The relevant features are: | |||
| 394 | (define-key map "\e[12~" [f2]) | 419 | (define-key map "\e[12~" [f2]) |
| 395 | (define-key map "\e[13~" [f3]) | 420 | (define-key map "\e[13~" [f3]) |
| 396 | (define-key map "\e[14~" [f4]) | 421 | (define-key map "\e[14~" [f4]) |
| 422 | |||
| 423 | ;; Recognize the start of a bracketed paste sequence. The handler | ||
| 424 | ;; internally recognizes the end. | ||
| 425 | (define-key map "\e[200~" [xterm-paste]) | ||
| 426 | |||
| 397 | map) | 427 | map) |
| 398 | "Function key map overrides for xterm.") | 428 | "Function key map overrides for xterm.") |
| 399 | 429 | ||
| @@ -463,9 +493,6 @@ The relevant features are: | |||
| 463 | map) | 493 | map) |
| 464 | "Keymap of possible alternative meanings for some keys.") | 494 | "Keymap of possible alternative meanings for some keys.") |
| 465 | 495 | ||
| 466 | ;; List of terminals for which modify-other-keys has been turned on. | ||
| 467 | (defvar xterm-modify-other-keys-terminal-list nil) | ||
| 468 | |||
| 469 | (defun xterm--report-background-handler () | 496 | (defun xterm--report-background-handler () |
| 470 | (let ((str "") | 497 | (let ((str "") |
| 471 | chr) | 498 | chr) |
| @@ -595,21 +622,23 @@ We run the first FUNCTION whose STRING matches the input events." | |||
| 595 | (when (memq 'modifyOtherKeys xterm-extra-capabilities) | 622 | (when (memq 'modifyOtherKeys xterm-extra-capabilities) |
| 596 | (terminal-init-xterm-modify-other-keys))) | 623 | (terminal-init-xterm-modify-other-keys))) |
| 597 | 624 | ||
| 625 | ;; Unconditionally enable bracketed paste mode: terminals that don't | ||
| 626 | ;; support it just ignore the sequence. | ||
| 627 | (terminal-init-xterm-bracketed-paste-mode) | ||
| 628 | |||
| 598 | (run-hooks 'terminal-init-xterm-hook)) | 629 | (run-hooks 'terminal-init-xterm-hook)) |
| 599 | 630 | ||
| 600 | (defun terminal-init-xterm-modify-other-keys () | 631 | (defun terminal-init-xterm-modify-other-keys () |
| 601 | "Terminal initialization for xterm's modifyOtherKeys support." | 632 | "Terminal initialization for xterm's modifyOtherKeys support." |
| 602 | ;; Make sure that the modifyOtherKeys state is restored when | 633 | (send-string-to-terminal "\e[>4;1m") |
| 603 | ;; suspending, resuming and exiting. | 634 | (push "\e[>4m" (terminal-parameter nil 'tty-mode-reset-strings)) |
| 604 | (add-hook 'suspend-hook 'xterm-turn-off-modify-other-keys) | 635 | (push "\e[>4;1m" (terminal-parameter nil 'tty-mode-set-strings))) |
| 605 | (add-hook 'suspend-resume-hook 'xterm-turn-on-modify-other-keys) | 636 | |
| 606 | (add-hook 'kill-emacs-hook 'xterm-remove-modify-other-keys) | 637 | (defun terminal-init-xterm-bracketed-paste-mode () |
| 607 | (add-hook 'delete-terminal-functions 'xterm-remove-modify-other-keys) | 638 | "Terminal initialization for bracketed paste mode." |
| 608 | ;; Add the selected frame to the list of frames that | 639 | (send-string-to-terminal "\e[?2004h") |
| 609 | ;; need to deal with modify-other-keys. | 640 | (push "\e[?2004l" (terminal-parameter nil 'tty-mode-reset-strings)) |
| 610 | (push (frame-terminal) | 641 | (push "\e[?2004h" (terminal-parameter nil 'tty-mode-set-strings))) |
| 611 | xterm-modify-other-keys-terminal-list) | ||
| 612 | (xterm-turn-on-modify-other-keys)) | ||
| 613 | 642 | ||
| 614 | ;; Set up colors, for those versions of xterm that support it. | 643 | ;; Set up colors, for those versions of xterm that support it. |
| 615 | (defvar xterm-standard-colors | 644 | (defvar xterm-standard-colors |
| @@ -727,29 +756,6 @@ versions of xterm." | |||
| 727 | ;; right colors, so clear them. | 756 | ;; right colors, so clear them. |
| 728 | (clear-face-cache))) | 757 | (clear-face-cache))) |
| 729 | 758 | ||
| 730 | (defun xterm-turn-on-modify-other-keys () | ||
| 731 | "Turn the modifyOtherKeys feature of xterm back on." | ||
| 732 | (let ((terminal (frame-terminal))) | ||
| 733 | (when (and (terminal-live-p terminal) | ||
| 734 | (memq terminal xterm-modify-other-keys-terminal-list)) | ||
| 735 | (send-string-to-terminal "\e[>4;1m" terminal)))) | ||
| 736 | |||
| 737 | (defun xterm-turn-off-modify-other-keys (&optional frame) | ||
| 738 | "Temporarily turn off the modifyOtherKeys feature of xterm." | ||
| 739 | (let ((terminal (when frame (frame-terminal frame)))) | ||
| 740 | (when (and (terminal-live-p terminal) | ||
| 741 | (memq terminal xterm-modify-other-keys-terminal-list)) | ||
| 742 | (send-string-to-terminal "\e[>4m" terminal)))) | ||
| 743 | |||
| 744 | (defun xterm-remove-modify-other-keys (&optional terminal) | ||
| 745 | "Turn off the modifyOtherKeys feature of xterm for good." | ||
| 746 | (setq terminal (or terminal (frame-terminal))) | ||
| 747 | (when (and (terminal-live-p terminal) | ||
| 748 | (memq terminal xterm-modify-other-keys-terminal-list)) | ||
| 749 | (setq xterm-modify-other-keys-terminal-list | ||
| 750 | (delq terminal xterm-modify-other-keys-terminal-list)) | ||
| 751 | (send-string-to-terminal "\e[>4m" terminal))) | ||
| 752 | |||
| 753 | (defun xterm-maybe-set-dark-background-mode (redc greenc bluec) | 759 | (defun xterm-maybe-set-dark-background-mode (redc greenc bluec) |
| 754 | ;; Use the heuristic in `frame-set-background-mode' to decide if a | 760 | ;; Use the heuristic in `frame-set-background-mode' to decide if a |
| 755 | ;; frame is dark. | 761 | ;; frame is dark. |
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index 26a07b46840..b03b2c95394 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el | |||
| @@ -263,36 +263,27 @@ single clicks are supported. When turned on, the normal xterm | |||
| 263 | mouse functionality for such clicks is still available by holding | 263 | mouse functionality for such clicks is still available by holding |
| 264 | down the SHIFT key while pressing the mouse button." | 264 | down the SHIFT key while pressing the mouse button." |
| 265 | :global t :group 'mouse | 265 | :global t :group 'mouse |
| 266 | (let ((do-hook (if xterm-mouse-mode 'add-hook 'remove-hook))) | 266 | (funcall (if xterm-mouse-mode 'add-hook 'remove-hook) |
| 267 | (funcall do-hook 'terminal-init-xterm-hook | 267 | 'terminal-init-xterm-hook |
| 268 | 'turn-on-xterm-mouse-tracking-on-terminal) | 268 | 'turn-on-xterm-mouse-tracking-on-terminal) |
| 269 | (funcall do-hook 'delete-terminal-functions | ||
| 270 | 'turn-off-xterm-mouse-tracking-on-terminal) | ||
| 271 | (funcall do-hook 'suspend-tty-functions | ||
| 272 | 'turn-off-xterm-mouse-tracking-on-terminal) | ||
| 273 | (funcall do-hook 'resume-tty-functions | ||
| 274 | 'turn-on-xterm-mouse-tracking-on-terminal) | ||
| 275 | (funcall do-hook 'suspend-hook 'turn-off-xterm-mouse-tracking) | ||
| 276 | (funcall do-hook 'suspend-resume-hook 'turn-on-xterm-mouse-tracking) | ||
| 277 | (funcall do-hook 'kill-emacs-hook 'turn-off-xterm-mouse-tracking)) | ||
| 278 | (if xterm-mouse-mode | 269 | (if xterm-mouse-mode |
| 279 | ;; Turn it on | 270 | ;; Turn it on |
| 280 | (progn | 271 | (progn |
| 281 | (setq mouse-position-function #'xterm-mouse-position-function) | 272 | (setq mouse-position-function #'xterm-mouse-position-function) |
| 282 | (turn-on-xterm-mouse-tracking)) | 273 | (mapc #'turn-on-xterm-mouse-tracking-on-terminal (terminal-list))) |
| 283 | ;; Turn it off | 274 | ;; Turn it off |
| 284 | (turn-off-xterm-mouse-tracking 'force) | 275 | (mapc #'turn-off-xterm-mouse-tracking-on-terminal (terminal-list)) |
| 285 | (setq mouse-position-function nil))) | 276 | (setq mouse-position-function nil))) |
| 286 | 277 | ||
| 287 | (defun turn-on-xterm-mouse-tracking () | 278 | (defconst xterm-mouse-tracking-enable-sequence |
| 288 | "Enable Emacs mouse tracking in xterm." | 279 | "\e[?1000h\e[?1006h" |
| 289 | (dolist (terminal (terminal-list)) | 280 | "Control sequence to enable xterm mouse tracking. |
| 290 | (turn-on-xterm-mouse-tracking-on-terminal terminal))) | 281 | Enables basic tracking, then extended tracking on |
| 282 | terminals that support it.") | ||
| 291 | 283 | ||
| 292 | (defun turn-off-xterm-mouse-tracking (&optional _force) | 284 | (defconst xterm-mouse-tracking-disable-sequence |
| 293 | "Disable Emacs mouse tracking in xterm." | 285 | "\e[?1006l\e[?1000l" |
| 294 | (dolist (terminal (terminal-list)) | 286 | "Reset the modes set by `xterm-mouse-tracking-enable-sequence'.") |
| 295 | (turn-off-xterm-mouse-tracking-on-terminal terminal))) | ||
| 296 | 287 | ||
| 297 | (defun turn-on-xterm-mouse-tracking-on-terminal (&optional terminal) | 288 | (defun turn-on-xterm-mouse-tracking-on-terminal (&optional terminal) |
| 298 | "Enable xterm mouse tracking on TERMINAL." | 289 | "Enable xterm mouse tracking on TERMINAL." |
| @@ -302,30 +293,36 @@ down the SHIFT key while pressing the mouse button." | |||
| 302 | (not (string= (terminal-name terminal) "initial_terminal"))) | 293 | (not (string= (terminal-name terminal) "initial_terminal"))) |
| 303 | (unless (terminal-parameter terminal 'xterm-mouse-mode) | 294 | (unless (terminal-parameter terminal 'xterm-mouse-mode) |
| 304 | ;; Simulate selecting a terminal by selecting one of its frames | 295 | ;; Simulate selecting a terminal by selecting one of its frames |
| 296 | ;; so that we can set the terminal-local `input-decode-map'. | ||
| 305 | (with-selected-frame (car (frames-on-display-list terminal)) | 297 | (with-selected-frame (car (frames-on-display-list terminal)) |
| 306 | (define-key input-decode-map "\e[M" 'xterm-mouse-translate) | 298 | (define-key input-decode-map "\e[M" 'xterm-mouse-translate) |
| 307 | (define-key input-decode-map "\e[<" 'xterm-mouse-translate-extended)) | 299 | (define-key input-decode-map "\e[<" 'xterm-mouse-translate-extended)) |
| 308 | (set-terminal-parameter terminal 'xterm-mouse-mode t)) | 300 | (send-string-to-terminal xterm-mouse-tracking-enable-sequence terminal) |
| 309 | (send-string-to-terminal "\e[?1000h" terminal) | 301 | (push xterm-mouse-tracking-enable-sequence |
| 310 | ;; Request extended mouse support, if available (xterm >= 277). | 302 | (terminal-parameter nil 'tty-mode-set-strings)) |
| 311 | (send-string-to-terminal "\e[?1006h" terminal))) | 303 | (push xterm-mouse-tracking-disable-sequence |
| 304 | (terminal-parameter nil 'tty-mode-reset-strings)) | ||
| 305 | (set-terminal-parameter terminal 'xterm-mouse-mode t)))) | ||
| 312 | 306 | ||
| 313 | (defun turn-off-xterm-mouse-tracking-on-terminal (terminal) | 307 | (defun turn-off-xterm-mouse-tracking-on-terminal (terminal) |
| 314 | "Disable xterm mouse tracking on TERMINAL." | 308 | "Disable xterm mouse tracking on TERMINAL." |
| 315 | ;; Only send the disable command to those terminals to which we've already | 309 | ;; Only send the disable command to those terminals to which we've already |
| 316 | ;; sent the enable command. | 310 | ;; sent the enable command. |
| 317 | (when (and (terminal-parameter terminal 'xterm-mouse-mode) | 311 | (when (and (terminal-parameter terminal 'xterm-mouse-mode) |
| 318 | (eq t (terminal-live-p terminal)) | 312 | (eq t (terminal-live-p terminal))) |
| 319 | ;; Avoid the initial terminal which is not a termcap device. | ||
| 320 | ;; FIXME: is there more elegant way to detect the initial terminal? | ||
| 321 | (not (string= (terminal-name terminal) "initial_terminal"))) | ||
| 322 | ;; We could remove the key-binding and unset the `xterm-mouse-mode' | 313 | ;; We could remove the key-binding and unset the `xterm-mouse-mode' |
| 323 | ;; terminal parameter, but it seems less harmful to send this escape | 314 | ;; terminal parameter, but it seems less harmful to send this escape |
| 324 | ;; command too many times (or to catch an unintended key sequence), than | 315 | ;; command too many times (or to catch an unintended key sequence), than |
| 325 | ;; to send it too few times (or to fail to let xterm-mouse events | 316 | ;; to send it too few times (or to fail to let xterm-mouse events |
| 326 | ;; pass by untranslated). | 317 | ;; pass by untranslated). |
| 327 | (send-string-to-terminal "\e[?1000l" terminal) | 318 | (send-string-to-terminal xterm-mouse-tracking-disable-sequence terminal) |
| 328 | (send-string-to-terminal "\e[?1006l" terminal))) | 319 | (setf (terminal-parameter nil 'tty-mode-set-strings) |
| 320 | (remq xterm-mouse-tracking-enable-sequence | ||
| 321 | (terminal-parameter nil 'tty-mode-set-strings))) | ||
| 322 | (setf (terminal-parameter nil 'tty-mode-reset-strings) | ||
| 323 | (remq xterm-mouse-tracking-disable-sequence | ||
| 324 | (terminal-parameter nil 'tty-mode-reset-strings))) | ||
| 325 | (set-terminal-parameter terminal 'xterm-mouse-mode nil))) | ||
| 329 | 326 | ||
| 330 | (provide 'xt-mouse) | 327 | (provide 'xt-mouse) |
| 331 | 328 | ||
diff --git a/src/ChangeLog b/src/ChangeLog index b3cc3ff32ec..e916fc03fde 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2014-04-17 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | * term.c (Qtty_mode_set_strings, Qtty_mode_reset_strings): New | ||
| 4 | symbols. | ||
| 5 | (tty_send_additional_strings): New function. | ||
| 6 | (tty_set_terminal_modes, tty_reset_terminal_modes): Use it. | ||
| 7 | (syms_of_term): Intern tty-mode-set-strings and | ||
| 8 | tty-mode-reset-strings. | ||
| 9 | |||
| 1 | 2014-04-16 Stefan Monnier <monnier@iro.umontreal.ca> | 10 | 2014-04-16 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 11 | ||
| 3 | * window.c (save_window_save): Lookup window_point_insertion_type in | 12 | * window.c (save_window_save): Lookup window_point_insertion_type in |
diff --git a/src/term.c b/src/term.c index 47be788f31a..9d9d682a544 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -131,6 +131,9 @@ enum no_color_bit | |||
| 131 | 131 | ||
| 132 | static int max_frame_cols; | 132 | static int max_frame_cols; |
| 133 | 133 | ||
| 134 | static Lisp_Object Qtty_mode_set_strings; | ||
| 135 | static Lisp_Object Qtty_mode_reset_strings; | ||
| 136 | |||
| 134 | 137 | ||
| 135 | 138 | ||
| 136 | #ifdef HAVE_GPM | 139 | #ifdef HAVE_GPM |
| @@ -162,6 +165,29 @@ tty_ring_bell (struct frame *f) | |||
| 162 | /* Set up termcap modes for Emacs. */ | 165 | /* Set up termcap modes for Emacs. */ |
| 163 | 166 | ||
| 164 | static void | 167 | static void |
| 168 | tty_send_additional_strings (struct terminal* terminal, Lisp_Object sym) | ||
| 169 | { | ||
| 170 | Lisp_Object lisp_terminal; | ||
| 171 | Lisp_Object extra_codes; | ||
| 172 | struct tty_display_info *tty = terminal->display_info.tty; | ||
| 173 | |||
| 174 | XSETTERMINAL (lisp_terminal, terminal); | ||
| 175 | for (extra_codes = Fterminal_parameter (lisp_terminal, sym); | ||
| 176 | CONSP (extra_codes); | ||
| 177 | extra_codes = XCDR (extra_codes)) | ||
| 178 | { | ||
| 179 | Lisp_Object string = XCAR (extra_codes); | ||
| 180 | if (STRINGP (string)) | ||
| 181 | { | ||
| 182 | fwrite (SDATA (string), 1, SBYTES (string), tty->output); | ||
| 183 | fflush (tty->output); | ||
| 184 | if (tty->termscript) | ||
| 185 | fwrite (SDATA (string), 1, SBYTES (string), tty->termscript); | ||
| 186 | } | ||
| 187 | } | ||
| 188 | } | ||
| 189 | |||
| 190 | static void | ||
| 165 | tty_set_terminal_modes (struct terminal *terminal) | 191 | tty_set_terminal_modes (struct terminal *terminal) |
| 166 | { | 192 | { |
| 167 | struct tty_display_info *tty = terminal->display_info.tty; | 193 | struct tty_display_info *tty = terminal->display_info.tty; |
| @@ -184,6 +210,7 @@ tty_set_terminal_modes (struct terminal *terminal) | |||
| 184 | OUTPUT_IF (tty, tty->TS_keypad_mode); | 210 | OUTPUT_IF (tty, tty->TS_keypad_mode); |
| 185 | losecursor (tty); | 211 | losecursor (tty); |
| 186 | fflush (tty->output); | 212 | fflush (tty->output); |
| 213 | tty_send_additional_strings (terminal, Qtty_mode_set_strings); | ||
| 187 | } | 214 | } |
| 188 | } | 215 | } |
| 189 | 216 | ||
| @@ -196,6 +223,7 @@ tty_reset_terminal_modes (struct terminal *terminal) | |||
| 196 | 223 | ||
| 197 | if (tty->output) | 224 | if (tty->output) |
| 198 | { | 225 | { |
| 226 | tty_send_additional_strings (terminal, Qtty_mode_reset_strings); | ||
| 199 | tty_turn_off_highlight (tty); | 227 | tty_turn_off_highlight (tty); |
| 200 | tty_turn_off_insert (tty); | 228 | tty_turn_off_insert (tty); |
| 201 | OUTPUT_IF (tty, tty->TS_end_keypad_mode); | 229 | OUTPUT_IF (tty, tty->TS_end_keypad_mode); |
| @@ -4562,6 +4590,9 @@ bigger, or it may make it blink, or it may do nothing at all. */); | |||
| 4562 | encode_terminal_src = NULL; | 4590 | encode_terminal_src = NULL; |
| 4563 | encode_terminal_dst = NULL; | 4591 | encode_terminal_dst = NULL; |
| 4564 | 4592 | ||
| 4593 | DEFSYM (Qtty_mode_set_strings, "tty-mode-set-strings"); | ||
| 4594 | DEFSYM (Qtty_mode_reset_strings, "tty-mode-reset-strings"); | ||
| 4595 | |||
| 4565 | #ifndef MSDOS | 4596 | #ifndef MSDOS |
| 4566 | DEFSYM (Qtty_menu_next_item, "tty-menu-next-item"); | 4597 | DEFSYM (Qtty_menu_next_item, "tty-menu-next-item"); |
| 4567 | DEFSYM (Qtty_menu_prev_item, "tty-menu-prev-item"); | 4598 | DEFSYM (Qtty_menu_prev_item, "tty-menu-prev-item"); |