Some more kkp stuff

This commit is contained in:
Alexander Rosenberg 2024-11-19 18:13:37 -08:00
parent bf1f2a7bfa
commit 4e94728235
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

14
init.el
View File

@ -377,15 +377,19 @@ directory. Otherwise, run `find-file' on that file."
;; kitty keyboard protocol
(use-package kkp
:defer nil
:config
(global-kkp-mode 1)
(defun my/-kkp-after-terminal-setup (&rest _)
(defun my/-kkp-after-terminal-setup ()
;; Make tab and backtab work properly
(define-key input-decode-map [(control ?i)] [tab])
(define-key input-decode-map [(control ?I)] [backtab]))
(defun my/-kkp-after-terminal-teardown (&rest _)
(define-key input-decode-map [(control ?I)] [backtab])
(define-key input-decode-map [(control ?m)] [return]))
(defun my/-kkp-after-terminal-teardown (term)
(with-selected-frame (car (frames-on-display-list term))
(define-key input-decode-map [(control ?i)] nil t)
(define-key input-decode-map [(control ?I)] nil t))
(define-key input-decode-map [(control ?I)] nil t)
(define-key input-decode-map [(control ?m)] nil t)))
(advice-add 'kkp--terminal-setup :after 'my/-kkp-after-terminal-setup)
(advice-add 'kkp--terminal-teardown :after 'my/-kkp-after-terminal-teardown)
(defun my/quoted-insert (arg)
@ -407,7 +411,7 @@ directory. Otherwise, run `find-file' on that file."
(let ((status (kkp--terminal-has-active-kkp-p)))
(unwind-protect
(progn
(when status (kkp--terminal-teardown (kkp--selected-terminal)))
(when status (kkp-disable-in-terminal))
(apply oldfun args))
(when (and status (not (kkp--terminal-has-active-kkp-p)))
;; this does async stuff that will make kitty send characters after