xahlee / xah-fly-keys

the most efficient keybinding for emacs
http://xahlee.info/emacs/misc/xah-fly-keys.html
470 stars 80 forks source link

mode indicator in terminals #96

Open spiderbit opened 4 years ago

spiderbit commented 4 years ago

When I start emacsclient in from a terminal tty/ssh, the cursor doesn't change between a line and a block depending if I am in command-mode or insert-mode, that makes it very hard to see in which Mode you are you only see the I or C in the left bottom corner.

Can that be somehow fixed (some .Xresources line, or other terminal emulator) or could there be some other indicator be used like changing the color of the cursor as example?

(set-cursor-color) also doesn't change the color in the console, so that workaround would also not work.

wi11dey commented 4 years ago

Afaik emacs uses the tty's native cursor to display the cursor, so it would be difficult to implement this. Some terminals may have an escape code they recognize to change the cursor shape or color, but we would probably need to collect a list of these and add it to Emacs itself, so setting cursor-type will do the right thing on ttys

ghost commented 3 years ago

This is how I did it for 'xterm', just adapt to whatever terminal emulator you use.

(defun my/xterm-cursor ()
  "Change the cursor shape in xterm to match the GUI (xah-fly-keys)."
  (unless (display-graphic-p)
    (if xah-fly-insert-state-q
        (send-string-to-terminal "\033[6 q") ; Vertical bar
      (send-string-to-terminal "\033[2 q")))) ; Box
(add-hook 'xah-fly-command-mode-activate-hook #'my/xterm-cursor)
(add-hook 'xah-fly-insert-mode-activate-hook #'my/xterm-cursor)
spiderbit commented 3 years ago

Would that be hard to add that to xah-fly-keys or has any disadvantages?

ghost commented 3 years ago

Terminal emulator's use different ones and IDK anyway to find what terminal you are in from inside GNU Emacs.