aboutsummaryrefslogtreecommitdiff
path: root/vterm.el
diff options
context:
space:
mode:
authorTyler Grinn <tylergrinn@gmail.com>2022-04-19 02:16:06 -0400
committerGabriele Bozzola <sbozzolator@gmail.com>2022-04-21 08:35:37 -0700
commit8d7c8c593f528646bd3304e64f4ec47d52c40aec (patch)
tree9db3a46860bc96b678f611eb0bc576dcb381dfbd /vterm.el
parentdccb6b23edb8c983eb2a3862fad3c9602c03b8df (diff)
Add send-next-key function
Read next input event and send it to the libvterm. This is useful for controlling an emacs session within emacs-libvterm.
Diffstat (limited to 'vterm.el')
-rw-r--r--vterm.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/vterm.el b/vterm.el
index 13ead8d..1c8772a 100644
--- a/vterm.el
+++ b/vterm.el
@@ -922,6 +922,23 @@ will invert `vterm-copy-exclude-prompt' for that call."
(memq 'meta modifiers)
(memq 'control modifiers))))
+(defun vterm-send-next-key ()
+ "Read next input event and send it to the libvterm.
+
+With this you can directly send modified keys to applications
+running in the terminal (like Emacs or Nano)."
+ (interactive)
+ (let* ((inhibit-quit t)
+ (event (read-event))
+ (inhibit-quit nil)
+ (modifiers (event-modifiers event))
+ (basic (event-basic-type event)))
+ (if (characterp basic)
+ (vterm-send-key (string basic)
+ (memq 'shift modifiers)
+ (memq 'meta modifiers)
+ (memq 'control modifiers)))))
+
(defun vterm-send-start ()
"Output from the system is started when the system receives START."
(interactive)