]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.1.1421: drawing "~" line in popup window v8.1.1421
authorBram Moolenaar <Bram@vim.org>
Wed, 29 May 2019 22:12:11 +0000 (00:12 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 29 May 2019 22:12:11 +0000 (00:12 +0200)
Problem:    Drawing "~" line in popup window.
Solution:   Just draw text in the last line of the popup window.

src/popupwin.c
src/proto/popupwin.pro
src/screen.c
src/structs.h
src/testdir/dumps/Test_popupwin_05.dump
src/testdir/dumps/Test_popupwin_06.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c

index 9465008737d6540b82c2f55c9a8407bd821590c9..64309ff8b794bf0efbae80d927444fb22a104c54 100644 (file)
@@ -151,7 +151,7 @@ add_popup_dicts(buf_T *buf, list_T *l)
 /*
  * Adjust the position and size of the popup to fit on the screen.
  */
-    static void
+    void
 popup_adjust_position(win_T *wp)
 {
     linenr_T   lnum;
@@ -209,6 +209,8 @@ popup_adjust_position(win_T *wp)
        wp->w_height = wp->w_maxheight;
     if (wp->w_height > Rows - wp->w_winrow)
        wp->w_height = Rows - wp->w_winrow;
+
+    wp->w_popup_last_changedtick = CHANGEDTICK(wp->w_buffer);
 }
 
 /*
index 37b5273226be7b15f3d8b969ca360203ee207fb9..83b5f2ccb8ec1daea6862e3457f5b36cbaa48d9f 100644 (file)
@@ -1,13 +1,14 @@
 /* popupwin.c */
+void popup_adjust_position(win_T *wp);
 void f_popup_create(typval_T *argvars, typval_T *rettv);
 int popup_any_visible(void);
 void f_popup_close(typval_T *argvars, typval_T *rettv);
 void f_popup_hide(typval_T *argvars, typval_T *rettv);
-void f_popup_getposition(typval_T *argvars, typval_T *rettv);
 void f_popup_show(typval_T *argvars, typval_T *rettv);
 void popup_close(int id);
 void popup_close_tabpage(tabpage_T *tp, int id);
 void close_all_popups(void);
 void ex_popupclear(exarg_T *eap);
 void f_popup_move(typval_T *argvars, typval_T *rettv);
+void f_popup_getposition(typval_T *argvars, typval_T *rettv);
 /* vim: set ft=c : */
index de0833a679538b3c4c392017ff9ce623acedb088..5f3947bf9eeb2784f8d51b32bfbdf560fba4a4c1 100644 (file)
@@ -1030,6 +1030,12 @@ update_popups(void)
 
        if (lowest_wp == NULL)
            break;
+
+       // Recompute the position if the text changed.
+       if (lowest_wp->w_popup_last_changedtick
+                                          != CHANGEDTICK(lowest_wp->w_buffer))
+           popup_adjust_position(lowest_wp);
+
        win_update(lowest_wp);
        lowest_wp->w_popup_flags |= POPF_REDRAWN;
     }
@@ -2119,6 +2125,9 @@ win_update(win_T *wp)
                    && wp->w_lines[idx].wl_lnum == lnum
                    && lnum > wp->w_topline
                    && !(dy_flags & (DY_LASTLINE | DY_TRUNCATE))
+#ifdef FEAT_TEXT_PROP
+                   && !bt_popup(wp->w_buffer)
+#endif
                    && srow + wp->w_lines[idx].wl_size > wp->w_height
 #ifdef FEAT_DIFF
                    && diff_check_fill(wp, lnum) == 0
@@ -2273,6 +2282,13 @@ win_update(win_T *wp)
            wp->w_botline = lnum;
            wp->w_filler_rows = wp->w_height - srow;
        }
