]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1562: close button always visible in the 'tabline' v9.1.1562
authorGirish Palya <girishji@gmail.com>
Thu, 17 Jul 2025 19:56:16 +0000 (21:56 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 17 Jul 2025 19:56:16 +0000 (21:56 +0200)
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 <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/insert.txt
runtime/doc/tabpage.txt
runtime/doc/version9.txt
src/optionstr.c
src/popupwin.c
src/screen.c
src/testdir/dumps/Test_popupwin_info_border_mouse_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_popupwin_info_border_mouse_2.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/testdir/test_tabline.vim
src/version.c

index df0cff978cf5e6b7db07300f989d8a3a78827b33..80b60415586eb0e1007ff039aa6bf2c8bf32cbcb 100644 (file)
@@ -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"
index 4b0b591b4b1c1a5dcc211e7e13d22aca09793f22..4f46ddd0aa2f50e16beda8cdca10f84ca6077fe1 100644 (file)
@@ -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.
 
index 205366363bafdfc3457e018c3d0f29a62ebac85b..1dd1576acf249fbd26d64800c47824827502cb3a 100644 (file)
@@ -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 ~
index 4c363e5750acdc86e59cf9b5560f41b084af886d..9061792542c7498800406771ba36fcafa2040613 100644 (file)
@@ -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
index 536e1b64c678279ce31ed627cc5b213bb0ef7373..7f1e5d9f19562d60f28a6a46e81f6bc9624e458d 100644 (file)
@@ -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);
     }
index f262cf4c0272e78f11e45536ba5b63ff7e39351f..267791e960ef7716d32ea91bdb0ebed1fa7ffb5e 100644 (file)
@@ -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 (file)
index 0000000..7ee4e49
--- /dev/null
@@ -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 (file)
index 0000000..156de8b
--- /dev/null
@@ -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
index 21d6819a4f9990c6592bc13c1e948576ef379b72..444f25fd099cc31052b6cc69cb628c54f560f920 100644 (file)
@@ -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
index ce8cb58ae3bb1316ad75c207c39442649deabeb7..e02e4f303e0929507dfe17166566d979bee2dc5f 100644 (file)
@@ -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
index d7c183f07afacf17d5a8b46ae59bd2f9cff227b8..22480a00c059131338fd94d8923d1adb9a7aec87 100644 (file)
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1562,
 /**/
     1561,
 /**/