diff options
author | Daniel Colascione <dancol@dancol.org> | 2018-06-08 22:47:27 -0700 |
---|---|---|
committer | Daniel Colascione <dancol@dancol.org> | 2018-06-08 22:51:50 -0700 |
commit | 6fdc3fac5658a7ab142c358cddd90f3db5665ef5 (patch) | |
tree | 543c9c987546e0bf6dc1bf50f4e18dca097436f3 /lisp/term/xterm.el | |
parent | f1e65b73ca20f72717d0b50fa5d983668a49bc38 (diff) | |
download | emacs-6fdc3fac5658a7ab142c358cddd90f3db5665ef5.tar.gz |
Support terminal focus notifications
* lisp/frame.el (handle-focus-in,handle-focus-out): Make event
argument optional.
(blink-cursor-check): Make sure that the current frame is a
window-system frame before restarting the blink timer. TTY frames
can get focus, but don't need a blink timer because the terminal
will do the blinking.
* lisp/term/xterm.el
(xterm-handle-focus-in,xterm-handle-focus-out): New functions.
(xterm-rxvt-function-map): Recognize focus notification sequences.
(xterm--init-focus-tracking): New function.
(terminal-init-xterm): Call it.
Diffstat (limited to 'lisp/term/xterm.el')
-rw-r--r-- | lisp/term/xterm.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el index fea9851d720..6410a4b83c9 100644 --- a/lisp/term/xterm.el +++ b/lisp/term/xterm.el @@ -104,6 +104,16 @@ Return the pasted text as a string." (define-key global-map [xterm-paste] #'xterm-paste) +(defun xterm-handle-focus-in () + (interactive) + (handle-focus-in)) +(define-key global-map [xterm-focus-in] #'xterm-handle-focus-in) + +(defun xterm-handle-focus-out () + (interactive) + (handle-focus-out)) +(define-key global-map [xterm-focus-out] #'xterm-handle-focus-out) + (defvar xterm-rxvt-function-map (let ((map (make-sparse-keymap))) (define-key map "\e[2~" [insert]) @@ -136,6 +146,9 @@ Return the pasted text as a string." ;; internally recognizes the end. (define-key map "\e[200~" [xterm-paste]) + (define-key map "\e[I" [xterm-focus-in]) + (define-key map "\e[O" [xterm-focus-out]) + map) "Keymap of escape sequences, shared between xterm and rxvt support.") @@ -817,6 +830,8 @@ We run the first FUNCTION whose STRING matches the input events." ;; Unconditionally enable bracketed paste mode: terminals that don't ;; support it just ignore the sequence. (xterm--init-bracketed-paste-mode) + ;; We likewise unconditionally enable support for focus tracking. + (xterm--init-focus-tracking) (run-hooks 'terminal-init-xterm-hook)) @@ -832,6 +847,12 @@ We run the first FUNCTION whose STRING matches the input events." (push "\e[?2004l" (terminal-parameter nil 'tty-mode-reset-strings)) (push "\e[?2004h" (terminal-parameter nil 'tty-mode-set-strings))) +(defun xterm--init-focus-tracking () + "Terminal initialization for focus tracking mode." + (send-string-to-terminal "\e[?1004h") + (push "\e[?1004l" (terminal-parameter nil 'tty-mode-reset-strings)) + (push "\e[?1004h" (terminal-parameter nil 'tty-mode-set-strings))) + (defun xterm--init-activate-get-selection () "Terminal initialization for `gui-get-selection'." (set-terminal-parameter nil 'xterm--get-selection t)) |