Skip to content

Commit fb45809

Browse files
girishjichrisbra
authored andcommitted
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>
1 parent b7fc24d commit fb45809

11 files changed

Lines changed: 112 additions & 12 deletions

runtime/doc/insert.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*insert.txt* For Vim version 9.1. Last change: 2025 Jul 05
1+
*insert.txt* For Vim version 9.1. Last change: 2025 Jul 17
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1258,13 +1258,16 @@ of values:
12581258
Example: >
12591259
:set completepopup=height:10,width:60,highlight:InfoPopup
12601260
1261-
When the "align" value is "item" then the popup is positioned close to the
1262-
selected item. Changing the selection will also move the popup. When "align"
1263-
is "menu" then the popup is aligned with the top of the menu if the menu is
1264-
below the text, and the bottom of the menu otherwise.
1261+
When `"align"` is set to `"item"`, the popup is positioned near the selected
1262+
item, and moves as the selection changes.
1263+
When set to `"menu"`, the popup aligns with the top of the menu (if the menu
1264+
appears below the text), or with the bottom (if the menu appears above).
12651265

1266-
After the info popup is created it can be found with |popup_findinfo()| and
1267-
properties can be changed with |popup_setoptions()|.
1266+
If the 'mouse' is enabled, a close button and resize handle will appear on the
1267+
popup border.
1268+
1269+
After creation, the info popup can be located with |popup_findinfo()| and
1270+
modified using |popup_setoptions()|.
12681271

12691272
*complete-popuphidden*
12701273
If the information for the popup is obtained asynchronously, use "popuphidden"

runtime/doc/tabpage.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*tabpage.txt* For Vim version 9.1. Last change: 2025 Jul 01
1+
*tabpage.txt* For Vim version 9.1. Last change: 2025 Jul 17
22

33

44
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
363363
windows in a tabpage is also shown. Thus "3+" means three windows and one of
364364
them has a modified buffer.
365365

366+
An "X" (close button) will appear in the last column when multiple tabs are
367+
open, but only if the 'mouse' is enabled.
368+
366369
The 'tabline' option allows you to define your preferred way to tab pages
367370
labels. This isn't easy, thus an example will be given here.
368371

runtime/doc/version9.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41726,6 +41726,8 @@ Others: ~
4172641726
- the configure script will favor using GTK3 over GTK2 when auto-detecting the
4172741727
gui toolkit
4172841728
- |gv| works in operator pending mode and does not abort
41729+
- The close button shown in the non-GUI 'tabline' will only be visible if the
41730+
'mouse' option contains either "a" or any of the flags "n", "v", or "i".
4172941731

4173041732
*added-9.2*
4173141733
Added ~

src/optionstr.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3254,9 +3254,20 @@ did_set_mkspellmem(optset_T *args UNUSED)
32543254
did_set_mouse(optset_T *args)
32553255
{
32563256
char_u **varp = (char_u **)args->os_varp;
3257+
char *retval;
32573258

3258-
return did_set_option_listflag(*varp, (char_u *)MOUSE_ALL, args->os_errbuf,
3259+
retval = did_set_option_listflag(*varp, (char_u *)MOUSE_ALL, args->os_errbuf,
32593260
args->os_errbuflen);
3261+
if (retval == NULL)
3262+
{
3263+
redraw_tabline = TRUE;
3264+
if (tabline_height() > 0)
3265+
update_screen(UPD_VALID);
3266+
#if (defined(FEAT_PROP_POPUP) && defined(FEAT_QUICKFIX)) || defined(PROTO)
3267+
popup_close_info(); // Close info popup to apply new properties
3268+
#endif
3269+
}
3270+
return retval;
32603271
}
32613272

32623273
int

src/popupwin.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,8 +2286,11 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type)
22862286
if (type == TYPE_INFO)
22872287
{
22882288
wp->w_popup_pos = POPPOS_TOPLEFT;
2289-
wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
2290-
wp->w_popup_close = POPCLOSE_BUTTON;
2289+
if (mouse_has(MOUSE_INSERT))
2290+
{
2291+
wp->w_popup_flags |= POPF_DRAG | POPF_RESIZE;
2292+
wp->w_popup_close = POPCLOSE_BUTTON;
2293+
}
22912294
add_border_left_right_padding(wp);
22922295
parse_completepopup(wp);
22932296
}