+#endif
+#ifdef FEAT_TEXT_PROP
+       else if (bt_popup(wp->w_buffer))
+       {
+           // popup line that doesn't fit is left as-is
+           wp->w_botline = lnum;
+       }
 #endif
        else if (dy_flags & DY_TRUNCATE)        /* 'display' has "truncate" */
        {
@@ -2334,7 +2350,11 @@ win_update(win_T *wp)
 
        // Make sure the rest of the screen is blank
        // put '~'s on rows that aren't part of the file.
-       win_draw_end(wp, '~', ' ', FALSE, row, wp->w_height, HLF_EOB);
+       win_draw_end(wp,
+#ifdef FEAT_TEXT_PROP
+               bt_popup(wp->w_buffer) ? ' ' :
+#endif
+                                 '~', ' ', FALSE, row, wp->w_height, HLF_EOB);
     }
 
 #ifdef SYN_TIME_LIMIT
index 79681cc2a83fb4c0b0c86972449ff8e46d022f13..9f63949208cae4525dd9574792f4f856a28c5c3e 100644 (file)
@@ -2881,6 +2881,8 @@ struct window_S
     int                w_maxwidth;         // "maxwidth" for popup window
     int                w_wantline;         // "line" for popup window
     int                w_wantcol;          // "col" for popup window
+    varnumber_T        w_popup_last_changedtick; // b:changedtick when position was
+                                         // computed
 # if defined(FEAT_TIMERS)
     timer_T    *w_popup_timer;     // timer for closing popup window
 # endif
index bfb50f0f007a5fd6b20d5e0b12edd5defaa8fd9c..2c74d7469ed9b84b6873988088ca54ae9ca363ff 100644 (file)
@@ -3,7 +3,7 @@
 |~| @73
 |~| @6|o+0#0000001#ffd7ff255|t|h|e|r| |t|a|b| @5| +0#4040ff13#ffffff0@51
 |~| @6|a+0#0000001#ffd7ff255| |c+0#ff404010&|o|m@1|e|n|t| +0#0000001&|l|i|n|e| | +0#4040ff13#ffffff0@51
-|~| @6|~+0&#ffd7ff255| @13| +0&#ffffff0@51
+|~| @6| +0&#ffd7ff255@14| +0&#ffffff0@51
 |~| @73
 |~| @73
 |~| @73
diff --git a/src/testdir/dumps/Test_popupwin_06.dump b/src/testdir/dumps/Test_popupwin_06.dump
new file mode 100644 (file)
index 0000000..3dfcbc2
--- /dev/null
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @6|o+0#0000001#ffd7ff255|t|h|e|r| |t|a|b| @15| +0#4040ff13#ffffff0@41
+|~| @6|a+0#0000001#ffd7ff255| |c+0#ff404010&|o|m@1|e|n|t| +0#0000001&|l|i|n|e| @10| +0#4040ff13#ffffff0@41
+|~| @6|t+0#0000001#ffd7ff255|h|i|s| |l|i|n|e| |w|i|l@1| |n|o|t| |f|i|t| |h|e| +0#4040ff13#ffffff0@41
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|r|e|d|r|a|w| @49|0|,|0|-|1| @8|A|l@1| 
index a2d2e803b131b0b5663d88571d9bf35d94fc7847..4511cd1ac0351b5785fe123f99000437010284c0 100644 (file)
@@ -41,11 +41,16 @@ func Test_simple_popup()
   call term_sendkeys(buf, ":quit!\<CR>")
   call VerifyScreenDump(buf, 'Test_popupwin_04', {})
 
-  " resize popup
+  " resize popup, show empty line at bottom
   call term_sendkeys(buf, ":call popup_move(popupwin, {'minwidth': 15, 'maxwidth': 25, 'minheight': 3, 'maxheight': 5})\<CR>")
   call term_sendkeys(buf, ":redraw\<CR>")
   call VerifyScreenDump(buf, 'Test_popupwin_05', {})
 
+  " show not fitting line at bottom
+  call term_sendkeys(buf, ":call setbufline(winbufnr(popupwin), 3, 'this line will not fit here')\<CR>")
+  call term_sendkeys(buf, ":redraw\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_06', {})
+
   " clean up
   call StopVimInTerminal(buf)
   call delete('XtestPopup')
index 00eaacb5b4668233cf7091cfcd6cd0ebc285d53d..ca487930314d0b34a626c9cc88240bb48ebc86a9 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1421,
 /**/
     1420,
 /**/