patch 9.1.1562: close button always visible in the 'tabline'

Commit: 
https://github.com/vim/vim/commit/fb45809f01fa0c8e7ea1eb9bb26cda04d24d3fe5
Author: Girish Palya <giris...@gmail.com>
Date:   Thu Jul 17 21:56:16 2025 +0200

    patch 9.1.1562: close button always visible in the 'tabline'
    
    Problem:  close button "X" is visible in the non-GUI 'tabline', even
              when the mouse is disabled
    Solution: only show the button when 'mouse' contains any of the flags
              "anvi" (Girish Palya)
    
    The tabline always displays an "X" (close) button, and the info popup
    shows both a close button and a resize handle—even when the mouse is
    disabled. These UI elements are only actionable with the mouse and serve
    no purpose for keyboard users who disable the mouse. Displaying
    non-functional, clickable elements in a non-GUI environment is
    misleading and adds unnecessary visual clutter.
    
    So remove the close button and resize handle when the mouse is disabled.
    They appear again when mouse is enabled.
    
    closes: #17765
    
    Signed-off-by: Girish Palya <giris...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index df0cff978..80b604155 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1,4 +1,4 @@
-*insert.txt*    For Vim version 9.1.  Last change: 2025 Jul 05
+*insert.txt*    For Vim version 9.1.  Last change: 2025 Jul 17
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1258,13 +1258,16 @@ of values:
 Example: >
        :set completepopup=height:10,width:60,highlight:InfoPopup
 
-When the "align" value is "item" then the popup is positioned close to the
-selected item.  Changing the selection will also move the popup.  When "align"
-is "menu" then the popup is aligned with the top of the menu if the menu is
-below the text, and the bottom of the menu otherwise.
+When `"align"` is set to `"item"`, the popup is positioned near the selected
+item, and moves as the selection changes.
+When set to `"menu"`, the popup aligns with the top of the menu (if the menu
+appears below the text), or with the bottom (if the menu appears above).
 
-After the info popup is created it can be found with |popup_findinfo()| and
-properties can be changed with |popup_setoptions()|.
+If the 'mouse' is enabled, a close button and resize handle will appear on the
+popup border.
+
+After creation, the info popup can be located with |popup_findinfo()| and
+modified using |popup_setoptions()|.
 
                                                *complete-popuphidden*
 If the information for the popup is obtained asynchronously, use "popuphidden"
diff --git a/runtime/doc/tabpage.txt b/runtime/doc/tabpage.txt
index 4b0b591b4..4f46ddd0a 100644
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -1,4 +1,4 @@
-*tabpage.txt*   For Vim version 9.1.  Last change: 2025 Jul 01
+*tabpage.txt*   For Vim version 9.1.  Last change: 2025 Jul 17
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -363,6 +363,9 @@ A "+" will be shown for a tab page that has a modified 
window.  The number of
 windows in a tabpage is also shown.  Thus "3+" means three windows and one of
 them has a modified buffer.
 
+An "X" (close button) will appear in the last column when multiple tabs are
+open, but only if the 'mouse' is enabled.
+
 The 'tabline' option allows you to define your preferred way to tab pages
 labels.  This isn't easy, thus an example will be given here.
 
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 205366363..1dd1576ac 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -41726,6 +41726,8 @@ Others: ~
 - the configure script will favor using GTK3 over GTK2 when auto-detecting the
   gui toolkit
 - |gv| works in operator pending mode and does not abort
+- The close button shown in the non-GUI 'tabline' will only be visible if the
+  'mouse' option contains either "a" or any of the flags "n", "v", or "i".
 
                                                        *added-9.2*
 Added ~
diff --git a/src/optionstr.c b/src/optionstr.c
index 4c363e575..906179254 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -3254,9 +3254,20 @@ did_set_mkspellmem(optset_T *args UNUSED)
 did_set_mouse(optset_T *args)
 {
     char_u     **varp = (char_u **)args->os_varp;
+    char       *retval;
 
-    return did_set_option_listflag(*varp, (char_u *)MOUSE_ALL, args->os_errbuf,
+    retval = did_set_option_listflag(*varp, (char_u *)MOUSE_ALL, 
args->os_errbuf,
                    args->os_errbuflen);
+    if (retval == NULL)
+    {
+       redraw_tabline = TRUE;
+       if (tabline_height() > 0)
+           update_screen(UPD_VALID);
+#if (defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)) || defined(PROTO)
+       popup_close_info(); // Close info popup to apply new properties
+#endif
+    }
+    return retval;
 }
 
     int
diff --git a/src/popupwin.c b/src/popupwin.c
index 536e1b64c..7f1e5d9f1 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -2286,8 +2286,11 @@ popup_create(typval_T *argvars, typval_T *rettv, 
create_type_T type)
     if (type == TYPE_INFO)
     {
        wp->w_popup_pos = POPPOS_TOPLEFT;
-       wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
-       wp->w_popup_close = POPCLOSE_BUTTON;
+       if (mouse_has(MOUSE_INSERT))
+       {
+           wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
+           wp->w_popup_close = POPCLOSE_BUTTON;
+       }
        add_border_left_right_padding(wp);
        parse_completepopup(wp);
     }
diff --git a/src/screen.c b/src/screen.c
index f262cf4c0..267791e96 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -4284,6 +4284,16 @@ recording_mode(int attr)
     msg_puts_attr(s, attr);
 }
 
