mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 19:25:11 -07: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:
parent
a9186501f6
commit
ede747c2cc
@ -2487,6 +2487,7 @@ wait({timeout}, {condition}[, {interval}])
|
||||
wildmenumode() Number whether 'wildmenu' mode is active
|
||||
win_findbuf({bufnr}) List find windows containing {bufnr}
|
||||
win_getid([{win} [, {tab}]]) Number get |window-ID| for {win} in {tab}
|
||||
win_gettype([{nr}]) String type of window {nr}
|
||||
win_gotoid({expr}) Number go to |window-ID| {expr}
|
||||
win_id2tabwin({expr}) List get tab and window nr from |window-ID|
|
||||
win_id2win({expr}) Number get window nr from |window-ID|
|
||||
@ -9277,6 +9278,21 @@ win_getid([{win} [, {tab}]]) *win_getid()*
|
||||
number {tab}. The first tab has number one.
|
||||
Return zero if the window cannot be found.
|
||||
|
||||
win_gettype([{nr}]) *win_gettype()*
|
||||
Return the type of the window:
|
||||
"popup" popup window |popup|
|
||||
"command" command-line window |cmdwin|
|
||||
(empty) normal window
|
||||
"unknown" window {nr} not found
|
||||
|
||||
When {nr} is omitted return the type of the current window.
|
||||
When {nr} is given return the type of this window by number or
|
||||
|window-ID|.
|
||||
|
||||
Also see the 'buftype' option. When running a terminal in a
|
||||
popup window then 'buftype' is "terminal" and win_gettype()
|
||||
returns "popup".
|
||||
|
||||
win_gotoid({expr}) *win_gotoid()*
|
||||
Go to window with ID {expr}. This may also change the current
|
||||
tabpage.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user