gettabwinvar({tabnr}, {winnr}, {name} [, {def}])
any {name} in {winnr} in tab page {tabnr}
getwininfo([{winid}]) List list of windows
-getwinposx() Number X coord in pixels of GUI Vim window
-getwinposy() Number Y coord in pixels of GUI Vim window
+getwinpos([{tmeout}]) List X and Y coord in pixels of the Vim window
+getwinposx() Number X coord in pixels of the Vim window
+getwinposy() Number Y coord in pixels of the Vim window
getwinvar({nr}, {varname} [, {def}])
any variable {varname} in window {nr}
glob({expr} [, {nosuf} [, {list} [, {alllinks}]]])
:let list_is_on = gettabwinvar(1, 2, '&list')
:echo "myvar = " . gettabwinvar(3, 1, 'myvar')
<
+getwinpos([{timeout}]) *getwinpos()*
+ The result is a list with two numbers, the result of
+ getwinposx() and getwinposy() combined:
+ [x-pos, y-pos]
+ {timeout} can be used to specify how long to wait in msec for
+ a response from the terminal. When omitted 100 msec is used.
+
*getwinposx()*
getwinposx() The result is a Number, which is the X coordinate in pixels of
the left hand side of the GUI Vim window. Also works for an
- xterm.
+ xterm (uses a timeout of 100 msec).
The result will be -1 if the information is not available.
The value can be used with `:winpos`.
*getwinposy()*
getwinposy() The result is a Number, which is the Y coordinate in pixels of
- the top of the GUI Vim window. Also works for an xterm.
+ the top of the GUI Vim window. Also works for an xterm (uses
+ a timeout of 100 msec).
The result will be -1 if the information is not available.
The value can be used with `:winpos`.
static void f_gettabvar(typval_T *argvars, typval_T *rettv);
static void f_gettabwinvar(typval_T *argvars, typval_T *rettv);
static void f_getwininfo(typval_T *argvars, typval_T *rettv);
+static void f_getwinpos(typval_T *argvars, typval_T *rettv);
static void f_getwinposx(typval_T *argvars, typval_T *rettv);
static void f_getwinposy(typval_T *argvars, typval_T *rettv);
static void f_getwinvar(typval_T *argvars, typval_T *rettv);
{"gettabvar", 2, 3, f_gettabvar},
{"gettabwinvar", 3, 4, f_gettabwinvar},
{"getwininfo", 0, 1, f_getwininfo},
+ {"getwinpos", 0, 1, f_getwinpos},
{"getwinposx", 0, 0, f_getwinposx},
{"getwinposy", 0, 0, f_getwinposy},
{"getwinvar", 2, 3, f_getwinvar},
list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_wincol + 1);
}
+/*
+ * "getwinpos({timeout})" function
+ */
+ static void
+f_getwinpos(typval_T *argvars UNUSED, typval_T *rettv)
+{
+ int x = -1;
+ int y = -1;
+
+ if (rettv_list_alloc(rettv) == FAIL)
+ return;
+#ifdef FEAT_GUI
+ if (gui.in_use)
+ gui_mch_get_winpos(&x, &y);
+# if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
+ else
+# endif
+#endif
+#if defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)
+ {
+ varnumber_T timeout = 100;
+
+ if (argvars[0].v_type != VAR_UNKNOWN)
+ timeout = get_tv_number(&argvars[0]);
+ term_get_winpos(&x, &y, timeout);
+ }
+#endif
+ list_append_number(rettv->vval.v_list, (varnumber_T)x);
+ list_append_number(rettv->vval.v_list, (varnumber_T)y);
+}
+
+
/*
* "getwinposx()" function
*/
{
int x, y;
- if (term_get_winpos(&x, &y) == OK)
+ if (term_get_winpos(&x, &y, (varnumber_T)100) == OK)
rettv->vval.v_number = x;
}
#endif
{
int x, y;
- if (term_get_winpos(&x, &y) == OK)
+ if (term_get_winpos(&x, &y, (varnumber_T)100) == OK)
rettv->vval.v_number = y;
}
#endif