diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-08-18 15:25:17 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-08-18 15:25:17 +0200 |
commit | 576a4a6ff14da876d7c4418e5f27e926fcfa8d2a (patch) | |
tree | 6c34c1eaed6f1b46c573bb0fe3ce8d375e678e29 /src/popupwin.c | |
parent | 93cf85f9ef02931de3f8c8e536a137da0b48b7dc (diff) | |
download | vim-git-576a4a6ff14da876d7c4418e5f27e926fcfa8d2a.tar.gz |
patch 8.1.1880: cannot show extra info for completion in a popup windowv8.1.1880
Problem: Cannot show extra info for completion in a popup window.
Solution: Add the "popup" entry in 'completeopt'.
Diffstat (limited to 'src/popupwin.c')
-rw-r--r-- | src/popupwin.c | 115 |
1 files changed, 87 insertions, 28 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index 9d801ea4b..0198fb569 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -951,8 +951,8 @@ popup_top_extra(win_T *wp) popup_height(win_T *wp) { return wp->w_height - + popup_top_extra(wp) - + wp->w_popup_padding[2] + wp->w_popup_border[2]; + + popup_top_extra(wp) + + wp->w_popup_padding[2] + wp->w_popup_border[2]; } /* @@ -965,10 +965,19 @@ popup_width(win_T *wp) // w_leftcol is how many columns of the core are left of the screen // w_popup_rightoff is how many columns of the core are right of the screen return wp->w_width + wp->w_leftcol - + wp->w_popup_padding[3] + wp->w_popup_border[3] - + wp->w_popup_padding[1] + wp->w_popup_border[1] - + wp->w_has_scrollbar - + wp->w_popup_rightoff; + + popup_extra_width(wp) + + wp->w_popup_rightoff; +} + +/* + * Return the extra width of popup window "wp": border, padding and scrollbar. + */ + int +popup_extra_width(win_T *wp) +{ + return wp->w_popup_padding[3] + wp->w_popup_border[3] + + wp->w_popup_padding[1] + wp->w_popup_border[1] + + wp->w_has_scrollbar; } /* @@ -1230,7 +1239,8 @@ typedef enum TYPE_NOTIFICATION, TYPE_DIALOG, TYPE_MENU, - TYPE_PREVIEW + TYPE_PREVIEW, // preview window + TYPE_INFO // popup menu info } create_type_T; /* @@ -1330,7 +1340,7 @@ parse_previewpopup(win_T *wp) * Keep at least "width" columns from the right of the screen. */ void -popup_set_wantpos(win_T *wp, int width) +popup_set_wantpos_cursor(win_T *wp, int width) { setcursor_mayforce(TRUE); wp->w_wantline = curwin->w_winrow + curwin->w_wrow; @@ -1351,10 +1361,37 @@ popup_set_wantpos(win_T *wp, int width) } /* + * Set w_wantline and w_wantcol for the a given screen position. + * Caller must take care of running into the window border. + */ + void +popup_set_wantpos_rowcol(win_T *wp, int row, int col) +{ + wp->w_wantline = row; + wp->w_wantcol = col; + popup_adjust_position(wp); +} + +/* + * Add a border and lef&right padding. + */ + static void +add_border_left_right_padding(win_T *wp) +{ + int i; + + for (i = 0; i < 4; ++i) + { + wp->w_popup_border[i] = 1; + wp->w_popup_padding[i] = (i & 1) ? 1 : 0; + } +} + +/* * popup_create({text}, {options}) * popup_atcursor({text}, {options}) * etc. - * When creating a preview window popup "argvars" and "rettv" are NULL. + * When creating a preview or info popup "argvars" and "rettv" are NULL. */ static win_T * popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) @@ -1495,7 +1532,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) } if (type == TYPE_ATCURSOR) { - popup_set_wantpos(wp, 0); + popup_set_wantpos_cursor(wp, 0); set_moved_values(wp); set_moved_columns(wp, FIND_STRING); } @@ -1571,11 +1608,7 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) wp->w_zindex = POPUPWIN_DIALOG_ZINDEX; wp->w_popup_flags |= POPF_DRAG; wp->w_popup_flags &= ~POPF_MAPPING; - for (i = 0; i < 4; ++i) - { - wp->w_popup_border[i] = 1; - wp->w_popup_padding[i] = (i & 1) ? 1 : 0; - } + add_border_left_right_padding(wp); } if (type == TYPE_MENU) @@ -1600,7 +1633,14 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) for (i = 0; i < 4; ++i) wp->w_popup_border[i] = 1; parse_previewpopup(wp); - popup_set_wantpos(wp, wp->w_minwidth); + popup_set_wantpos_cursor(wp, wp->w_minwidth); + } + if (type == TYPE_INFO) + { + wp->w_popup_pos = POPPOS_TOPLEFT; + wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE; + wp->w_popup_close = POPCLOSE_BUTTON; + add_border_left_right_padding(wp); } for (i = 0; i < 4; ++i) @@ -3171,6 +3211,28 @@ popup_find_preview_window(void) return NULL; } + int +popup_is_popup(win_T *wp) +{ + return wp->w_popup_flags != 0; +} + +/* + * Find an existing popup used as the info window, in the current tab page. + * Return NULL if not found. + */ + win_T * +popup_find_info_window(void) +{ + win_T *wp; + + // info window popup is always local to tab page. + for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) + if (wp->w_popup_flags & POPF_INFO) + return wp; + return NULL; +} + void f_popup_getpreview(typval_T *argvars UNUSED, typval_T *rettv) { @@ -3179,26 +3241,23 @@ f_popup_getpreview(typval_T *argvars UNUSED, typval_T *rettv) rettv->vval.v_number = wp == NULL ? 0 : wp->w_id; } - int -popup_is_popup(win_T *wp) -{ - return wp->w_popup_flags != 0; -} - /* - * Create a popup to be used as the preview window. + * Create a popup to be used as the preview or info window. * NOTE: this makes the popup the current window, so that the file can be * edited. However, it must not remain to be the current window, the caller * must make sure of that. */ int -popup_create_preview_window(void) +popup_create_preview_window(int info) { - win_T *wp = popup_create(NULL, NULL, TYPE_PREVIEW); + win_T *wp = popup_create(NULL, NULL, info ? TYPE_INFO : TYPE_PREVIEW); if (wp == NULL) return FAIL; - wp->w_p_pvw = TRUE; + if (info) + wp->w_popup_flags |= POPF_INFO; + else + wp->w_p_pvw = TRUE; // Set the width to a reasonable value, so that w_topline can be computed. if (wp->w_minwidth > 0) @@ -3216,9 +3275,9 @@ popup_create_preview_window(void) } void -popup_close_preview() +popup_close_preview(int info) { - win_T *wp = popup_find_preview_window(); + win_T *wp = info ? popup_find_info_window() : popup_find_preview_window(); if (wp != NULL) { |