summaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/xterm-kitty.el65
1 files changed, 37 insertions, 28 deletions
diff --git a/lisp/xterm-kitty.el b/lisp/xterm-kitty.el
index ed26b91..7d30e20 100644
--- a/lisp/xterm-kitty.el
+++ b/lisp/xterm-kitty.el
@@ -195,28 +195,30 @@ would swap meta and super.")
(defun xterm-kitty-decode-key-stroke (keycode modifiers suffix)
"Take KEYCODE MODIFIERS SUFFIX of the form 105;5u and construct key."
- (if (eql suffix ?u)
- (when (< keycode 57344)
- ;; To do: support remaining keycodes in unicode private use area
- ;; (send-string-to-terminal (format "%s" (logior code (aref xterm-kitty--numeric-modifiers modifiers))))
- (let* ((shifted-key (and (eql (logand modifiers xterm-kitty--shift-modifier)
- xterm-kitty--shift-modifier)
- (alist-get keycode xterm-kitty-shift-alist)))
- ;; The following is equivalent to modifiers & ~shift
- (new-modifiers (and shifted-key (- modifiers xterm-kitty--shift-modifier))))
- (vector (logior (or shifted-key keycode)
- (aref xterm-kitty--numeric-modifiers (if shifted-key new-modifiers modifiers))))))
- (if (eql suffix ?~)
- (if (eql keycode 200)
- (xterm-translate-bracketed-paste nil)
- (aref (aref xterm-kitty--suffix-tilde-precomputed keycode) modifiers))
- (when (<= ?A suffix ?S)
- (if (and (or (eql suffix ?I) (eql suffix ?O))
- (eql keycode 0)
- (eql modifiers 0))
- ;; xterm focus in/out; perhaps there's a better way to do this
- (if (eql suffix ?I) (xterm-translate-focus-in nil) (xterm-translate-focus-out nil))
- (aref (aref xterm-kitty--suffix-alpha-precomputed (- suffix ?A)) modifiers))))))
+ ;; Ignore modifiers that we cannot understand (CapsLock and NumLock status)
+ (let ((mods (logand modifiers (1- (length xterm-kitty--numeric-modifiers)))))
+ (if (eql suffix ?u)
+ (when (< keycode 57344)
+ ;; To do: support remaining keycodes in unicode private use area
+ ;; (send-string-to-terminal (format "%s" (logior keycode (aref xterm-kitty--numeric-modifiers mods))))
+ (let* ((shifted-key (and (eql (logand mods xterm-kitty--shift-modifier)
+ xterm-kitty--shift-modifier)
+ (alist-get keycode xterm-kitty-shift-alist)))
+ ;; The following is equivalent to mods & ~shift
+ (new-modifiers (and shifted-key (- mods xterm-kitty--shift-modifier))))
+ (vector (logior (or shifted-key keycode)
+ (aref xterm-kitty--numeric-modifiers (if shifted-key new-modifiers mods))))))
+ (if (eql suffix ?~)
+ (if (eql keycode 200)
+ (xterm-translate-bracketed-paste nil)
+ (aref (aref xterm-kitty--suffix-tilde-precomputed keycode) mods))
+ (when (<= ?A suffix ?S)
+ (if (and (or (eql suffix ?I) (eql suffix ?O))
+ (eql keycode 0)
+ (eql mods 0))
+ ;; xterm focus in/out; perhaps there's a better way to do this
+ (if (eql suffix ?I) (xterm-translate-focus-in nil) (xterm-translate-focus-out nil))
+ (aref (aref xterm-kitty--suffix-alpha-precomputed (- suffix ?A)) mods)))))))
(defun xterm-kitty-handle-non-printable (keystr)
(let* ((suffix (aref keystr (1- (length keystr))))
@@ -411,15 +413,22 @@ function is almost equivalent to 'event-convert-list'."
(setq payload (gethash "data" parsed-data)))
payload))
-(defun xterm-kitty--elem-has-focus (h)
- (eq (gethash "is_focused" h) t))
(defun xterm-kitty--save-kitty-window-id ()
(let* ((kitty-response (xterm-kitty--remote-control-response))
(response-json (json-parse-string kitty-response))
- (os-win (seq-find 'xterm-kitty--elem-has-focus response-json))
- (win-tab (and os-win (seq-find 'xterm-kitty--elem-has-focus (gethash "tabs" os-win))))
- (win (and win-tab (seq-find 'xterm-kitty--elem-has-focus (gethash "windows" win-tab))))
- (window-id (and win (gethash "id" win))))
+ window-id)
+ (mapc (lambda (os-win)
+ (mapc (lambda (tab)
+ (mapc (lambda (win)
+ (let ((is-self (eq (gethash "is_self" win) t))
+ (win-id (gethash "id" win)))
+ (when is-self
+ (if window-id
+ (message "Multiple windows match: using %s, not %s" window-id win-id)
+ (setq window-id win-id)))))
+ (gethash "windows" tab)))
+ (gethash "tabs" os-win)))
+ response-json)
(puthash (terminal-name) window-id xterm-kitty--window-id-hash-table)))
(defun xterm-kitty-save-window-id ()