mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 17:06:30 +00:00
vim-patch:8.2.0257: cannot recognize a terminal in a popup window
Problem: Cannot recognize a terminal in a popup window.
Solution: Add the win_gettype() function.
00f3b4e007
This commit is contained in:
@@ -385,6 +385,7 @@ return {
|
||||
wildmenumode={},
|
||||
win_findbuf={args=1},
|
||||
win_getid={args={0,2}},
|
||||
win_gettype={args={0,1}},
|
||||
win_gotoid={args=1},
|
||||
win_id2tabwin={args=1},
|
||||
win_id2win={args=1},
|
||||
|
@@ -10992,6 +10992,27 @@ static void f_win_getid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
rettv->vval.v_number = win_getid(argvars);
|
||||
}
|
||||
|
||||
/// "win_gettype(nr)" function
|
||||
static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
win_T *wp = curwin;
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = NULL;
|
||||
if (argvars[0].v_type != VAR_UNKNOWN) {
|
||||
wp = find_win_by_nr_or_id(&argvars[0]);
|
||||
if (wp == NULL) {
|
||||
rettv->vval.v_string = vim_strsave((char_u *)"unknown");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (wp->w_floating) {
|
||||
rettv->vval.v_string = vim_strsave((char_u *)"popup");
|
||||
} else if (wp == curwin && cmdwin_type != 0) {
|
||||
rettv->vval.v_string = vim_strsave((char_u *)"command");
|
||||
}
|
||||
}
|
||||
|
||||
/// "win_gotoid()" function
|
||||
static void f_win_gotoid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
|
@@ -806,12 +806,14 @@ func Test_cmdwin_cedit()
|
||||
let g:cmd_wintype = ''
|
||||
func CmdWinType()
|
||||
let g:cmd_wintype = getcmdwintype()
|
||||
let g:wintype = win_gettype()
|
||||
return ''
|
||||
endfunc
|
||||
|
||||
call feedkeys("\<C-c>a\<C-R>=CmdWinType()\<CR>\<CR>")
|
||||
echo input('')
|
||||
call assert_equal('@', g:cmd_wintype)
|
||||
call assert_equal('command', g:wintype)
|
||||
|
||||
set cedit&vim
|
||||
delfunc CmdWinType
|
||||
|
Reference in New Issue
Block a user