]> granicus.if.org Git - vim/commitdiff
patch 8.1.1905: cannot set all properties of the info popup v8.1.1905
authorBram Moolenaar <Bram@vim.org>
Wed, 21 Aug 2019 16:31:03 +0000 (18:31 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 21 Aug 2019 16:31:03 +0000 (18:31 +0200)
Problem:    Cannot set all properties of the info popup.
Solution:   Add popup_findinfo().  Rename popup_getpreview() to
            popup_findpreview().

runtime/doc/popup.txt
src/evalfunc.c
src/ex_cmds.c
src/ex_docmd.c
src/popupmnu.c
src/popupwin.c
src/proto/popupwin.pro
src/testdir/dumps/Test_popupwin_infopopup_align_3.dump
src/testdir/test_popupwin.vim
src/version.c

index 67ad70bc55dc354a6b0ee0f90e531205715dd7a8..e766deb4a7b7ff7c9154ea3a2c62789bffdea280 100644 (file)
@@ -289,6 +289,20 @@ popup_filter_yesno({id}, {key})                            *popup_filter_yesno()*
                See the example here: |popup_dialog-example|
 
 
+popup_findinfo()                                       *popup_findinfo()*
+               Get the |window-ID| for the popup info window, as it used by
+               the popup menu.  See |complete-popup|.  The info popup is
+               hidden when not used, it can be deleted with |popup_clear()|
+               and |popup_close()|.
+               Return zero if there is none.
+
+
+popup_findpreview()                                    *popup_findpreview()*
+               Get the |window-ID| for the popup preview window.
+               Return zero if there is none.
+
+
+
 popup_getoptions({id})                                 *popup_getoptions()*
                Return the {options} for popup {id} in a Dict.
                A zero value means the option was not set.  For "zindex" the
@@ -336,10 +350,6 @@ popup_getpos({id})                                 *popup_getpos()*
 
                If popup window {id} is not found an empty Dict is returned.
 
-popup_getpreview()                                     *popup_getpreview()*
-               Get the |window-ID| for the popup preview window.
-               Return zero if there is none.
-
 
 popup_hide({id})                                               *popup_hide()*
                If {id} is a displayed popup, hide it now. If the popup has a
index d2a0c64bdc0c6f26923a21db159616ed274db840..62938c1ca7b8119dbdf85490b8cb0f0da186f39f 100644 (file)
@@ -702,9 +702,10 @@ static funcentry_T global_functions[] =
     {"popup_dialog",   2, 2, 0,          f_popup_dialog},
     {"popup_filter_menu", 2, 2, 0,       f_popup_filter_menu},
     {"popup_filter_yesno", 2, 2, 0,      f_popup_filter_yesno},
+    {"popup_findinfo", 0, 0, 0,          f_popup_findinfo},
+    {"popup_findpreview", 0, 0, 0,       f_popup_findpreview},
     {"popup_getoptions", 1, 1, 0,        f_popup_getoptions},
     {"popup_getpos",   1, 1, 0,          f_popup_getpos},
-    {"popup_getpreview", 0, 0, 0,        f_popup_getpreview},
     {"popup_hide",     1, 1, 0,          f_popup_hide},
     {"popup_locate",   2, 2, 0,          f_popup_locate},
     {"popup_menu",     2, 2, 0,          f_popup_menu},
index ee3291c110aa205f365181d6fb0f631f09ef2559..dceb1a7395b401cc4a8c7ba9aa0ca6c817b3850e 100644 (file)
@@ -5154,7 +5154,8 @@ prepare_tagpreview(
        else if (use_popup)
        {
            wp = popup_find_info_window();
-           // TODO: set position
+           if (wp != NULL)
+               popup_show(wp);
        }
        else
 # endif
index a64a0b40ccac66b113cb15d5a06dc59e185efe68..aad1bae66f8f18ee20b37a816fe0c8c084f687ae 100644 (file)
@@ -5808,7 +5808,7 @@ ex_pclose(exarg_T *eap)
        }
 # ifdef FEAT_TEXT_PROP
     // Also when 'previewpopup' is empty, it might have been cleared.
-    popup_close_preview(FALSE);
+    popup_close_preview();
 # endif
 }
 #endif