src/screen.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4284,6 +4284,16 @@ recording_mode(int attr)
42844284
msg_puts_attr(s, attr);
42854285
}
42864286

4287+
/*
4288+
* Return TRUE if mouse is enabled.
4289+
*/
4290+
static int
4291+
mouse_has_any(void)
4292+
{
4293+
return mouse_has(MOUSE_NORMAL) || mouse_has(MOUSE_INSERT)
4294+
|| mouse_has(MOUSE_VISUAL);
4295+
}
4296+
42874297
/*
42884298
* Draw the tab pages line at the top of the Vim window.
42894299
*/
@@ -4460,7 +4470,7 @@ draw_tabline(void)
44604470
}
44614471

44624472
// Put an "X" for closing the current tab if there are several.
4463-
if (tabcount > 1)
4473+
if (tabcount > 1 && mouse_has_any())
44644474
{
44654475
screen_putchar('X', 0, (int)Columns - 1, attr_nosel);
44664476
TabPageIdxs[Columns - 1] = -999;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
|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
2+
@75
3+
|a|w|o|r|d> @15|╔+0#0000001#e0e0e08|═@15|X| +0#0000000#ffffff0@35
4+
|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
5+
|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
6+
|n+0#0000001#ffd7ff255|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@53
7+
|t+0#0000001#ffd7ff255|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@53
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|-+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
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
|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
2+
|a|w|o|r|d> @15|╔+0#0000001#e0e0e08|═@15|╗| +0#0000000#ffffff0@35
3+
|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
4+
|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
5+
|n+0#0000001#ffd7ff255|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@53
6+
|t+0#0000001#ffd7ff255|h|a|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| | +0#4040ff13#ffffff0@53
7+
|~| @73
8+
|~| @73
9+
|~| @73
10+
|~| @73
11+
|~| @73
12+
|~| @73
13+
|~| @73
14+
|-+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

src/testdir/test_popupwin.vim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3726,6 +3726,31 @@ func Test_popupmenu_info_noborder()
37263726
call StopVimInTerminal(buf)
37273727
endfunc
37283728

3729+
" Info popup should not have close (X) and resize buttons when mouse is
3730+
" disabled.
3731+
func Test_popupmenu_info_border_mouse()
3732+
CheckScreendump
3733+
CheckFeature quickfix
3734+
3735+
let lines = Get_popupmenu_lines()
3736+
call writefile(lines, 'XtestInfoPopup', 'D')
3737+
3738+
let buf = RunVimInTerminal('-S XtestInfoPopup', #{rows: 14})
3739+
call TermWait(buf, 25)
3740+
3741+
call term_sendkeys(buf, "Go\<CR>\<C-X>\<C-U>")
3742+
call TermWait(buf, 25)
3743+
call VerifyScreenDump(buf, 'Test_popupwin_info_border_mouse_1', {})
3744+
3745+
call term_sendkeys(buf, "\<ESC>u:set mouse=\<CR>")
3746+
call term_sendkeys(buf, "o\<C-X>\<C-U>")
3747+
call TermWait(buf, 25)
3748+
call VerifyScreenDump(buf, 'Test_popupwin_info_border_mouse_2', {})
3749+
3750+
call term_sendkeys(buf, "\<Esc>")
3751+
call StopVimInTerminal(buf)
3752+
endfunc
3753+
37293754
func Test_popupmenu_info_align_menu()
37303755
CheckScreendump
37313756
CheckFeature quickfix

src/testdir/test_tabline.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,17 @@ func Test_tabline_truncated_double_width()
223223
set tabline=
224224
endfunc
225225

226+
" Test that 'X' is removed when mouse is disabled.
227+
func Test_tabline_mouse_enable()
228+
tabnew
229+
for val in ['n', 'i', 'v', 'a']
230+
set mouse=
231+
redraw
232+
call assert_notmatch('X$', Screenline(1))
233+
execute $'set mouse={val}'
234+
redraw
235+
call assert_match('X$', Screenline(1))
236+
endfor
237+
endfunc
238+
226239
" vim: shiftwidth=2 sts=2 expandtab

0 commit comments

Comments
 (0)