How to determine the x and y position of the Vim text window on screen

196 views
Skip to first unread message

Lubos Pintes

unread,
Dec 18, 2014, 5:20:19 AM12/18/14
to vim...@vim.org
Hello,
We have functions winwidth(winnr) and winheight(winnr).
I thing that winleft(winnr) and wintop(winnr), are missing. Perhaps I
greatly overlooked something, I don't know how to determine where the
window with concrete winnr starts.
Any help how to determine window coordinates greatly appreciated.
Thanks

toothpik

unread,
Dec 18, 2014, 11:20:01 AM12/18/14
to vim...@googlegroups.com
if you know all those win_ functions I'm surprised you don't also know
about the winpos command -- without arguments it tells you the current
(gui) window position -- with x and y arguments it will position the
window for you

see

:h winpos

for the gory details

--
_|_ _ __|_|_ ._ o|
|_(_)(_)|_| ||_)||<
|

Lubos Pintes

unread,
Dec 18, 2014, 3:01:39 PM12/18/14
to vim...@vim.org
Hi,
I tried to be as clear as possible, but I am realizing that I was not
clear enough, sorry about that.
I talked about text window, not GUI window.
For example, if I issue the ":split file" command, the window area is
split, this doesn't affect the GUI window. At least I think so.
I am using gvim. I am trying to make it accessible, or better said,
usable with screen reader, NVDA in my case.
I am communicating with gvim through its OLE interface. I can use
information which eval can provide, but it is not enough for proper
usability.
I had some success, but I need to handle a situation when several
windows are on the screen. Again, when text area is split to several
windows.
I don't care about GUI window, it is simulating the console. I am only
interested in text area. I need to identify text window dimensions. So
for example, if only one window is displayed, it starts on (1, 1) and
has a width of 80 and height of 25. Also it has a number 1.
But what if I split the text area say to 4 windows? How can I
algorithmically determine window positions?
Hopefully I explained what I need. And if I am stupid and I overlooked
something obvious, then sorry again.

Dňa 18. 12. 2014 o 17:19 toothpik napísal(a):

Павлов Николай Александрович

unread,
Dec 19, 2014, 1:18:46 AM12/19/14
to vim...@googlegroups.com, Lubos Pintes, vim...@vim.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
>--
>--
>You received this message from the "vim_dev" maillist.
>Do not top-post! Type your reply below the text you are replying to.
>For more information, visit http://www.vim.org/maillist.php
>
>---
>You received this message because you are subscribed to the Google
>Groups "vim_dev" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to vim_dev+u...@googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

You may use pyeval('vim.current.window.col') and pyeval('vim.current.window.row'), same with py3eval. Requires +python (+python3 for py3eval) and running :python import vim (:python3 import vim) prior to using function.

You may check out the code used for implementing __getattribute__ slot function for vim.Window object to create a patch for wincol() and winrow(). At the time I was writing patch that added col and row vim.Window attributes nothing like this existed in VimL.
-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1

iQI1BAEBCgAfBQJUk8MyGBxaeVggPHp5eC52aW1AZ21haWwuY29tPgAKCRCf3UKj
HhHSvs5REACmUHqhxHCG1YNjxiyf4o8W/16rlGfpHxSzR80hHwVz4KhwcCZ96zSV
CCXRdbH8VfKF7ttq/Io5nzakUDBuheIkRtSOshliQfG/1ESHMZZbq29ZBeU1ujUo
b8eQkEP57J0Hc4WkQ2aC2PEEkI6KUIYofQJiKxeUp+JHBu/Vxgvcm4Hm7JMzvDUW
cY5UiMPR3vRpTd/ML3z6sFwzmfpUJtYC1Qa+Zqe1q0cqceDTF2nh9rtBGqnw6Cj2
D7cjIysudQvEw2beTxzhzSpNi6pPMc15LAjlBeNXqJvopR/sZl18celw00EvuxaU
J2rW3nG0Muc0QLI6MZFis6jRlmUeMTYWLO5okI74hLzABAKMtAPz6BuPePF0B3VR
APa3dFE2FpgUgENETlRpK9Acn1aIx1mqHRLFM92CkkK5y0TPUxWmhfUkRktEzgOc
AT4oQVOVeSRX4gReT8IkOBjUM40XZhYqb7//C91Vt9lBC5qdjw0SZtyPi1A0e7dF
xsZ7v4rkogXRA5HnfpoxHxb6j6Ywu/paXLsXBVBk0elJcWPF+KhAht7Vjzg5fTGA
Y9gqyP2oi2IzuV1bOGb9oWsfDrGp6X6xbzWW9NwGMcVKZuSXY3gHYsrC35YGFwwr
iMXKC3DEqEug5K6IrHvxnUd5rYwjGkCDAOOVKcWYr5H982J/APr1UA==
=Ijii
-----END PGP SIGNATURE-----

