0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

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 <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Girish Palya 2025-07-17 21:56:16 +02:00 committed by Christian Brabandt
parent b7fc24d3a3
commit fb45809f01
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
11 changed files with 112 additions and 12 deletions

View 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"

View 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.

View 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 ~

View 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

View 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;
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);
}

View 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;

View File

@ -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

View File

@ -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

View 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

View 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

View File

@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1562,
/**/
1561,
/**/