annotate src/popupwin.c @ 18492:41a5f241e9d5 v8.1.2240

patch 8.1.2240: popup window width changes when scrolling Commit: https://github.com/vim/vim/commit/f2885d3fb7045d14ae58824e9cb8dea65e4052c4 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Nov 2 20:21:25 2019 +0100 patch 8.1.2240: popup window width changes when scrolling Problem: Popup window width changes when scrolling. Solution: Also adjust maxwidth when applying minwidth and there is a scrollbar. Fix off-by-one error. (closes #5162)
author Bram Moolenaar <Bram@vim.org>
date Sat, 02 Nov 2019 20:30:03 +0100
parents 144fa40ee706
children e855058e0c23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read a list of people who contributed.
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * Implementation of popup windows. See ":help popup".
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
16 #if defined(FEAT_TEXT_PROP) || defined(PROTO)
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
18 typedef struct {
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
19 char *pp_name;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
20 poppos_T pp_val;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
21 } poppos_entry_T;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
22
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
23 static poppos_entry_T poppos_entries[] = {
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
24 {"botleft", POPPOS_BOTLEFT},
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
25 {"topleft", POPPOS_TOPLEFT},
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
26 {"botright", POPPOS_BOTRIGHT},
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
27 {"topright", POPPOS_TOPRIGHT},
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
28 {"center", POPPOS_CENTER}
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
29 };
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
30
17789
0f7ae8010787 patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
31 static void popup_adjust_position(win_T *wp);
0f7ae8010787 patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
32
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 /*
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
34 * Get option value for "key", which is "line" or "col".
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
35 * Handles "cursor+N" and "cursor-N".
17879
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
36 * Returns MAXCOL if the entry is not present.
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
37 */
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
38 static int
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
39 popup_options_one(dict_T *dict, char_u *key)
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
40 {
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
41 dictitem_T *di;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
42 char_u *val;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
43 char_u *s;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
44 char_u *endp;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
45 int n = 0;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
46
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
47 di = dict_find(dict, key, -1);
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
48 if (di == NULL)
17879
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
49 return MAXCOL;
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
50
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
51 val = tv_get_string(&di->di_tv);
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
52 if (STRNCMP(val, "cursor", 6) != 0)
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
53 return dict_get_number_check(dict, key);
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
54
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
55 setcursor_mayforce(TRUE);
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
56 s = val + 6;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
57 if (*s != NUL)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
58 {
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
59 endp = s;
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
60 if (*skipwhite(s) == '+' || *skipwhite(s) == '-')
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
61 n = strtol((char *)s, (char **)&endp, 10);
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
62 if (endp != NULL && *skipwhite(endp) != NUL)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
63 {
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
64 semsg(_(e_invexpr2), val);
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
65 return 0;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
66 }
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
67 }
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
68
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
69 if (STRCMP(key, "line") == 0)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
70 n = screen_screenrow() + 1 + n;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
71 else // "col"
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
72 n = screen_screencol() + 1 + n;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
73
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
74 // Zero means "not set", use -1 instead.
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
75 if (n == 0)
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
76 n = -1;
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
77 return n;
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
78 }
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
79
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
80 static void
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
81 set_padding_border(dict_T *dict, int *array, char *name, int max_val)
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
82 {
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
83 dictitem_T *di;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
84
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
85 di = dict_find(dict, (char_u *)name, -1);
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
86 if (di != NULL)
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
87 {
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
88 if (di->di_tv.v_type != VAR_LIST)
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
89 emsg(_(e_listreq));
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
90 else
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
91 {
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
92 list_T *list = di->di_tv.vval.v_list;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
93 listitem_T *li;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
94 int i;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
95 int nr;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
96
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
97 for (i = 0; i < 4; ++i)
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
98 array[i] = 1;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
99 if (list != NULL)
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
100 for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
101 ++i, li = li->li_next)
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
102 {
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
103 nr = (int)tv_get_number(&li->li_tv);
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
104 if (nr >= 0)
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
105 array[i] = nr > max_val ? max_val : nr;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
106 }
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
107 }
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
108 }
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
109 }
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
110
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
111 /*
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
112 * Used when popup options contain "moved": set default moved values.
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
113 */
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
114 static void
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
115 set_moved_values(win_T *wp)
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
116 {
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
117 wp->w_popup_curwin = curwin;
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
118 wp->w_popup_lnum = curwin->w_cursor.lnum;
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
119 wp->w_popup_mincol = curwin->w_cursor.col;
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
120 wp->w_popup_maxcol = curwin->w_cursor.col;
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
121 }
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
122
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
123 /*
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
124 * Used when popup options contain "moved" with "word" or "WORD".
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
125 */
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
126 static void
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
127 set_moved_columns(win_T *wp, int flags)
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
128 {
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
129 char_u *ptr;
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
130 int len = find_ident_under_cursor(&ptr, flags | FIND_NOERROR);
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
131
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
132 if (len > 0)
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
133 {
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
134 wp->w_popup_mincol = (int)(ptr - ml_get_curline());
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
135 wp->w_popup_maxcol = wp->w_popup_mincol + len - 1;
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
136 }
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
137 }
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
138
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
139 /*
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
140 * Used when popup options contain "mousemoved": set default moved values.
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
141 */
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
142 static void
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
143 set_mousemoved_values(win_T *wp)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
144 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
145 wp->w_popup_mouse_row = mouse_row;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
146 wp->w_popup_mouse_mincol = mouse_col;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
147 wp->w_popup_mouse_maxcol = mouse_col;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
148 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
149
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
150 /*
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
151 * Used when popup options contain "moved" with "word" or "WORD".
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
152 */
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
153 static void
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
154 set_mousemoved_columns(win_T *wp, int flags)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
155 {
17320
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
156 win_T *textwp;
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
157 char_u *text;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
158 int col;
17320
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
159 pos_T pos;
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
160 colnr_T mcol;
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
161
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
162 if (find_word_under_cursor(mouse_row, mouse_col, TRUE, flags,
17320
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
163 &textwp, &pos.lnum, &text, NULL, &col) == OK)
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
164 {
17320
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
165 // convert text column to mouse column
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
166 pos.col = col;
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
167 pos.coladd = 0;
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
168 getvcol(textwp, &pos, &mcol, NULL, NULL);
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
169 wp->w_popup_mouse_mincol = mcol;
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
170
17328
12c1f01b304e patch 8.1.1663: compiler warning for using size_t
Bram Moolenaar <Bram@vim.org>
parents: 17320
diff changeset
171 pos.col = col + (colnr_T)STRLEN(text) - 1;
17320
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
172 getvcol(textwp, &pos, NULL, NULL, &mcol);
33dccaafb214 patch 8.1.1659: popup window "mousemoved" values not correct
Bram Moolenaar <Bram@vim.org>
parents: 17318
diff changeset
173 wp->w_popup_mouse_maxcol = mcol;
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
174 vim_free(text);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
175 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
176 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
177
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
178 /*
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
179 * Return TRUE if "row"/"col" is on the border of the popup.
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
180 * The values are relative to the top-left corner.
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
181 */
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
182 int
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
183 popup_on_border(win_T *wp, int row, int col)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
184 {
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
185 return (row == 0 && wp->w_popup_border[0] > 0)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
186 || (row == popup_height(wp) - 1 && wp->w_popup_border[2] > 0)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
187 || (col == 0 && wp->w_popup_border[3] > 0)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
188 || (col == popup_width(wp) - 1 && wp->w_popup_border[1] > 0);
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
189 }
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
190
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
191 /*
17847
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
192 * Return TRUE and close the popup if "row"/"col" is on the "X" button of the
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
193 * popup and w_popup_close is POPCLOSE_BUTTON.
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
194 * The values are relative to the top-left corner.
17847
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
195 * Caller should check the left mouse button was clicked.
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
196 * Return TRUE if the popup was closed.
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
197 */
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
198 int
17847
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
199 popup_close_if_on_X(win_T *wp, int row, int col)
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
200 {
17847
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
201 if (wp->w_popup_close == POPCLOSE_BUTTON
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
202 && row == 0 && col == popup_width(wp) - 1)
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
203 {
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
204 popup_close_for_mouse_click(wp);
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
205 return TRUE;
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
206 }
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
207 return FALSE;
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
208 }
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
209
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
210 // Values set when dragging a popup window starts.
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
211 static int drag_start_row;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
212 static int drag_start_col;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
213 static int drag_start_wantline;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
214 static int drag_start_wantcol;
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
215 static int drag_on_resize_handle;
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
216
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
217 /*
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
218 * Mouse down on border of popup window: start dragging it.
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
219 * Uses mouse_col and mouse_row.
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
220 */
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
221 void
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
222 popup_start_drag(win_T *wp, int row, int col)
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
223 {
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
224 drag_start_row = mouse_row;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
225 drag_start_col = mouse_col;
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
226 if (wp->w_wantline <= 0)
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
227 drag_start_wantline = wp->w_winrow + 1;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
228 else
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
229 drag_start_wantline = wp->w_wantline;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
230 if (wp->w_wantcol == 0)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
231 drag_start_wantcol = wp->w_wincol + 1;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
232 else
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
233 drag_start_wantcol = wp->w_wantcol;
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
234
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
235 // Stop centering the popup
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
236 if (wp->w_popup_pos == POPPOS_CENTER)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
237 wp->w_popup_pos = POPPOS_TOPLEFT;
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
238
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
239 drag_on_resize_handle = wp->w_popup_border[1] > 0
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
240 && wp->w_popup_border[2] > 0
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
241 && row == popup_height(wp) - 1
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
242 && col == popup_width(wp) - 1;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
243
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
244 if (wp->w_popup_pos != POPPOS_TOPLEFT && drag_on_resize_handle)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
245 {
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
246 if (wp->w_popup_pos == POPPOS_TOPRIGHT
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
247 || wp->w_popup_pos == POPPOS_BOTRIGHT)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
248 wp->w_wantcol = wp->w_wincol + 1;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
249 if (wp->w_popup_pos == POPPOS_BOTLEFT)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
250 wp->w_wantline = wp->w_winrow + 1;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
251 wp->w_popup_pos = POPPOS_TOPLEFT;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
252 }
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
253 }
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
254
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
255 /*
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
256 * Mouse moved while dragging a popup window: adjust the window popup position
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
257 * or resize.
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
258 */
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
259 void
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
260 popup_drag(win_T *wp)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
261 {
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
262 // The popup may be closed before dragging stops.
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
263 if (!win_valid_popup(wp))
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
264 return;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
265
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
266 if ((wp->w_popup_flags & POPF_RESIZE) && drag_on_resize_handle)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
267 {
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
268 int width_inc = mouse_col - drag_start_col;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
269 int height_inc = mouse_row - drag_start_row;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
270
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
271 if (width_inc != 0)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
272 {
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
273 int width = wp->w_width + width_inc;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
274
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
275 if (width < 1)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
276 width = 1;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
277 wp->w_minwidth = width;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
278 wp->w_maxwidth = width;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
279 drag_start_col = mouse_col;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
280 }
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
281
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
282 if (height_inc != 0)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
283 {
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
284 int height = wp->w_height + height_inc;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
285
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
286 if (height < 1)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
287 height = 1;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
288 wp->w_minheight = height;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
289 wp->w_maxheight = height;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
290 drag_start_row = mouse_row;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
291 }
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
292
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
293 popup_adjust_position(wp);
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
294 return;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
295 }
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
296
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
297 if (!(wp->w_popup_flags & POPF_DRAG))
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
298 return;
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
299 wp->w_wantline = drag_start_wantline + (mouse_row - drag_start_row);
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
300 if (wp->w_wantline < 1)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
301 wp->w_wantline = 1;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
302 if (wp->w_wantline > Rows)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
303 wp->w_wantline = Rows;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
304 wp->w_wantcol = drag_start_wantcol + (mouse_col - drag_start_col);
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
305 if (wp->w_wantcol < 1)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
306 wp->w_wantcol = 1;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
307 if (wp->w_wantcol > Columns)
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
308 wp->w_wantcol = Columns;
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
309
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
310 popup_adjust_position(wp);
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
311 }
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
312
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
313 /*
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
314 * Set w_firstline to match the current "wp->w_topline".
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
315 */
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
316 void
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
317 popup_set_firstline(win_T *wp)
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
318 {
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
319 int height = wp->w_height;
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
320
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
321 wp->w_firstline = wp->w_topline;
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
322 popup_adjust_position(wp);
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
323
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
324 // we don't want the popup to get smaller, decrement the first line
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
325 // until it doesn't
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
326 while (wp->w_firstline > 1 && wp->w_height < height)
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
327 {
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
328 --wp->w_firstline;
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
329 popup_adjust_position(wp);
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
330 }
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
331 }
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
332
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
333 /*
17578
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
334 * Return TRUE if the position is in the popup window scrollbar.
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
335 */
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
336 int
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
337 popup_is_in_scrollbar(win_T *wp, int row, int col)
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
338 {
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
339 return wp->w_has_scrollbar
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
340 && row >= wp->w_popup_border[0]
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
341 && row < popup_height(wp) - wp->w_popup_border[2]
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
342 && col == popup_width(wp) - wp->w_popup_border[1] - 1;
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
343 }
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
344
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
345
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
346 /*
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
347 * Handle a click in a popup window, if it is in the scrollbar.
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
348 */
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
349 void
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
350 popup_handle_scrollbar_click(win_T *wp, int row, int col)
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
351 {
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
352 int height = popup_height(wp);
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
353 int old_topline = wp->w_topline;
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
354
17578
696030820746 patch 8.1.1786: double click in popup scrollbar starts selection
Bram Moolenaar <Bram@vim.org>
parents: 17563
diff changeset
355 if (popup_is_in_scrollbar(wp, row, col))
17216
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
356 {
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
357 if (row >= height / 2)
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
358 {
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
359 // Click in lower half, scroll down.
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
360 if (wp->w_topline < wp->w_buffer->b_ml.ml_line_count)
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
361 ++wp->w_topline;
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
362 }
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
363 else if (wp->w_topline > 1)
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
364 // click on upper half, scroll up.
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
365 --wp->w_topline;
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
366 if (wp->w_topline != old_topline)
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
367 {
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
368 popup_set_firstline(wp);
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
369 redraw_win_later(wp, NOT_VALID);
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
370 }
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
371 }
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
372 }
11f3cf51d43b patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17206
diff changeset
373
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
374 #if defined(FEAT_TIMERS)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
375 static void
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
376 popup_add_timeout(win_T *wp, int time)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
377 {
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
378 char_u cbbuf[50];
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
379 char_u *ptr = cbbuf;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
380 typval_T tv;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
381
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
382 vim_snprintf((char *)cbbuf, sizeof(cbbuf),
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
383 "{_ -> popup_close(%d)}", wp->w_id);
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
384 if (get_lambda_tv(&ptr, &tv, TRUE) == OK)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
385 {
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
386 wp->w_popup_timer = create_timer(time, 0);
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
387 wp->w_popup_timer->tr_callback = get_callback(&tv);
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
388 clear_tv(&tv);
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
389 }
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
390 }
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
391 #endif
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
392
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
393 /*
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
394 * Shared between popup_create() and f_popup_move().
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 */
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 static void
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
397 apply_move_options(win_T *wp, dict_T *d)
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 {
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
399 int nr;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
400 char_u *str;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
401 dictitem_T *di;
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
402
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
403 if ((nr = dict_get_number_def(d, (char_u *)"minwidth", -1)) >= 0)
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
404 wp->w_minwidth = nr;
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
405 if ((nr = dict_get_number_def(d, (char_u *)"minheight", -1)) >= 0)
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
406 wp->w_minheight = nr;
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
407 if ((nr = dict_get_number_def(d, (char_u *)"maxwidth", -1)) >= 0)
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
408 wp->w_maxwidth = nr;
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
409 if ((nr = dict_get_number_def(d, (char_u *)"maxheight", -1)) >= 0)
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
410 wp->w_maxheight = nr;
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
411
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
412 nr = popup_options_one(d, (char_u *)"line");
17879
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
413 if (nr != MAXCOL)
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
414 wp->w_wantline = nr;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
415 nr = popup_options_one(d, (char_u *)"col");
17879
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
416 if (nr != MAXCOL)
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
417 wp->w_wantcol = nr;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
418
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
419 di = dict_find(d, (char_u *)"fixed", -1);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
420 if (di != NULL)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
421 wp->w_popup_fixed = dict_get_number(d, (char_u *)"fixed") != 0;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
422
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
423 str = dict_get_string(d, (char_u *)"pos", FALSE);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
424 if (str != NULL)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
425 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
426 for (nr = 0;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
427 nr < (int)(sizeof(poppos_entries) / sizeof(poppos_entry_T));
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
428 ++nr)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
429 if (STRCMP(str, poppos_entries[nr].pp_name) == 0)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
430 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
431 wp->w_popup_pos = poppos_entries[nr].pp_val;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
432 nr = -1;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
433 break;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
434 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
435 if (nr != -1)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
436 semsg(_(e_invarg2), str);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
437 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
438
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
439 str = dict_get_string(d, (char_u *)"textprop", FALSE);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
440 if (str != NULL)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
441 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
442 wp->w_popup_prop_type = 0;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
443 if (*str != NUL)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
444 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
445 nr = find_prop_type_id(str, wp->w_buffer);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
446 if (nr <= 0)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
447 nr = find_prop_type_id(str, NULL);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
448 if (nr <= 0)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
449 semsg(_(e_invarg2), str);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
450 else
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
451 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
452 wp->w_popup_prop_type = nr;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
453 wp->w_popup_prop_win = curwin;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
454
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
455 di = dict_find(d, (char_u *)"textpropwin", -1);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
456 if (di != NULL)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
457 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
458 wp->w_popup_prop_win = find_win_by_nr_or_id(&di->di_tv);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
459 if (win_valid(wp->w_popup_prop_win))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
460 wp->w_popup_prop_win = curwin;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
461 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
462 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
463 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
464 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
465
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
466 di = dict_find(d, (char_u *)"textpropid", -1);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
467 if (di != NULL)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
468 wp->w_popup_prop_id = dict_get_number(d, (char_u *)"textpropid");
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
469 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
470
17202
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
471 static void
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
472 handle_moved_argument(win_T *wp, dictitem_T *di, int mousemoved)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
473 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
474 if (di->di_tv.v_type == VAR_STRING && di->di_tv.vval.v_string != NULL)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
475 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
476 char_u *s = di->di_tv.vval.v_string;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
477 int flags = 0;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
478
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
479 if (STRCMP(s, "word") == 0)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
480 flags = FIND_IDENT | FIND_STRING;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
481 else if (STRCMP(s, "WORD") == 0)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
482 flags = FIND_STRING;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
483 else if (STRCMP(s, "expr") == 0)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
484 flags = FIND_IDENT | FIND_STRING | FIND_EVAL;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
485 else if (STRCMP(s, "any") != 0)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
486 semsg(_(e_invarg2), s);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
487 if (flags != 0)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
488 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
489 if (mousemoved)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
490 set_mousemoved_columns(wp, flags);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
491 else
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
492 set_moved_columns(wp, flags);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
493 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
494 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
495 else if (di->di_tv.v_type == VAR_LIST
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
496 && di->di_tv.vval.v_list != NULL
18398
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
497 && (di->di_tv.vval.v_list->lv_len == 2
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
498 || di->di_tv.vval.v_list->lv_len == 3))
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
499 {
18398
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
500 list_T *l = di->di_tv.vval.v_list;
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
501 listitem_T *li = l->lv_first;
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
502 int mincol;
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
503 int maxcol;
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
504
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
505 if (di->di_tv.vval.v_list->lv_len == 3)
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
506 {
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
507 varnumber_T nr = tv_get_number(&l->lv_first->li_tv);
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
508
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
509 // Three numbers, might be from popup_getoptions().
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
510 if (mousemoved)
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
511 wp->w_popup_mouse_row = nr;
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
512 else
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
513 wp->w_popup_lnum = nr;
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
514 li = li->li_next;
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
515 }
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
516
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
517 mincol = tv_get_number(&li->li_tv);
21c25bee9df8 patch 8.1.2193: popup_setoptions(popup_getoptions()) does not work
Bram Moolenaar <Bram@vim.org>
parents: 18396
diff changeset
518 maxcol = tv_get_number(&li->li_next->li_tv);
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
519 if (mousemoved)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
520 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
521 wp->w_popup_mouse_mincol = mincol;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
522 wp->w_popup_mouse_maxcol = maxcol;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
523 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
524 else
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
525 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
526 wp->w_popup_mincol = mincol;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
527 wp->w_popup_maxcol = maxcol;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
528 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
529 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
530 else
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
531 semsg(_(e_invarg2), tv_get_string(&di->di_tv));
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
532 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
533
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
534 static void
17202
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
535 check_highlight(dict_T *dict, char *name, char_u **pval)
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
536 {
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
537 dictitem_T *di;
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
538 char_u *str;
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
539
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
540 di = dict_find(dict, (char_u *)name, -1);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
541 if (di != NULL)
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
542 {
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
543 if (di->di_tv.v_type != VAR_STRING)
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
544 semsg(_(e_invargval), name);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
545 else
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
546 {
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
547 str = tv_get_string(&di->di_tv);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
548 if (*str != NUL)
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
549 *pval = vim_strsave(str);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
550 }
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
551 }
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
552 }
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
553
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
554 /*
18339
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18239
diff changeset
555 * Scroll to show the line with the cursor.
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
556 */
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
557 static void
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
558 popup_show_curline(win_T *wp)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
559 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
560 if (wp->w_cursor.lnum < wp->w_topline)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
561 wp->w_topline = wp->w_cursor.lnum;
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
562 else if (wp->w_cursor.lnum >= wp->w_botline
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
563 && (curwin->w_valid & VALID_BOTLINE))
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
564 {
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
565 wp->w_topline = wp->w_cursor.lnum - wp->w_height + 1;
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
566 if (wp->w_topline < 1)
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
567 wp->w_topline = 1;
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
568 else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
569 wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
18339
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18239
diff changeset
570 while (wp->w_topline < wp->w_cursor.lnum
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18239
diff changeset
571 && wp->w_topline < wp->w_buffer->b_ml.ml_line_count
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18239
diff changeset
572 && plines_m_win(wp, wp->w_topline, wp->w_cursor.lnum)
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18239
diff changeset
573 > wp->w_height)
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18239
diff changeset
574 ++wp->w_topline;
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
575 }
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
576
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
577 // Don't use "firstline" now.
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
578 wp->w_firstline = 0;
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
579 }
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
580
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
581 /*
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
582 * Get the sign group name for window "wp".
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
583 * Returns a pointer to a static buffer, overwritten on the next call.
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
584 */
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
585 static char_u *
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
586 popup_get_sign_name(win_T *wp)
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
587 {
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
588 static char buf[30];
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
589
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
590 vim_snprintf(buf, sizeof(buf), "popup-%d", wp->w_id);
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
591 return (char_u *)buf;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
592 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
593
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
594 /*
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
595 * Highlight the line with the cursor.
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
596 * Also scrolls the text to put the cursor line in view.
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
597 */
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
598 static void
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
599 popup_highlight_curline(win_T *wp)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
600 {
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
601 int sign_id = 0;
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
602 char_u *sign_name = popup_get_sign_name(wp);
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
603
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
604 buf_delete_signs(wp->w_buffer, (char_u *)"popupmenu");
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
605
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
606 if ((wp->w_popup_flags & POPF_CURSORLINE) != 0)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
607 {
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
608 popup_show_curline(wp);
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
609
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
610 if (!sign_exists_by_name(sign_name))
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
611 {
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
612 char *linehl = "PopupSelected";
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
613
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
614 if (syn_name2id((char_u *)linehl) == 0)
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
615 linehl = "PmenuSel";
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
616 sign_define_by_name(sign_name, NULL, (char_u *)linehl, NULL, NULL);
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
617 }
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
618
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
619 sign_place(&sign_id, (char_u *)"popupmenu", sign_name,
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
620 wp->w_buffer, wp->w_cursor.lnum, SIGN_DEF_PRIO);
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
621 redraw_win_later(wp, NOT_VALID);
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
622 }
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
623 else
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
624 sign_undefine_by_name(sign_name, FALSE);
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
625 wp->w_popup_last_curline = wp->w_cursor.lnum;
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
626 }
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
627
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
628 /*
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
629 * Shared between popup_create() and f_popup_setoptions().
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
630 */
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
631 static void
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
632 apply_general_options(win_T *wp, dict_T *dict)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
633 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
634 dictitem_T *di;
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16855
diff changeset
635 int nr;
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16855
diff changeset
636 char_u *str;
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16796
diff changeset
637
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
638 // TODO: flip
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
639
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
640 di = dict_find(dict, (char_u *)"firstline", -1);
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
641 if (di != NULL)
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
642 {
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
643 wp->w_firstline = dict_get_number(dict, (char_u *)"firstline");
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
644 if (wp->w_firstline < 0)
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
645 wp->w_firstline = -1;
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
646 }
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
647
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
648 di = dict_find(dict, (char_u *)"scrollbar", -1);
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
649 if (di != NULL)
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
650 wp->w_want_scrollbar = dict_get_number(dict, (char_u *)"scrollbar");
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
651
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
652 str = dict_get_string(dict, (char_u *)"title", FALSE);
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
653 if (str != NULL)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
654 {
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
655 vim_free(wp->w_popup_title);
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
656 wp->w_popup_title = vim_strsave(str);
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
657 }
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
658
16857
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16855
diff changeset
659 di = dict_find(dict, (char_u *)"wrap", -1);
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16855
diff changeset
660 if (di != NULL)
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16855
diff changeset
661 {
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16855
diff changeset
662 nr = dict_get_number(dict, (char_u *)"wrap");
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16855
diff changeset
663 wp->w_p_wrap = nr != 0;
4de94f6161f2 patch 8.1.1430: popup window option "wrap" not supported
Bram Moolenaar <Bram@vim.org>
parents: 16855
diff changeset
664 }
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
665
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
666 di = dict_find(dict, (char_u *)"drag", -1);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
667 if (di != NULL)
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
668 {
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
669 nr = dict_get_number(dict, (char_u *)"drag");
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
670 if (nr)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
671 wp->w_popup_flags |= POPF_DRAG;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
672 else
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
673 wp->w_popup_flags &= ~POPF_DRAG;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
674 }
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
675
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
676 di = dict_find(dict, (char_u *)"resize", -1);
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
677 if (di != NULL)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
678 {
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
679 nr = dict_get_number(dict, (char_u *)"resize");
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
680 if (nr)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
681 wp->w_popup_flags |= POPF_RESIZE;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
682 else
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
683 wp->w_popup_flags &= ~POPF_RESIZE;
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
684 }
17051
221d4b82bc0b patch 8.1.1525: cannot move a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17047
diff changeset
685
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
686 di = dict_find(dict, (char_u *)"close", -1);
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
687 if (di != NULL)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
688 {
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
689 int ok = TRUE;
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
690
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
691 if (di->di_tv.v_type == VAR_STRING && di->di_tv.vval.v_string != NULL)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
692 {
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
693 char_u *s = di->di_tv.vval.v_string;
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
694
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
695 if (STRCMP(s, "none") == 0)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
696 wp->w_popup_close = POPCLOSE_NONE;
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
697 else if (STRCMP(s, "button") == 0)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
698 wp->w_popup_close = POPCLOSE_BUTTON;
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
699 else if (STRCMP(s, "click") == 0)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
700 wp->w_popup_close = POPCLOSE_CLICK;
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
701 else
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
702 ok = FALSE;
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
703 }
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
704 else
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
705 ok = FALSE;
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
706 if (!ok)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
707 semsg(_(e_invargNval), "close", tv_get_string(&di->di_tv));
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
708 }
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
709
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
710 str = dict_get_string(dict, (char_u *)"highlight", FALSE);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
711 if (str != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
712 set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
713 str, OPT_FREE|OPT_LOCAL, 0);
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
714
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
715 set_string_option_direct_in_win(wp, (char_u *)"signcolumn", -1,
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
716 (char_u *)"no", OPT_FREE|OPT_LOCAL, 0);
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
717 set_padding_border(dict, wp->w_popup_padding, "padding", 999);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
718 set_padding_border(dict, wp->w_popup_border, "border", 1);
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
719
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
720 di = dict_find(dict, (char_u *)"borderhighlight", -1);
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
721 if (di != NULL)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
722 {
17421
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
723 if (di->di_tv.v_type != VAR_LIST || di->di_tv.vval.v_list == NULL)
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
724 emsg(_(e_listreq));
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
725 else
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
726 {
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
727 list_T *list = di->di_tv.vval.v_list;
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
728 listitem_T *li;
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
729 int i;
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
730
17421
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
731 for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
732 ++i, li = li->li_next)
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
733 {
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
734 str = tv_get_string(&li->li_tv);
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
735 if (*str != NUL)
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
736 wp->w_border_highlight[i] = vim_strsave(str);
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
737 }
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
738 if (list->lv_len == 1 && wp->w_border_highlight[0] != NULL)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
739 for (i = 1; i < 4; ++i)
17421
73e81cd9e6cb patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17417
diff changeset
740 wp->w_border_highlight[i] =
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
741 vim_strsave(wp->w_border_highlight[0]);
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
742 }
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
743 }
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
744
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
745 di = dict_find(dict, (char_u *)"borderchars", -1);
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
746 if (di != NULL)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
747 {
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
748 if (di->di_tv.v_type != VAR_LIST)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
749 emsg(_(e_listreq));
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
750 else
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
751 {
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
752 list_T *list = di->di_tv.vval.v_list;
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
753 listitem_T *li;
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
754 int i;
16888
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
755
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
756 if (list != NULL)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
757 for (i = 0, li = list->lv_first; i < 8 && i < list->lv_len;
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
758 ++i, li = li->li_next)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
759 {
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
760 str = tv_get_string(&li->li_tv);
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
761 if (*str != NUL)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
762 wp->w_border_char[i] = mb_ptr2char(str);
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
763 }
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
764 if (list->lv_len == 1)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
765 for (i = 1; i < 8; ++i)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
766 wp->w_border_char[i] = wp->w_border_char[0];
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
767 if (list->lv_len == 2)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
768 {
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
769 for (i = 4; i < 8; ++i)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
770 wp->w_border_char[i] = wp->w_border_char[1];
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
771 for (i = 1; i < 4; ++i)
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
772 wp->w_border_char[i] = wp->w_border_char[0];
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
773 }
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
774 }
ec61b6b79865 patch 8.1.1445: popup window border highlight not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16884
diff changeset
775 }
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
776
17202
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
777 check_highlight(dict, "scrollbarhighlight", &wp->w_scrollbar_highlight);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
778 check_highlight(dict, "thumbhighlight", &wp->w_thumb_highlight);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
779
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
780 di = dict_find(dict, (char_u *)"zindex", -1);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
781 if (di != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
782 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
783 wp->w_zindex = dict_get_number(dict, (char_u *)"zindex");
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
784 if (wp->w_zindex < 1)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
785 wp->w_zindex = POPUPWIN_DEFAULT_ZINDEX;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
786 if (wp->w_zindex > 32000)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
787 wp->w_zindex = 32000;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
788 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
789
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
790 di = dict_find(dict, (char_u *)"mask", -1);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
791 if (di != NULL)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
792 {
17417
aa4532c1d001 patch 8.1.1707: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17383
diff changeset
793 int ok = FALSE;
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
794
17417
aa4532c1d001 patch 8.1.1707: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17383
diff changeset
795 if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL)
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
796 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
797 listitem_T *li;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
798
17417
aa4532c1d001 patch 8.1.1707: Coverity warns for possibly using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 17383
diff changeset
799 ok = TRUE;
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
800 for (li = di->di_tv.vval.v_list->lv_first; li != NULL;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
801 li = li->li_next)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
802 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
803 if (li->li_tv.v_type != VAR_LIST
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
804 || li->li_tv.vval.v_list == NULL
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
805 || li->li_tv.vval.v_list->lv_len != 4)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
806 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
807 ok = FALSE;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
808 break;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
809 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
810 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
811 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
812 if (ok)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
813 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
814 wp->w_popup_mask = di->di_tv.vval.v_list;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
815 ++wp->w_popup_mask->lv_refcount;
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
816 VIM_CLEAR(wp->w_popup_mask_cells);
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
817 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
818 else
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
819 semsg(_(e_invargval), "mask");
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
820 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
821
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
822 #if defined(FEAT_TIMERS)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
823 // Add timer to close the popup after some time.
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
824 nr = dict_get_number(dict, (char_u *)"time");
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
825 if (nr > 0)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
826 popup_add_timeout(wp, nr);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
827 #endif
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
828
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
829 di = dict_find(dict, (char_u *)"moved", -1);
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
830 if (di != NULL)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
831 {
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
832 set_moved_values(wp);
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
833 handle_moved_argument(wp, di, FALSE);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
834 }
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
835
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
836 di = dict_find(dict, (char_u *)"mousemoved", -1);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
837 if (di != NULL)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
838 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
839 set_mousemoved_values(wp);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
840 handle_moved_argument(wp, di, TRUE);
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
841 }
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
842
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
843 di = dict_find(dict, (char_u *)"cursorline", -1);
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
844 if (di != NULL)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
845 {
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
846 if (di->di_tv.v_type == VAR_NUMBER)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
847 {
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
848 if (di->di_tv.vval.v_number != 0)
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
849 wp->w_popup_flags |= POPF_CURSORLINE;
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
850 else
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
851 wp->w_popup_flags &= ~POPF_CURSORLINE;
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
852 }
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
853 else
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
854 semsg(_(e_invargval), "cursorline");
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
855 }
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
856
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
857 di = dict_find(dict, (char_u *)"filter", -1);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
858 if (di != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
859 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
860 callback_T callback = get_callback(&di->di_tv);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
861
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
862 if (callback.cb_name != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
863 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
864 free_callback(&wp->w_filter_cb);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
865 set_callback(&wp->w_filter_cb, &callback);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
866 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
867 }
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
868 di = dict_find(dict, (char_u *)"mapping", -1);
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
869 if (di != NULL)
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
870 {
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
871 nr = dict_get_number(dict, (char_u *)"mapping");
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
872 if (nr)
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
873 wp->w_popup_flags |= POPF_MAPPING;
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
874 else
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
875 wp->w_popup_flags &= ~POPF_MAPPING;
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
876 }
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
877
17946
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
878 str = dict_get_string(dict, (char_u *)"filtermode", FALSE);
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
879 if (str != NULL)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
880 {
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
881 if (STRCMP(str, "a") == 0)
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
882 wp->w_filter_mode = MODE_ALL;
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
883 else
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
884 wp->w_filter_mode = mode_str2flags(str);
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
885 }
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
886
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
887 di = dict_find(dict, (char_u *)"callback", -1);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
888 if (di != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
889 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
890 callback_T callback = get_callback(&di->di_tv);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
891
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
892 if (callback.cb_name != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
893 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
894 free_callback(&wp->w_close_cb);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
895 set_callback(&wp->w_close_cb, &callback);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
896 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
897 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
898 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
899
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
900 /*
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
901 * Go through the options in "dict" and apply them to popup window "wp".
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
902 * Only used when creating a new popup window.
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
903 */
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
904 static void
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
905 apply_options(win_T *wp, dict_T *dict)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
906 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
907 int nr;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
908
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
909 apply_move_options(wp, dict);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
910 apply_general_options(wp, dict);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
911
17121
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
912 nr = dict_get_number(dict, (char_u *)"hidden");
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
913 if (nr > 0)
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
914 {
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
915 wp->w_popup_flags |= POPF_HIDDEN;
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
916 --wp->w_buffer->b_nwindows;
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
917 }
808ea76535a9 patch 8.1.1560: popup window hidden option not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17119
diff changeset
918
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
919 popup_mask_refresh = TRUE;
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
920 popup_highlight_curline(wp);
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921 }
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 /*
16811
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
924 * Add lines to the popup from a list of strings.
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
925 */
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
926 static void
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
927 add_popup_strings(buf_T *buf, list_T *l)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
928 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
929 listitem_T *li;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
930 linenr_T lnum = 0;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
931 char_u *p;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
932
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
933 for (li = l->lv_first; li != NULL; li = li->li_next)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
934 if (li->li_tv.v_type == VAR_STRING)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
935 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
936 p = li->li_tv.vval.v_string;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
937 ml_append_buf(buf, lnum++,
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
938 p == NULL ? (char_u *)"" : p, (colnr_T)0, TRUE);
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
939 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
940 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
941
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
942 /*
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
943 * Add lines to the popup from a list of dictionaries.
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
944 */
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
945 static void
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
946 add_popup_dicts(buf_T *buf, list_T *l)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
947 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
948 listitem_T *li;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
949 listitem_T *pli;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
950 linenr_T lnum = 0;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
951 char_u *p;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
952 dict_T *dict;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
953
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
954 // first add the text lines
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
955 for (li = l->lv_first; li != NULL; li = li->li_next)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
956 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
957 if (li->li_tv.v_type != VAR_DICT)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
958 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
959 emsg(_(e_dictreq));
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
960 return;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
961 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
962 dict = li->li_tv.vval.v_dict;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
963 p = dict == NULL ? NULL
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
964 : dict_get_string(dict, (char_u *)"text", FALSE);
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
965 ml_append_buf(buf, lnum++,
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
966 p == NULL ? (char_u *)"" : p, (colnr_T)0, TRUE);
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
967 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
968
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
969 // add the text properties
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
970 lnum = 1;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
971 for (li = l->lv_first; li != NULL; li = li->li_next, ++lnum)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
972 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
973 dictitem_T *di;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
974 list_T *plist;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
975
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
976 dict = li->li_tv.vval.v_dict;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
977 di = dict_find(dict, (char_u *)"props", -1);
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
978 if (di != NULL)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
979 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
980 if (di->di_tv.v_type != VAR_LIST)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
981 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
982 emsg(_(e_listreq));
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
983 return;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
984 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
985 plist = di->di_tv.vval.v_list;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
986 if (plist != NULL)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
987 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
988 for (pli = plist->lv_first; pli != NULL; pli = pli->li_next)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
989 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
990 if (pli->li_tv.v_type != VAR_DICT)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
991 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
992 emsg(_(e_dictreq));
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
993 return;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
994 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
995 dict = pli->li_tv.vval.v_dict;
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
996 if (dict != NULL)
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
997 {
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
998 int col = dict_get_number(dict, (char_u *)"col");
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
999
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1000 prop_add_common( lnum, col, dict, buf, NULL);
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1001 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1002 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1003 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1004 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1005 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1006 }
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1007
0457d49eb2d9 patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents: 16809
diff changeset
1008 /*
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1009 * Get the padding plus border at the top, adjusted to 1 if there is a title.
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1010 */
17811
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1011 int
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1012 popup_top_extra(win_T *wp)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1013 {
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1014 int extra = wp->w_popup_border[0] + wp->w_popup_padding[0];
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1015
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1016 if (extra == 0 && wp->w_popup_title != NULL && *wp->w_popup_title != NUL)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1017 return 1;
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1018 return extra;
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1019 }
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1020
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1021 /*
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1022 * Return the height of popup window "wp", including border and padding.
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1023 */
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1024 int
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1025 popup_height(win_T *wp)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1026 {
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1027 return wp->w_height
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1028 + popup_top_extra(wp)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1029 + wp->w_popup_padding[2] + wp->w_popup_border[2];
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1030 }
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1031
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1032 /*
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1033 * Return the width of popup window "wp", including border, padding and
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1034 * scrollbar.
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1035 */
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1036 int
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1037 popup_width(win_T *wp)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1038 {
17354
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1039 // w_leftcol is how many columns of the core are left of the screen
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1040 // w_popup_rightoff is how many columns of the core are right of the screen
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1041 return wp->w_width + wp->w_leftcol
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1042 + popup_extra_width(wp)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1043 + wp->w_popup_rightoff;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1044 }
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1045
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1046 /*
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1047 * Return the extra width of popup window "wp": border, padding and scrollbar.
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1048 */
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1049 int
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1050 popup_extra_width(win_T *wp)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1051 {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1052 return wp->w_popup_padding[3] + wp->w_popup_border[3]
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1053 + wp->w_popup_padding[1] + wp->w_popup_border[1]
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1054 + wp->w_has_scrollbar;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1055 }
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1056
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1057 /*
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1058 * Adjust the position and size of the popup to fit on the screen.
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1059 */
17789
0f7ae8010787 patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents: 17771
diff changeset
1060 static void
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1061 popup_adjust_position(win_T *wp)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1062 {
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1063 linenr_T lnum;
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1064 int wrapped = 0;
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1065 int maxwidth;
18339
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18239
diff changeset
1066 int used_maxwidth = FALSE;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1067 int maxspace;
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1068 int center_vert = FALSE;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1069 int center_hor = FALSE;
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1070 int allow_adjust_left = !wp->w_popup_fixed;
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1071 int top_extra = popup_top_extra(wp);
16898
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
1072 int right_extra = wp->w_popup_border[1] + wp->w_popup_padding[1];
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
1073 int bot_extra = wp->w_popup_border[2] + wp->w_popup_padding[2];
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
1074 int left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3];
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
1075 int extra_height = top_extra + bot_extra;
16fd1bb2e675 patch 8.1.1450: popup window positioning wrong when using padding or borders
Bram Moolenaar <Bram@vim.org>
parents: 16896
diff changeset
1076 int extra_width = left_extra + right_extra;
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1077 int org_winrow = wp->w_winrow;
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1078 int org_wincol = wp->w_wincol;
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1079 int org_width = wp->w_width;
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1080 int org_height = wp->w_height;
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1081 int org_leftcol = wp->w_leftcol;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1082 int org_leftoff = wp->w_popup_leftoff;
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1083 int minwidth;
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1084 int wantline = wp->w_wantline; // adjusted for textprop
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1085 int wantcol = wp->w_wantcol; // adjusted for textprop
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
1086 int use_wantcol = wantcol != 0;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1087
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1088 wp->w_winrow = 0;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1089 wp->w_wincol = 0;
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1090 wp->w_leftcol = 0;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1091 wp->w_popup_leftoff = 0;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1092 wp->w_popup_rightoff = 0;
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1093
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
1094 // May need to update the "cursorline" highlighting, which may also change
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
1095 // "topline"
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
1096 if (wp->w_popup_last_curline != wp->w_cursor.lnum)
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
1097 popup_highlight_curline(wp);
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
1098
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1099 if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1100 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1101 win_T *prop_win = wp->w_popup_prop_win;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1102 textprop_T prop;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1103 linenr_T prop_lnum;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1104 pos_T pos;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1105 int screen_row;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1106 int screen_scol;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1107 int screen_ccol;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1108 int screen_ecol;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1109
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1110 // Popup window is positioned relative to a text property.
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1111 if (find_visible_prop(prop_win,
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1112 wp->w_popup_prop_type, wp->w_popup_prop_id,
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1113 &prop, &prop_lnum) == FAIL)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1114 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1115 // Text property is no longer visible, hide the popup.
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1116 // Unhiding the popup is done in check_popup_unhidden().
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1117 if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1118 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1119 wp->w_popup_flags |= POPF_HIDDEN;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1120 --wp->w_buffer->b_nwindows;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1121 if (win_valid(wp->w_popup_prop_win))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1122 redraw_win_later(wp->w_popup_prop_win, SOME_VALID);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1123 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1124 return;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1125 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1126
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1127 // Compute the desired position from the position of the text
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1128 // property. Use "wantline" and "wantcol" as offsets.
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1129 pos.lnum = prop_lnum;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1130 pos.col = prop.tp_col;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1131 if (wp->w_popup_pos == POPPOS_TOPLEFT
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1132 || wp->w_popup_pos == POPPOS_BOTLEFT)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1133 pos.col += prop.tp_len - 1;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1134 textpos2screenpos(prop_win, &pos, &screen_row,
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1135 &screen_scol, &screen_ccol, &screen_ecol);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1136
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1137 if (wp->w_popup_pos == POPPOS_TOPLEFT
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1138 || wp->w_popup_pos == POPPOS_TOPRIGHT)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1139 // below the text
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1140 wantline = screen_row + wantline + 1;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1141 else
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1142 // above the text
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1143 wantline = screen_row + wantline - 1;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1144 center_vert = FALSE;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1145 if (wp->w_popup_pos == POPPOS_TOPLEFT
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1146 || wp->w_popup_pos == POPPOS_BOTLEFT)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1147 // right of the text
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1148 wantcol = screen_ecol + wantcol;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1149 else
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1150 // left of the text
17875
f13a5c48320b patch 8.1.1934: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17863
diff changeset
1151 wantcol = screen_scol + wantcol - 2;
18438
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1152 use_wantcol = TRUE;
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1153 }
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1154 else
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1155 {
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1156 // If no line was specified default to vertical centering.
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1157 if (wantline == 0)
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1158 center_vert = TRUE;
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1159 else if (wantline < 0)
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1160 // If "wantline" is negative it actually means zero.
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1161 wantline = 0;
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1162 if (wantcol < 0)
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1163 // If "wantcol" is negative it actually means zero.
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1164 wantcol = 0;
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1165 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1166
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1167 if (wp->w_popup_pos == POPPOS_CENTER)
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1168 {
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1169 // center after computing the size
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1170 center_vert = TRUE;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1171 center_hor = TRUE;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1172 }
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1173 else
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1174 {
18438
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1175 if (wantline > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT
144fa40ee706 patch 8.1.2213: popup_textprop tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18432
diff changeset
1176 || wp->w_popup_pos == POPPOS_TOPRIGHT))
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1177 {
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1178 wp->w_winrow = wantline - 1;
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1179 if (wp->w_winrow >= Rows)
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1180 wp->w_winrow = Rows - 1;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1181 }
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1182
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
1183 if (!use_wantcol)
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1184 center_hor = TRUE;
17879
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
1185 else if (wantcol > 0 && (wp->w_popup_pos == POPPOS_TOPLEFT
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
1186 || wp->w_popup_pos == POPPOS_BOTLEFT))
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1187 {
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1188 wp->w_wincol = wantcol - 1;
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1189 if (wp->w_wincol >= Columns - 3)
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1190 wp->w_wincol = Columns - 3;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1191 }
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1192 }
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1193
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1194 // When centering or right aligned, use maximum width.
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1195 // When left aligned use the space available, but shift to the left when we
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1196 // hit the right of the screen.
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1197 maxspace = Columns - wp->w_wincol - left_extra;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1198 maxwidth = maxspace;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1199 if (wp->w_maxwidth > 0 && maxwidth > wp->w_maxwidth)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1200 {
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1201 allow_adjust_left = FALSE;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1202 maxwidth = wp->w_maxwidth;
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1203 }
18492
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1204 minwidth = wp->w_minwidth;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1205
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
1206 // start at the desired first line
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1207 if (wp->w_firstline > 0)
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1208 wp->w_topline = wp->w_firstline;
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
1209 if (wp->w_topline < 1)
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
1210 wp->w_topline = 1;
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
1211 else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
1212 wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
1213
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1214 // Compute width based on longest text line and the 'wrap' option.
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1215 // Use a minimum width of one, so that something shows when there is no
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1216 // text.
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1217 // When "firstline" is -1 then start with the last buffer line and go
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1218 // backwards.
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1219 // TODO: more accurate wrapping
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1220 wp->w_width = 1;
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1221 if (wp->w_firstline < 0)
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1222 lnum = wp->w_buffer->b_ml.ml_line_count;
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1223 else
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1224 lnum = wp->w_topline;
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1225 while (lnum >= 1 && lnum <= wp->w_buffer->b_ml.ml_line_count)
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1226 {
17442
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1227 int len;
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1228 int w_width = wp->w_width;
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1229
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1230 // Count Tabs for what they are worth and compute the length based on
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1231 // the maximum width (matters when 'showbreak' is set).
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1232 if (wp->w_width < maxwidth)
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1233 wp->w_width = maxwidth;
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1234 len = win_linetabsize(wp, ml_get_buf(wp->w_buffer, lnum, FALSE),
17314
b60402471f69 patch 8.1.1656: popup window width is wrong when using Tabs
Bram Moolenaar <Bram@vim.org>
parents: 17300
diff changeset
1235 (colnr_T)MAXCOL);
17442
57b9fca8c7d2 patch 8.1.1719: popup too wide when 'showbreak' is set
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
1236 wp->w_width = w_width;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1237
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1238 if (wp->w_p_wrap)
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1239 {
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1240 while (len > maxwidth)
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1241 {
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1242 ++wrapped;
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1243 len -= maxwidth;
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1244 wp->w_width = maxwidth;
18339
a776385eac9f patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menu
Bram Moolenaar <Bram@vim.org>
parents: 18239
diff changeset
1245 used_maxwidth = TRUE;
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1246 }
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1247 }
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1248 else if (len > maxwidth
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1249 && allow_adjust_left
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1250 && (wp->w_popup_pos == POPPOS_TOPLEFT
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1251 || wp->w_popup_pos == POPPOS_BOTLEFT))
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1252 {
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1253 // adjust leftwise to fit text on screen
17101
1a23650f8da5 patch 8.1.1550: when a popup has left padding text may be cut off
Bram Moolenaar <Bram@vim.org>
parents: 17097
diff changeset
1254 int shift_by = len - maxwidth;
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1255
17101
1a23650f8da5 patch 8.1.1550: when a popup has left padding text may be cut off
Bram Moolenaar <Bram@vim.org>
parents: 17097
diff changeset
1256 if (shift_by > wp->w_wincol)
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1257 {
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1258 int truncate_shift = shift_by - wp->w_wincol;
17101
1a23650f8da5 patch 8.1.1550: when a popup has left padding text may be cut off
Bram Moolenaar <Bram@vim.org>
parents: 17097
diff changeset
1259
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1260 len -= truncate_shift;
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1261 shift_by -= truncate_shift;
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1262 }
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1263
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1264 wp->w_wincol -= shift_by;
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
1265 maxwidth += shift_by;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1266 wp->w_width = maxwidth;
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1267 }
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1268 if (wp->w_width < len)
17354
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1269 {
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1270 wp->w_width = len;
17354
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1271 if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth)
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1272 wp->w_width = wp->w_maxwidth;
102ed3a26a5d patch 8.1.1676: "maxwidth" of popup window does not always work properly
Bram Moolenaar <Bram@vim.org>
parents: 17348
diff changeset
1273 }
18492
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1274
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1275 if (wp->w_firstline < 0)
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1276 --lnum;
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1277 else
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1278 ++lnum;
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1279
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
1280 // do not use the width of lines we're not going to show
17245
13a2d3364b3f patch 8.1.1622: wrong width if displaying a lot of lines in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17241
diff changeset
1281 if (wp->w_maxheight > 0
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1282 && (wp->w_firstline >= 0
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1283 ? lnum - wp->w_topline
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1284 : wp->w_buffer->b_ml.ml_line_count - lnum)
18492
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1285 + wrapped >= wp->w_maxheight)
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
1286 break;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1287 }
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1288
17905
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1289 if (wp->w_firstline < 0)
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1290 wp->w_topline = lnum > 0 ? lnum + 1 : lnum;
fb773f73a4be patch 8.1.1949: cannot scroll a popup window to the very bottom
Bram Moolenaar <Bram@vim.org>
parents: 17897
diff changeset
1291
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
1292 wp->w_has_scrollbar = wp->w_want_scrollbar
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
1293 && (wp->w_topline > 1 || lnum <= wp->w_buffer->b_ml.ml_line_count);
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1294 if (wp->w_has_scrollbar)
17821
fe92aaf166c1 patch 8.1.1907: wrong position for info popup with scrollbar on the left
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
1295 {
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1296 ++right_extra;
17821
fe92aaf166c1 patch 8.1.1907: wrong position for info popup with scrollbar on the left
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
1297 ++extra_width;
18492
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1298 // make space for the scrollbar if needed, when lines wrap and when
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1299 // applying minwidth
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1300 if (maxwidth + right_extra >= maxspace
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1301 && (used_maxwidth || (minwidth > 0 && wp->w_width < minwidth)))
41a5f241e9d5 patch 8.1.2240: popup window width changes when scrolling
Bram Moolenaar <Bram@vim.org>
parents: 18438
diff changeset
1302 maxwidth -= wp->w_popup_padding[1] + 1;
17821
fe92aaf166c1 patch 8.1.1907: wrong position for info popup with scrollbar on the left
Bram Moolenaar <Bram@vim.org>
parents: 17817
diff changeset
1303 }
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
1304
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1305 if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1306 {
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1307 int title_len = vim_strsize(wp->w_popup_title) + 2 - extra_width;
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1308
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1309 if (minwidth < title_len)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1310 minwidth = title_len;
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1311 }
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1312
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1313 if (minwidth > 0 && wp->w_width < minwidth)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
1314 wp->w_width = minwidth;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1315 if (wp->w_width > maxwidth)
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1316 {
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1317 if (wp->w_width > maxspace && !wp->w_p_wrap)
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1318 // some columns cut off on the right
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1319 wp->w_popup_rightoff = wp->w_width - maxspace;
16837
18593056d8f1 patch 8.1.1420: popup window size only uses first line length
Bram Moolenaar <Bram@vim.org>
parents: 16833
diff changeset
1320 wp->w_width = maxwidth;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1321 }
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1322 if (center_hor)
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1323 {
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1324 wp->w_wincol = (Columns - wp->w_width - extra_width) / 2;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1325 if (wp->w_wincol < 0)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1326 wp->w_wincol = 0;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1327 }
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1328 else if (wp->w_popup_pos == POPPOS_BOTRIGHT
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1329 || wp->w_popup_pos == POPPOS_TOPRIGHT)
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1330 {
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1331 int leftoff = wantcol - (wp->w_width + extra_width);
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1332
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1333 // Right aligned: move to the right if needed.
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1334 // No truncation, because that would change the height.
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1335 if (leftoff >= 0)
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1336 wp->w_wincol = leftoff;
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1337 else if (wp->w_popup_fixed)
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1338 {
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1339 // "col" specifies the right edge, but popup doesn't fit, skip some
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1340 // columns when displaying the window, minus left border and
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1341 // padding.
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1342 if (-leftoff > left_extra)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1343 wp->w_leftcol = -leftoff - left_extra;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1344 wp->w_width -= wp->w_leftcol;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1345 wp->w_popup_leftoff = -leftoff;
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1346 if (wp->w_width < 0)
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1347 wp->w_width = 0;
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1348 }
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1349 }
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1350
17563
cc2c4179427c patch 8.1.1779: not showing the popup window right border is confusing
Bram Moolenaar <Bram@vim.org>
parents: 17561
diff changeset
1351 if (wp->w_p_wrap || (!wp->w_popup_fixed
cc2c4179427c patch 8.1.1779: not showing the popup window right border is confusing
Bram Moolenaar <Bram@vim.org>
parents: 17561
diff changeset
1352 && (wp->w_popup_pos == POPPOS_TOPLEFT
cc2c4179427c patch 8.1.1779: not showing the popup window right border is confusing
Bram Moolenaar <Bram@vim.org>
parents: 17561
diff changeset
1353 || wp->w_popup_pos == POPPOS_BOTLEFT)))
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1354 {
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1355 int want_col = 0;
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1356
17561
724370d05e79 patch 8.1.1778: not showing the popup window right border is confusing
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
1357 // try to show the right border and any scrollbar
724370d05e79 patch 8.1.1778: not showing the popup window right border is confusing
Bram Moolenaar <Bram@vim.org>
parents: 17551
diff changeset
1358 want_col = left_extra + wp->w_width + right_extra;
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1359 if (want_col > 0 && wp->w_wincol > 0
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1360 && wp->w_wincol + want_col >= Columns)
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1361 {
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1362 wp->w_wincol = Columns - want_col;
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1363 if (wp->w_wincol < 0)
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1364 wp->w_wincol = 0;
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1365 }
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1366 }
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1367
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
1368 wp->w_height = wp->w_buffer->b_ml.ml_line_count - wp->w_topline
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
1369 + 1 + wrapped;
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1370 if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1371 wp->w_height = wp->w_minheight;
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1372 if (wp->w_maxheight > 0 && wp->w_height > wp->w_maxheight)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1373 wp->w_height = wp->w_maxheight;
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1374 if (wp->w_height > Rows - wp->w_winrow)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1375 wp->w_height = Rows - wp->w_winrow;
16839
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
1376
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1377 if (center_vert)
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1378 {
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1379 wp->w_winrow = (Rows - wp->w_height - extra_height) / 2;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1380 if (wp->w_winrow < 0)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1381 wp->w_winrow = 0;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1382 }
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1383 else if (wp->w_popup_pos == POPPOS_BOTRIGHT
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1384 || wp->w_popup_pos == POPPOS_BOTLEFT)
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1385 {
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1386 if ((wp->w_height + extra_height) <= wantline)
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1387 // bottom aligned: may move down
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1388 wp->w_winrow = wantline - (wp->w_height + extra_height);
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1389 else
18432
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
1390 // Not enough space, make top aligned.
ee8db42dacf6 patch 8.1.2210: using negative offset for popup_create() does not work
Bram Moolenaar <Bram@vim.org>
parents: 18398
diff changeset
1391 wp->w_winrow = (wantline < 0 ? 0 : wantline) + 1;
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1392 }
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1393 if (wp->w_winrow >= Rows)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1394 wp->w_winrow = Rows - 1;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1395 else if (wp->w_winrow < 0)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1396 wp->w_winrow = 0;
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1397
16839
032d5335987e patch 8.1.1421: drawing "~" line in popup window
Bram Moolenaar <Bram@vim.org>
parents: 16837
diff changeset
1398 wp->w_popup_last_changedtick = CHANGEDTICK(wp->w_buffer);
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1399 if (win_valid(wp->w_popup_prop_win))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1400 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1401 wp->w_popup_prop_changedtick =
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1402 CHANGEDTICK(wp->w_popup_prop_win->w_buffer);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1403 wp->w_popup_prop_topline = wp->w_popup_prop_win->w_topline;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
1404 }
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1405
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1406 // Need to update popup_mask if the position or size changed.
17841
9513821d9d8f patch 8.1.1917: non-current window is not redrawn when moving popup
Bram Moolenaar <Bram@vim.org>
parents: 17823
diff changeset
1407 // And redraw windows and statuslines that were behind the popup.
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1408 if (org_winrow != wp->w_winrow
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1409 || org_wincol != wp->w_wincol
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1410 || org_leftcol != wp->w_leftcol
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
1411 || org_leftoff != wp->w_popup_leftoff
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1412 || org_width != wp->w_width
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1413 || org_height != wp->w_height)
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1414 {
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1415 redraw_win_later(wp, NOT_VALID);
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1416 if (wp->w_popup_flags & POPF_ON_CMDLINE)
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1417 clear_cmdline = TRUE;
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1418 popup_mask_refresh = TRUE;
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1419 }
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1420 }
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1421
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1422 typedef enum
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1423 {
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1424 TYPE_NORMAL,
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1425 TYPE_ATCURSOR,
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1426 TYPE_BEVAL,
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
1427 TYPE_NOTIFICATION,
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1428 TYPE_DIALOG,
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1429 TYPE_MENU,
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1430 TYPE_PREVIEW, // preview window
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1431 TYPE_INFO // popup menu info
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1432 } create_type_T;
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1433
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1434 /*
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1435 * Make "buf" empty and set the contents to "text".
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1436 * Used by popup_create() and popup_settext().
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1437 */
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1438 static void
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1439 popup_set_buffer_text(buf_T *buf, typval_T text)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1440 {
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1441 int lnum;
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1442
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1443 // Clear the buffer, then replace the lines.
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1444 curbuf = buf;
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1445 for (lnum = buf->b_ml.ml_line_count; lnum > 0; --lnum)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1446 ml_delete(lnum, FALSE);
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1447 curbuf = curwin->w_buffer;
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1448
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1449 // Add text to the buffer.
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1450 if (text.v_type == VAR_STRING)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1451 {
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1452 // just a string
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1453 ml_append_buf(buf, 0, text.vval.v_string, (colnr_T)0, TRUE);
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1454 }
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1455 else
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1456 {
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1457 list_T *l = text.vval.v_list;
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1458
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1459 if (l->lv_len > 0)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1460 {
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1461 if (l->lv_first->li_tv.v_type == VAR_STRING)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1462 // list of strings
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1463 add_popup_strings(buf, l);
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1464 else
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1465 // list of dictionaries
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1466 add_popup_dicts(buf, l);
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1467 }
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1468 }
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1469
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1470 // delete the line that was in the empty buffer
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1471 curbuf = buf;
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1472 ml_delete(buf->b_ml.ml_line_count, FALSE);
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1473 curbuf = curwin->w_buffer;
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1474 }
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1475
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
1476 /*
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1477 * Parse the 'previewpopup' or 'completepopup' option and apply the values to
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1478 * window "wp" if it is not NULL.
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1479 * Return FAIL if the parsing fails.
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1480 */
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1481 static int
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1482 parse_popup_option(win_T *wp, int is_preview)
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1483 {
17791
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1484 char_u *p =
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1485 #ifdef FEAT_QUICKFIX
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1486 !is_preview ? p_cpp :
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1487 #endif
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1488 p_pvp;
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1489
17815
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1490 if (wp != NULL)
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1491 wp->w_popup_flags &= ~POPF_INFO_MENU;
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1492
17791
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1493 for ( ; *p != NUL; p += (*p == ',' ? 1 : 0))
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1494 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1495 char_u *e, *dig;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1496 char_u *s = p;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1497 int x;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1498
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1499 e = vim_strchr(p, ':');
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1500 if (e == NULL || e[1] == NUL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1501 return FAIL;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1502
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1503 p = vim_strchr(e, ',');
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1504 if (p == NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1505 p = e + STRLEN(e);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1506 dig = e + 1;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1507 x = getdigits(&dig);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1508
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1509 if (STRNCMP(s, "height:", 7) == 0)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1510 {
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1511 if (dig != p)
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1512 return FAIL;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1513 if (wp != NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1514 {
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1515 if (is_preview)
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1516 wp->w_minheight = x;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1517 wp->w_maxheight = x;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1518 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1519 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1520 else if (STRNCMP(s, "width:", 6) == 0)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1521 {
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1522 if (dig != p)
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1523 return FAIL;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1524 if (wp != NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1525 {
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1526 if (is_preview)
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1527 wp->w_minwidth = x;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1528 wp->w_maxwidth = x;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1529 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1530 }
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1531 else if (STRNCMP(s, "highlight:", 10) == 0)
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1532 {
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1533 if (wp != NULL)
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1534 {
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1535 int c = *p;
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1536
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1537 *p = NUL;
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1538 set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1539 s + 10, OPT_FREE|OPT_LOCAL, 0);
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1540 *p = c;
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1541 }
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1542 }
17811
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1543 else if (STRNCMP(s, "border:", 7) == 0)
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1544 {
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1545 char_u *arg = s + 7;
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1546 int on = STRNCMP(arg, "on", 2) == 0 && arg + 2 == p;
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1547 int off = STRNCMP(arg, "off", 3) == 0 && arg + 3 == p;
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1548 int i;
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1549
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1550 if (!on && !off)
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1551 return FAIL;
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1552 if (wp != NULL)
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1553 {
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1554 for (i = 0; i < 4; ++i)
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1555 wp->w_popup_border[i] = on ? 1 : 0;
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1556 if (off)
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1557 // only show the X for close when there is a border
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1558 wp->w_popup_close = POPCLOSE_NONE;
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1559 }
b5499bf22a97 patch 8.1.1902: cannot have an info popup without a border
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
1560 }
17815
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1561 else if (STRNCMP(s, "align:", 6) == 0)
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1562 {
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1563 char_u *arg = s + 6;
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1564 int item = STRNCMP(arg, "item", 4) == 0 && arg + 4 == p;
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1565 int menu = STRNCMP(arg, "menu", 4) == 0 && arg + 4 == p;
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1566
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1567 if (!menu && !item)
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1568 return FAIL;
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1569 if (wp != NULL && menu)
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1570 wp->w_popup_flags |= POPF_INFO_MENU;
9ec2526c04c5 patch 8.1.1904: cannot have an info popup align with the popup menu
Bram Moolenaar <Bram@vim.org>
parents: 17811
diff changeset
1571 }
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1572 else
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1573 return FAIL;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1574 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1575 return OK;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1576 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1577
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1578 /*
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1579 * Parse the 'previewpopup' option and apply the values to window "wp" if it
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1580 * is not NULL.
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1581 * Return FAIL if the parsing fails.
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1582 */
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1583 int
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1584 parse_previewpopup(win_T *wp)
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1585 {
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1586 return parse_popup_option(wp, TRUE);
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1587 }
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1588
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1589 /*
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1590 * Parse the 'completepopup' option and apply the values to window "wp" if it
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1591 * is not NULL.
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1592 * Return FAIL if the parsing fails.
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1593 */
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1594 int
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1595 parse_completepopup(win_T *wp)
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1596 {
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1597 return parse_popup_option(wp, FALSE);
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1598 }
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1599
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1600 /*
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1601 * Set w_wantline and w_wantcol for the cursor position in the current window.
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1602 * Keep at least "width" columns from the right of the screen.
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1603 */
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1604 void
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1605 popup_set_wantpos_cursor(win_T *wp, int width)
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1606 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1607 setcursor_mayforce(TRUE);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1608 wp->w_wantline = curwin->w_winrow + curwin->w_wrow;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1609 if (wp->w_wantline == 0) // cursor in first line
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1610 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1611 wp->w_wantline = 2;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1612 wp->w_popup_pos = POPPOS_TOPLEFT;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1613 }
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1614
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1615 wp->w_wantcol = curwin->w_wincol + curwin->w_wcol + 1;
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1616 if (wp->w_wantcol > Columns - width)
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1617 {
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1618 wp->w_wantcol = Columns - width;
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1619 if (wp->w_wantcol < 1)
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1620 wp->w_wantcol = 1;
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
1621 }
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1622 popup_adjust_position(wp);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1623 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1624
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1625 /*
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1626 * Set w_wantline and w_wantcol for the a given screen position.
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1627 * Caller must take care of running into the window border.
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1628 */
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1629 void
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1630 popup_set_wantpos_rowcol(win_T *wp, int row, int col)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1631 {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1632 wp->w_wantline = row;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1633 wp->w_wantcol = col;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1634 popup_adjust_position(wp);
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1635 }
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1636
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1637 /*
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1638 * Add a border and lef&right padding.
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1639 */
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1640 static void
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1641 add_border_left_right_padding(win_T *wp)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1642 {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1643 int i;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1644
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1645 for (i = 0; i < 4; ++i)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1646 {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1647 wp->w_popup_border[i] = 1;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1648 wp->w_popup_padding[i] = (i & 1) ? 1 : 0;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1649 }
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1650 }
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1651
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1652 /*
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1653 * popup_create({text}, {options})
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1654 * popup_atcursor({text}, {options})
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1655 * etc.
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1656 * When creating a preview or info popup "argvars" and "rettv" are NULL.
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1657 */
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1658 static win_T *
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1659 popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1660 {
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1661 win_T *wp;
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1662 tabpage_T *tp = NULL;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1663 int tabnr = 0;
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1664 int new_buffer;
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1665 buf_T *buf = NULL;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1666 dict_T *d = NULL;
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1667 int nr;
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1668 int i;
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1669
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1670 if (argvars != NULL)
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1671 {
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
1672 // Check that arguments look OK.
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1673 if (argvars[0].v_type == VAR_NUMBER)
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1674 {
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1675 buf = buflist_findnr( argvars[0].vval.v_number);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1676 if (buf == NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1677 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1678 semsg(_(e_nobufnr), argvars[0].vval.v_number);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1679 return NULL;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1680 }
18166
8d7899bd6bca patch 8.1.2078: build error with +textprop but without +terminal
Bram Moolenaar <Bram@vim.org>
parents: 18162
diff changeset
1681 #ifdef FEAT_TERMINAL
18162
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18074
diff changeset
1682 if (buf->b_term != NULL)
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18074
diff changeset
1683 {
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18074
diff changeset
1684 emsg(_("E278: Cannot put a terminal buffer in a popup window"));
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18074
diff changeset
1685 return NULL;
9c3347b21b89 patch 8.1.2076: crash when trying to put a terminal in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18074
diff changeset
1686 }
18166
8d7899bd6bca patch 8.1.2078: build error with +textprop but without +terminal
Bram Moolenaar <Bram@vim.org>
parents: 18162
diff changeset
1687 #endif
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1688 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1689 else if (!(argvars[0].v_type == VAR_STRING
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1690 && argvars[0].vval.v_string != NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1691 && !(argvars[0].v_type == VAR_LIST
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1692 && argvars[0].vval.v_list != NULL))
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1693 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1694 emsg(_(e_listreq));
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1695 return NULL;
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1696 }
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1697 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1698 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1699 emsg(_(e_dictreq));
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1700 return NULL;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1701 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1702 d = argvars[1].vval.v_dict;
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1703 }
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1704
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1705 if (d != NULL)
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1706 {
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1707 if (dict_find(d, (char_u *)"tabpage", -1) != NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1708 tabnr = (int)dict_get_number(d, (char_u *)"tabpage");
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1709 else if (type == TYPE_NOTIFICATION)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1710 tabnr = -1; // notifications are global by default
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1711 else
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1712 tabnr = 0;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1713 if (tabnr > 0)
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1714 {
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1715 tp = find_tabpage(tabnr);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1716 if (tp == NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1717 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1718 semsg(_("E997: Tabpage not found: %d"), tabnr);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1719 return NULL;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1720 }
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1721 }
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1722 }
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1723
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1724 // Create the window and buffer.
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1725 wp = win_alloc_popup_win();
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1726 if (wp == NULL)
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1727 return NULL;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1728 if (rettv != NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1729 rettv->vval.v_number = wp->w_id;
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1730 wp->w_popup_pos = POPPOS_TOPLEFT;
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
1731 wp->w_popup_flags = POPF_IS_POPUP | POPF_MAPPING;
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1732
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1733 if (buf != NULL)
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1734 {
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1735 // use existing buffer
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1736 new_buffer = FALSE;
17231
e9ebf3f27af6 patch 8.1.1615: crash when passing buffer number to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17225
diff changeset
1737 win_init_popup_win(wp, buf);
17845
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17843
diff changeset
1738 set_local_options_default(wp, FALSE);
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1739 buffer_ensure_loaded(buf);
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1740 }
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1741 else
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1742 {
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1743 // create a new buffer associated with the popup
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1744 new_buffer = TRUE;
17823
7e6b7a4f13bc patch 8.1.1908: every popup window consumes a buffer number
Bram Moolenaar <Bram@vim.org>
parents: 17821
diff changeset
1745 buf = buflist_new(NULL, NULL, (linenr_T)0, BLN_NEW|BLN_DUMMY|BLN_REUSE);
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1746 if (buf == NULL)
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1747 return NULL;
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1748 ml_open(buf);
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1749
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1750 win_init_popup_win(wp, buf);
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16841
diff changeset
1751
17845
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17843
diff changeset
1752 set_local_options_default(wp, TRUE);
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1753 set_string_option_direct_in_buf(buf, (char_u *)"buftype", -1,
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1754 (char_u *)"popup", OPT_FREE|OPT_LOCAL, 0);
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1755 set_string_option_direct_in_buf(buf, (char_u *)"bufhidden", -1,
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1756 (char_u *)"wipe", OPT_FREE|OPT_LOCAL, 0);
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1757 buf->b_p_ul = -1; // no undo
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1758 buf->b_p_swf = FALSE; // no swap file
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1759 buf->b_p_bl = FALSE; // unlisted buffer
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1760 buf->b_locked = TRUE;
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
1761
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1762 // Avoid that 'buftype' is reset when this buffer is entered.
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1763 buf->b_p_initialized = TRUE;
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1764 }
17926
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17905
diff changeset
1765 wp->w_p_wrap = TRUE; // 'wrap' is default on
ad7a4bd65f20 patch 8.1.1959: when using "firstline" in popup window text may jump
Bram Moolenaar <Bram@vim.org>
parents: 17905
diff changeset
1766 wp->w_p_so = 0; // 'scrolloff' zero
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1767
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1768 if (tp != NULL)
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1769 {
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1770 // popup on specified tab page
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1771 wp->w_next = tp->tp_first_popupwin;
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1772 tp->tp_first_popupwin = wp;
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1773 }
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1774 else if (tabnr == 0)
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1775 {
17075
dacd46fbaa90 patch 8.1.1537: using "tab" for popup window can be confusing
Bram Moolenaar <Bram@vim.org>
parents: 17057
diff changeset
1776 // popup on current tab page
16796
5f98d80d116a patch 8.1.1400: using global pointer for tab-local popups is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1777 wp->w_next = curtab->tp_first_popupwin;
5f98d80d116a patch 8.1.1400: using global pointer for tab-local popups is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
1778 curtab->tp_first_popupwin = wp;
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1779 }
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
1780 else // (tabnr < 0)
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1781 {
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1782 win_T *prev = first_popupwin;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1783
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1784 // Global popup: add at the end, so that it gets displayed on top of
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1785 // older ones with the same zindex. Matters for notifications.
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1786 if (first_popupwin == NULL)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1787 first_popupwin = wp;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1788 else
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1789 {
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1790 while (prev->w_next != NULL)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1791 prev = prev->w_next;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1792 prev->w_next = wp;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1793 }
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1794 }
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1795
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1796 if (new_buffer && argvars != NULL)
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
1797 popup_set_buffer_text(buf, argvars[0]);
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1798
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1799 if (type == TYPE_ATCURSOR || type == TYPE_PREVIEW)
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1800 {
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1801 wp->w_popup_pos = POPPOS_BOTLEFT;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1802 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1803 if (type == TYPE_ATCURSOR)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1804 {
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1805 popup_set_wantpos_cursor(wp, 0);
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1806 set_moved_values(wp);
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1807 set_moved_columns(wp, FIND_STRING);
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1808 }
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1809
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1810 if (type == TYPE_BEVAL)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1811 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1812 wp->w_popup_pos = POPPOS_BOTLEFT;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1813
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1814 // by default use the mouse position
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1815 wp->w_wantline = mouse_row;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1816 if (wp->w_wantline <= 0) // mouse on first line
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1817 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1818 wp->w_wantline = 2;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1819 wp->w_popup_pos = POPPOS_TOPLEFT;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1820 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1821 wp->w_wantcol = mouse_col + 1;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1822 set_mousemoved_values(wp);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1823 set_mousemoved_columns(wp, FIND_IDENT + FIND_STRING + FIND_EVAL);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1824 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1825
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1826 // set default values
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1827 wp->w_zindex = POPUPWIN_DEFAULT_ZINDEX;
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
1828 wp->w_popup_close = POPCLOSE_NONE;
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1829
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1830 if (type == TYPE_NOTIFICATION)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1831 {
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1832 win_T *twp, *nextwin;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1833 int height = buf->b_ml.ml_line_count + 3;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1834
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1835 // Try to not overlap with another global popup. Guess we need 3
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1836 // more screen lines than buffer lines.
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1837 wp->w_wantline = 1;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1838 for (twp = first_popupwin; twp != NULL; twp = nextwin)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1839 {
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1840 nextwin = twp->w_next;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1841 if (twp != wp
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1842 && twp->w_zindex == POPUPWIN_NOTIFICATION_ZINDEX
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1843 && twp->w_winrow <= wp->w_wantline - 1 + height
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1844 && twp->w_winrow + popup_height(twp) > wp->w_wantline - 1)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1845 {
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1846 // move to below this popup and restart the loop to check for
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1847 // overlap with other popups
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1848 wp->w_wantline = twp->w_winrow + popup_height(twp) + 1;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1849 nextwin = first_popupwin;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1850 }
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1851 }
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1852 if (wp->w_wantline + height > Rows)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1853 {
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1854 // can't avoid overlap, put on top in the hope that message goes
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1855 // away soon.
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1856 wp->w_wantline = 1;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1857 }
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1858
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1859 wp->w_wantcol = 10;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1860 wp->w_zindex = POPUPWIN_NOTIFICATION_ZINDEX;
17077
2546930657a9 patch 8.1.1538: cannot specify highlighting for notifications
Bram Moolenaar <Bram@vim.org>
parents: 17075
diff changeset
1861 wp->w_minwidth = 20;
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
1862 wp->w_popup_flags |= POPF_DRAG;
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
1863 wp->w_popup_close = POPCLOSE_CLICK;
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1864 for (i = 0; i < 4; ++i)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1865 wp->w_popup_border[i] = 1;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1866 wp->w_popup_padding[1] = 1;
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1867 wp->w_popup_padding[3] = 1;
17077
2546930657a9 patch 8.1.1538: cannot specify highlighting for notifications
Bram Moolenaar <Bram@vim.org>
parents: 17075
diff changeset
1868
2546930657a9 patch 8.1.1538: cannot specify highlighting for notifications
Bram Moolenaar <Bram@vim.org>
parents: 17075
diff changeset
1869 nr = syn_name2id((char_u *)"PopupNotification");
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1870 set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
17077
2546930657a9 patch 8.1.1538: cannot specify highlighting for notifications
Bram Moolenaar <Bram@vim.org>
parents: 17075
diff changeset
1871 (char_u *)(nr == 0 ? "WarningMsg" : "PopupNotification"),
2546930657a9 patch 8.1.1538: cannot specify highlighting for notifications
Bram Moolenaar <Bram@vim.org>
parents: 17075
diff changeset
1872 OPT_FREE|OPT_LOCAL, 0);
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1873 }
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1874
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1875 if (type == TYPE_DIALOG || type == TYPE_MENU)
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
1876 {
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
1877 wp->w_popup_pos = POPPOS_CENTER;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
1878 wp->w_zindex = POPUPWIN_DIALOG_ZINDEX;
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
1879 wp->w_popup_flags |= POPF_DRAG;
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
1880 wp->w_popup_flags &= ~POPF_MAPPING;
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1881 add_border_left_right_padding(wp);
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
1882 }
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
1883
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1884 if (type == TYPE_MENU)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1885 {
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1886 typval_T tv;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1887 callback_T callback;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1888
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1889 tv.v_type = VAR_STRING;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1890 tv.vval.v_string = (char_u *)"popup_filter_menu";
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1891 callback = get_callback(&tv);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1892 if (callback.cb_name != NULL)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1893 set_callback(&wp->w_filter_cb, &callback);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1894
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1895 wp->w_p_wrap = 0;
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
1896 wp->w_popup_flags |= POPF_CURSORLINE;
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1897 }
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1898
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1899 if (type == TYPE_PREVIEW)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1900 {
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
1901 wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1902 wp->w_popup_close = POPCLOSE_BUTTON;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1903 for (i = 0; i < 4; ++i)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1904 wp->w_popup_border[i] = 1;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1905 parse_previewpopup(wp);
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1906 popup_set_wantpos_cursor(wp, wp->w_minwidth);
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1907 }
17791
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1908 # ifdef FEAT_QUICKFIX
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1909 if (type == TYPE_INFO)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1910 {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1911 wp->w_popup_pos = POPPOS_TOPLEFT;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1912 wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1913 wp->w_popup_close = POPCLOSE_BUTTON;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
1914 add_border_left_right_padding(wp);
17771
4bd21046902b patch 8.1.1882: cannot specify properties of the info popup window
Bram Moolenaar <Bram@vim.org>
parents: 17767
diff changeset
1915 parse_completepopup(wp);
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1916 }
17791
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
1917 # endif
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1918
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1919 for (i = 0; i < 4; ++i)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1920 VIM_CLEAR(wp->w_border_highlight[i]);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1921 for (i = 0; i < 8; ++i)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1922 wp->w_border_char[i] = 0;
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
1923 wp->w_want_scrollbar = 1;
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
1924 wp->w_popup_fixed = 0;
17946
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
1925 wp->w_filter_mode = MODE_ALL;
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
1926
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1927 if (d != NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1928 // Deal with options.
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
1929 apply_options(wp, d);
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1930
17166
59a4e78ccc5c patch 8.1.1582: cannot build with +textprop but without +timers
Bram Moolenaar <Bram@vim.org>
parents: 17162
diff changeset
1931 #ifdef FEAT_TIMERS
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1932 if (type == TYPE_NOTIFICATION && wp->w_popup_timer == NULL)
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1933 popup_add_timeout(wp, 3000);
17166
59a4e78ccc5c patch 8.1.1582: cannot build with +textprop but without +timers
Bram Moolenaar <Bram@vim.org>
parents: 17162
diff changeset
1934 #endif
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
1935
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
1936 popup_adjust_position(wp);
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1937
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1938 wp->w_vsep_width = 0;
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1939
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1940 redraw_all_later(NOT_VALID);
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
1941 popup_mask_refresh = TRUE;
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1942
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
1943 return wp;
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1944 }
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1945
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946 /*
17026
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1947 * popup_clear()
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1948 */
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1949 void
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1950 f_popup_clear(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1951 {
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1952 close_all_popups();
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1953 }
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1954
905e1b154058 patch 8.1.1513: all popup functionality is in functions, except :popupclear
Bram Moolenaar <Bram@vim.org>
parents: 16992
diff changeset
1955 /*
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1956 * popup_create({text}, {options})
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1957 */
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1958 void
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1959 f_popup_create(typval_T *argvars, typval_T *rettv)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1960 {
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1961 popup_create(argvars, rettv, TYPE_NORMAL);
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1962 }
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1963
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1964 /*
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1965 * popup_atcursor({text}, {options})
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1966 */
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1967 void
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1968 f_popup_atcursor(typval_T *argvars, typval_T *rettv)
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1969 {
16908
df06694b761b patch 8.1.1455: popup_atcursor() not completely implemented
Bram Moolenaar <Bram@vim.org>
parents: 16904
diff changeset
1970 popup_create(argvars, rettv, TYPE_ATCURSOR);
16853
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1971 }
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1972
e6bcccccbf7b patch 8.1.1428: popup_atcursor() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16851
diff changeset
1973 /*
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1974 * popup_beval({text}, {options})
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1975 */
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1976 void
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1977 f_popup_beval(typval_T *argvars, typval_T *rettv)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1978 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1979 popup_create(argvars, rettv, TYPE_BEVAL);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1980 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1981
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
1982 /*
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1983 * Invoke the close callback for window "wp" with value "result".
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1984 * Careful: The callback may make "wp" invalid!
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1985 */
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1986 static void
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1987 invoke_popup_callback(win_T *wp, typval_T *result)
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1988 {
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1989 typval_T rettv;
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1990 typval_T argv[3];
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1991
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1992 argv[0].v_type = VAR_NUMBER;
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1993 argv[0].vval.v_number = (varnumber_T)wp->w_id;
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1994
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1995 if (result != NULL && result->v_type != VAR_UNKNOWN)
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1996 copy_tv(result, &argv[1]);
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1997 else
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1998 {
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
1999 argv[1].v_type = VAR_NUMBER;
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2000 argv[1].vval.v_number = 0;
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2001 }
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2002
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2003 argv[2].v_type = VAR_UNKNOWN;
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2004
17606
ff097edaae89 patch 8.1.1800: function call functions have too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 17604
diff changeset
2005 call_callback(&wp->w_close_cb, -1, &rettv, 2, argv);
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2006 if (result != NULL)
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2007 clear_tv(&argv[1]);
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2008 clear_tv(&rettv);
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2009 }
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2010
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2011 /*
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2012 * Close popup "wp" and invoke any close callback for it.
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2013 */
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2014 static void
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2015 popup_close_and_callback(win_T *wp, typval_T *arg)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2016 {
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2017 int id = wp->w_id;
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2018
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2019 if (wp->w_close_cb.cb_name != NULL)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2020 // Careful: This may make "wp" invalid.
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2021 invoke_popup_callback(wp, arg);
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2022
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2023 popup_close(id);
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2024 }
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2025
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2026 static void
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2027 popup_close_with_retval(win_T *wp, int retval)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2028 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2029 typval_T res;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2030
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2031 res.v_type = VAR_NUMBER;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2032 res.vval.v_number = retval;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2033 popup_close_and_callback(wp, &res);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2034 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2035
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2036 /*
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2037 * Close popup "wp" because of a mouse click.
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2038 */
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2039 void
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2040 popup_close_for_mouse_click(win_T *wp)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2041 {
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2042 popup_close_with_retval(wp, -2);
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2043 }
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2044
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2045 static void
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2046 check_mouse_moved(win_T *wp, win_T *mouse_wp)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2047 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2048 // Close the popup when all if these are true:
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2049 // - the mouse is not on this popup
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2050 // - "mousemoved" was used
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2051 // - the mouse is no longer on the same screen row or the mouse column is
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2052 // outside of the relevant text
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2053 if (wp != mouse_wp
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2054 && wp->w_popup_mouse_row != 0
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2055 && (wp->w_popup_mouse_row != mouse_row
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2056 || mouse_col < wp->w_popup_mouse_mincol
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2057 || mouse_col > wp->w_popup_mouse_maxcol))
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2058 {
17300
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2059 // Careful: this makes "wp" invalid.
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2060 popup_close_with_retval(wp, -2);
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2061 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2062 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2063
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2064 /*
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2065 * Called when the mouse moved: may close a popup with "mousemoved".
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2066 */
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2067 void
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2068 popup_handle_mouse_moved(void)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2069 {
17300
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2070 win_T *wp, *nextwp;
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2071 win_T *mouse_wp;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2072 int row = mouse_row;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2073 int col = mouse_col;
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2074
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2075 // find the window where the mouse is in
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2076 mouse_wp = mouse_find_win(&row, &col, FIND_POPUP);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2077
17300
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2078 for (wp = first_popupwin; wp != NULL; wp = nextwp)
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2079 {
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2080 nextwp = wp->w_next;
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2081 check_mouse_moved(wp, mouse_wp);
17300
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2082 }
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2083 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = nextwp)
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2084 {
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2085 nextwp = wp->w_next;
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2086 check_mouse_moved(wp, mouse_wp);
17300
0dff534a0807 patch 8.1.1649: Illegal memory access when closing popup window
Bram Moolenaar <Bram@vim.org>
parents: 17292
diff changeset
2087 }
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2088 }
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2089
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2090 /*
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2091 * In a filter: check if the typed key is a mouse event that is used for
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2092 * dragging the popup.
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2093 */
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2094 static void
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2095 filter_handle_drag(win_T *wp, int c, typval_T *rettv)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2096 {
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2097 int row = mouse_row;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2098 int col = mouse_col;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2099
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
2100 if ((wp->w_popup_flags & POPF_DRAG)
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2101 && is_mouse_key(c)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2102 && (wp == popup_dragwin
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2103 || wp == mouse_find_win(&row, &col, FIND_POPUP)))
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2104 // do not consume the key, allow for dragging the popup
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2105 rettv->vval.v_number = 0;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2106 }
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2107
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2108 /*
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2109 * popup_filter_menu({text}, {options})
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2110 */
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2111 void
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2112 f_popup_filter_menu(typval_T *argvars, typval_T *rettv)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2113 {
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2114 int id = tv_get_number(&argvars[0]);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2115 win_T *wp = win_id2wp(id);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2116 char_u *key = tv_get_string(&argvars[1]);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2117 typval_T res;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2118 int c;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2119 linenr_T old_lnum;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2120
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2121 // If the popup has been closed do not consume the key.
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2122 if (wp == NULL)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2123 return;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2124
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2125 c = *key;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2126 if (c == K_SPECIAL && key[1] != NUL)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2127 c = TO_SPECIAL(key[1], key[2]);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2128
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2129 // consume all keys until done
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2130 rettv->vval.v_number = 1;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2131 res.v_type = VAR_NUMBER;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2132
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2133 old_lnum = wp->w_cursor.lnum;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2134 if ((c == 'k' || c == 'K' || c == K_UP) && wp->w_cursor.lnum > 1)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2135 --wp->w_cursor.lnum;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2136 if ((c == 'j' || c == 'J' || c == K_DOWN)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2137 && wp->w_cursor.lnum < wp->w_buffer->b_ml.ml_line_count)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2138 ++wp->w_cursor.lnum;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2139 if (old_lnum != wp->w_cursor.lnum)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2140 {
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
2141 // caller will call popup_highlight_curline()
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2142 return;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2143 }
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2144
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2145 if (c == 'x' || c == 'X' || c == ESC || c == Ctrl_C)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2146 {
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2147 // Cancelled, invoke callback with -1
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2148 res.vval.v_number = -1;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2149 popup_close_and_callback(wp, &res);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2150 return;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2151 }
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2152 if (c == ' ' || c == K_KENTER || c == CAR || c == NL)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2153 {
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2154 // Invoke callback with current index.
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2155 res.vval.v_number = wp->w_cursor.lnum;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2156 popup_close_and_callback(wp, &res);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2157 return;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2158 }
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2159
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2160 filter_handle_drag(wp, c, rettv);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2161 }
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2162
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2163 /*
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2164 * popup_filter_yesno({text}, {options})
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2165 */
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2166 void
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2167 f_popup_filter_yesno(typval_T *argvars, typval_T *rettv)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2168 {
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2169 int id = tv_get_number(&argvars[0]);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2170 win_T *wp = win_id2wp(id);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2171 char_u *key = tv_get_string(&argvars[1]);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2172 typval_T res;
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2173 int c;
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2174
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2175 // If the popup has been closed don't consume the key.
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2176 if (wp == NULL)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2177 return;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2178
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2179 c = *key;
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2180 if (c == K_SPECIAL && key[1] != NUL)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2181 c = TO_SPECIAL(key[1], key[2]);
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2182
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2183 // consume all keys until done
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2184 rettv->vval.v_number = 1;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2185
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2186 if (c == 'y' || c == 'Y')
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2187 res.vval.v_number = 1;
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2188 else if (c == 'n' || c == 'N' || c == 'x' || c == 'X' || c == ESC)
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2189 res.vval.v_number = 0;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2190 else
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2191 {
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2192 filter_handle_drag(wp, c, rettv);
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2193 return;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2194 }
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2195
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2196 // Invoke callback
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2197 res.v_type = VAR_NUMBER;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2198 popup_close_and_callback(wp, &res);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2199 }
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2200
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2201 /*
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2202 * popup_dialog({text}, {options})
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2203 */
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2204 void
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2205 f_popup_dialog(typval_T *argvars, typval_T *rettv)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2206 {
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2207 popup_create(argvars, rettv, TYPE_DIALOG);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2208 }
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2209
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2210 /*
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2211 * popup_menu({text}, {options})
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2212 */
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2213 void
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2214 f_popup_menu(typval_T *argvars, typval_T *rettv)
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2215 {
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2216 popup_create(argvars, rettv, TYPE_MENU);
17117
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2217 }
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2218
7ef5283ace3c patch 8.1.1558: popup_menu() and popup_filter_menu() are not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17111
diff changeset
2219 /*
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2220 * popup_notification({text}, {options})
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2221 */
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2222 void
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2223 f_popup_notification(typval_T *argvars, typval_T *rettv)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2224 {
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2225 popup_create(argvars, rettv, TYPE_NOTIFICATION);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2226 }
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2227
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2228 /*
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2229 * Find the popup window with window-ID "id".
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2230 * If the popup window does not exist NULL is returned.
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2231 * If the window is not a popup window, and error message is given.
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2232 */
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2233 static win_T *
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2234 find_popup_win(int id)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2235 {
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2236 win_T *wp = win_id2wp(id);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2237
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2238 if (wp != NULL && !WIN_IS_POPUP(wp))
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2239 {
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2240 semsg(_("E993: window %d is not a popup window"), id);
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2241 return NULL;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2242 }
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2243 return wp;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2244 }
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2245
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2246 /*
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2247 * popup_close({id})
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2248 */
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2249 void
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2250 f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2251 {
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2252 int id = (int)tv_get_number(argvars);
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2253 win_T *wp = find_popup_win(id);
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2254
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2255 if (wp != NULL)
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2256 popup_close_and_callback(wp, &argvars[1]);
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2257 }
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2258
18396
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2259 void
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2260 popup_hide(win_T *wp)
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2261 {
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2262 if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2263 {
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2264 wp->w_popup_flags |= POPF_HIDDEN;
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2265 --wp->w_buffer->b_nwindows;
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2266 redraw_all_later(NOT_VALID);
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2267 popup_mask_refresh = TRUE;
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2268 }
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2269 }
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2270
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2271 /*
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2272 * popup_hide({id})
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2273 */
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2274 void
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2275 f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED)
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2276 {
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2277 int id = (int)tv_get_number(argvars);
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2278 win_T *wp = find_popup_win(id);
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2279
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2280 if (wp != NULL)
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2281 popup_hide(wp);
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2282 }
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2283
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2284 void
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2285 popup_show(win_T *wp)
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2286 {
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2287 if ((wp->w_popup_flags & POPF_HIDDEN) != 0)
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2288 {
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2289 wp->w_popup_flags &= ~POPF_HIDDEN;
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2290 ++wp->w_buffer->b_nwindows;
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2291 redraw_all_later(NOT_VALID);
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
2292 popup_mask_refresh = TRUE;
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2293 }
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2294 }
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2295
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2296 /*
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2297 * popup_show({id})
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2298 */
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2299 void
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2300 f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2301 {
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2302 int id = (int)tv_get_number(argvars);
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2303 win_T *wp = find_popup_win(id);
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2304
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2305 if (wp != NULL)
18396
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2306 {
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
2307 popup_show(wp);
18396
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2308 if (wp->w_popup_flags & POPF_INFO)
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2309 pum_position_info_popup(wp);
ba5d8c5d77d7 patch 8.1.2192: cannot easily fill the info popup asynchronously
Bram Moolenaar <Bram@vim.org>
parents: 18339
diff changeset
2310 }
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2311 }
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2312
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2313 /*
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2314 * popup_settext({id}, {text})
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2315 */
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2316 void
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2317 f_popup_settext(typval_T *argvars, typval_T *rettv UNUSED)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2318 {
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2319 int id = (int)tv_get_number(&argvars[0]);
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2320 win_T *wp = find_popup_win(id);
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2321
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2322 if (wp != NULL)
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2323 {
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2324 if (argvars[1].v_type != VAR_STRING && argvars[1].v_type != VAR_LIST)
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2325 semsg(_(e_invarg2), tv_get_string(&argvars[1]));
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2326 else
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2327 {
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2328 popup_set_buffer_text(wp->w_buffer, argvars[1]);
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
2329 redraw_win_later(wp, NOT_VALID);
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2330 popup_adjust_position(wp);
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2331 }
17107
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2332 }
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2333 }
0001d10a7661 patch 8.1.1553: not easy to change the text in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17101
diff changeset
2334
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16796
diff changeset
2335 static void
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2336 popup_free(win_T *wp)
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16796
diff changeset
2337 {
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
2338 sign_undefine_by_name(popup_get_sign_name(wp), FALSE);
16833
6699c03347d2 patch 8.1.1418: win_execute() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16829
diff changeset
2339 wp->w_buffer->b_locked = FALSE;
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
2340 if (wp->w_winrow + popup_height(wp) >= cmdline_row)
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16796
diff changeset
2341 clear_cmdline = TRUE;
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16796
diff changeset
2342 win_free_popup(wp);
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
2343
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16796
diff changeset
2344 redraw_all_later(NOT_VALID);
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
2345 popup_mask_refresh = TRUE;
16800
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16796
diff changeset
2346 }
12e3a3afdb6a patch 8.1.1402: "timer" option of popup windows not supported
Bram Moolenaar <Bram@vim.org>
parents: 16796
diff changeset
2347
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2348 /*
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2349 * Close a popup window by Window-id.
16890
5131023c5728 patch 8.1.1446: popup window callback not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16888
diff changeset
2350 * Does not invoke the callback.
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2351 */
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2352 void
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2353 popup_close(int id)
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2354 {
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2355 win_T *wp;
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2356 tabpage_T *tp;
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2357 win_T *prev = NULL;
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2358
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2359 // go through global popups
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2360 for (wp = first_popupwin; wp != NULL; prev = wp, wp = wp->w_next)
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2361 if (wp->w_id == id)
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2362 {
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2363 if (prev == NULL)
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2364 first_popupwin = wp->w_next;
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2365 else
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2366 prev->w_next = wp->w_next;
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2367 popup_free(wp);
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2368 return;
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2369 }
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2370
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2371 // go through tab-local popups
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2372 FOR_ALL_TABPAGES(tp)
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2373 popup_close_tabpage(tp, id);
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2374 }
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2375
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2376 /*
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2377 * Close a popup window with Window-id "id" in tabpage "tp".
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2378 */
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2379 void
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2380 popup_close_tabpage(tabpage_T *tp, int id)
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2381 {
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2382 win_T *wp;
16796
5f98d80d116a patch 8.1.1400: using global pointer for tab-local popups is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
2383 win_T **root = &tp->tp_first_popupwin;
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2384 win_T *prev = NULL;
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2385
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2386 for (wp = *root; wp != NULL; prev = wp, wp = wp->w_next)
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2387 if (wp->w_id == id)
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2388 {
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2389 if (prev == NULL)
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2390 *root = wp->w_next;
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2391 else
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2392 prev->w_next = wp->w_next;
16809
5ff14f96f1c9 patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16806
diff changeset
2393 popup_free(wp);
16794
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2394 return;
ddfa924df50d patch 8.1.1399: popup windows not adjusted when switching tabs
Bram Moolenaar <Bram@vim.org>
parents: 16778
diff changeset
2395 }
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2396 }
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2397
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2398 void
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2399 close_all_popups(void)
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2400 {
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2401 while (first_popupwin != NULL)
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2402 popup_close(first_popupwin->w_id);
16796
5f98d80d116a patch 8.1.1400: using global pointer for tab-local popups is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
2403 while (curtab->tp_first_popupwin != NULL)
5f98d80d116a patch 8.1.1400: using global pointer for tab-local popups is clumsy
Bram Moolenaar <Bram@vim.org>
parents: 16794
diff changeset
2404 popup_close(curtab->tp_first_popupwin->w_id);
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2405 }
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2406
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2407 /*
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2408 * popup_move({id}, {options})
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2409 */
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2410 void
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2411 f_popup_move(typval_T *argvars, typval_T *rettv UNUSED)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2412 {
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2413 dict_T *dict;
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2414 int id = (int)tv_get_number(argvars);
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2415 win_T *wp = find_popup_win(id);
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2416
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2417 if (wp == NULL)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2418 return; // invalid {id}
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2419
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2420 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2421 {
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2422 emsg(_(e_dictreq));
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2423 return;
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2424 }
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2425 dict = argvars[1].vval.v_dict;
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2426
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2427 apply_move_options(wp, dict);
16817
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2428
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2429 if (wp->w_winrow + wp->w_height >= cmdline_row)
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2430 clear_cmdline = TRUE;
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2431 popup_adjust_position(wp);
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2432 }
069ee8dc8c8d patch 8.1.1410: popup_move() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16813
diff changeset
2433
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2434 /*
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2435 * popup_setoptions({id}, {options})
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2436 */
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2437 void
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2438 f_popup_setoptions(typval_T *argvars, typval_T *rettv UNUSED)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2439 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2440 dict_T *dict;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2441 int id = (int)tv_get_number(argvars);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2442 win_T *wp = find_popup_win(id);
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
2443 linenr_T old_firstline;
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2444
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2445 if (wp == NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2446 return; // invalid {id}
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2447
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2448 if (argvars[1].v_type != VAR_DICT || argvars[1].vval.v_dict == NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2449 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2450 emsg(_(e_dictreq));
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2451 return;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2452 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2453 dict = argvars[1].vval.v_dict;
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
2454 old_firstline = wp->w_firstline;
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2455
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2456 apply_move_options(wp, dict);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2457 apply_general_options(wp, dict);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2458
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
2459 if (old_firstline != wp->w_firstline)
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
2460 redraw_win_later(wp, NOT_VALID);
17125
b4eb06233448 patch 8.1.1562: popup window not always redrawn after popup_setoptions()
Bram Moolenaar <Bram@vim.org>
parents: 17123
diff changeset
2461 popup_mask_refresh = TRUE;
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2462 popup_highlight_curline(wp);
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2463 popup_adjust_position(wp);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2464 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2465
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2466 /*
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2467 * popup_getpos({id})
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2468 */
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2469 void
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2470 f_popup_getpos(typval_T *argvars, typval_T *rettv)
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2471 {
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2472 dict_T *dict;
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2473 int id = (int)tv_get_number(argvars);
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2474 win_T *wp = find_popup_win(id);
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2475 int top_extra;
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2476 int left_extra;
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2477
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2478 if (rettv_dict_alloc(rettv) == OK)
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2479 {
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2480 if (wp == NULL)
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2481 return; // invalid {id}
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
2482 top_extra = popup_top_extra(wp);
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2483 left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3];
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2484
17508
34966be2e856 patch 8.1.1752: resizing hashtable is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17506
diff changeset
2485 // we know how much space we need, avoid resizing halfway
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2486 dict = rettv->vval.v_dict;
17508
34966be2e856 patch 8.1.1752: resizing hashtable is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17506
diff changeset
2487 hash_lock_size(&dict->dv_hashtab, 11);
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2488
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2489 dict_add_number(dict, "line", wp->w_winrow + 1);
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2490 dict_add_number(dict, "col", wp->w_wincol + 1);
17045
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
2491 dict_add_number(dict, "width", wp->w_width + left_extra
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
2492 + wp->w_popup_border[1] + wp->w_popup_padding[1]);
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
2493 dict_add_number(dict, "height", wp->w_height + top_extra
7fe328ad5573 patch 8.1.1522: poup_notification() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17041
diff changeset
2494 + wp->w_popup_border[2] + wp->w_popup_padding[2]);
16884
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2495
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2496 dict_add_number(dict, "core_line", wp->w_winrow + 1 + top_extra);
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2497 dict_add_number(dict, "core_col", wp->w_wincol + 1 + left_extra);
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2498 dict_add_number(dict, "core_width", wp->w_width);
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2499 dict_add_number(dict, "core_height", wp->w_height);
59e4148c0c73 patch 8.1.1443: popup window padding and border not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16880
diff changeset
2500
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
2501 dict_add_number(dict, "scrollbar", wp->w_has_scrollbar);
17196
983950357c40 patch 8.1.1597: cannot scroll a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17194
diff changeset
2502 dict_add_number(dict, "firstline", wp->w_topline);
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2503 dict_add_number(dict, "visible",
16902
23645f9a5ce2 patch 8.1.1452: line and col property of popup windows not properly checked
Bram Moolenaar <Bram@vim.org>
parents: 16898
diff changeset
2504 win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0);
17508
34966be2e856 patch 8.1.1752: resizing hashtable is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17506
diff changeset
2505
34966be2e856 patch 8.1.1752: resizing hashtable is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17506
diff changeset
2506 hash_unlock(&dict->dv_hashtab);
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2507 }
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2508 }
17348
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2509 /*
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2510 * popup_locate({row}, {col})
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2511 */
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2512 void
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2513 f_popup_locate(typval_T *argvars, typval_T *rettv)
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2514 {
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2515 int row = tv_get_number(&argvars[0]) - 1;
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2516 int col = tv_get_number(&argvars[1]) - 1;
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2517 win_T *wp;
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2518
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2519 wp = mouse_find_win(&row, &col, FIND_POPUP);
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2520 if (WIN_IS_POPUP(wp))
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2521 rettv->vval.v_number = wp->w_id;
d82b0cfb1e82 patch 8.1.1673: cannot easily find the popup window at a certain position
Bram Moolenaar <Bram@vim.org>
parents: 17334
diff changeset
2522 }
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2523
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2524 /*
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2525 * For popup_getoptions(): add a "border" or "padding" entry to "dict".
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2526 */
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2527 static void
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2528 get_padding_border(dict_T *dict, int *array, char *name)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2529 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2530 list_T *list;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2531 int i;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2532
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2533 if (array[0] == 0 && array[1] == 0 && array[2] == 0 && array[3] == 0)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2534 return;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2535
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2536 list = list_alloc();
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2537 if (list != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2538 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2539 dict_add_list(dict, name, list);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2540 if (array[0] != 1 || array[1] != 1 || array[2] != 1 || array[3] != 1)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2541 for (i = 0; i < 4; ++i)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2542 list_append_number(list, array[i]);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2543 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2544 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2545
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2546 /*
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2547 * For popup_getoptions(): add a "borderhighlight" entry to "dict".
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2548 */
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2549 static void
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2550 get_borderhighlight(dict_T *dict, win_T *wp)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2551 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2552 list_T *list;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2553 int i;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2554
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2555 for (i = 0; i < 4; ++i)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2556 if (wp->w_border_highlight[i] != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2557 break;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2558 if (i == 4)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2559 return;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2560
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2561 list = list_alloc();
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2562 if (list != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2563 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2564 dict_add_list(dict, "borderhighlight", list);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2565 for (i = 0; i < 4; ++i)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2566 list_append_string(list, wp->w_border_highlight[i], -1);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2567 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2568 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2569
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2570 /*
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2571 * For popup_getoptions(): add a "borderchars" entry to "dict".
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2572 */
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2573 static void
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2574 get_borderchars(dict_T *dict, win_T *wp)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2575 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2576 list_T *list;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2577 int i;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2578 char_u buf[NUMBUFLEN];
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2579 int len;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2580
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2581 for (i = 0; i < 8; ++i)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2582 if (wp->w_border_char[i] != 0)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2583 break;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2584 if (i == 8)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2585 return;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2586
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2587 list = list_alloc();
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2588 if (list != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2589 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2590 dict_add_list(dict, "borderchars", list);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2591 for (i = 0; i < 8; ++i)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2592 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2593 len = mb_char2bytes(wp->w_border_char[i], buf);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2594 list_append_string(list, buf, len);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2595 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2596 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2597 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2598
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2599 /*
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2600 * For popup_getoptions(): add a "moved" and "mousemoved" entry to "dict".
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2601 */
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2602 static void
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2603 get_moved_list(dict_T *dict, win_T *wp)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2604 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2605 list_T *list;
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2606
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2607 list = list_alloc();
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2608 if (list != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2609 {
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2610 dict_add_list(dict, "moved", list);
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2611 list_append_number(list, wp->w_popup_lnum);
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2612 list_append_number(list, wp->w_popup_mincol);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2613 list_append_number(list, wp->w_popup_maxcol);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2614 }
17292
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2615 list = list_alloc();
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2616 if (list != NULL)
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2617 {
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2618 dict_add_list(dict, "mousemoved", list);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2619 list_append_number(list, wp->w_popup_mouse_row);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2620 list_append_number(list, wp->w_popup_mouse_mincol);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2621 list_append_number(list, wp->w_popup_mouse_maxcol);
8a095d343c59 patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17274
diff changeset
2622 }
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2623 }
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2624
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2625 /*
16986
03f3a9ca2770 patch 8.1.1493: redrawing with popups is slow and causes flicker
Bram Moolenaar <Bram@vim.org>
parents: 16908
diff changeset
2626 * popup_getoptions({id})
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2627 */
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2628 void
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2629 f_popup_getoptions(typval_T *argvars, typval_T *rettv)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2630 {
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2631 dict_T *dict;
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2632 int id = (int)tv_get_number(argvars);
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2633 win_T *wp = find_popup_win(id);
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2634 tabpage_T *tp;
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2635 int i;
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2636
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2637 if (rettv_dict_alloc(rettv) == OK)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2638 {
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2639 if (wp == NULL)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2640 return;
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2641
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2642 dict = rettv->vval.v_dict;
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2643 dict_add_number(dict, "line", wp->w_wantline);
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2644 dict_add_number(dict, "col", wp->w_wantcol);
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2645 dict_add_number(dict, "minwidth", wp->w_minwidth);
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2646 dict_add_number(dict, "minheight", wp->w_minheight);
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2647 dict_add_number(dict, "maxheight", wp->w_maxheight);
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2648 dict_add_number(dict, "maxwidth", wp->w_maxwidth);
17047
6400d1ad5e4b patch 8.1.1523: cannot show range of buffer lines in popup window
Bram Moolenaar <Bram@vim.org>
parents: 17045
diff changeset
2649 dict_add_number(dict, "firstline", wp->w_firstline);
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
2650 dict_add_number(dict, "scrollbar", wp->w_want_scrollbar);
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2651 dict_add_number(dict, "zindex", wp->w_zindex);
16896
52fc577a087d patch 8.1.1449: popup text truncated at end of screen
Bram Moolenaar <Bram@vim.org>
parents: 16892
diff changeset
2652 dict_add_number(dict, "fixed", wp->w_popup_fixed);
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2653 if (wp->w_popup_prop_type && win_valid(wp->w_popup_prop_win))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2654 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2655 proptype_T *pt = text_prop_type_by_id(
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2656 wp->w_popup_prop_win->w_buffer,
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2657 wp->w_popup_prop_type);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2658
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2659 if (pt != NULL)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2660 dict_add_string(dict, "textprop", pt->pt_name);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2661 dict_add_number(dict, "textpropwin", wp->w_popup_prop_win->w_id);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2662 dict_add_number(dict, "textpropid", wp->w_popup_prop_id);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2663 }
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2664 dict_add_string(dict, "title", wp->w_popup_title);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2665 dict_add_number(dict, "wrap", wp->w_p_wrap);
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
2666 dict_add_number(dict, "drag", (wp->w_popup_flags & POPF_DRAG) != 0);
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2667 dict_add_number(dict, "mapping",
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2668 (wp->w_popup_flags & POPF_MAPPING) != 0);
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
2669 dict_add_number(dict, "resize", (wp->w_popup_flags & POPF_RESIZE) != 0);
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
2670 dict_add_number(dict, "cursorline",
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
2671 (wp->w_popup_flags & POPF_CURSORLINE) != 0);
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2672 dict_add_string(dict, "highlight", wp->w_p_wcr);
17202
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
2673 if (wp->w_scrollbar_highlight != NULL)
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
2674 dict_add_string(dict, "scrollbarhighlight",
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
2675 wp->w_scrollbar_highlight);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
2676 if (wp->w_thumb_highlight != NULL)
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
2677 dict_add_string(dict, "thumbhighlight", wp->w_thumb_highlight);
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2678
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2679 // find the tabpage that holds this popup
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2680 i = 1;
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2681 FOR_ALL_TABPAGES(tp)
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2682 {
18229
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
2683 win_T *twp;
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
2684
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
2685 for (twp = tp->tp_first_popupwin; twp != NULL; twp = twp->w_next)
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
2686 if (twp->w_id == id)
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2687 break;
18229
e6c83ae0c4d0 patch 8.1.2109: popup_getoptions() hangs with tab-local popup
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
2688 if (twp != NULL)
17149
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2689 break;
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2690 ++i;
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2691 }
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2692 if (tp == NULL)
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2693 i = -1; // must be global
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2694 else if (tp == curtab)
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2695 i = 0;
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2696 dict_add_number(dict, "tabpage", i);
c90fdb999393 patch 8.1.1574: tabpage option not yet implemented for popup window
Bram Moolenaar <Bram@vim.org>
parents: 17125
diff changeset
2697
17123
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2698 get_padding_border(dict, wp->w_popup_padding, "padding");
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2699 get_padding_border(dict, wp->w_popup_border, "border");
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2700 get_borderhighlight(dict, wp);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2701 get_borderchars(dict, wp);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2702 get_moved_list(dict, wp);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2703
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2704 if (wp->w_filter_cb.cb_name != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2705 dict_add_callback(dict, "filter", &wp->w_filter_cb);
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2706 if (wp->w_close_cb.cb_name != NULL)
efc6f5e3b543 patch 8.1.1561: popup_setoptions() is not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17121
diff changeset
2707 dict_add_callback(dict, "callback", &wp->w_close_cb);
16855
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2708
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2709 for (i = 0; i < (int)(sizeof(poppos_entries) / sizeof(poppos_entry_T));
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2710 ++i)
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2711 if (wp->w_popup_pos == poppos_entries[i].pp_val)
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2712 {
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2713 dict_add_string(dict, "pos",
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2714 (char_u *)poppos_entries[i].pp_name);
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2715 break;
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2716 }
19162ff4eacd patch 8.1.1429: "pos" option of popup window not supported yet
Bram Moolenaar <Bram@vim.org>
parents: 16853
diff changeset
2717
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2718 dict_add_string(dict, "close", (char_u *)(
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2719 wp->w_popup_close == POPCLOSE_BUTTON ? "button"
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2720 : wp->w_popup_close == POPCLOSE_CLICK ? "click" : "none"));
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
2721
16841
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2722 # if defined(FEAT_TIMERS)
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2723 dict_add_number(dict, "time", wp->w_popup_timer != NULL
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2724 ? (long)wp->w_popup_timer->tr_interval : 0L);
cf630fab9fb6 patch 8.1.1422: popup_getoptions() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16839
diff changeset
2725 # endif
16829
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2726 }
5cebaecad422 patch 8.1.1416: popup_getposition() not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16817
diff changeset
2727 }
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2728
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2729 int
17111
af861fccc309 patch 8.1.1555: NOT_IN_POPUP_WINDOW is confusing
Bram Moolenaar <Bram@vim.org>
parents: 17107
diff changeset
2730 error_if_popup_window()
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2731 {
17225
09fa437d33d8 patch 8.1.1612: cannot show an existing buffer in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17219
diff changeset
2732 if (WIN_IS_POPUP(curwin))
16874
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2733 {
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2734 emsg(_("E994: Not allowed in a popup window"));
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2735 return TRUE;
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2736 }
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2737 return FALSE;
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2738 }
da5f5836e90c patch 8.1.1438: some commands cause trouble in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 16872
diff changeset
2739
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2740 /*
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2741 * Reset all the POPF_HANDLED flags in global popup windows and popup windows
17075
dacd46fbaa90 patch 8.1.1537: using "tab" for popup window can be confusing
Bram Moolenaar <Bram@vim.org>
parents: 17057
diff changeset
2742 * in the current tab page.
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2743 */
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2744 void
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2745 popup_reset_handled()
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2746 {
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2747 win_T *wp;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2748
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2749 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2750 wp->w_popup_flags &= ~POPF_HANDLED;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2751 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2752 wp->w_popup_flags &= ~POPF_HANDLED;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2753 }
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2754
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2755 /*
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2756 * Find the next visible popup where POPF_HANDLED is not set.
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2757 * Must have called popup_reset_handled() first.
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2758 * When "lowest" is TRUE find the popup with the lowest zindex, otherwise the
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2759 * popup with the highest zindex.
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2760 */
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2761 win_T *
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2762 find_next_popup(int lowest)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2763 {
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2764 win_T *wp;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2765 win_T *found_wp;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2766 int found_zindex;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2767
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2768 found_zindex = lowest ? INT_MAX : 0;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2769 found_wp = NULL;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2770 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2771 if ((wp->w_popup_flags & (POPF_HANDLED|POPF_HIDDEN)) == 0
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2772 && (lowest ? wp->w_zindex < found_zindex
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2773 : wp->w_zindex > found_zindex))
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2774 {
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2775 found_zindex = wp->w_zindex;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2776 found_wp = wp;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2777 }
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2778 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2779 if ((wp->w_popup_flags & (POPF_HANDLED|POPF_HIDDEN)) == 0
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2780 && (lowest ? wp->w_zindex < found_zindex
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2781 : wp->w_zindex > found_zindex))
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2782 {
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2783 found_zindex = wp->w_zindex;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2784 found_wp = wp;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2785 }
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2786
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2787 if (found_wp != NULL)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2788 found_wp->w_popup_flags |= POPF_HANDLED;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2789 return found_wp;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2790 }
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2791
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2792 /*
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2793 * Invoke the filter callback for window "wp" with typed character "c".
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2794 * Uses the global "mod_mask" for modifiers.
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2795 * Returns the return value of the filter.
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2796 * Careful: The filter may make "wp" invalid!
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2797 */
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2798 static int
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2799 invoke_popup_filter(win_T *wp, int c)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2800 {
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2801 int res;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2802 typval_T rettv;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2803 typval_T argv[3];
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2804 char_u buf[NUMBUFLEN];
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2805 linenr_T old_lnum = wp->w_cursor.lnum;
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2806
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2807 // Emergency exit: CTRL-C closes the popup.
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2808 if (c == Ctrl_C)
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2809 {
18239
9e696b8fee7d patch 8.1.2114: when a popup is closed with CTRL-C the callback aborts
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2810 int save_got_int = got_int;
9e696b8fee7d patch 8.1.2114: when a popup is closed with CTRL-C the callback aborts
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2811
9e696b8fee7d patch 8.1.2114: when a popup is closed with CTRL-C the callback aborts
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2812 // Reset got_int to avoid the callback isn't called.
9e696b8fee7d patch 8.1.2114: when a popup is closed with CTRL-C the callback aborts
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2813 got_int = FALSE;
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2814 popup_close_with_retval(wp, -1);
18239
9e696b8fee7d patch 8.1.2114: when a popup is closed with CTRL-C the callback aborts
Bram Moolenaar <Bram@vim.org>
parents: 18229
diff changeset
2815 got_int |= save_got_int;
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2816 return 1;
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2817 }
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2818
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2819 argv[0].v_type = VAR_NUMBER;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2820 argv[0].vval.v_number = (varnumber_T)wp->w_id;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2821
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2822 // Convert the number to a string, so that the function can use:
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2823 // if a:c == "\<F2>"
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2824 buf[special_to_buf(c, mod_mask, TRUE, buf)] = NUL;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2825 argv[1].v_type = VAR_STRING;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2826 argv[1].vval.v_string = vim_strsave(buf);
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2827
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2828 argv[2].v_type = VAR_UNKNOWN;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2829
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2830 // NOTE: The callback might close the popup, thus make "wp" invalid.
17606
ff097edaae89 patch 8.1.1800: function call functions have too many arguments
Bram Moolenaar <Bram@vim.org>
parents: 17604
diff changeset
2831 call_callback(&wp->w_filter_cb, -1, &rettv, 2, argv);
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17431
diff changeset
2832 if (win_valid_popup(wp) && old_lnum != wp->w_cursor.lnum)
17429
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2833 popup_highlight_curline(wp);
6e756ad5ef1a patch 8.1.1713: highlighting cursor line only works with popup_menu()
Bram Moolenaar <Bram@vim.org>
parents: 17421
diff changeset
2834
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2835 res = tv_get_number(&rettv);
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2836 vim_free(argv[1].vval.v_string);
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2837 clear_tv(&rettv);
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2838 return res;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2839 }
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2840
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2841 /*
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2842 * Called when "c" was typed: invoke popup filter callbacks.
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2843 * Returns TRUE when the character was consumed,
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2844 */
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2845 int
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2846 popup_do_filter(int c)
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2847 {
17934
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2848 static int recursive = FALSE;
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2849 int res = FALSE;
17097
94007c802045 patch 8.1.1548: popup_dialog() is not implemented
Bram Moolenaar <Bram@vim.org>
parents: 17077
diff changeset
2850 win_T *wp;
17934
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2851 int save_KeyTyped = KeyTyped;
17946
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
2852 int state;
18004
6006bb74bd52 patch 8.1.1998: redraw even when no popup window filter was invoked
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2853 int was_must_redraw = must_redraw;
17934
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2854
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2855 if (recursive)
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2856 return FALSE;
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2857 recursive = TRUE;
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2858
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2859 popup_reset_handled();
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2860
17847
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2861 if (c == K_LEFTMOUSE)
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2862 {
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2863 int row = mouse_row;
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2864 int col = mouse_col;
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2865
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2866 wp = mouse_find_win(&row, &col, FIND_POPUP);
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2867 if (wp != NULL && popup_close_if_on_X(wp, row, col))
17934
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2868 res = TRUE;
17847
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2869 }
bdddd215bf09 patch 8.1.1920: cannot always close a popup when filter consumes all events
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2870
17946
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
2871 state = get_real_state();
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2872 while (!res && (wp = find_next_popup(FALSE)) != NULL)
17946
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
2873 if (wp->w_filter_cb.cb_name != NULL
ec4248c4b92c patch 8.1.1969: popup window filter is used in all modes
Bram Moolenaar <Bram@vim.org>
parents: 17934
diff changeset
2874 && (wp->w_filter_mode & state) != 0)
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2875 res = invoke_popup_filter(wp, c);
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2876
18004
6006bb74bd52 patch 8.1.1998: redraw even when no popup window filter was invoked
Bram Moolenaar <Bram@vim.org>
parents: 18002
diff changeset
2877 if (must_redraw > was_must_redraw)
18002
2fdbcecab216 patch 8.1.1997: no redraw after a popup window filter is invoked
Bram Moolenaar <Bram@vim.org>
parents: 17946
diff changeset
2878 redraw_after_callback(FALSE);
17934
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2879 recursive = FALSE;
0bf8cb0258be patch 8.1.1963: popup window filter may be called recursively
Bram Moolenaar <Bram@vim.org>
parents: 17926
diff changeset
2880 KeyTyped = save_KeyTyped;
16880
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2881 return res;
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2882 }
998603a243d7 patch 8.1.1441: popup window filter not yet implemented
Bram Moolenaar <Bram@vim.org>
parents: 16874
diff changeset
2883
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2884 /*
17604
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2885 * Return TRUE if there is a popup visible with a filter callback and the
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2886 * "mapping" property off.
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2887 */
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2888 int
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2889 popup_no_mapping(void)
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2890 {
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2891 int round;
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2892 win_T *wp;
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2893
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2894 for (round = 1; round <= 2; ++round)
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2895 for (wp = round == 1 ? first_popupwin : curtab->tp_first_popupwin;
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2896 wp != NULL; wp = wp->w_next)
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2897 if (wp->w_filter_cb.cb_name != NULL
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2898 && (wp->w_popup_flags & (POPF_HIDDEN | POPF_MAPPING)) == 0)
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2899 return TRUE;
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2900 return FALSE;
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2901 }
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2902
506dd2efcbb2 patch 8.1.1799: cannot avoid mapping for a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17584
diff changeset
2903 /*
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2904 * Called when the cursor moved: check if any popup needs to be closed if the
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2905 * cursor moved far enough.
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2906 */
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2907 void
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2908 popup_check_cursor_pos()
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2909 {
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2910 win_T *wp;
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2911
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2912 popup_reset_handled();
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2913 while ((wp = find_next_popup(TRUE)) != NULL)
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2914 if (wp->w_popup_curwin != NULL
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2915 && (curwin != wp->w_popup_curwin
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2916 || curwin->w_cursor.lnum != wp->w_popup_lnum
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2917 || curwin->w_cursor.col < wp->w_popup_mincol
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2918 || curwin->w_cursor.col > wp->w_popup_maxcol))
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
2919 popup_close_with_retval(wp, -1);
16904
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2920 }
9138e2c60bf1 patch 8.1.1453: popup window "moved" property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 16902
diff changeset
2921
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
2922 /*
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2923 * Update "w_popup_mask_cells".
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2924 */
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2925 static void
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2926 popup_update_mask(win_T *wp, int width, int height)
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2927 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2928 listitem_T *lio, *li;
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2929 char_u *cells;
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2930 int row, col;
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2931
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2932 if (wp->w_popup_mask == NULL)
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2933 return;
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2934 if (wp->w_popup_mask_cells != NULL
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2935 && wp->w_popup_mask_height == height
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2936 && wp->w_popup_mask_width == width)
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2937 return; // cache is still valid
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2938
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2939 vim_free(wp->w_popup_mask_cells);
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2940 wp->w_popup_mask_cells = alloc_clear(width * height);
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2941 if (wp->w_popup_mask_cells == NULL)
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2942 return;
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2943 cells = wp->w_popup_mask_cells;
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2944
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2945 for (lio = wp->w_popup_mask->lv_first; lio != NULL; lio = lio->li_next)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2946 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2947 int cols, cole;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2948 int lines, linee;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2949
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2950 li = lio->li_tv.vval.v_list->lv_first;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2951 cols = tv_get_number(&li->li_tv);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2952 if (cols < 0)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2953 cols = width + cols + 1;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2954 li = li->li_next;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2955 cole = tv_get_number(&li->li_tv);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2956 if (cole < 0)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2957 cole = width + cole + 1;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2958 li = li->li_next;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2959 lines = tv_get_number(&li->li_tv);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2960 if (lines < 0)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2961 lines = height + lines + 1;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2962 li = li->li_next;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2963 linee = tv_get_number(&li->li_tv);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2964 if (linee < 0)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2965 linee = height + linee + 1;
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2966
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2967 for (row = lines - 1; row < linee && row < height; ++row)
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2968 for (col = cols - 1; col < cole && col < width; ++col)
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2969 cells[row * width + col] = 1;
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2970 }
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2971 }
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2972
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2973 /*
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2974 * Return TRUE if "col" / "line" matches with an entry in w_popup_mask.
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2975 * "col" and "line" are screen coordinates.
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2976 */
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2977 static int
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2978 popup_masked(win_T *wp, int width, int height, int screencol, int screenline)
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2979 {
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2980 int col = screencol - wp->w_wincol + wp->w_popup_leftoff;
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2981 int line = screenline - wp->w_winrow;
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2982
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2983 return col >= 0 && col < width
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2984 && line >= 0 && line < height
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
2985 && wp->w_popup_mask_cells[line * width + col];
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2986 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2987
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2988 /*
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2989 * Set flags in popup_transparent[] for window "wp" to "val".
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2990 */
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2991 static void
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2992 update_popup_transparent(win_T *wp, int val)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2993 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2994 if (wp->w_popup_mask != NULL)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2995 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2996 int width = popup_width(wp);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2997 int height = popup_height(wp);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2998 listitem_T *lio, *li;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
2999 int cols, cole;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3000 int lines, linee;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3001 int col, line;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3002
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3003 for (lio = wp->w_popup_mask->lv_first; lio != NULL; lio = lio->li_next)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3004 {
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3005 li = lio->li_tv.vval.v_list->lv_first;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3006 cols = tv_get_number(&li->li_tv);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3007 if (cols < 0)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3008 cols = width + cols + 1;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3009 li = li->li_next;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3010 cole = tv_get_number(&li->li_tv);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3011 if (cole < 0)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3012 cole = width + cole + 1;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3013 li = li->li_next;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3014 lines = tv_get_number(&li->li_tv);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3015 if (lines < 0)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3016 lines = height + lines + 1;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3017 li = li->li_next;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3018 linee = tv_get_number(&li->li_tv);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3019 if (linee < 0)
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3020 linee = height + linee + 1;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3021
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3022 --cols;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3023 cols -= wp->w_popup_leftoff;
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
3024 if (cols < 0)
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
3025 cols = 0;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3026 cole -= wp->w_popup_leftoff;
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3027 --lines;
17206
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
3028 if (lines < 0)
8ca93f88b84a patch 8.1.1602: popup window cannot overflow on the left or right
Bram Moolenaar <Bram@vim.org>
parents: 17202
diff changeset
3029 lines = 0;
17332
61f0bf94ef92 patch 8.1.1665: crash when popup window with mask is below the screen
Bram Moolenaar <Bram@vim.org>
parents: 17328
diff changeset
3030 for (line = lines; line < linee
61f0bf94ef92 patch 8.1.1665: crash when popup window with mask is below the screen
Bram Moolenaar <Bram@vim.org>
parents: 17328
diff changeset
3031 && line + wp->w_winrow < screen_Rows; ++line)
61f0bf94ef92 patch 8.1.1665: crash when popup window with mask is below the screen
Bram Moolenaar <Bram@vim.org>
parents: 17328
diff changeset
3032 for (col = cols; col < cole
61f0bf94ef92 patch 8.1.1665: crash when popup window with mask is below the screen
Bram Moolenaar <Bram@vim.org>
parents: 17328
diff changeset
3033 && col + wp->w_wincol < screen_Columns; ++col)
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3034 popup_transparent[(line + wp->w_winrow) * screen_Columns
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3035 + col + wp->w_wincol] = val;
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3036 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3037 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3038 }
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3039
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3040 /*
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3041 * Only called when popup window "wp" is hidden: If the window is positioned
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3042 * next to a text property, and it is now visible, then unhide the popup.
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3043 * We don't check if visible popups become hidden, that is done in
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3044 * popup_adjust_position().
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3045 * Return TRUE if the popup became unhidden.
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3046 */
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3047 static int
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3048 check_popup_unhidden(win_T *wp)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3049 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3050 if (wp->w_popup_prop_type > 0 && win_valid(wp->w_popup_prop_win))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3051 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3052 textprop_T prop;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3053 linenr_T lnum;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3054
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3055 if (find_visible_prop(wp->w_popup_prop_win,
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3056 wp->w_popup_prop_type, wp->w_popup_prop_id,
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3057 &prop, &lnum) == OK)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3058 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3059 wp->w_popup_flags &= ~POPF_HIDDEN;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3060 ++wp->w_buffer->b_nwindows;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3061 wp->w_popup_prop_topline = 0; // force repositioning
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3062 return TRUE;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3063 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3064 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3065 return FALSE;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3066 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3067
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3068 /*
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3069 * Return TRUE if popup_adjust_position() needs to be called for "wp".
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3070 * That is when the buffer in the popup was changed, or the popup is following
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3071 * a textprop and the referenced buffer was changed.
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
3072 * Or when the cursor line changed and "cursorline" is set.
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3073 */
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3074 static int
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3075 popup_need_position_adjust(win_T *wp)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3076 {
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3077 if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3078 return TRUE;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3079 if (win_valid(wp->w_popup_prop_win))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3080 return wp->w_popup_prop_changedtick
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3081 != CHANGEDTICK(wp->w_popup_prop_win->w_buffer)
18027
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
3082 || wp->w_popup_prop_topline != wp->w_popup_prop_win->w_topline
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
3083 || ((wp->w_popup_flags & POPF_CURSORLINE)
56032a704448 patch 8.1.2009: cursorline highlighting not updated in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18004
diff changeset
3084 && wp->w_cursor.lnum != wp->w_popup_last_curline);
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3085 return FALSE;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3086 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3087
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3088 /*
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3089 * Update "popup_mask" if needed.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3090 * Also recomputes the popup size and positions.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3091 * Also updates "popup_visible".
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3092 * Also marks window lines for redrawing.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3093 */
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3094 void
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3095 may_update_popup_mask(int type)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3096 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3097 win_T *wp;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3098 short *mask;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3099 int line, col;
17843
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3100 int redraw_all_popups = FALSE;
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3101 int redrawing_all_win;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3102
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3103 // Need to recompute when switching tabs.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3104 // Also recompute when the type is CLEAR or NOT_VALID, something basic
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3105 // (such as the screen size) must have changed.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3106 if (popup_mask_tab != curtab || type >= NOT_VALID)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3107 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3108 popup_mask_refresh = TRUE;
17843
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3109 redraw_all_popups = TRUE;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3110 }
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3111
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3112 // Check if any popup window buffer has changed and if any popup connected
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3113 // to a text property has become visible.
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3114 for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3115 if (wp->w_popup_flags & POPF_HIDDEN)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3116 popup_mask_refresh |= check_popup_unhidden(wp);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3117 else if (popup_need_position_adjust(wp))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3118 popup_mask_refresh = TRUE;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3119 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3120 if (wp->w_popup_flags & POPF_HIDDEN)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3121 popup_mask_refresh |= check_popup_unhidden(wp);
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3122 else if (popup_need_position_adjust(wp))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3123 popup_mask_refresh = TRUE;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3124
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3125 if (!popup_mask_refresh)
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3126 return;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3127
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3128 // Need to update the mask, something has changed.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3129 popup_mask_refresh = FALSE;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3130 popup_mask_tab = curtab;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3131 popup_visible = FALSE;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3132
17843
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3133 // If redrawing all windows, just update "popup_mask".
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3134 // If redrawing only what is needed, update "popup_mask_next" and then
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3135 // compare with "popup_mask" to see what changed.
17843
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3136 redrawing_all_win = TRUE;
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3137 FOR_ALL_WINDOWS(wp)
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3138 if (wp->w_redr_type < SOME_VALID)
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3139 redrawing_all_win = FALSE;
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3140 if (redrawing_all_win)
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3141 mask = popup_mask;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3142 else
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3143 mask = popup_mask_next;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3144 vim_memset(mask, 0, screen_Rows * screen_Columns * sizeof(short));
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3145
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3146 // Find the window with the lowest zindex that hasn't been handled yet,
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3147 // so that the window with a higher zindex overwrites the value in
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3148 // popup_mask.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3149 popup_reset_handled();
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3150 while ((wp = find_next_popup(TRUE)) != NULL)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3151 {
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
3152 int width;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3153 int height;
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3154
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3155 popup_visible = TRUE;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3156
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3157 // Recompute the position if the text changed. It may make the popup
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3158 // hidden if it's attach to a text property that is no longer visible.
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3159 if (redraw_all_popups || popup_need_position_adjust(wp))
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3160 {
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3161 popup_adjust_position(wp);
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3162 if (wp->w_popup_flags & POPF_HIDDEN)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3163 continue;
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3164 }
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3165
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
3166 width = popup_width(wp);
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3167 height = popup_height(wp);
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
3168 popup_update_mask(wp, width, height);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3169 for (line = wp->w_winrow;
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3170 line < wp->w_winrow + height && line < screen_Rows; ++line)
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3171 for (col = wp->w_wincol;
17510
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
3172 col < wp->w_wincol + width - wp->w_popup_leftoff
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
3173 && col < screen_Columns; ++col)
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
3174 if (wp->w_popup_mask_cells == NULL
a5427e35d0fb patch 8.1.1753: use of popup window mask is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17508
diff changeset
3175 || !popup_masked(wp, width, height, col, line))
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3176 mask[line * screen_Columns + col] = wp->w_zindex;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3177 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3178
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3179 // Only check which lines are to be updated if not already
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3180 // updating all lines.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3181 if (mask == popup_mask_next)
17506
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3182 {
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3183 int *plines_cache = ALLOC_CLEAR_MULT(int, Rows);
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3184 win_T *prev_wp = NULL;
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3185
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3186 for (line = 0; line < screen_Rows; ++line)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3187 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3188 int col_done = 0;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3189
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3190 for (col = 0; col < screen_Columns; ++col)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3191 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3192 int off = line * screen_Columns + col;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3193
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3194 if (popup_mask[off] != popup_mask_next[off])
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3195 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3196 popup_mask[off] = popup_mask_next[off];
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3197
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3198 if (line >= cmdline_row)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3199 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3200 // the command line needs to be cleared if text below
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3201 // the popup is now visible.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3202 if (!msg_scrolled && popup_mask_next[off] == 0)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3203 clear_cmdline = TRUE;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3204 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3205 else if (col >= col_done)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3206 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3207 linenr_T lnum;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3208 int line_cp = line;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3209 int col_cp = col;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3210
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3211 // The screen position "line" / "col" needs to be
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3212 // redrawn. Figure out what window that is and update
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3213 // w_redraw_top and w_redr_bot. Only needs to be done
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3214 // once for each window line.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3215 wp = mouse_find_win(&line_cp, &col_cp, IGNORE_POPUP);
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3216 if (wp != NULL)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3217 {
17506
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3218 if (wp != prev_wp)
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3219 {
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3220 vim_memset(plines_cache, 0, sizeof(int) * Rows);
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3221 prev_wp = wp;
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3222 }
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3223
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3224 if (line_cp >= wp->w_height)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3225 // In (or below) status line
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3226 wp->w_redr_status = TRUE;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3227 else
17843
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3228 {
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3229 // compute the position in the buffer line from
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3230 // the position in the window
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3231 mouse_comp_pos(wp, &line_cp, &col_cp,
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3232 &lnum, plines_cache);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3233 redrawWinline(wp, lnum);
17843
9696c76f2213 patch 8.1.1918: redrawing popups is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17841
diff changeset
3234 }
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3235
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3236 // This line is going to be redrawn, no need to
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3237 // check until the right side of the window.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3238 col_done = wp->w_wincol + wp->w_width - 1;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3239 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3240 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3241 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3242 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3243 }
17506
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3244
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3245 vim_free(plines_cache);
74b6674b99fd patch 8.1.1751: when redrawing popups plines_win() may be called often
Bram Moolenaar <Bram@vim.org>
parents: 17442
diff changeset
3246 }
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3247 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3248
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3249 /*
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3250 * Return a string of "len" spaces in IObuff.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3251 */
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3252 static char_u *
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3253 get_spaces(int len)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3254 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3255 vim_memset(IObuff, ' ', (size_t)len);
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3256 IObuff[len] = NUL;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3257 return IObuff;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3258 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3259
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3260 /*
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3261 * Update popup windows. They are drawn on top of normal windows.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3262 * "win_update" is called for each popup window, lowest zindex first.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3263 */
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3264 void
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3265 update_popups(void (*win_update)(win_T *wp))
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3266 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3267 win_T *wp;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3268 int top_off;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3269 int left_extra;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3270 int total_width;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3271 int total_height;
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3272 int top_padding;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3273 int popup_attr;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3274 int border_attr[4];
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3275 int border_char[8];
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3276 char_u buf[MB_MAXBYTES];
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3277 int row;
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3278 int wincol;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3279 int padcol = 0;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3280 int padwidth = 0;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3281 int i;
17200
db81cee3a0e1 patch 8.1.1599: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 17196
diff changeset
3282 int sb_thumb_top = 0;
db81cee3a0e1 patch 8.1.1599: compiler warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents: 17196
diff changeset
3283 int sb_thumb_height = 0;
17202
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3284 int attr_scroll = 0;
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3285 int attr_thumb = 0;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3286
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3287 // Find the window with the lowest zindex that hasn't been updated yet,
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3288 // so that the window with a higher zindex is drawn later, thus goes on
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3289 // top.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3290 popup_reset_handled();
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3291 while ((wp = find_next_popup(TRUE)) != NULL)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3292 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3293 // This drawing uses the zindex of the popup window, so that it's on
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3294 // top of the text but doesn't draw when another popup with higher
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3295 // zindex is on top of the character.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3296 screen_zindex = wp->w_zindex;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3297
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3298 // Set flags in popup_transparent[] for masked cells.
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3299 update_popup_transparent(wp, 1);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3300
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3301 // adjust w_winrow and w_wincol for border and padding, since
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3302 // win_update() doesn't handle them.
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3303 top_off = popup_top_extra(wp);
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3304 left_extra = wp->w_popup_padding[3] + wp->w_popup_border[3]
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3305 - wp->w_popup_leftoff;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3306 if (wp->w_wincol + left_extra < 0)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3307 left_extra = -wp->w_wincol;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3308 wp->w_winrow += top_off;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3309 wp->w_wincol += left_extra;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3310
17194
f4c6c1bc5e41 patch 8.1.1596: when resizing the screen may draw popup in wrong position
Bram Moolenaar <Bram@vim.org>
parents: 17180
diff changeset
3311 // Draw the popup text, unless it's off screen.
f4c6c1bc5e41 patch 8.1.1596: when resizing the screen may draw popup in wrong position
Bram Moolenaar <Bram@vim.org>
parents: 17180
diff changeset
3312 if (wp->w_winrow < screen_Rows && wp->w_wincol < screen_Columns)
17897
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3313 {
17194
f4c6c1bc5e41 patch 8.1.1596: when resizing the screen may draw popup in wrong position
Bram Moolenaar <Bram@vim.org>
parents: 17180
diff changeset
3314 win_update(wp);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3315
17897
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3316 // move the cursor into the visible lines, otherwise executing
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3317 // commands with win_execute() may cause the text to jump.
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3318 if (wp->w_cursor.lnum < wp->w_topline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3319 wp->w_cursor.lnum = wp->w_topline;
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3320 else if (wp->w_cursor.lnum >= wp->w_botline)
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3321 wp->w_cursor.lnum = wp->w_botline - 1;
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3322 }
fa032e079825 patch 8.1.1945: popup window "firstline" cannot be reset
Bram Moolenaar <Bram@vim.org>
parents: 17879
diff changeset
3323
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3324 wp->w_winrow -= top_off;
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3325 wp->w_wincol -= left_extra;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3326
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3327 total_width = popup_width(wp);
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3328 total_height = popup_height(wp);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3329 popup_attr = get_wcr_attr(wp);
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3330
17551
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
3331 if (wp->w_winrow + total_height > cmdline_row)
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
3332 wp->w_popup_flags |= POPF_ON_CMDLINE;
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
3333 else
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
3334 wp->w_popup_flags &= ~POPF_ON_CMDLINE;
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
3335
8cca2654d459 patch 8.1.1773: the preview popup window may be too far to the right
Bram Moolenaar <Bram@vim.org>
parents: 17545
diff changeset
3336
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3337 // We can only use these line drawing characters when 'encoding' is
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3338 // "utf-8" and 'ambiwidth' is "single".
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3339 if (enc_utf8 && *p_ambw == 's')
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3340 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3341 border_char[0] = border_char[2] = 0x2550;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3342 border_char[1] = border_char[3] = 0x2551;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3343 border_char[4] = 0x2554;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3344 border_char[5] = 0x2557;
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
3345 border_char[6] = (wp->w_popup_flags & POPF_RESIZE)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
3346 ? 0x21f2 : 0x255d;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3347 border_char[7] = 0x255a;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3348 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3349 else
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3350 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3351 border_char[0] = border_char[2] = '-';
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3352 border_char[1] = border_char[3] = '|';
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3353 for (i = 4; i < 8; ++i)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3354 border_char[i] = '+';
17580
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
3355 if (wp->w_popup_flags & POPF_RESIZE)
d5e5d0fc3fa8 patch 8.1.1787: cannot resize a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17578
diff changeset
3356 border_char[6] = '@';
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3357 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3358 for (i = 0; i < 8; ++i)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3359 if (wp->w_border_char[i] != 0)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3360 border_char[i] = wp->w_border_char[i];
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3361
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3362 for (i = 0; i < 4; ++i)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3363 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3364 border_attr[i] = popup_attr;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3365 if (wp->w_border_highlight[i] != NULL)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3366 border_attr[i] = syn_name2attr(wp->w_border_highlight[i]);
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3367 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3368
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3369 wincol = wp->w_wincol - wp->w_popup_leftoff;
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3370 top_padding = wp->w_popup_padding[0];
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3371 if (wp->w_popup_border[0] > 0)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3372 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3373 // top border
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3374 screen_fill(wp->w_winrow, wp->w_winrow + 1,
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3375 wincol < 0 ? 0 : wincol, wincol + total_width,
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3376 wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3377 ? border_char[4] : border_char[0],
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3378 border_char[0], border_attr[0]);
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3379 if (wp->w_popup_border[1] > 0 && wp->w_popup_rightoff == 0)
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3380 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3381 buf[mb_char2bytes(border_char[5], buf)] = NUL;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3382 screen_puts(buf, wp->w_winrow,
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3383 wincol + total_width - 1, border_attr[1]);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3384 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3385 }
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3386 else if (wp->w_popup_padding[0] == 0 && popup_top_extra(wp) > 0)
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3387 top_padding = 1;
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3388
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3389 if (top_padding > 0 || wp->w_popup_padding[2] > 0)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3390 {
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3391 padcol = wincol + wp->w_popup_border[3];
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3392 padwidth = wp->w_wincol + total_width - wp->w_popup_border[1]
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3393 - wp->w_has_scrollbar;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3394 if (padcol < 0)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3395 {
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3396 padwidth += padcol;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3397 padcol = 0;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3398 }
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3399 }
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3400 if (top_padding > 0)
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3401 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3402 // top padding
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3403 row = wp->w_winrow + wp->w_popup_border[0];
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3404 screen_fill(row, row + top_padding, padcol, padwidth,
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3405 ' ', ' ', popup_attr);
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3406 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3407
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3408 // Title goes on top of border or padding.
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3409 if (wp->w_popup_title != NULL)
17634
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17626
diff changeset
3410 {
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17626
diff changeset
3411 int len = (int)STRLEN(wp->w_popup_title) + 1;
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17626
diff changeset
3412 char_u *title = alloc(len);
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17626
diff changeset
3413
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17626
diff changeset
3414 trunc_string(wp->w_popup_title, title, total_width - 2, len);
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17626
diff changeset
3415 screen_puts(title, wp->w_winrow, wp->w_wincol + 1,
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3416 wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
18225
6c3a8312486d patch 8.1.2107: various memory leaks reported by asan
Bram Moolenaar <Bram@vim.org>
parents: 18166
diff changeset
3417 vim_free(title);
17634
6e6a84993444 patch 8.1.1814: a long title in a popup window overflows
Bram Moolenaar <Bram@vim.org>
parents: 17626
diff changeset
3418 }
17119
b439e096a011 patch 8.1.1559: popup window title property not implemented yet
Bram Moolenaar <Bram@vim.org>
parents: 17117
diff changeset
3419
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3420 // Compute scrollbar thumb position and size.
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3421 if (wp->w_has_scrollbar)
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3422 {
18074
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3423 linenr_T linecount = wp->w_buffer->b_ml.ml_line_count;
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3424 int height = wp->w_height;
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3425
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3426 sb_thumb_height = (height * height + linecount / 2) / linecount;
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3427 if (wp->w_topline > 1 && sb_thumb_height == height)
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3428 --sb_thumb_height; // scrolled, no full thumb
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3429 if (sb_thumb_height == 0)
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3430 sb_thumb_height = 1;
17274
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
3431 if (linecount <= wp->w_height)
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
3432 // it just fits, avoid divide by zero
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
3433 sb_thumb_top = 0;
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
3434 else
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
3435 sb_thumb_top = (wp->w_topline - 1
6a7ba68d448e patch 8.1.1636: crash when popup has fitting scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17245
diff changeset
3436 + (linecount / wp->w_height) / 2)
17196
983950357c40 patch 8.1.1597: cannot scroll a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17194
diff changeset
3437 * (wp->w_height - sb_thumb_height)
983950357c40 patch 8.1.1597: cannot scroll a popup window with the mouse
Bram Moolenaar <Bram@vim.org>
parents: 17194
diff changeset
3438 / (linecount - wp->w_height);
18074
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3439 if (wp->w_topline > 1 && sb_thumb_top == 0 && height > 1)
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3440 sb_thumb_top = 1; // show it's scrolled
364a9be6a21e patch 8.1.2032: scrollbar thumb wrong in popup window
Bram Moolenaar <Bram@vim.org>
parents: 18027
diff changeset
3441
17202
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3442 if (wp->w_scrollbar_highlight != NULL)
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3443 attr_scroll = syn_name2attr(wp->w_scrollbar_highlight);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3444 else
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3445 attr_scroll = highlight_attr[HLF_PSB];
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3446 if (wp->w_thumb_highlight != NULL)
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3447 attr_thumb = syn_name2attr(wp->w_thumb_highlight);
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3448 else
4b40e8821f56 patch 8.1.1600: cannot specify highlighting for popup window scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 17200
diff changeset
3449 attr_thumb = highlight_attr[HLF_PST];
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3450 }
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3451
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3452 for (i = wp->w_popup_border[0];
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3453 i < total_height - wp->w_popup_border[2]; ++i)
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3454 {
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3455 int pad_left;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3456 // left and right padding only needed next to the body
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3457 int do_padding =
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3458 i >= wp->w_popup_border[0] + wp->w_popup_padding[0]
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3459 && i < total_height - wp->w_popup_border[2]
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3460 - wp->w_popup_padding[2];
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3461
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3462 row = wp->w_winrow + i;
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3463
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3464 // left border
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3465 if (wp->w_popup_border[3] > 0 && wincol >= 0)
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3466 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3467 buf[mb_char2bytes(border_char[3], buf)] = NUL;
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3468 screen_puts(buf, row, wincol, border_attr[3]);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3469 }
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3470 if (do_padding && wp->w_popup_padding[3] > 0)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3471 {
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3472 int col = wincol + wp->w_popup_border[3];
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3473
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3474 // left padding
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3475 pad_left = wp->w_popup_padding[3];
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3476 if (col < 0)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3477 {
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3478 pad_left += col;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3479 col = 0;
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3480 }
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3481 if (pad_left > 0)
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3482 screen_puts(get_spaces(pad_left), row, col, popup_attr);
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3483 }
17180
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3484 // scrollbar
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3485 if (wp->w_has_scrollbar)
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3486 {
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3487 int line = i - top_off;
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3488 int scroll_col = wp->w_wincol + total_width - 1
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3489 - wp->w_popup_border[1];
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3490
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3491 if (line >= 0 && line < wp->w_height)
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3492 screen_putchar(' ', row, scroll_col,
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3493 line >= sb_thumb_top
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3494 && line < sb_thumb_top + sb_thumb_height
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3495 ? attr_thumb : attr_scroll);
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3496 else
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3497 screen_putchar(' ', row, scroll_col, popup_attr);
8581779aa16f patch 8.1.1589: popup window does not indicate scroll position
Bram Moolenaar <Bram@vim.org>
parents: 17174
diff changeset
3498 }
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3499 // right border
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3500 if (wp->w_popup_border[1] > 0)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3501 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3502 buf[mb_char2bytes(border_char[1], buf)] = NUL;
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3503 screen_puts(buf, row, wincol + total_width - 1, border_attr[1]);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3504 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3505 // right padding
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3506 if (do_padding && wp->w_popup_padding[1] > 0)
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3507 screen_puts(get_spaces(wp->w_popup_padding[1]), row,
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3508 wincol + wp->w_popup_border[3]
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3509 + wp->w_popup_padding[3] + wp->w_width + wp->w_leftcol,
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3510 popup_attr);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3511 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3512
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3513 if (wp->w_popup_padding[2] > 0)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3514 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3515 // bottom padding
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3516 row = wp->w_winrow + wp->w_popup_border[0]
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3517 + wp->w_popup_padding[0] + wp->w_height;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3518 screen_fill(row, row + wp->w_popup_padding[2],
17235
2a97167854fc patch 8.1.1617: no test for popup window with mask and position fixed
Bram Moolenaar <Bram@vim.org>
parents: 17231
diff changeset
3519 padcol, padwidth, ' ', ' ', popup_attr);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3520 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3521
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3522 if (wp->w_popup_border[2] > 0)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3523 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3524 // bottom border
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3525 row = wp->w_winrow + total_height - 1;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3526 screen_fill(row , row + 1,
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3527 wincol < 0 ? 0 : wincol,
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3528 wincol + total_width,
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3529 wp->w_popup_border[3] != 0 && wp->w_popup_leftoff == 0
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3530 ? border_char[7] : border_char[2],
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3531 border_char[2], border_attr[2]);
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3532 if (wp->w_popup_border[1] > 0)
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3533 {
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3534 buf[mb_char2bytes(border_char[6], buf)] = NUL;
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3535 screen_puts(buf, row, wincol + total_width - 1, border_attr[2]);
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3536 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3537 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3538
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
3539 if (wp->w_popup_close == POPCLOSE_BUTTON)
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
3540 {
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
3541 // close button goes on top of anything at the top-right corner
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
3542 buf[mb_char2bytes('X', buf)] = NUL;
17241
3ada3d207b33 patch 8.1.1620: no test for popup window with border and mask
Bram Moolenaar <Bram@vim.org>
parents: 17235
diff changeset
3543 screen_puts(buf, wp->w_winrow, wincol + total_width - 1,
17219
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
3544 wp->w_popup_border[0] > 0 ? border_attr[0] : popup_attr);
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
3545 }
5169811b3044 patch 8.1.1609: the user cannot easily close a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17216
diff changeset
3546
17162
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3547 update_popup_transparent(wp, 0);
f16cee6adf29 patch 8.1.1580: cannot make part of a popup transparent
Bram Moolenaar <Bram@vim.org>
parents: 17151
diff changeset
3548
17055
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3549 // Back to the normal zindex.
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3550 screen_zindex = 0;
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3551 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3552 }
f4de7ccdfd8c patch 8.1.1527: when moving popup window over the cmdline it is not redrawn
Bram Moolenaar <Bram@vim.org>
parents: 17051
diff changeset
3553
17151
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3554 /*
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3555 * Mark references in callbacks of one popup window.
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3556 */
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3557 static int
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3558 set_ref_in_one_popup(win_T *wp, int copyID)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3559 {
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3560 int abort = FALSE;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3561 typval_T tv;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3562
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3563 if (wp->w_close_cb.cb_partial != NULL)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3564 {
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3565 tv.v_type = VAR_PARTIAL;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3566 tv.vval.v_partial = wp->w_close_cb.cb_partial;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3567 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3568 }
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3569 if (wp->w_filter_cb.cb_partial != NULL)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3570 {
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3571 tv.v_type = VAR_PARTIAL;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3572 tv.vval.v_partial = wp->w_filter_cb.cb_partial;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3573 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL);
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3574 }
17168
1d30eb64a7a2 patch 8.1.1583: set_ref_in_list() only sets ref in items
Bram Moolenaar <Bram@vim.org>
parents: 17166
diff changeset
3575 abort = abort || set_ref_in_list(wp->w_popup_mask, copyID);
17151
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3576 return abort;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3577 }
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3578
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3579 /*
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3580 * Set reference in callbacks of popup windows.
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3581 */
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3582 int
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3583 set_ref_in_popups(int copyID)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3584 {
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3585 int abort = FALSE;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3586 win_T *wp;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3587 tabpage_T *tp;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3588
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3589 for (wp = first_popupwin; !abort && wp != NULL; wp = wp->w_next)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3590 abort = abort || set_ref_in_one_popup(wp, copyID);
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3591
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3592 FOR_ALL_TABPAGES(tp)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3593 {
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3594 for (wp = tp->tp_first_popupwin; !abort && wp != NULL; wp = wp->w_next)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3595 abort = abort || set_ref_in_one_popup(wp, copyID);
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3596 if (abort)
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3597 break;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3598 }
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3599 return abort;
ebe9aab81898 patch 8.1.1575: callbacks may be garbage collected
Bram Moolenaar <Bram@vim.org>
parents: 17149
diff changeset
3600 }
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3601
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3602 /*
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3603 * Find an existing popup used as the preview window, in the current tab page.
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3604 * Return NULL if not found.
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3605 */
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3606 win_T *
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3607 popup_find_preview_window(void)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3608 {
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3609 win_T *wp;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3610
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3611 // Preview window popup is always local to tab page.
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3612 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3613 if (wp->w_p_pvw)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3614 return wp;
17545
1e45331bd2ab patch 8.1.1770: cannot get the window ID of the popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17510
diff changeset
3615 return NULL;
1e45331bd2ab patch 8.1.1770: cannot get the window ID of the popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17510
diff changeset
3616 }
1e45331bd2ab patch 8.1.1770: cannot get the window ID of the popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17510
diff changeset
3617
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3618 int
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3619 popup_is_popup(win_T *wp)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3620 {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3621 return wp->w_popup_flags != 0;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3622 }
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3623
17791
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
3624 #if defined(FEAT_QUICKFIX) || defined(PROTO)
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3625 /*
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3626 * Find an existing popup used as the info window, in the current tab page.
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3627 * Return NULL if not found.
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3628 */
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3629 win_T *
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3630 popup_find_info_window(void)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3631 {
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3632 win_T *wp;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3633
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3634 // info window popup is always local to tab page.
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3635 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3636 if (wp->w_popup_flags & POPF_INFO)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3637 return wp;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3638 return NULL;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3639 }
17791
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
3640 #endif
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3641
17545
1e45331bd2ab patch 8.1.1770: cannot get the window ID of the popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17510
diff changeset
3642 void
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3643 f_popup_findinfo(typval_T *argvars UNUSED, typval_T *rettv)
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3644 {
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3645 win_T *wp = popup_find_info_window();
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3646
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3647 rettv->vval.v_number = wp == NULL ? 0 : wp->w_id;
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3648 }
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3649
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3650 void
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3651 f_popup_findpreview(typval_T *argvars UNUSED, typval_T *rettv)
17545
1e45331bd2ab patch 8.1.1770: cannot get the window ID of the popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17510
diff changeset
3652 {
1e45331bd2ab patch 8.1.1770: cannot get the window ID of the popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17510
diff changeset
3653 win_T *wp = popup_find_preview_window();
1e45331bd2ab patch 8.1.1770: cannot get the window ID of the popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17510
diff changeset
3654
1e45331bd2ab patch 8.1.1770: cannot get the window ID of the popup preview window
Bram Moolenaar <Bram@vim.org>
parents: 17510
diff changeset
3655 rettv->vval.v_number = wp == NULL ? 0 : wp->w_id;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3656 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3657
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3658 /*
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3659 * Create a popup to be used as the preview or info window.
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3660 * NOTE: this makes the popup the current window, so that the file can be
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3661 * edited. However, it must not remain to be the current window, the caller
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3662 * must make sure of that.
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3663 */
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3664 int
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3665 popup_create_preview_window(int info)
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3666 {
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3667 win_T *wp = popup_create(NULL, NULL, info ? TYPE_INFO : TYPE_PREVIEW);
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3668
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3669 if (wp == NULL)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3670 return FAIL;
17767
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3671 if (info)
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3672 wp->w_popup_flags |= POPF_INFO;
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3673 else
c75da1064e33 patch 8.1.1880: cannot show extra info for completion in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17634
diff changeset
3674 wp->w_p_pvw = TRUE;
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3675
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3676 // Set the width to a reasonable value, so that w_topline can be computed.
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3677 if (wp->w_minwidth > 0)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3678 wp->w_width = wp->w_minwidth;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3679 else if (wp->w_maxwidth > 0)
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3680 wp->w_width = wp->w_maxwidth;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3681 else
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3682 wp->w_width = curwin->w_width;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3683
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3684 // Will switch to another buffer soon, dummy one can be wiped.
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3685 wp->w_buffer->b_locked = FALSE;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3686
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3687 win_enter(wp, FALSE);
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3688 return OK;
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3689 }
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3690
17791
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
3691 #if defined(FEAT_QUICKFIX) || defined(PROTO)
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3692 /*
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3693 * Close any preview popup.
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3694 */
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3695 void
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3696 popup_close_preview(void)
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3697 {
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3698 win_T *wp = popup_find_preview_window();
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3699
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3700 if (wp != NULL)
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3701 popup_close_with_retval(wp, -1);
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3702 }
17817
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3703
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3704 /*
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3705 * Hide the info popup.
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3706 */
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3707 void
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3708 popup_hide_info(void)
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3709 {
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3710 win_T *wp = popup_find_info_window();
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3711
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3712 if (wp != NULL)
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3713 popup_hide(wp);
e8a7029efa40 patch 8.1.1905: cannot set all properties of the info popup
Bram Moolenaar <Bram@vim.org>
parents: 17815
diff changeset
3714 }
17791
55c167b08c2b patch 8.1.1892: missing index entry and option menu for 'completepopup'
Bram Moolenaar <Bram@vim.org>
parents: 17789
diff changeset
3715 #endif
17431
ce35cdbe9f74 patch 8.1.1714: cannot preview a file in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 17429
diff changeset
3716
17584
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3717 /*
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3718 * Close any popup for a text property associated with "win".
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3719 * Return TRUE if a popup was closed.
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3720 */
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3721 int
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3722 popup_win_closed(win_T *win)
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3723 {
17879
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3724 int round;
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3725 win_T *wp;
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3726 win_T *next;
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3727 int ret = FALSE;
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3728
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3729 for (round = 1; round <= 2; ++round)
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3730 for (wp = round == 1 ? first_popupwin : curtab->tp_first_popupwin;
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3731 wp != NULL; wp = next)
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3732 {
17879
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3733 next = wp->w_next;
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3734 if (wp->w_popup_prop_win == win)
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3735 {
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3736 popup_close_with_retval(wp, -1);
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3737 ret = TRUE;
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3738 }
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3739 }
17879
5d5b460926ca patch 8.1.1936: not enough tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents: 17875
diff changeset
3740 return ret;
17863
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3741 }
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3742
08f1dd29550e patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents: 17847
diff changeset
3743 /*
17584
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3744 * Set the title of the popup window to the file name.
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3745 */
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3746 void
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3747 popup_set_title(win_T *wp)
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3748 {
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3749 if (wp->w_buffer->b_fname != NULL)
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3750 {
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3751 char_u dirname[MAXPATHL];
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3752 size_t len;
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3753
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3754 mch_dirname(dirname, MAXPATHL);
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3755 shorten_buf_fname(wp->w_buffer, dirname, FALSE);
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3756
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3757 vim_free(wp->w_popup_title);
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3758 len = STRLEN(wp->w_buffer->b_fname) + 3;
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3759 wp->w_popup_title = alloc((int)len);
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3760 if (wp->w_popup_title != NULL)
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3761 vim_snprintf((char *)wp->w_popup_title, len, " %s ",
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3762 wp->w_buffer->b_fname);
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3763 redraw_win_later(wp, VALID);
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3764 }
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3765 }
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3766
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3767 /*
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3768 * If there is a preview window, update the title.
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3769 * Used after changing directory.
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3770 */
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3771 void
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3772 popup_update_preview_title(void)
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3773 {
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3774 win_T *wp = popup_find_preview_window();
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3775
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3776 if (wp != NULL)
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3777 popup_set_title(wp);
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3778 }
65a8099fc0e8 patch 8.1.1789: cannot see file name of preview popup window
Bram Moolenaar <Bram@vim.org>
parents: 17580
diff changeset
3779
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3780 #endif // FEAT_TEXT_PROP