index 8f35ee5454895c85f1ee04e988bdbb6a6b18c33c..03eb412bb050ed36de3f6ed5752ef90017543740 100644 (file)
@@ -923,8 +923,8 @@ pum_set_selected(int n, int repeat UNUSED)
     }
 #if defined(FEAT_TEXT_PROP) && defined(FEAT_QUICKFIX)
     if (!has_info)
-       // close any popup info window
-       popup_close_preview(TRUE);
+       // hide any popup info window
+       popup_hide_info();
 #endif
 
     if (!resized)
@@ -944,8 +944,8 @@ pum_undisplay(void)
     redraw_tabline = TRUE;
     status_redraw_all();
 #if defined(FEAT_TEXT_PROP) && defined(FEAT_QUICKFIX)
-    // close any popup info window
-    popup_close_preview(TRUE);
+    // hide any popup info window
+    popup_hide_info();
 #endif
 }
 
index b8fc8fdf219edf5017972745d61d22df6e6d9b89..482c5a6e1bca5bb808a480871d1b2c9a8dc565a1 100644 (file)
@@ -2058,6 +2058,18 @@ f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
        popup_close_and_callback(wp, &argvars[1]);
 }
 
+    static void
+popup_hide(win_T *wp)
+{
+    if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
+    {
+       wp->w_popup_flags |= POPF_HIDDEN;
+       --wp->w_buffer->b_nwindows;
+       redraw_all_later(NOT_VALID);
+       popup_mask_refresh = TRUE;
+    }
+}
+
 /*
  * popup_hide({id})
  */
@@ -2067,10 +2079,17 @@ f_popup_hide(typval_T *argvars, typval_T *rettv UNUSED)
     int                id = (int)tv_get_number(argvars);
     win_T      *wp = find_popup_win(id);
 
-    if (wp != NULL && (wp->w_popup_flags & POPF_HIDDEN) == 0)
+    if (wp != NULL)
+       popup_hide(wp);
+}
+
+    void
+popup_show(win_T *wp)
+{
+    if ((wp->w_popup_flags & POPF_HIDDEN) != 0)
     {
-       wp->w_popup_flags |= POPF_HIDDEN;
-       --wp->w_buffer->b_nwindows;
+       wp->w_popup_flags &= ~POPF_HIDDEN;
+       ++wp->w_buffer->b_nwindows;
        redraw_all_later(NOT_VALID);
        popup_mask_refresh = TRUE;
     }
@@ -2085,13 +2104,8 @@ f_popup_show(typval_T *argvars, typval_T *rettv UNUSED)
     int                id = (int)tv_get_number(argvars);
     win_T      *wp = find_popup_win(id);
 
-    if (wp != NULL && (wp->w_popup_flags & POPF_HIDDEN) != 0)
-    {
-       wp->w_popup_flags &= ~POPF_HIDDEN;
-       ++wp->w_buffer->b_nwindows;
-       redraw_all_later(NOT_VALID);
-       popup_mask_refresh = TRUE;
-    }
+    if (wp != NULL)
+       popup_show(wp);
 }
 
 /*
@@ -3314,7 +3328,15 @@ popup_find_info_window(void)
 #endif
 
     void
-f_popup_getpreview(typval_T *argvars UNUSED, typval_T *rettv)
+f_popup_findinfo(typval_T *argvars UNUSED, typval_T *rettv)
+{
+    win_T   *wp = popup_find_info_window();
+
+    rettv->vval.v_number = wp == NULL ? 0 : wp->w_id;
+}
+
+    void
+f_popup_findpreview(typval_T *argvars UNUSED, typval_T *rettv)
 {
     win_T   *wp = popup_find_preview_window();
 
@@ -3355,10 +3377,13 @@ popup_create_preview_window(int info)
 }
 
 #if defined(FEAT_QUICKFIX) || defined(PROTO)
+/*
+ * Close any preview popup.
+ */
     void
-popup_close_preview(int info)
+popup_close_preview(void)
 {
-    win_T *wp = info ? popup_find_info_window() : popup_find_preview_window();
+    win_T *wp = popup_find_preview_window();
 
     if (wp != NULL)
     {
@@ -3369,6 +3394,18 @@ popup_close_preview(int info)
        popup_close_and_callback(wp, &res);
     }
 }
