Bram Moolenaar wrote:
Tony Mechelynck wrote:
Bug or feature? When running GUI-enabled Vim in a console (not possible
on W32, but on Unix it is), the has() and exists() functions do not
always reflect the _current_ reality. Examples:
:echo has("gui_gtk2")
1
In the above case it may be regarded as a feature: I can still check
has("gui_running") to know if the GUI is currently enabled, after all.
But:
:echo exists("+guicursor")
1
This makes my vimrc believe that we are in a console version where
'guicursor' is functional -- W32, maybe. Actually, setting 'guicursor'
will give no error but it won't work either: the cursor remains a block
in all modes, even if "hor15" or similar is used. Example:
You checked if the option exists and works. That doesn't mean the value
is used. In this case it's only used in the GUI, thus you still have to
check if the GUI is running.
In a console you can set 'guicursor' and it becomes effective after
doing ":gui".
...but in the MS-DOS console (and maybe in some other future versions?)
it becomes effective even before duing ":gui"; however a different value
should be used than when has("gui_running") is TRUE, because the cursor
width cannot be changed in the console. How should I best test for a Vim
version where 'guicursor' is effective in the console terminal? Which
test should I add, assuming that I already know that has("gui_running")
is FALSE and exists("+guicursor") is TRUE: ":if !has('gui')" or "if
&term == 'pcterm' || &term == 'win32'"? IIUC, neither takes care of the
possibility that some future non-Dos/Windows console version may be able
to set the cursor height by means of 'guicursor' the way the current
Dos/Windows versions do. (Of course I can always change my vimrc again
if and when I encounter such a "future" version but I believe in making
my vimrc as portable as possible, e.g. by testing for all 4 flavours of
GUI when setting 'guifont'.)
Also: Which values should I use in t_SI and t_EI (which are empty by
default) to alternate between a block cursor and an underline cursor in
"linux" and "xterm" terminals? Or is it simply not possible to change
even the cursor height in those consoles? (The Vim help shows how to
change color but not shape, and I don't know where to look for non-Vim
documentation.)
Best regards,
Tony.