diff src/popupwin.c @ 17771:4bd21046902b v8.1.1882

patch 8.1.1882: cannot specify properties of the info popup window commit https://github.com/vim/vim/commit/62a0cb443c3184f24a6dac73d3505f9056cf6056 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 18 16:35:23 2019 +0200 patch 8.1.1882: cannot specify properties of the info popup window Problem: Cannot specify properties of the info popup window. Solution: Add the 'completepopup' option. Default to PmenuSel highlight.
author Bram Moolenaar <Bram@vim.org>
date Sun, 18 Aug 2019 16:45:03 +0200
parents c75da1064e33
children 0f7ae8010787
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -550,8 +550,7 @@ popup_highlight_curline(win_T *wp)
 
 	    if (syn_name2id((char_u *)linehl) == 0)
 		linehl = "PmenuSel";
-	    sign_define_by_name(sign_name, NULL,
-						 (char_u *)linehl, NULL, NULL);
+	    sign_define_by_name(sign_name, NULL, (char_u *)linehl, NULL, NULL);
 	}
 
 	sign_place(&sign_id, (char_u *)"popupmenu", sign_name,
@@ -1286,16 +1285,16 @@ popup_set_buffer_text(buf_T *buf, typval
 }
 
 /*
- * Parse the 'previewpopup' option and apply the values to window "wp" if it
- * not NULL.
+ * Parse the 'previewpopup' or 'completepopup' option and apply the values to
+ * window "wp" if it is not NULL.
  * Return FAIL if the parsing fails.
  */
-    int
-parse_previewpopup(win_T *wp)
+    static int
+parse_popup_option(win_T *wp, int is_preview)
 {
     char_u *p;
 
-    for (p = p_pvp; *p != NUL; p += (*p == ',' ? 1 : 0))
+    for (p = is_preview ? p_pvp : p_cpp; *p != NUL; p += (*p == ',' ? 1 : 0))
     {
 	char_u	*e, *dig;
 	char_u	*s = p;
@@ -1310,25 +1309,41 @@ parse_previewpopup(win_T *wp)
 	    p = e + STRLEN(e);
 	dig = e + 1;
 	x = getdigits(&dig);
-	if (dig != p)
-	    return FAIL;
 
 	if (STRNCMP(s, "height:", 7) == 0)
 	{
+	    if (dig != p)
+		return FAIL;
 	    if (wp != NULL)
 	    {
-		wp->w_minheight = x;
+		if (is_preview)
+		    wp->w_minheight = x;
 		wp->w_maxheight = x;
 	    }
 	}
 	else if (STRNCMP(s, "width:", 6) == 0)
 	{
+	    if (dig != p)
+		return FAIL;
 	    if (wp != NULL)
 	    {
-		wp->w_minwidth = x;
+		if (is_preview)
+		    wp->w_minwidth = x;
 		wp->w_maxwidth = x;
 	    }
 	}
+	else if (STRNCMP(s, "highlight:", 10) == 0)
+	{
+	    if (wp != NULL)
+	    {
+		int c = *p;
+
+		*p = NUL;
+		set_string_option_direct_in_win(wp, (char_u *)"wincolor", -1,
+						s + 10, OPT_FREE|OPT_LOCAL, 0);
+		*p = c;
+	    }
+	}
 	else
 	    return FAIL;
     }
@@ -1336,6 +1351,28 @@ parse_previewpopup(win_T *wp)
 }
 
 /*
+ * Parse the 'previewpopup' option and apply the values to window "wp" if it
+ * is not NULL.
+ * Return FAIL if the parsing fails.
+ */
+    int
+parse_previewpopup(win_T *wp)
+{
+    return parse_popup_option(wp, TRUE);
+}
+
+/*
+ * Parse the 'completepopup' option and apply the values to window "wp" if it
+ * is not NULL.
+ * Return FAIL if the parsing fails.
+ */
+    int
+parse_completepopup(win_T *wp)
+{
+    return parse_popup_option(wp, FALSE);
+}
+
+/*
  * Set w_wantline and w_wantcol for the cursor position in the current window.
  * Keep at least "width" columns from the right of the screen.
  */
@@ -1641,6 +1678,7 @@ popup_create(typval_T *argvars, typval_T
 	wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
 	wp->w_popup_close = POPCLOSE_BUTTON;
 	add_border_left_right_padding(wp);
+	parse_completepopup(wp);
     }
 
     for (i = 0; i < 4; ++i)