+
+/*
+ * Hide the info popup.
+ */
+    void
+popup_hide_info(void)
+{
+    win_T *wp = popup_find_info_window();
+
+    if (wp != NULL)
+       popup_hide(wp);
+}
 #endif
 
 /*
index 9f6d4339ebfe8b68d128c1dddc8843f89fa9259a..0507114224d23249e9f989996f62df763b3c1ced 100644 (file)
@@ -27,6 +27,7 @@ void f_popup_menu(typval_T *argvars, typval_T *rettv);
 void f_popup_notification(typval_T *argvars, typval_T *rettv);
 void f_popup_close(typval_T *argvars, typval_T *rettv);
 void f_popup_hide(typval_T *argvars, typval_T *rettv);
+void popup_show(win_T *wp);
 void f_popup_show(typval_T *argvars, typval_T *rettv);
 void f_popup_settext(typval_T *argvars, typval_T *rettv);
 void popup_close(int id);
@@ -49,9 +50,11 @@ int set_ref_in_popups(int copyID);
 win_T *popup_find_preview_window(void);
 int popup_is_popup(win_T *wp);
 win_T *popup_find_info_window(void);
-void f_popup_getpreview(typval_T *argvars, typval_T *rettv);
+void f_popup_findinfo(typval_T *argvars, typval_T *rettv);
+void f_popup_findpreview(typval_T *argvars, typval_T *rettv);
 int popup_create_preview_window(int info);
-void popup_close_preview(int info);
+void popup_close_preview(void);
+void popup_hide_info(void);
 void popup_set_title(win_T *wp);
 void popup_update_preview_title(void);
 /* vim: set ft=c : */
index 6effda0e582aa79ca76062ba1b3632b4d042006b..2599094f8379ccbb49503a46e950a075b0b804fb 100644 (file)
@@ -8,7 +8,7 @@
 |x| @7| +0#0000001#e0e0e08|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| | +0#0000000#ffffff0@43
 |x| @7| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#0000000#ffffff0@43
 |x| @7| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#0000000#ffffff0@43
-|x| @7| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0&#e0e0e08|w|o|r|d|s| |a|r|e| |c|o@1|l| | +0#0000000#ffffff0@27
+|x| @7| +0#0000001#ffd7ff255|t|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#0000000#ffff4012|w|o|r|d|s| |a|r|e| |c|o@1|l| | +0&#ffffff0@27
 |t|e|s|t| |t|e|x|t| |a|w|o|r|d> @59
 |~+0#4040ff13&| @73
 |-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@26
index 1f1f7314b41096a45c3a8be34240e3d0f4fc4158..6c1ac524a2f9e52c0b7298543328aadec140b1d5 100644 (file)
@@ -2162,7 +2162,7 @@ func Test_previewpopup()
   call term_sendkeys(buf, "/another\<CR>\<C-W>}")
   call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_2', {})
 
-  call term_sendkeys(buf, ":call popup_move(popup_getpreview(), #{col: 15})\<CR>")
+  call term_sendkeys(buf, ":call popup_move(popup_findpreview(), #{col: 15})\<CR>")
   call term_sendkeys(buf, ":\<CR>")
   call VerifyScreenDump(buf, 'Test_popupwin_previewpopup_3', {})
 
@@ -2245,6 +2245,10 @@ func Get_popupmenu_lines()
              \ }
       endfunc
       call setline(1, 'text text text text text text text ')
+      func ChangeColor()
+       let id = popup_findinfo()
+       call popup_setoptions(id, #{highlight: 'InfoPopup'})
+      endfunc
   END
   return lines
 endfunc
@@ -2313,6 +2317,7 @@ func Test_popupmenu_info_align_menu()
   call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_2', {})
 
   call term_sendkeys(buf, "\<Esc>")
+  call term_sendkeys(buf, ":call ChangeColor()\<CR>")
   call term_sendkeys(buf, ":call setline(2, ['x']->repeat(10))\<CR>")
   call term_sendkeys(buf, "Gotest text test text\<C-X>\<C-U>")
   call VerifyScreenDump(buf, 'Test_popupwin_infopopup_align_3', {})
index 6c8bd8983177b6adb196008f2c95c3a41daf3072..ae0bd9c4e04288ee12bee44ce4cf9a6365755b22 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1905,
 /**/
     1904,
 /**/