2020-08-07 23:40:06 -04:00
|
|
|
;;; os/tty/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2022-02-10 19:30:50 +01:00
|
|
|
;; Keep window title up-to-date. Should fail gracefully in non-xterm terminals.
|
2021-04-17 00:18:52 -04:00
|
|
|
;; Only works in Emacs 27+.
|
|
|
|
(setq xterm-set-window-title t)
|
2022-02-10 19:30:37 +01:00
|
|
|
;; DEPRECATED Not needed on Emacs 28+. Remove when dropping 27 support.
|
2021-05-06 00:38:39 -04:00
|
|
|
(defadvice! +tty--only-set-window-title-in-tty-a (&optional terminal)
|
|
|
|
"`xterm-set-window-title' fails in GUI Emacs. Stop that. Get some help."
|
2022-02-10 19:30:37 +01:00
|
|
|
:before-while #'xterm-set-window-title
|
2021-05-06 00:38:39 -04:00
|
|
|
(not (display-graphic-p terminal)))
|
2021-04-17 00:18:52 -04:00
|
|
|
|
2020-08-07 23:40:06 -04:00
|
|
|
;; Some terminals offer two different cursors: a "visible" static cursor and a
|
|
|
|
;; "very visible" blinking one. By default, Emacs uses the very visible cursor
|
|
|
|
;; and will switch back to it when Emacs is started or resumed. A nil
|
|
|
|
;; `visible-cursor' prevents this.
|
|
|
|
(setq visible-cursor nil)
|
|
|
|
|
|
|
|
;; Enable the mouse in terminal Emacs
|
|
|
|
(add-hook 'tty-setup-hook #'xterm-mouse-mode)
|
|
|
|
|
2022-02-10 19:30:50 +01:00
|
|
|
;; Windows terminals don't support what I'm about to do, but best not to wrap
|
2023-12-05 17:05:13 -05:00
|
|
|
;; this in an OS check, in case you're using WSL or Cygwin, which *might*
|
|
|
|
;; support it.
|
2020-08-07 23:40:06 -04:00
|
|
|
(add-hook! 'tty-setup-hook
|
|
|
|
(defun doom-init-clipboard-in-tty-emacs-h ()
|
|
|
|
;; Fix the clipboard in tty Emacs by...
|
2022-08-12 20:29:19 +02:00
|
|
|
(if (modulep! +osc)
|
2020-08-07 23:40:06 -04:00
|
|
|
;; ...communicating with the clibpoard through OSC escape codes (must
|
|
|
|
;; use a terminal that supports it)
|
|
|
|
(and (require 'clipetty nil t)
|
|
|
|
(global-clipetty-mode +1))
|
|
|
|
;; ...OR piping clipboard I/O through xclip, xsel, pb{copy,paste},
|
|
|
|
;; wl-copy, termux-clipboard-get, or getclip (cygwin); depending on what
|
|
|
|
;; is available.
|
|
|
|
(and (require 'xclip nil t)
|
2020-12-14 15:42:15 -06:00
|
|
|
(with-demoted-errors "%s" (xclip-mode +1))))))
|
2020-08-07 23:40:06 -04:00
|
|
|
|
2022-07-22 21:44:26 +02:00
|
|
|
;; Fix cursor shape-changing in the terminal. Only supported in XTerm, Gnome
|
|
|
|
;; Terminal, iTerm, Konsole, dumb (etc. mintty), and Apple Terminal.app. If
|
|
|
|
;; using Apple Terminal.app, install
|
|
|
|
;; http://www.culater.net/software/SIMBL/SIMBL.php and
|
|
|
|
;; https://github.com/saitoha/mouseterm-plus/releases. That makes to support
|
|
|
|
;; VT's DECSCUSR sequence.
|
2024-08-23 17:23:43 -04:00
|
|
|
(use-package! evil-terminal-cursor-changer
|
|
|
|
:hook (tty-setup . evil-terminal-cursor-changer-activate))
|
2024-08-23 17:20:25 -04:00
|
|
|
|
|
|
|
;; Add support for the Kitty keyboard protocol.
|
|
|
|
(use-package! kkp
|
fix(tty): meta keybinds in KKP supported terminals
In a KKP supported terminal, Emacs now receives a number of new input
events from the terminal, like [M-return] and [M-tab], but if they
aren't bound to, they don't fall through to bindings on "M-RET" and
"M-TAB", like [return], [tab], and others do, thus rendering those
keybinds inaccessible. Rather than play whack-a-mole with all the
keymaps out there, I just teach Emacs to let them fall through.
X->Y remappings on `local-function-key-map` do not apply if anything is
bound explicitly to X, so this change bows out if you (or packages, in
the future) do, for some reason, want to bind to them directly.
2024-08-30 20:04:12 -04:00
|
|
|
:hook (after-init . global-kkp-mode)
|
|
|
|
:config
|
|
|
|
;; HACK: Emacs falls back to RET, TAB, and/or DEL if [return], [tab], and/or
|
|
|
|
;; [backspace] are unbound, but this isn't the case for all input events,
|
|
|
|
;; like these, which don't fall back to M-RET, M-TAB, etc. Therefore making
|
|
|
|
;; these keybinds inaccessible in KKP supported terminals.
|
|
|
|
;; REVIEW: See benjaminor/kkp#13.
|
|
|
|
(define-key! local-function-key-map
|
|
|
|
[M-return] (kbd "M-RET")
|
|
|
|
[M-tab] (kbd "M-TAB")
|
|
|
|
[M-backspace] (kbd "M-DEL")
|
|
|
|
[M-delete] (kbd "M-DEL")))
|