mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.1364: there is no easy way to get the window position
Problem: There is no easy way to get the window position.
Solution: Add win_screenpos().
22044dc317
This commit is contained in:
parent
b5cfac0894
commit
b89c08901c
@ -2352,6 +2352,7 @@ win_getid([{win} [, {tab}]]) Number get |window-ID| for {win} in {tab}
|
|||||||
win_gotoid({expr}) Number go to |window-ID| {expr}
|
win_gotoid({expr}) Number go to |window-ID| {expr}
|
||||||
win_id2tabwin({expr}) List get tab and window nr from |window-ID|
|
win_id2tabwin({expr}) List get tab and window nr from |window-ID|
|
||||||
win_id2win({expr}) Number get window nr from |window-ID|
|
win_id2win({expr}) Number get window nr from |window-ID|
|
||||||
|
win_screenpos({nr}) List get screen position of window {nr}
|
||||||
winbufnr({nr}) Number buffer number of window {nr}
|
winbufnr({nr}) Number buffer number of window {nr}
|
||||||
wincol() Number window column of the cursor
|
wincol() Number window column of the cursor
|
||||||
winheight({nr}) Number height of window {nr}
|
winheight({nr}) Number height of window {nr}
|
||||||
@ -8181,6 +8182,14 @@ win_id2win({expr}) *win_id2win()*
|
|||||||
Return the window number of window with ID {expr}.
|
Return the window number of window with ID {expr}.
|
||||||
Return 0 if the window cannot be found in the current tabpage.
|
Return 0 if the window cannot be found in the current tabpage.
|
||||||
|
|
||||||
|
win_screenpos({nr}) *win_screenpos()*
|
||||||
|
Return the screen position of window {nr} as a list with two
|
||||||
|
numbers: [row, col]. The first window always has position
|
||||||
|
[1, 1].
|
||||||
|
{nr} can be the window number or the |window-ID|.
|
||||||
|
Return [0, 0] if the window cannot be found in the current
|
||||||
|
tabpage.
|
||||||
|
|
||||||
*winbufnr()*
|
*winbufnr()*
|
||||||
winbufnr({nr}) The result is a Number, which is the number of the buffer
|
winbufnr({nr}) The result is a Number, which is the number of the buffer
|
||||||
associated with window {nr}. {nr} can be the window number or
|
associated with window {nr}. {nr} can be the window number or
|
||||||
|
@ -10310,6 +10310,15 @@ static void f_getwininfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "win_screenpos()" function
|
||||||
|
static void f_win_screenpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
|
{
|
||||||
|
tv_list_alloc_ret(rettv, 2);
|
||||||
|
const win_T *const wp = find_win_by_nr(&argvars[0], NULL);
|
||||||
|
tv_list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_winrow + 1);
|
||||||
|
tv_list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_wincol + 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "getwinposx()" function
|
* "getwinposx()" function
|
||||||
*/
|
*/
|
||||||
|
@ -338,6 +338,7 @@ return {
|
|||||||
win_gotoid={args=1},
|
win_gotoid={args=1},
|
||||||
win_id2tabwin={args=1},
|
win_id2tabwin={args=1},
|
||||||
win_id2win={args=1},
|
win_id2win={args=1},
|
||||||
|
win_screenpos={args=1},
|
||||||
winbufnr={args=1},
|
winbufnr={args=1},
|
||||||
wincol={},
|
wincol={},
|
||||||
winheight={args=1},
|
winheight={args=1},
|
||||||
|
@ -374,6 +374,19 @@ func Test_equalalways_on_close()
|
|||||||
set equalalways&
|
set equalalways&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_win_screenpos()
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
split
|
||||||
|
vsplit
|
||||||
|
10wincmd _
|
||||||
|
30wincmd |
|
||||||
|
call assert_equal([1, 1], win_screenpos(1))
|
||||||
|
call assert_equal([1, 32], win_screenpos(2))
|
||||||
|
call assert_equal([12, 1], win_screenpos(3))
|
||||||
|
call assert_equal([0, 0], win_screenpos(4))
|
||||||
|
only
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_window_jump_tag()
|
func Test_window_jump_tag()
|
||||||
help
|
help
|
||||||
/iccf
|
/iccf
|
||||||
|
Loading…
Reference in New Issue
Block a user