mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.1131: getwinpos() does not work in the MS-Windows console
Problem: getwinpos() does not work in the MS-Windows console. Solution: Implement getwinpos().
This commit is contained in:
parent
1164023828
commit
16c34c3765
@ -5985,7 +5985,9 @@ f_getwinpos(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
|
|
||||||
if (rettv_list_alloc(rettv) == FAIL)
|
if (rettv_list_alloc(rettv) == FAIL)
|
||||||
return;
|
return;
|
||||||
#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
|
#if defined(FEAT_GUI) \
|
||||||
|
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
|
||||||
|
|| defined(MSWIN)
|
||||||
{
|
{
|
||||||
varnumber_T timeout = 100;
|
varnumber_T timeout = 100;
|
||||||
|
|
||||||
@ -6007,7 +6009,10 @@ f_getwinpos(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
|
f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
|
||||||
{
|
{
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
|
#if defined(FEAT_GUI) \
|
||||||
|
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
|
||||||
|
|| defined(MSWIN)
|
||||||
|
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
@ -6024,7 +6029,9 @@ f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
|
|||||||
f_getwinposy(typval_T *argvars UNUSED, typval_T *rettv)
|
f_getwinposy(typval_T *argvars UNUSED, typval_T *rettv)
|
||||||
{
|
{
|
||||||
rettv->vval.v_number = -1;
|
rettv->vval.v_number = -1;
|
||||||
#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
|
#if defined(FEAT_GUI) \
|
||||||
|
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
|
||||||
|
|| defined(MSWIN)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
|
@ -3868,7 +3868,9 @@ parse_csi(
|
|||||||
|
|
||||||
// When getting the window position is not possible or it fails it results
|
// When getting the window position is not possible or it fails it results
|
||||||
// in zero/zero.
|
// in zero/zero.
|
||||||
#if defined(FEAT_GUI) || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE))
|
#if defined(FEAT_GUI) \
|
||||||
|
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
|
||||||
|
|| defined(MSWIN)
|
||||||
(void)ui_get_winpos(&x, &y, (varnumber_T)100);
|
(void)ui_get_winpos(&x, &y, (varnumber_T)100);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1889,12 +1889,6 @@ func Test_terminal_statusline()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_getwinpos()
|
func Test_terminal_getwinpos()
|
||||||
" getwinpos() does not work in the MS-Windows console, and the GUI runs the
|
|
||||||
" console version in the terminal window.
|
|
||||||
if has('win32')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
|
|
||||||
" split, go to the bottom-right window
|
" split, go to the bottom-right window
|
||||||
split
|
split
|
||||||
wincmd j
|
wincmd j
|
||||||
@ -1913,10 +1907,17 @@ func Test_terminal_getwinpos()
|
|||||||
let xpos = str2nr(substitute(line, '\[\(\d\+\), \d\+\]', '\1', ''))
|
let xpos = str2nr(substitute(line, '\[\(\d\+\), \d\+\]', '\1', ''))
|
||||||
let ypos = str2nr(substitute(line, '\[\d\+, \(\d\+\)\]', '\1', ''))
|
let ypos = str2nr(substitute(line, '\[\d\+, \(\d\+\)\]', '\1', ''))
|
||||||
|
|
||||||
|
" getwinpos() in the MS-Windows console returns the screen position of the
|
||||||
|
" emulated console.
|
||||||
|
if has('win32')
|
||||||
|
call assert_inrange(0, 4000, xpos)
|
||||||
|
call assert_inrange(0, 2000, ypos)
|
||||||
|
else
|
||||||
" Position must be bigger than the getwinpos() result of Vim itself.
|
" Position must be bigger than the getwinpos() result of Vim itself.
|
||||||
let [xroot, yroot] = getwinpos()
|
let [xroot, yroot] = getwinpos()
|
||||||
call assert_inrange(xroot + 2, xroot + 1000, xpos)
|
call assert_inrange(xroot + 2, xroot + 1000, xpos)
|
||||||
call assert_inrange(yroot + 2, yroot + 1000, ypos)
|
call assert_inrange(yroot + 2, yroot + 1000, ypos)
|
||||||
|
endif
|
||||||
|
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call term_sendkeys(buf, ":q\<CR>")
|
call term_sendkeys(buf, ":q\<CR>")
|
||||||
|
5
src/ui.c
5
src/ui.c
@ -629,6 +629,7 @@ ui_new_shellsize(void)
|
|||||||
|
|
||||||
#if ((defined(FEAT_EVAL) || defined(FEAT_TERMINAL)) \
|
#if ((defined(FEAT_EVAL) || defined(FEAT_TERMINAL)) \
|
||||||
&& (defined(FEAT_GUI) \
|
&& (defined(FEAT_GUI) \
|
||||||
|
|| defined(MSWIN) \
|
||||||
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)))) \
|
|| (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)))) \
|
||||||
|| defined(PROTO)
|
|| defined(PROTO)
|
||||||
/*
|
/*
|
||||||
@ -642,11 +643,15 @@ ui_get_winpos(int *x, int *y, varnumber_T timeout)
|
|||||||
if (gui.in_use)
|
if (gui.in_use)
|
||||||
return gui_mch_get_winpos(x, y);
|
return gui_mch_get_winpos(x, y);
|
||||||
# endif
|
# endif
|
||||||
|
# if defined(MSWIN) && !defined(FEAT_GUI)
|
||||||
|
return mch_get_winpos(x, y);
|
||||||
|
# else
|
||||||
# if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
|
# if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
|
||||||
return term_get_winpos(x, y, timeout);
|
return term_get_winpos(x, y, timeout);
|
||||||
# else
|
# else
|
||||||
return FAIL;
|
return FAIL;
|
||||||
# endif
|
# endif
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -771,6 +771,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1131,
|
||||||
/**/
|
/**/
|
||||||
1130,
|
1130,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user