Shidong Wang

unread,
Jul 7, 2018, 9:11:16 AM7/7/18
to vim_dev
在 2014年12月19日星期五 UTC+8下午2:18:46,ZyX写道:
Hello, any update on this topic? I want to use vim script to get the windows position instead of using `pyeval('vim.current.window.col') `.

Christian Brabandt

unread,
Jul 13, 2018, 5:40:26 PM7/13/18
to vim_dev

On Sa, 07 Jul 2018, Shidong Wang wrote:

> Hello, any update on this topic? I want to use vim script to get the windows position instead of using `pyeval('vim.current.window.col') `.

What exactly is your problem?

Best,
Christian
--
Es ist falsch, mit dem Zahnstocher an Probleme heranzugehen, wenn der
Abbruchhammer verlangt wird.
-- M.S. Salomon (eigentl. Michael Schmidt-Salomon)

Shidong Wang

unread,
Jul 13, 2018, 6:30:34 PM7/13/18
to vim...@googlegroups.com
I want to get the position of a window, but my vim has no +py/+py3 support.

发自我的华为手机

-------- 原始邮件 --------
主题:Re: How to determine the x and y position of the Vim text window on screen
发件人:Christian Brabandt
收件人:vim_dev
抄送:

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to a topic in the Google Groups "vim_dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/_5rtuXn7w7E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_dev+u...@googlegroups.com.

tooth pik

unread,
Jul 13, 2018, 7:30:49 PM7/13/18
to vim...@googlegroups.com
are you looking for :winpos?
> You received this message because you are subscribed to the Google Groups
> "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Tony Mechelynck

unread,
Jul 13, 2018, 7:39:48 PM7/13/18
to vim_dev
On Sat, Jul 14, 2018 at 1:30 AM, tooth pik <toot...@gmail.com> wrote:
> are you looking for :winpos?

No, according to earllier posts in this thread he doesn't want to know
the pixel position of the Vim screen relative to the desktop, but the
position in character cells of the current window (containing one view
on one buffer) relative to the Vim screen.

Best regards,
Tony.

Christian Brabandt

unread,
Jul 14, 2018, 5:38:20 AM7/14/18
to vim_dev
And what :py commands have you been using to get the information? I'll
have a look how hard that would be to add this information to
getwininfo()

Best,
Christian
--
10E12 Mikrophone = 1 Megaphon
10E-6 Fisch = 1 Mikrofiche
10E21 Picolos = 1 Gigolo
10 Rationen = 1 Dekoration
3 1/3 Tridents = 1 Dekadent
10 Monologe = 5 Dialoge
2 Monogramme = 1 Diagramm

Christian Brabandt

unread,
Jul 14, 2018, 4:16:34 PM7/14/18
to vim_dev

On Sa, 14 Jul 2018, Christian Brabandt wrote:
> And what :py commands have you been using to get the information? I'll
> have a look how hard that would be to add this information to
> getwininfo()

Looks like patch 8.1.0184 might solve the problem?

Best,
Christian
--
Charakter im Großen und Kleinen ist, dass der Mensch demjenigen
eine stete Folge gibt, dessen er sich fähig fühlt.
-- Goethe, Maximen und Reflektionen, Nr. 556
Reply all
Reply to author
Forward
0 new messages