Closed kurkale6ka closed 9 years ago
How do I know pangoterm is running? Does it export an environment variable we can check? If not, then I cannot automatically detect it. You can set a variable in your ~/.vimrc to force vim-togglecursor to use a particular escape sequence though:
let g:togglecursor_force = 'xterm'
That works. Thank you. Not sure pangoterm exports a variable to anounce itself. @leonerd?
@kurkale6ka short answer: no
Longer answer: I don't want terminals to end up like early-2000s era web programming, where webapps would serve up one of 20 different stylesheets depending on asking the web browser for its version string.
Programs that run in terminals have a fully interactive communication channel with that terminal. They can ask questions. If you want to know if the terminal you're running on supports DECSCUSR
for setting the cursor shape, and if so which option values it supports, it's easiest and best to just ask it. Far nicer than trying to map some concept of its product name to a table somewhere where you look up a preprogrammed idea of whether the program's author thought the terminal could support it. In many ways that table is always going to be wrong. E.g. you don't currently take account of the exact version of xterm where values 5 and 6 were added. If you just ask the terminal, you'd already cope with that.
Thanks for that detailed answer @leonerd.
Maybe I am asking an obvious thing here but how do you ask? Is there a shell utility for that? stty
?
Or are you talking about other means altogether?
@kurkale6ka stty
operates at the level of the termios(3)
state within the (Linux/etc.../) kernel. It has no bearing on the actual terminal.
The way to ask the terminal is to send a query bytesequence to it. In the case of DECSCUSR
for example, send it the query to ask it the current setting of that mode. If the terminal understands entirely, it'll reply to remind you what the current setting is. If it understands queries generally but not DECSCUSR
specifically it'll reply to say it doesn't understand what mode. If it doesn't understand queries at all, then you'll get no reply and in addition you can surmise it likely doesn't understand setting cursor shapes at all.
The sequence to ask it is called DECRQM
; short for "request mode", and is encoded as
CSI ? Pm $ p
Where Pm
is the mode number to query.
Other than my vterm-ctl
utility that comes as part of libvterm
, I'm not aware of any pre-written shell wrapping utilities for asking this.
Er.. oops; I was misremembering. DECSCUSR
isn't a mode setting, so it doesn't respond to DECRQM
. The way to query that is DECRQSS
; "request status string":
DCS $ q Sp q ST
To which the reply should come back
DCS 1 $ r Pn Sp q ST
Where Pn
gives the current value of the cursor shape.
And how do I do that from Vim?
Without any way of really detecting the terminal through Vim, I'm afraid I can't support auto-detection of pangoterm.
You don't need to know it's pangoterm. That's the point. It declares TERM=xterm
because it recognises the same standard terminal encodings as xterm does. Simply perform whatever activity is required dependent on it being TERM=xterm
and pangoterm will cope.
I cannot simply do that. I need to know the terminal is capable, and I have no way of doing that through Vim.
Well, sure. It is well-known by now that vim in particular gets actively in the way of any kind of modern terminal ability stuff; this doesn't come as news. ;) It may be that neovim will handle it better...
This works for me:
if system('grep -zo pangoterm /proc/"$(xdotool getwindowpid "$(xdotool getactivewindow)")"/cmdline') != ''
let g:togglecursor_force = 'xterm'
endif
but xdotool
has to be installed
@kurkale6ka but of course that's only going to work locally, and only if pangoterm
really is somewhere in the parent tree. It won't help e.g. remotely over ssh, or via screen or tmux, etc...
The way to talk to the terminal is to talk to the terminal, via that convenient channel on stdin and stdout. Nothing else is suitable.
Hi,
Can we add pangoterm to the terminal checks as it supports the feature.
Ta