Ricky wrote:

> Hi
>
>   I want to see the caps lock's status more easily,  how to display caps
> lock status in status line?
>   It seems that vim don't support.

You can query the status of the LEDs (LED caps lock among other
things) with the Linux command "xset q".

I tried the following but it is not fully satisfactory.  Perhaps someone
can improve on it:

func! ShowCapsLockStatus()
  let xs = system('xset q')
  let mask = matchstr(xs, 'LED mask:\s*\zs\d\+')
  return ((mask % 2) == 0) ? 'off' : 'on'
endfunction

Then you can add something like this in your status line:

set statusline+=%{ShowCapsLockStatus()}        " show caps lock status

However, it is far from being ideal:
- the statusline is not refreshed immediately when pressing Caps-Lock
  (you need to move the cursor for example to see it being refreshed)
  There is no asynchronous event to notify when Caps-Lock key was
  pressed as far as I know.
- ShowCapsLockStatus() messes up display in xterm terminal
  when I move the cursor with the up, down, left, right keys.  I see some
  ^[OA or ^[OB showing up on the screen.  Why?
  Pressing CTRL-L or :redr! makes them disappear.
  I don't see that in gvim.
- And of course "xset q" will only work on Linux

Regards
-- Dominique

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to