aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/term
diff options
context:
space:
mode:
authorDaniel Colascione2018-06-08 22:47:27 -0700
committerDaniel Colascione2018-06-08 22:51:50 -0700
commit6fdc3fac5658a7ab142c358cddd90f3db5665ef5 (patch)
tree543c9c987546e0bf6dc1bf50f4e18dca097436f3 /lisp/term
parentf1e65b73ca20f72717d0b50fa5d983668a49bc38 (diff)
downloademacs-6fdc3fac5658a7ab142c358cddd90f3db5665ef5.tar.gz
emacs-6fdc3fac5658a7ab142c358cddd90f3db5665ef5.zip
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')
-rw-r--r--lisp/term/xterm.el21
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."
104 104
105(define-key global-map [xterm-paste] #'xterm-paste) 105(define-key global-map [xterm-paste] #'xterm-paste)
106 106
107(defun xterm-handle-focus-in ()
108 (interactive)
109 (handle-focus-in))
110(define-key global-map [xterm-focus-in] #'xterm-handle-focus-in)
111
112(defun xterm-handle-focus-out ()
113 (interactive)
114 (handle-focus-out))
115(define-key global-map [xterm-focus-out] #'xterm-handle-focus-out)
116
107(defvar xterm-rxvt-function-map 117(defvar xterm-rxvt-function-map
108 (let ((map (make-sparse-keymap))) 118 (let ((map (make-sparse-keymap)))
109 (define-key map "\e[2~" [insert]) 119 (define-key map "\e[2~" [insert])
@@ -136,6 +146,9 @@ Return the pasted text as a string."
136 ;; internally recognizes the end. 146 ;; internally recognizes the end.
137 (define-key map "\e[200~" [xterm-paste]) 147 (define-key map "\e[200~" [xterm-paste])
138 148
149 (define-key map "\e[I" [xterm-focus-in])
150 (define-key map "\e[O" [xterm-focus-out])
151
139 map) 152 map)
140 "Keymap of escape sequences, shared between xterm and rxvt support.") 153 "Keymap of escape sequences, shared between xterm and rxvt support.")
141 154
@@ -817,6 +830,8 @@ We run the first FUNCTION whose STRING matches the input events."
817 ;; Unconditionally enable bracketed paste mode: terminals that don't 830 ;; Unconditionally enable bracketed paste mode: terminals that don't
818 ;; support it just ignore the sequence. 831 ;; support it just ignore the sequence.
819 (xterm--init-bracketed-paste-mode) 832 (xterm--init-bracketed-paste-mode)
833 ;; We likewise unconditionally enable support for focus tracking.
834 (xterm--init-focus-tracking)
820 835
821 (run-hooks 'terminal-init-xterm-hook)) 836 (run-hooks 'terminal-init-xterm-hook))
822 837
@@ -832,6 +847,12 @@ We run the first FUNCTION whose STRING matches the input events."
832 (push "\e[?2004l" (terminal-parameter nil 'tty-mode-reset-strings)) 847 (push "\e[?2004l" (terminal-parameter nil 'tty-mode-reset-strings))
833 (push "\e[?2004h" (terminal-parameter nil 'tty-mode-set-strings))) 848 (push "\e[?2004h" (terminal-parameter nil 'tty-mode-set-strings)))
834 849
850(defun xterm--init-focus-tracking ()
851 "Terminal initialization for focus tracking mode."
852 (send-string-to-terminal "\e[?1004h")
853 (push "\e[?1004l" (terminal-parameter nil 'tty-mode-reset-strings))
854 (push "\e[?1004h" (terminal-parameter nil 'tty-mode-set-strings)))
855
835(defun xterm--init-activate-get-selection () 856(defun xterm--init-activate-get-selection ()
836 "Terminal initialization for `gui-get-selection'." 857 "Terminal initialization for `gui-get-selection'."
837 (set-terminal-parameter nil 'xterm--get-selection t)) 858 (set-terminal-parameter nil 'xterm--get-selection t))