gpt4 book ai didi

emacs - 在 Emacs 中显示大写锁定、数字锁定和移位键的状态

转载 作者:行者123 更新时间:2023-12-04 12:13:00 26 4
gpt4 key购买 nike

是否可以在 Emacs 中显示大写锁定和数字锁定键是否打开?我问的原因是因为我是一个单手打字员并且使用FrogPad . 20 键设备使用多个 shift 键序列来拥有标准 qwerty 键盘的全部功能。我会发现在 emacs 中显示 shift、caps lock 和 numlock 键的状态非常有帮助。我用谷歌搜索过这个,只能找到关于重新映射键的帖子。这甚至可能吗?

最佳答案

这在可移植 Emacs 中是不可能的,但如果您使用的是 X11:

(require 'dash)
(require 's)

(defun x-led-mask ()
"Get the current status of the LED mask from X."
(with-temp-buffer
(call-process "xset" nil t nil "q")
(let ((led-mask-string
(->> (buffer-string)
s-lines
(--first (s-contains? "LED mask" it))
s-split-words
-last-item)))
(string-to-number led-mask-string 16))))

(defun caps-lock-on (led-mask)
"Return non-nil if caps lock is on."
(eq (logand led-mask 1) 1))

(define-minor-mode caps-lock-show-mode
"Display whether caps lock is on."
:global t
:lighter (:eval (if (caps-lock-on (x-led-mask)) " CAPS-LOCK" "")))

关于emacs - 在 Emacs 中显示大写锁定、数字锁定和移位键的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6638842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com