To: vim_dev@googlegroups.com Subject: Patch 8.1.1597 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1597 Problem: Cannot scroll a popup window with the mouse. Solution: If the popup window has a scrollbar let the mouse scroll wheel scroll the window. Files: runtime/doc/popup.txt, src/normal.c, src/popupwin.c, src/screen.c, src/testdir/dumps/Test_popupwin_firstline.dump, src/testdir/dumps/Test_popupwin_scroll_1.dump, src/testdir/dumps/Test_popupwin_scroll_2.dump, src/testdir/dumps/Test_popupwin_scroll_3.dump, src/testdir/dumps/Test_popupwin_scroll_5.dump, src/testdir/dumps/Test_popupwin_scroll_6.dump, src/testdir/dumps/Test_popupwin_scroll_7.dump *** ../vim-8.1.1596/runtime/doc/popup.txt 2019-06-25 05:15:15.188891898 +0200 --- runtime/doc/popup.txt 2019-06-26 03:38:38.653919493 +0200 *************** *** 85,95 **** that it is in. - TODO: ! - When the lines do not fit show a scrollbar (like in the popup menu). ! - Use the mouse wheel for scrolling. ! - Have a way to scroll to the botton. (#4577) - Why does 'nrformats' leak from the popup window buffer??? - Disable commands, feedkeys(), CTRL-W, etc. in a popup window. Use ERROR_IF_POPUP_WINDOW for more commands. --- 85,95 ---- that it is in. TODO: ! - click near top of scrollbar scrolls down, clear near bottom scrolls up. ! - Allow for setting scrollbar color: scrollbarhighlight, ! scrollbarthumbhighlight ? ! - Have a way to scroll to the bottom? (#4577) - Why does 'nrformats' leak from the popup window buffer??? - Disable commands, feedkeys(), CTRL-W, etc. in a popup window. Use ERROR_IF_POPUP_WINDOW for more commands. *************** *** 275,280 **** --- 275,282 ---- core_line screen line of the text box core_width width of the text box in screen cells core_height height of the text box in screen cells + firstline line of the buffer at top (1 unless scrolled) + scrollbar non-zero if a scrollbar is displayed visible one if the popup is displayed, zero if hidden Note that these are the actual screen positions. They differ from the values in `popup_getoptions()` for the sizing and *************** *** 483,489 **** Also see "scrollbar". hidden When TRUE the popup exists but is not displayed; use `popup_show()` to unhide it. - {not implemented yet} tabpage When -1: display the popup on all tab pages. When 0 (the default): display the popup on the current tab page. --- 485,490 ---- *** ../vim-8.1.1596/src/normal.c 2019-06-25 04:12:12.312665250 +0200 --- src/normal.c 2019-06-26 02:36:22.631035658 +0200 *************** *** 4521,4529 **** col = mouse_col; /* find the window at the pointer coordinates */ ! wp = mouse_find_win(&row, &col, FAIL_POPUP); if (wp == NULL) return; curwin = wp; curbuf = curwin->w_buffer; } --- 4521,4533 ---- col = mouse_col; /* find the window at the pointer coordinates */ ! wp = mouse_find_win(&row, &col, FIND_POPUP); if (wp == NULL) return; + #ifdef FEAT_TEXT_PROP + if (bt_popup(wp->w_buffer) && !wp->w_has_scrollbar) + return; + #endif curwin = wp; curbuf = curwin->w_buffer; } *************** *** 4543,4552 **** } else { ! cap->count1 = 3; ! cap->count0 = 3; nv_scroll_line(cap); } } # ifdef FEAT_GUI else --- 4547,4581 ---- } else { ! // Don't scroll more than half the window height. ! if (curwin->w_height < 6) ! { ! cap->count1 = curwin->w_height / 2; ! if (cap->count1 == 0) ! cap->count1 = 1; ! } ! else ! cap->count1 = 3; ! cap->count0 = cap->count1; nv_scroll_line(cap); } + #ifdef FEAT_TEXT_PROP + if (bt_popup(wp->w_buffer)) + { + int height = wp->w_height; + + curwin->w_firstline = curwin->w_topline; + popup_adjust_position(curwin); + + // we don't want the popup to get smaller, decrement the first line + // until it doesn't + while (curwin->w_firstline > 1 && curwin->w_height < height) + { + --curwin->w_firstline; + popup_adjust_position(curwin); + } + } + #endif } # ifdef FEAT_GUI else *** ../vim-8.1.1596/src/popupwin.c 2019-06-26 01:03:49.489879814 +0200 --- src/popupwin.c 2019-06-26 02:54:34.662852966 +0200 *************** *** 1547,1552 **** --- 1547,1553 ---- dict_add_number(dict, "core_height", wp->w_height); dict_add_number(dict, "scrollbar", wp->w_has_scrollbar); + dict_add_number(dict, "firstline", wp->w_topline); dict_add_number(dict, "visible", win_valid(wp) && (wp->w_popup_flags & POPF_HIDDEN) == 0); } *************** *** 2238,2249 **** { linenr_T linecount = wp->w_buffer->b_ml.ml_line_count; ! sb_thumb_height = wp->w_height * wp->w_height / linecount; if (sb_thumb_height == 0) sb_thumb_height = 1; ! sb_thumb_top = ((wp->w_topline * (wp->w_height - sb_thumb_height) ! + (linecount - wp->w_height) / 2)) ! / (linecount - (wp->w_height - sb_thumb_height)); } for (i = wp->w_popup_border[0]; --- 2239,2251 ---- { linenr_T linecount = wp->w_buffer->b_ml.ml_line_count; ! sb_thumb_height = (wp->w_height * wp->w_height + linecount / 2) ! / linecount; if (sb_thumb_height == 0) sb_thumb_height = 1; ! sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2) ! * (wp->w_height - sb_thumb_height) ! / (linecount - wp->w_height); } for (i = wp->w_popup_border[0]; *** ../vim-8.1.1596/src/screen.c 2019-06-23 00:15:02.577534926 +0200 --- src/screen.c 2019-06-26 03:05:49.828469527 +0200 *************** *** 875,881 **** #endif #ifdef FEAT_TEXT_PROP // Update popup_mask if needed. ! may_update_popup_mask(0); #endif } --- 875,881 ---- #endif #ifdef FEAT_TEXT_PROP // Update popup_mask if needed. ! may_update_popup_mask(must_redraw); #endif } *************** *** 1555,1561 **** if (mid_start == 0) { mid_end = wp->w_height; ! if (ONE_WINDOW) { /* Clear the screen when it was not done by win_del_lines() or * win_ins_lines() above, "screen_cleared" is FALSE or MAYBE --- 1555,1565 ---- if (mid_start == 0) { mid_end = wp->w_height; ! if (ONE_WINDOW ! #ifdef FEAT_TEXT_PROP ! && !bt_popup(wp->w_buffer) ! #endif ! ) { /* Clear the screen when it was not done by win_del_lines() or * win_ins_lines() above, "screen_cleared" is FALSE or MAYBE *** ../vim-8.1.1596/src/testdir/dumps/Test_popupwin_firstline.dump 2019-06-25 05:15:15.188891898 +0200 --- src/testdir/dumps/Test_popupwin_firstline.dump 2019-06-26 03:13:17.554776056 +0200 *************** *** 3,9 **** |3| @73 |4| @33|3+0#0000001#ffd7ff255@4| +0#0000000#a8a8a8255| +0&#ffffff0@33 |5| @33|4+0#0000001#ffd7ff255@1| @2| +0#0000000#0000001| +0&#ffffff0@33 ! |6| @33|5+0#0000001#ffd7ff255| @3| +0#0000000#a8a8a8255| +0&#ffffff0@33 |7| @33|6+0#0000001#ffd7ff255@4| +0#0000000#a8a8a8255| +0&#ffffff0@33 |8| @73 |9| @73 --- 3,9 ---- |3| @73 |4| @33|3+0#0000001#ffd7ff255@4| +0#0000000#a8a8a8255| +0&#ffffff0@33 |5| @33|4+0#0000001#ffd7ff255@1| @2| +0#0000000#0000001| +0&#ffffff0@33 ! |6| @33|5+0#0000001#ffd7ff255| @3| +0#0000000#0000001| +0&#ffffff0@33 |7| @33|6+0#0000001#ffd7ff255@4| +0#0000000#a8a8a8255| +0&#ffffff0@33 |8| @73 |9| @73 *** ../vim-8.1.1596/src/testdir/dumps/Test_popupwin_scroll_1.dump 2019-06-25 05:15:15.188891898 +0200 --- src/testdir/dumps/Test_popupwin_scroll_1.dump 2019-06-26 03:17:03.285909075 +0200 *************** *** 2,8 **** |2| @73 |3| @73 |4| @31|o+0#0000001#ffd7ff255|n|e| @4| +0#0000000#0000001| +0&#ffffff0@32 ! |5| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32 |6| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32 |7| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32 |8| @73 --- 2,8 ---- |2| @73 |3| @73 |4| @31|o+0#0000001#ffd7ff255|n|e| @4| +0#0000000#0000001| +0&#ffffff0@32 ! |5| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#0000001| +0&#ffffff0@32 |6| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32 |7| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32 |8| @73 *** ../vim-8.1.1596/src/testdir/dumps/Test_popupwin_scroll_2.dump 2019-06-25 05:15:15.188891898 +0200 --- src/testdir/dumps/Test_popupwin_scroll_2.dump 2019-06-26 03:17:04.337905018 +0200 *************** *** 1,7 **** >1+0&#ffffff0| @73 |2| @73 |3| @73 ! |4| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32 |5| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#0000001| +0&#ffffff0@32 |6| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32 |7| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32 --- 1,7 ---- >1+0&#ffffff0| @73 |2| @73 |3| @73 ! |4| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#0000001| +0&#ffffff0@32 |5| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#0000001| +0&#ffffff0@32 |6| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32 |7| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32 *** ../vim-8.1.1596/src/testdir/dumps/Test_popupwin_scroll_3.dump 2019-06-25 05:15:15.188891898 +0200 --- src/testdir/dumps/Test_popupwin_scroll_3.dump 2019-06-26 03:17:05.385900981 +0200 *************** *** 3,9 **** |3| @73 |4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32 |5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32 ! |6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32 |7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#0000001| +0&#ffffff0@32 |8| @73 |9| @73 --- 3,9 ---- |3| @73 |4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32 |5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32 ! |6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#0000001| +0&#ffffff0@32 |7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#0000001| +0&#ffffff0@32 |8| @73 |9| @73 *** ../vim-8.1.1596/src/testdir/dumps/Test_popupwin_scroll_5.dump 2019-06-26 03:39:20.685781019 +0200 --- src/testdir/dumps/Test_popupwin_scroll_5.dump 2019-06-26 03:36:39.802303783 +0200 *************** *** 0 **** --- 1,10 ---- + >1+0&#ffffff0| @73 + |2| @73 + |3| @73 + |4| @31|o+0#0000001#ffd7ff255|n|e| @4| +0#0000000#0000001| +0&#ffffff0@32 + |5| @31|t+0#0000001#ffd7ff255|w|o| @4| +0#0000000#0000001| +0&#ffffff0@32 + |6| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32 + |7| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#a8a8a8255| +0&#ffffff0@32 + |8| @73 + |9| @73 + |:|c|a|l@1| |S|c|r|o|l@1|U|p|(|)| @40|1|,|1| @10|T|o|p| *** ../vim-8.1.1596/src/testdir/dumps/Test_popupwin_scroll_6.dump 2019-06-26 03:39:20.689781008 +0200 --- src/testdir/dumps/Test_popupwin_scroll_6.dump 2019-06-26 03:36:40.850300447 +0200 *************** *** 0 **** --- 1,10 ---- + >1+0&#ffffff0| @73 + |2| @73 + |3| @73 + |4| @31|t+0#0000001#ffd7ff255|h|r|e@1| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32 + |5| @31|f+0#0000001#ffd7ff255|o|u|r| @3| +0#0000000#0000001| +0&#ffffff0@32 + |6| @31|f+0#0000001#ffd7ff255|i|v|e| @3| +0#0000000#0000001| +0&#ffffff0@32 + |7| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32 + |8| @73 + |9| @73 + |:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p| *** ../vim-8.1.1596/src/testdir/dumps/Test_popupwin_scroll_7.dump 2019-06-26 03:39:20.693780992 +0200 --- src/testdir/dumps/Test_popupwin_scroll_7.dump 2019-06-26 03:36:41.898297110 +0200 *************** *** 0 **** --- 1,10 ---- + >1+0&#ffffff0| @73 + |2| @73 + |3| @73 + |4| @31|s+0#0000001#ffd7ff255|i|x| @4| +0#0000000#a8a8a8255| +0&#ffffff0@32 + |5| @31|s+0#0000001#ffd7ff255|e|v|e|n| @2| +0#0000000#a8a8a8255| +0&#ffffff0@32 + |6| @31|e+0#0000001#ffd7ff255|i|g|h|t| @2| +0#0000000#0000001| +0&#ffffff0@32 + |7| @31|n+0#0000001#ffd7ff255|i|n|e| @3| +0#0000000#0000001| +0&#ffffff0@32 + |8| @73 + |9| @73 + |:|c|a|l@1| |S|c|r|o|l@1|D|o|w|n|(|)| @38|1|,|1| @10|T|o|p| *** ../vim-8.1.1596/src/version.c 2019-06-26 01:03:49.489879814 +0200 --- src/version.c 2019-06-26 03:38:59.521850901 +0200 *************** *** 779,780 **** --- 779,782 ---- { /* Add new patch number below this line */ + /**/ + 1597, /**/ -- MAN: Fetchez la vache! GUARD: Quoi? MAN: Fetchez la vache! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///