annotate src/evalwindow.c @ 18763:49b78d6465e5 v8.1.2371

patch 8.1.2371: FEAT_TEXT_PROP is a confusing name Commit: https://github.com/vim/vim/commit/05ad5ff0ab34ed9a5296dedd420ca81698b8ce22 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 30 22:48:27 2019 +0100 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name Problem: FEAT_TEXT_PROP is a confusing name. Solution: Use FEAT_PROP_POPUP. (Naruhiko Nishino, closes https://github.com/vim/vim/issues/5291)
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 Nov 2019 23:00:05 +0100
parents f254dd2bc107
children ef3633932b0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * evalwindow.c: Window related builtin functions
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 #if defined(FEAT_EVAL) || defined(PROTO)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 static int
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 win_getid(typval_T *argvars)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 int winnr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 if (argvars[0].v_type == VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 return curwin->w_id;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 winnr = tv_get_number(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 if (winnr > 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 if (argvars[1].v_type == VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 wp = firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 tabpage_T *tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 int tabnr = tv_get_number(&argvars[1]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 FOR_ALL_TABPAGES(tp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 if (--tabnr == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 break;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 if (tp == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 return -1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 if (tp == curtab)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 wp = firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 wp = tp->tp_firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 for ( ; wp != NULL; wp = wp->w_next)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 if (--winnr == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 return wp->w_id;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 return 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 static void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 win_id2tabwin(typval_T *argvars, list_T *list)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 tabpage_T *tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 int winnr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 int tabnr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 int id = tv_get_number(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 FOR_ALL_TABPAGES(tp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 FOR_ALL_WINDOWS_IN_TAB(tp, wp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 if (wp->w_id == id)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 list_append_number(list, tabnr);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 list_append_number(list, winnr);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 ++winnr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 ++tabnr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 winnr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 list_append_number(list, 0);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 list_append_number(list, 0);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 * Return the window pointer of window "id".
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 win_T *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 win_id2wp(int id)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 return win_id2wp_tp(id, NULL);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 * Return the window and tab pointer of window "id".
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 win_T *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 win_id2wp_tp(int id, tabpage_T **tpp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 tabpage_T *tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 FOR_ALL_TAB_WINDOWS(tp, wp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 if (wp->w_id == id)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 if (tpp != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 *tpp = tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 return wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 }
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18259
diff changeset
106 #ifdef FEAT_PROP_POPUP
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 // popup windows are in separate lists
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 FOR_ALL_TABPAGES(tp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 if (wp->w_id == id)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 if (tpp != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 *tpp = tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 return wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 if (wp->w_id == id)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 if (tpp != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 *tpp = tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 return wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 return NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 static int
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 win_id2win(typval_T *argvars)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 int nr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 int id = tv_get_number(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 FOR_ALL_WINDOWS(wp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 if (wp->w_id == id)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 return nr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 ++nr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 return 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 win_findbuf(typval_T *argvars, list_T *list)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 tabpage_T *tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 int bufnr = tv_get_number(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 FOR_ALL_TAB_WINDOWS(tp, wp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 if (wp->w_buffer->b_fnum == bufnr)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 list_append_number(list, wp->w_id);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 * Find window specified by "vp" in tabpage "tp".
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 win_T *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 find_win_by_nr(
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 typval_T *vp,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 tabpage_T *tp) // NULL for current tab page
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 int nr = (int)tv_get_number_chk(vp, NULL);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 if (nr < 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 return NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 if (nr == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 return curwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 FOR_ALL_WINDOWS_IN_TAB(tp, wp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 if (nr >= LOWEST_WIN_ID)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 if (wp->w_id == nr)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 return wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 else if (--nr <= 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 break;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 if (nr >= LOWEST_WIN_ID)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183 {
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18259
diff changeset
184 #ifdef FEAT_PROP_POPUP
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 // check tab-local popup windows
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 for (wp = tp->tp_first_popupwin; wp != NULL; wp = wp->w_next)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 if (wp->w_id == nr)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 return wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 // check global popup windows
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 if (wp->w_id == nr)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 return wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 return NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 return wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 * Find a window: When using a Window ID in any tab page, when using a number
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 * in the current tab page.
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18259
diff changeset
202 * Returns NULL when not found.
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 win_T *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 find_win_by_nr_or_id(typval_T *vp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 int nr = (int)tv_get_number_chk(vp, NULL);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 if (nr >= LOWEST_WIN_ID)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 return win_id2wp(tv_get_number(vp));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 return find_win_by_nr(vp, NULL);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 * Find window specified by "wvp" in tabpage "tvp".
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 * Returns the tab page in 'ptp'
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 win_T *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 find_tabwin(
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 typval_T *wvp, // VAR_UNKNOWN for current window
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 typval_T *tvp, // VAR_UNKNOWN for current tab page
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 tabpage_T **ptp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 win_T *wp = NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 tabpage_T *tp = NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 long n;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 if (wvp->v_type != VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 if (tvp->v_type != VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 n = (long)tv_get_number(tvp);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 if (n >= 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 tp = find_tabpage(n);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 tp = curtab;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 if (tp != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 wp = find_win_by_nr(wvp, tp);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 if (wp == NULL && wvp->v_type == VAR_NUMBER
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 && wvp->vval.v_number != -1)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 // A window with the specified number is not found
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 tp = NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 wp = curwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 tp = curtab;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 if (ptp != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 *ptp = tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 return wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 * Get the layout of the given tab page for winlayout().
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 static void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 get_framelayout(frame_T *fr, list_T *l, int outer)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 frame_T *child;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 list_T *fr_list;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 list_T *win_list;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 if (fr == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 if (outer)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 // outermost call from f_winlayout()
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 fr_list = l;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 fr_list = list_alloc();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 if (fr_list == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 list_append_list(l, fr_list);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 if (fr->fr_layout == FR_LEAF)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 if (fr->fr_win != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 list_append_string(fr_list, (char_u *)"leaf", -1);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 list_append_number(fr_list, fr->fr_win->w_id);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 list_append_string(fr_list,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 fr->fr_layout == FR_ROW ? (char_u *)"row" : (char_u *)"col", -1);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 win_list = list_alloc();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 if (win_list == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 list_append_list(fr_list, win_list);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 child = fr->fr_child;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 while (child != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 get_framelayout(child, win_list, FALSE);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 child = child->fr_next;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 * Common code for tabpagewinnr() and winnr().
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 static int
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 get_winnr(tabpage_T *tp, typval_T *argvar)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 win_T *twin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 int nr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 char_u *arg;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 twin = (tp == curtab) ? curwin : tp->tp_curwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 if (argvar->v_type != VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 int invalid_arg = FALSE;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 arg = tv_get_string_chk(argvar);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 if (arg == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 nr = 0; // type error; errmsg already given
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 else if (STRCMP(arg, "$") == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 twin = (tp == curtab) ? lastwin : tp->tp_lastwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 else if (STRCMP(arg, "#") == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 twin = (tp == curtab) ? prevwin : tp->tp_prevwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 if (twin == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 nr = 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 long count;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 char_u *endp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 // Extract the window count (if specified). e.g. winnr('3j')
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 count = strtol((char *)arg, (char **)&endp, 10);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 if (count <= 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 count = 1; // if count is not specified, default to 1
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 if (endp != NULL && *endp != '\0')
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 if (STRCMP(endp, "j") == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 twin = win_vert_neighbor(tp, twin, FALSE, count);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 else if (STRCMP(endp, "k") == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 twin = win_vert_neighbor(tp, twin, TRUE, count);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 else if (STRCMP(endp, "h") == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 twin = win_horz_neighbor(tp, twin, TRUE, count);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 else if (STRCMP(endp, "l") == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 twin = win_horz_neighbor(tp, twin, FALSE, count);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 invalid_arg = TRUE;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 invalid_arg = TRUE;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 if (invalid_arg)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 semsg(_(e_invexpr2), arg);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366 nr = 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 if (nr > 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 for (wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 wp != twin; wp = wp->w_next)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374 if (wp == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 // didn't find it in this tabpage
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 nr = 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378 break;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 ++nr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 return nr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 * Returns information about a window as a dictionary.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 static dict_T *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 get_win_info(win_T *wp, short tpnr, short winnr)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 dict_T *dict;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 dict = dict_alloc();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 if (dict == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 return NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 dict_add_number(dict, "tabnr", tpnr);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 dict_add_number(dict, "winnr", winnr);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 dict_add_number(dict, "winid", wp->w_id);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 dict_add_number(dict, "height", wp->w_height);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 dict_add_number(dict, "winrow", wp->w_winrow + 1);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 dict_add_number(dict, "topline", wp->w_topline);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 dict_add_number(dict, "botline", wp->w_botline - 1);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 #ifdef FEAT_MENU
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 dict_add_number(dict, "winbar", wp->w_winbar_height);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 dict_add_number(dict, "width", wp->w_width);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 dict_add_number(dict, "wincol", wp->w_wincol + 1);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 dict_add_number(dict, "bufnr", wp->w_buffer->b_fnum);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 #ifdef FEAT_TERMINAL
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 dict_add_number(dict, "terminal", bt_terminal(wp->w_buffer));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 #ifdef FEAT_QUICKFIX
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 dict_add_number(dict, "quickfix", bt_quickfix(wp->w_buffer));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 dict_add_number(dict, "loclist",
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 // Add a reference to window variables
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 dict_add_dict(dict, "variables", wp->w_vars);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 return dict;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 * Returns information (variables, options, etc.) about a tab page
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 * as a dictionary.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 static dict_T *
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 get_tabpage_info(tabpage_T *tp, int tp_idx)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 dict_T *dict;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 list_T *l;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 dict = dict_alloc();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 if (dict == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 return NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 dict_add_number(dict, "tabnr", tp_idx);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 l = list_alloc();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 if (l != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 for (wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 wp != NULL; wp = wp->w_next)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 list_append_number(l, (varnumber_T)wp->w_id);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 dict_add_list(dict, "windows", l);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 // Make a reference to tabpage variables
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 dict_add_dict(dict, "variables", tp->tp_vars);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 return dict;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 * "gettabinfo()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 f_gettabinfo(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 tabpage_T *tp, *tparg = NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 dict_T *d;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 int tpnr = 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 if (rettv_list_alloc(rettv) != OK)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 if (argvars[0].v_type != VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 // Information about one tab page
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 tparg = find_tabpage((int)tv_get_number_chk(&argvars[0], NULL));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 if (tparg == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 // Get information about a specific tab page or all tab pages
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 FOR_ALL_TABPAGES(tp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 tpnr++;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 if (tparg != NULL && tp != tparg)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 continue;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 d = get_tabpage_info(tp, tpnr);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 if (d != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 list_append_dict(rettv->vval.v_list, d);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 if (tparg != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 * "getwininfo()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 f_getwininfo(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 tabpage_T *tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 win_T *wp = NULL, *wparg = NULL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 dict_T *d;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502 short tabnr = 0, winnr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 if (rettv_list_alloc(rettv) != OK)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 if (argvars[0].v_type != VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 wparg = win_id2wp(tv_get_number(&argvars[0]));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 if (wparg == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 // Collect information about either all the windows across all the tab
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 // pages or one particular window.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 FOR_ALL_TABPAGES(tp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 tabnr++;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 winnr = 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 FOR_ALL_WINDOWS_IN_TAB(tp, wp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 winnr++;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 if (wparg != NULL && wp != wparg)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 continue;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 d = get_win_info(wp, tabnr, winnr);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 if (d != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 list_append_dict(rettv->vval.v_list, d);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 if (wparg != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 // found information about a specific window
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 * "getwinpos({timeout})" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 f_getwinpos(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 int x = -1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 int y = -1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 if (rettv_list_alloc(rettv) == FAIL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 #if defined(FEAT_GUI) \
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 || defined(MSWIN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 varnumber_T timeout = 100;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 if (argvars[0].v_type != VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 timeout = tv_get_number(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 (void)ui_get_winpos(&x, &y, timeout);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 list_append_number(rettv->vval.v_list, (varnumber_T)x);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 list_append_number(rettv->vval.v_list, (varnumber_T)y);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 * "getwinposx()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 f_getwinposx(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 rettv->vval.v_number = -1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 #if defined(FEAT_GUI) \
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 || defined(MSWIN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 int x, y;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 if (ui_get_winpos(&x, &y, 100) == OK)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 rettv->vval.v_number = x;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 * "getwinposy()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 f_getwinposy(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 rettv->vval.v_number = -1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 #if defined(FEAT_GUI) \
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 || (defined(HAVE_TGETENT) && defined(FEAT_TERMRESPONSE)) \
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 || defined(MSWIN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 int x, y;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 if (ui_get_winpos(&x, &y, 100) == OK)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 rettv->vval.v_number = y;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 * "tabpagenr()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 f_tabpagenr(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 int nr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 char_u *arg;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 if (argvars[0].v_type != VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 arg = tv_get_string_chk(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 nr = 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 if (arg != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 if (STRCMP(arg, "$") == 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 nr = tabpage_index(NULL) - 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 semsg(_(e_invexpr2), arg);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 nr = tabpage_index(curtab);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 rettv->vval.v_number = nr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 * "tabpagewinnr()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 f_tabpagewinnr(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 int nr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 tabpage_T *tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 tp = find_tabpage((int)tv_get_number(&argvars[0]));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 if (tp == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 nr = 0;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 nr = get_winnr(tp, &argvars[1]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 rettv->vval.v_number = nr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 * "win_execute()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 f_win_execute(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 int id = (int)tv_get_number(argvars);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 tabpage_T *tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 win_T *wp = win_id2wp_tp(id, &tp);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 win_T *save_curwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 tabpage_T *save_curtab;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 if (wp != NULL && tp != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 {
18259
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18084
diff changeset
659 pos_T curpos = wp->w_cursor;
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18084
diff changeset
660
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 if (switch_win_noblock(&save_curwin, &save_curtab, wp, tp, TRUE) == OK)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 check_cursor();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 execute_common(argvars, rettv, 1);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 restore_win_noblock(save_curwin, save_curtab, TRUE);
18259
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18084
diff changeset
667
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18084
diff changeset
668 // Update the status line if the cursor moved.
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18084
diff changeset
669 if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
f254dd2bc107 patch 8.1.2124: ruler is not updated if win_execute() moves cursor
Bram Moolenaar <Bram@vim.org>
parents: 18084
diff changeset
670 wp->w_redr_status = TRUE;
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 * "win_findbuf()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 f_win_findbuf(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 if (rettv_list_alloc(rettv) != FAIL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 win_findbuf(argvars, rettv->vval.v_list);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 * "win_getid()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 f_win_getid(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 rettv->vval.v_number = win_getid(argvars);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 * "win_gotoid()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 f_win_gotoid(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 {
18084
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
699 win_T *wp;
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
700 tabpage_T *tp;
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
701 int id = tv_get_number(&argvars[0]);
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
702
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
703 #ifdef FEAT_CMDWIN
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
704 if (cmdwin_type != 0)
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
705 {
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
706 emsg(_(e_cmdwin));
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
707 return;
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
708 }
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
709 #endif
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
710 FOR_ALL_TAB_WINDOWS(tp, wp)
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
711 if (wp->w_id == id)
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
712 {
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
713 goto_tabpage_win(tp, wp);
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
714 rettv->vval.v_number = 1;
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
715 return;
f4b51934d4f8 patch 8.1.2037: can call win_gotoid() in cmdline window
Bram Moolenaar <Bram@vim.org>
parents: 18049
diff changeset
716 }
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 * "win_id2tabwin()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 f_win_id2tabwin(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 if (rettv_list_alloc(rettv) != FAIL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 win_id2tabwin(argvars, rettv->vval.v_list);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 * "win_id2win()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 f_win_id2win(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
734 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
735 rettv->vval.v_number = win_id2win(argvars);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
739 * "win_screenpos()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742 f_win_screenpos(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
743 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 if (rettv_list_alloc(rettv) == FAIL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749 wp = find_win_by_nr_or_id(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_winrow + 1);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_wincol + 1);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
752 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 /*
18049
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
755 * Move the window wp into a new split of targetwin in a given direction
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
756 */
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
757 static void
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
758 win_move_into_split(win_T *wp, win_T *targetwin, int size, int flags)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
759 {
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
760 int dir;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
761 int height = wp->w_height;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
762 win_T *oldwin = curwin;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
763
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
764 if (wp == targetwin)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
765 return;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
766
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
767 // Jump to the target window
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
768 if (curwin != targetwin)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
769 win_goto(targetwin);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
770
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
771 // Remove the old window and frame from the tree of frames
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
772 (void)winframe_remove(wp, &dir, NULL);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
773 win_remove(wp, NULL);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
774 last_status(FALSE); // may need to remove last status line
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
775 (void)win_comp_pos(); // recompute window positions
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
776
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
777 // Split a window on the desired side and put the old window there
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
778 (void)win_split_ins(size, flags, wp, dir);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
779
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
780 // If splitting horizontally, try to preserve height
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
781 if (size == 0 && !(flags & WSP_VERT))
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
782 {
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
783 win_setheight_win(height, wp);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
784 if (p_ea)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
785 win_equal(wp, TRUE, 'v');
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
786 }
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
787
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
788 #if defined(FEAT_GUI)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
789 // When 'guioptions' includes 'L' or 'R' may have to remove or add
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
790 // scrollbars. Have to update them anyway.
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
791 gui_may_update_scrollbars();
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
792 #endif
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
793
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
794 if (oldwin != curwin)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
795 win_goto(oldwin);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
796 }
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
797
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
798 /*
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
799 * "win_splitmove()" function
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
800 */
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
801 void
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
802 f_win_splitmove(typval_T *argvars, typval_T *rettv)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
803 {
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
804 win_T *wp;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
805 win_T *targetwin;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
806 int flags = 0, size = 0;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
807
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
808 wp = find_win_by_nr_or_id(&argvars[0]);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
809 targetwin = find_win_by_nr_or_id(&argvars[1]);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
810
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
811 if (wp == NULL || targetwin == NULL || wp == targetwin)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
812 {
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
813 emsg(_(e_invalwindow));
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
814 rettv->vval.v_number = -1;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
815 return;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
816 }
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
817
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
818 if (argvars[2].v_type != VAR_UNKNOWN)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
819 {
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
820 dict_T *d;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
821 dictitem_T *di;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
822
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
823 if (argvars[2].v_type != VAR_DICT || argvars[2].vval.v_dict == NULL)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
824 {
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
825 emsg(_(e_invarg));
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
826 return;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
827 }
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
828
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
829 d = argvars[2].vval.v_dict;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
830 if (dict_get_number(d, (char_u *)"vertical"))
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
831 flags |= WSP_VERT;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
832 if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL)
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
833 flags |= tv_get_number(&di->di_tv) ? WSP_BELOW : WSP_ABOVE;
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
834 size = (int)dict_get_number(d, (char_u *)"size");
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
835 }
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
836
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
837 win_move_into_split(wp, targetwin, size, flags);
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
838 }
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
839
a9f1656f13c9 patch 8.1.2020: it is not easy to change the window layout
Bram Moolenaar <Bram@vim.org>
parents: 18010
diff changeset
840 /*
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 * "winbufnr(nr)" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 f_winbufnr(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 wp = find_win_by_nr_or_id(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
849 if (wp == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
850 rettv->vval.v_number = -1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
851 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 rettv->vval.v_number = wp->w_buffer->b_fnum;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
855 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
856 * "wincol()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
857 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
858 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
859 f_wincol(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
860 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
861 validate_cursor();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 rettv->vval.v_number = curwin->w_wcol + 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
863 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 * "winheight(nr)" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869 f_winheight(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
870 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
871 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 wp = find_win_by_nr_or_id(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
874 if (wp == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 rettv->vval.v_number = -1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
876 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 rettv->vval.v_number = wp->w_height;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
879
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881 * "winlayout()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
883 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 f_winlayout(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
885 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 tabpage_T *tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888 if (rettv_list_alloc(rettv) != OK)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 if (argvars[0].v_type == VAR_UNKNOWN)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 tp = curtab;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
895 tp = find_tabpage((int)tv_get_number(&argvars[0]));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 if (tp == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
897 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
898 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 get_framelayout(tp->tp_topframe, rettv->vval.v_list, TRUE);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904 * "winline()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907 f_winline(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 validate_cursor();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 rettv->vval.v_number = curwin->w_wrow + 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 * "winnr()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 f_winnr(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 int nr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 nr = get_winnr(curtab, &argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 rettv->vval.v_number = nr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 * "winrestcmd()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 int winnr = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 garray_T ga;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 char_u buf[50];
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 ga_init2(&ga, (int)sizeof(char), 70);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 FOR_ALL_WINDOWS(wp)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 sprintf((char *)buf, "%dresize %d|", winnr, wp->w_height);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 ga_concat(&ga, buf);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 sprintf((char *)buf, "vert %dresize %d|", winnr, wp->w_width);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 ga_concat(&ga, buf);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 ++winnr;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 ga_append(&ga, NUL);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 rettv->vval.v_string = ga.ga_data;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 rettv->v_type = VAR_STRING;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
949 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 * "winrestview()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955 f_winrestview(typval_T *argvars, typval_T *rettv UNUSED)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957 dict_T *dict;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959 if (argvars[0].v_type != VAR_DICT
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 || (dict = argvars[0].vval.v_dict) == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 emsg(_(e_invarg));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
964 if (dict_find(dict, (char_u *)"lnum", -1) != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, (char_u *)"lnum");
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 if (dict_find(dict, (char_u *)"col", -1) != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 curwin->w_cursor.col = (colnr_T)dict_get_number(dict, (char_u *)"col");
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 if (dict_find(dict, (char_u *)"coladd", -1) != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, (char_u *)"coladd");
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 if (dict_find(dict, (char_u *)"curswant", -1) != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 curwin->w_curswant = (colnr_T)dict_get_number(dict, (char_u *)"curswant");
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 curwin->w_set_curswant = FALSE;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 if (dict_find(dict, (char_u *)"topline", -1) != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 set_topline(curwin, (linenr_T)dict_get_number(dict, (char_u *)"topline"));
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 #ifdef FEAT_DIFF
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 if (dict_find(dict, (char_u *)"topfill", -1) != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 curwin->w_topfill = (int)dict_get_number(dict, (char_u *)"topfill");
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 if (dict_find(dict, (char_u *)"leftcol", -1) != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 curwin->w_leftcol = (colnr_T)dict_get_number(dict, (char_u *)"leftcol");
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 if (dict_find(dict, (char_u *)"skipcol", -1) != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 curwin->w_skipcol = (colnr_T)dict_get_number(dict, (char_u *)"skipcol");
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 check_cursor();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 win_new_height(curwin, curwin->w_height);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 win_new_width(curwin, curwin->w_width);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 changed_window_setting();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
992 if (curwin->w_topline <= 0)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 curwin->w_topline = 1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 if (curwin->w_topline > curbuf->b_ml.ml_line_count)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995 curwin->w_topline = curbuf->b_ml.ml_line_count;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 #ifdef FEAT_DIFF
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997 check_topfill(curwin, TRUE);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003 * "winsaveview()" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 f_winsaveview(typval_T *argvars UNUSED, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1008 dict_T *dict;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010 if (rettv_dict_alloc(rettv) == FAIL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 return;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 dict = rettv->vval.v_dict;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 dict_add_number(dict, "lnum", (long)curwin->w_cursor.lnum);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 dict_add_number(dict, "col", (long)curwin->w_cursor.col);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 dict_add_number(dict, "coladd", (long)curwin->w_cursor.coladd);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1017 update_curswant();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018 dict_add_number(dict, "curswant", (long)curwin->w_curswant);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020 dict_add_number(dict, "topline", (long)curwin->w_topline);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 #ifdef FEAT_DIFF
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 dict_add_number(dict, "topfill", (long)curwin->w_topfill);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 #endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024 dict_add_number(dict, "leftcol", (long)curwin->w_leftcol);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1025 dict_add_number(dict, "skipcol", (long)curwin->w_skipcol);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 * "winwidth(nr)" function
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032 f_winwidth(typval_T *argvars, typval_T *rettv)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1034 win_T *wp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 wp = find_win_by_nr_or_id(&argvars[0]);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 if (wp == NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 rettv->vval.v_number = -1;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 rettv->vval.v_number = wp->w_width;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042 #endif // FEAT_EVAL
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 #if defined(FEAT_EVAL) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 || defined(PROTO)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 * Set "win" to be the curwin and "tp" to be the current tab page.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1048 * restore_win() MUST be called to undo, also when FAIL is returned.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 * No autocommands will be executed until restore_win() is called.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 * When "no_display" is TRUE the display won't be affected, no redraw is
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1051 * triggered, another tabpage access is limited.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 * Returns FAIL if switching to "win" failed.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 int
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 switch_win(
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 win_T **save_curwin,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 tabpage_T **save_curtab,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 win_T *win,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 tabpage_T *tp,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 int no_display)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 block_autocmds();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063 return switch_win_noblock(save_curwin, save_curtab, win, tp, no_display);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 * As switch_win() but without blocking autocommands.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069 int
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070 switch_win_noblock(
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1071 win_T **save_curwin,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1072 tabpage_T **save_curtab,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 win_T *win,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 tabpage_T *tp,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 int no_display)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 *save_curwin = curwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 if (tp != NULL)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 *save_curtab = curtab;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 if (no_display)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 curtab->tp_firstwin = firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084 curtab->tp_lastwin = lastwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085 curtab = tp;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086 firstwin = curtab->tp_firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 lastwin = curtab->tp_lastwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090 goto_tabpage_tp(tp, FALSE, FALSE);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 if (!win_valid(win))
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093 return FAIL;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 curwin = win;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095 curbuf = curwin->w_buffer;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 return OK;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 * Restore current tabpage and window saved by switch_win(), if still valid.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 * When "no_display" is TRUE the display won't be affected, no redraw is
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102 * triggered.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1104 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105 restore_win(
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1106 win_T *save_curwin,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107 tabpage_T *save_curtab,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 int no_display)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1109 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110 restore_win_noblock(save_curwin, save_curtab, no_display);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 unblock_autocmds();
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114 /*
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115 * As restore_win() but without unblocking autocommands.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 */
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1117 void
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1118 restore_win_noblock(
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119 win_T *save_curwin,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120 tabpage_T *save_curtab,
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 int no_display)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 if (save_curtab != NULL && valid_tabpage(save_curtab))
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125 if (no_display)
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1127 curtab->tp_firstwin = firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1128 curtab->tp_lastwin = lastwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1129 curtab = save_curtab;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1130 firstwin = curtab->tp_firstwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131 lastwin = curtab->tp_lastwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1133 else
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1134 goto_tabpage_tp(save_curtab, FALSE, FALSE);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 if (win_valid(save_curwin))
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 {
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1138 curwin = save_curwin;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139 curbuf = curwin->w_buffer;
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 }
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18259
diff changeset
1141 # ifdef FEAT_PROP_POPUP
18010
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1142 else if (WIN_IS_POPUP(curwin))
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 // original window was closed and now we're in a popup window: Go
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 // to the first valid window.
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1145 win_goto(firstwin);
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 # endif
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 }
cf8e0c7e0cb9 patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 #endif