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:
Jan Edmund Lazo
2018-08-15 11:53:38 -04:00
parent b5cfac0894
commit b89c08901c
4 changed files with 32 additions and 0 deletions

View File

@@ -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
*/

View File

@@ -338,6 +338,7 @@ return {
win_gotoid={args=1},
win_id2tabwin={args=1},
win_id2win={args=1},
win_screenpos={args=1},
winbufnr={args=1},
wincol={},
winheight={args=1},

View File

@@ -374,6 +374,19 @@ func Test_equalalways_on_close()
set equalalways&
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()
help
/iccf