+/*
+ * Return TRUE if mouse is enabled.
+ */
+    static int
+mouse_has_any(void)
+{
+    return mouse_has(MOUSE_NORMAL) || mouse_has(MOUSE_INSERT)
+       || mouse_has(MOUSE_VISUAL);
+}
+
 /*
  * Draw the tab pages line at the top of the Vim window.
  */
@@ -4460,7 +4470,7 @@ draw_tabline(void)
        }
 
        // Put an "X" for closing the current tab if there are several.
-       if (tabcount > 1)
+       if (tabcount > 1 && mouse_has_any())
        {
            screen_putchar('X', 0, (int)Columns - 1, attr_nosel);
            TabPageIdxs[Columns - 1] = -999;
diff --git a/src/testdir/dumps/Test_popupwin_info_border_mouse_1.dump 
b/src/testdir/dumps/Test_popupwin_info_border_mouse_1.dump
new file mode 100644
index 000000000..7ee4e4969
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_info_border_mouse_1.dump
@@ -0,0 +1,14 @@
+|t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| 
|t|e|x|t| @40
+@75
+|a|w|o|r|d> @15|╔+0#0000001#e0e0e08|═@15|X| +0#0000000#ffffff0@35
+|w+0#0000001#e0e0e08|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| |║| |w|o|r|d|s| |a|r|e| 
|c|o@1|l| |║| +0#4040ff13#ffffff0@35
+|a+0#0000001#ffd7ff255|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| 
|╚+0&#e0e0e08|═@15|⇲| +0#4040ff13#ffffff0@35
+|n+0#0000001#ffd7ff255|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | 
+0#4040ff13#ffffff0@53
+|t+0#0000001#ffd7ff255|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | 
+0#4040ff13#ffffff0@53
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @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
diff --git a/src/testdir/dumps/Test_popupwin_info_border_mouse_2.dump 
b/src/testdir/dumps/Test_popupwin_info_border_mouse_2.dump
new file mode 100644
index 000000000..156de8b0f
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_info_border_mouse_2.dump
@@ -0,0 +1,14 @@
+|t+0&#ffffff0|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| |t|e|x|t| 
|t|e|x|t| @40
+|a|w|o|r|d> @15|╔+0#0000001#e0e0e08|═@15|╗| +0#0000000#ffffff0@35
+|w+0#0000001#e0e0e08|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| |║| |w|o|r|d|s| |a|r|e| 
|c|o@1|l| |║| +0#4040ff13#ffffff0@35
+|a+0#0000001#ffd7ff255|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| 
|╚+0&#e0e0e08|═@15|╝| +0#4040ff13#ffffff0@35
+|n+0#0000001#ffd7ff255|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | 
+0#4040ff13#ffffff0@53
+|t+0#0000001#ffd7ff255|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | 
+0#4040ff13#ffffff0@53
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @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
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index 21d6819a4..444f25fd0 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -3726,6 +3726,31 @@ func Test_popupmenu_info_noborder()
   call StopVimInTerminal(buf)
 endfunc
 
+" Info popup should not have close (X) and resize buttons when mouse is
+" disabled.
+func Test_popupmenu_info_border_mouse()
+  CheckScreendump
+  CheckFeature quickfix
+
+  let lines = Get_popupmenu_lines()
+  call writefile(lines, 'XtestInfoPopup', 'D')
+
+  let buf = RunVimInTerminal('-S XtestInfoPopup', #{rows: 14})
+  call TermWait(buf, 25)
+
+  call term_sendkeys(buf, "Go\<CR>\<C-X>\<C-U>")
+  call TermWait(buf, 25)
+  call VerifyScreenDump(buf, 'Test_popupwin_info_border_mouse_1', {})
+
+  call term_sendkeys(buf, "\<ESC>u:set mouse=\<CR>")
+  call term_sendkeys(buf, "o\<C-X>\<C-U>")
+  call TermWait(buf, 25)
+  call VerifyScreenDump(buf, 'Test_popupwin_info_border_mouse_2', {})
+
+  call term_sendkeys(buf, "\<Esc>")
+  call StopVimInTerminal(buf)
+endfunc
+
 func Test_popupmenu_info_align_menu()
   CheckScreendump
   CheckFeature quickfix
diff --git a/src/testdir/test_tabline.vim b/src/testdir/test_tabline.vim
index ce8cb58ae..e02e4f303 100644
--- a/src/testdir/test_tabline.vim
+++ b/src/testdir/test_tabline.vim
@@ -223,4 +223,17 @@ func Test_tabline_truncated_double_width()
   set tabline=
 endfunc
 
+" Test that 'X' is removed when mouse is disabled.
+func Test_tabline_mouse_enable()
+  tabnew
+  for val in ['n', 'i', 'v', 'a']
+    set mouse=
+    redraw
+    call assert_notmatch('X$', Screenline(1))
+    execute $'set mouse={val}'
+    redraw
+    call assert_match('X$', Screenline(1))
+  endfor
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index d7c183f07..22480a00c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1562,
 /**/
     1561,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1ucUlw-00BlIH-Lj%40256bit.org.

Raspunde prin e-mail lui