Mercurial > vim
comparison src/popupwin.c @ 16809:5ff14f96f1c9 v8.1.1406
patch 8.1.1406: popup_hide() and popup_show() not implemented yet
commit https://github.com/vim/vim/commit/2cd0dce898995a2b05f7285a70efec3f67f579f5
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 26 22:17:52 2019 +0200
patch 8.1.1406: popup_hide() and popup_show() not implemented yet
Problem: popup_hide() and popup_show() not implemented yet.
Solution: Implement the functions.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 May 2019 22:30:05 +0200 |
parents | 306766ed0f70 |
children | 0457d49eb2d9 |
comparison
equal
deleted
inserted
replaced
16808:c002c4899529 | 16809:5ff14f96f1c9 |
---|---|
193 | 193 |
194 redraw_all_later(NOT_VALID); | 194 redraw_all_later(NOT_VALID); |
195 } | 195 } |
196 | 196 |
197 /* | 197 /* |
198 * Find the popup window with window-ID "id". | |
199 * If the popup window does not exist NULL is returned. | |
200 * If the window is not a popup window, and error message is given. | |
201 */ | |
202 static win_T * | |
203 find_popup_win(int id) | |
204 { | |
205 win_T *wp = win_id2wp(id); | |
206 | |
207 if (wp != NULL && !bt_popup(wp->w_buffer)) | |
208 { | |
209 semsg(_("E993: window %d is not a popup window"), id); | |
210 return NULL; | |
211 } | |
212 return wp; | |
213 } | |
214 | |
215 /* | |
216 * Return TRUE if there any popups that are not hidden. | |
217 */ | |
218 int | |
219 popup_any_visible(void) | |
220 { | |
221 win_T *wp; | |
222 | |
223 for (wp = first_popupwin; wp != NULL; wp = wp->w_next) | |
224 if ((wp->w_popup_flags & PFL_HIDDEN) == 0) | |
225 return TRUE; | |
226 for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) | |
227 if ((wp->w_popup_flags & PFL_HIDDEN) == 0) | |
228 return TRUE; | |
229 return FALSE; | |
230 } | |
231 | |
232 /* | |
198 * popup_close({id}) | 233 * popup_close({id}) |
199 */ | 234 */ |
200 void | 235 void |
201 f_popup_close(typval_T *argvars, typval_T *rettv UNUSED) | 236 f_popup_close(typval_T *argvars, typval_T *rettv UNUSED) |
202 { | 237 { |
203 int nr = (int)tv_get_number(argvars); | 238 int id = (int)tv_get_number(argvars); |
204 | 239 |
205 popup_close(nr); | 240 popup_close(id); |
241 } | |
242 | |
243 /* | |
244 * popup_hide({id}) | |
245 */ | |
246 void | |
247 f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED) | |
248 { | |
249 int id = (int)tv_get_number(argvars); | |
250 win_T *wp = find_popup_win(id); | |
251 | |
252 if (wp != NULL && (wp->w_popup_flags & PFL_HIDDEN) == 0) | |
253 { | |
254 wp->w_popup_flags |= PFL_HIDDEN; | |
255 redraw_all_later(NOT_VALID); | |
256 } | |
257 } | |
258 | |
259 /* | |
260 * popup_show({id}) | |
261 */ | |
262 void | |
263 f_popup_show(typval_T *argvars, typval_T *rettv UNUSED) | |
264 { | |
265 int id = (int)tv_get_number(argvars); | |
266 win_T *wp = find_popup_win(id); | |
267 | |
268 if (wp != NULL && (wp->w_popup_flags & PFL_HIDDEN) != 0) | |
269 { | |
270 wp->w_popup_flags &= ~PFL_HIDDEN; | |
271 redraw_all_later(NOT_VALID); | |
272 } | |
206 } | 273 } |
207 | 274 |
208 static void | 275 static void |
209 popup_undisplay(win_T *wp) | 276 popup_free(win_T *wp) |
210 { | 277 { |
211 if (wp->w_winrow + wp->w_height >= cmdline_row) | 278 if (wp->w_winrow + wp->w_height >= cmdline_row) |
212 clear_cmdline = TRUE; | 279 clear_cmdline = TRUE; |
213 win_free_popup(wp); | 280 win_free_popup(wp); |
214 redraw_all_later(NOT_VALID); | 281 redraw_all_later(NOT_VALID); |
230 { | 297 { |
231 if (prev == NULL) | 298 if (prev == NULL) |
232 first_popupwin = wp->w_next; | 299 first_popupwin = wp->w_next; |
233 else | 300 else |
234 prev->w_next = wp->w_next; | 301 prev->w_next = wp->w_next; |
235 popup_undisplay(wp); | 302 popup_free(wp); |
236 return; | 303 return; |
237 } | 304 } |
238 | 305 |
239 // go through tab-local popups | 306 // go through tab-local popups |
240 FOR_ALL_TABPAGES(tp) | 307 FOR_ALL_TABPAGES(tp) |
256 { | 323 { |
257 if (prev == NULL) | 324 if (prev == NULL) |
258 *root = wp->w_next; | 325 *root = wp->w_next; |
259 else | 326 else |
260 prev->w_next = wp->w_next; | 327 prev->w_next = wp->w_next; |
261 popup_undisplay(wp); | 328 popup_free(wp); |
262 return; | 329 return; |
263 } | 330 } |
264 } | 331 } |
265 | 332 |
266 void | 333 void |