Patch 8.2.0257
Problem: Cannot recognize a terminal in a popup window.
Solution: Add the win_gettype() function.
Files: runtime/doc/eval.txt, src/evalfunc.c, src/evalwindow.c,
src/proto/
evalwindow.pro, src/testdir/test_cmdline.vim,
src/testdir/test_terminal.vim,
src/testdir/dumps/Test_terminal_popup_1.dump
*** ../vim-8.2.0256/runtime/doc/eval.txt 2020-02-12 22:15:14.852205223 +0100
--- runtime/doc/eval.txt 2020-02-14 14:18:10.422300852 +0100
***************
*** 10326,10331 ****
--- 10329,10351 ----
Can also be used as a |method|: >
GetWinnr()->win_getid()
+
+ 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.
*** ../vim-8.2.0256/src/evalfunc.c 2020-02-14 13:21:55.642197064 +0100
--- src/evalfunc.c 2020-02-14 14:30:55.230868563 +0100
***************
*** 86,92 ****
static void f_get(typval_T *argvars, typval_T *rettv);
static void f_getchangelist(typval_T *argvars, typval_T *rettv);
static void f_getcharsearch(typval_T *argvars, typval_T *rettv);
- static void f_getcmdwintype(typval_T *argvars, typval_T *rettv);
static void f_getenv(typval_T *argvars, typval_T *rettv);
static void f_getfontname(typval_T *argvars, typval_T *rettv);
static void f_getjumplist(typval_T *argvars, typval_T *rettv);
--- 86,91 ----
***************
*** 845,850 ****
--- 844,850 ----
{"win_execute", 2, 3, FEARG_2, &t_string, f_win_execute},
{"win_findbuf", 1, 1, FEARG_1, &t_list_number, f_win_findbuf},
{"win_getid", 0, 2, FEARG_1, &t_number, f_win_getid},
+ {"win_gettype", 0, 1, FEARG_1, &t_string, f_win_gettype},
{"win_gotoid", 1, 1, FEARG_1, &t_number, f_win_gotoid},
{"win_id2tabwin", 1, 1, FEARG_1, &t_list_number, f_win_id2tabwin},
{"win_id2win", 1, 1, FEARG_1, &t_number, f_win_id2win},
***************
*** 2920,2943 ****
}
/*
- * "getcmdwintype()" function
- */
- static void
- f_getcmdwintype(typval_T *argvars UNUSED, typval_T *rettv)
- {
- rettv->v_type = VAR_STRING;
- rettv->vval.v_string = NULL;
- #ifdef FEAT_CMDWIN
- rettv->vval.v_string = alloc(2);
- if (rettv->vval.v_string != NULL)
- {
- rettv->vval.v_string[0] = cmdwin_type;
- rettv->vval.v_string[1] = NUL;
- }
- #endif
- }
-
- /*
* "getenv()" function
*/
static void
--- 2920,2925 ----
*** ../vim-8.2.0256/src/evalwindow.c 2020-02-03 22:15:22.206649093 +0100
--- src/evalwindow.c 2020-02-14 14:17:29.674576829 +0100
***************
*** 840,845 ****
--- 840,893 ----
}
/*
+ * "win_gettype(nr)" function
+ */
+ void
+ f_win_gettype(typval_T *argvars, typval_T *rettv)
+ {
+ 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;
+ }
+ }
+ #ifdef FEAT_PROP_POPUP
+ if (WIN_IS_POPUP(wp))
+ rettv->vval.v_string = vim_strsave((char_u *)"popup");
+ else
+ #endif
+ #ifdef FEAT_CMDWIN
+ if (wp == curwin && cmdwin_type != 0)
+ rettv->vval.v_string = vim_strsave((char_u *)"command");
+ #endif
+ }
+
+ /*
+ * "getcmdwintype()" function
+ */
+ void
+ f_getcmdwintype(typval_T *argvars UNUSED, typval_T *rettv)
+ {
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
+ #ifdef FEAT_CMDWIN
+ rettv->vval.v_string = alloc(2);
+ if (rettv->vval.v_string != NULL)
+ {
+ rettv->vval.v_string[0] = cmdwin_type;
+ rettv->vval.v_string[1] = NUL;
+ }
+ #endif
+ }
+
+ /*
* "winbufnr(nr)" function
*/
void
*** ../vim-8.2.0256/src/proto/
evalwindow.pro 2019-12-12 12:55:19.000000000 +0100
--- src/proto/
evalwindow.pro 2020-02-14 14:18:55.390012734 +0100
***************
*** 20,25 ****
--- 20,27 ----
void f_win_id2win(typval_T *argvars, typval_T *rettv);
void f_win_screenpos(typval_T *argvars, typval_T *rettv);
void f_win_splitmove(typval_T *argvars, typval_T *rettv);
+ void f_win_gettype(typval_T *argvars, typval_T *rettv);
+ void f_getcmdwintype(typval_T *argvars, typval_T *rettv);
void f_winbufnr(typval_T *argvars, typval_T *rettv);
void f_wincol(typval_T *argvars, typval_T *rettv);
void f_winheight(typval_T *argvars, typval_T *rettv);
*** ../vim-8.2.0256/src/testdir/test_cmdline.vim 2020-02-11 22:03:43.038846226 +0100
--- src/testdir/test_cmdline.vim 2020-02-14 14:17:08.806724039 +0100
***************
*** 894,905 ****
--- 894,907 ----
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
*** ../vim-8.2.0256/src/testdir/test_terminal.vim 2020-02-10 20:33:44.113043189 +0100
--- src/testdir/test_terminal.vim 2020-02-14 14:16:54.766825457 +0100
***************
*** 2333,2338 ****
--- 2333,2339 ----
call writefile(text, 'Xtext')
let cmd = GetVimCommandCleanTerm()
let lines = [
+ \ 'set t_u7=',
\ 'call setline(1, range(20))',
\ 'hi PopTerm ctermbg=grey',
\ 'func OpenTerm(setColor)',
***************
*** 2346,2351 ****
--- 2347,2355 ----
\ 'func HidePopup()',
\ ' call popup_hide(s:winid)',
\ 'endfunc',
+ \ 'sleep 10m',
+ \ 'redraw',
+ \ 'echo getwinvar(s:winid, "&buftype") win_gettype(s:winid)',
\ ]
call writefile(lines, 'XtermPopup')
let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
*** ../vim-8.2.0256/src/testdir/dumps/Test_terminal_popup_1.dump 2020-02-01 21:57:00.848520936 +0100
--- src/testdir/dumps/Test_terminal_popup_1.dump 2020-02-14 14:15:34.355445605 +0100
***************
*** 8,15 ****
|7| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
|8| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
|9| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
! |1|0| @11|║+0#0000001#ffd7ff255|"+0#0000000#ffffff0|X|t|e|x|t|"| |3|L|,| |3|6|C| @11|1|,|1| @10|A|l@1| |║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
|1@1| @11|╚+0#0000001#ffd7ff255|═@44|⇲| +0#0000000#ffffff0@13
|1|2| @72
|1|3| @72
! @57|0|,|0|-|1| @8|A|l@1|
--- 8,15 ----
|7| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
|8| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
|9| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
! |1|0| @11|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@26|1|,|1| @10|A|l@1| |║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13
|1@1| @11|╚+0#0000001#ffd7ff255|═@44|⇲| +0#0000000#ffffff0@13
|1|2| @72
|1|3| @72
! |t|e|r|m|i|n|a|l| |p|o|p|u|p| @42|0|,|0|-|1| @8|A|l@1|
*** ../vim-8.2.0256/src/version.c 2020-02-14 13:21:55.646197062 +0100
--- src/version.c 2020-02-14 13:45:32.088567911 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 257,
/**/
--
hundred-and-one symptoms of being an internet addict:
83. Batteries in the TV remote now last for months.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///