mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 17:06:30 +00:00
feat(tabline): middle mouse button now closes tab (#27522)
This commit is contained in:
@@ -136,6 +136,26 @@ static void move_tab_to_mouse(void)
|
||||
tabpage_move(tabnr);
|
||||
}
|
||||
}
|
||||
/// Close the current or specified tab page.
|
||||
///
|
||||
/// @param c1 tabpage number, or 999 for the current tabpage
|
||||
static void mouse_tab_close(int c1)
|
||||
{
|
||||
tabpage_T *tp;
|
||||
|
||||
if (c1 == 999) {
|
||||
tp = curtab;
|
||||
} else {
|
||||
tp = find_tabpage(c1);
|
||||
}
|
||||
if (tp == curtab) {
|
||||
if (first_tabpage->tp_next != NULL) {
|
||||
tabpage_close(false);
|
||||
}
|
||||
} else if (tp != NULL) {
|
||||
tabpage_close_other(tp, false);
|
||||
}
|
||||
}
|
||||
|
||||
static bool got_click = false; // got a click some time back
|
||||
|
||||
@@ -487,43 +507,32 @@ bool do_mouse(oparg_T *oap, int c, int dir, int count, bool fixindent)
|
||||
if (is_click && cmdwin_type == 0 && mouse_col < Columns) {
|
||||
in_tab_line = true;
|
||||
c1 = tab_page_click_defs[mouse_col].tabnr;
|
||||
|
||||
switch (tab_page_click_defs[mouse_col].type) {
|
||||
case kStlClickDisabled:
|
||||
break;
|
||||
case kStlClickTabClose: {
|
||||
tabpage_T *tp;
|
||||
|
||||
// Close the current or specified tab page.
|
||||
if (c1 == 999) {
|
||||
tp = curtab;
|
||||
} else {
|
||||
tp = find_tabpage(c1);
|
||||
}
|
||||
if (tp == curtab) {
|
||||
if (first_tabpage->tp_next != NULL) {
|
||||
tabpage_close(false);
|
||||
}
|
||||
} else if (tp != NULL) {
|
||||
tabpage_close_other(tp, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kStlClickTabSwitch:
|
||||
if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) {
|
||||
// double click opens new page
|
||||
end_visual_mode();
|
||||
tabpage_new();
|
||||
tabpage_move(c1 == 0 ? 9999 : c1 - 1);
|
||||
} else {
|
||||
// Go to specified tab page, or next one if not clicking
|
||||
// on a label.
|
||||
goto_tabpage(c1);
|
||||
|
||||
// It's like clicking on the status line of a window.
|
||||
if (curwin != old_curwin) {
|
||||
if (which_button != MOUSE_MIDDLE) {
|
||||
if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK) {
|
||||
// double click opens new page
|
||||
end_visual_mode();
|
||||
tabpage_new();
|
||||
tabpage_move(c1 == 0 ? 9999 : c1 - 1);
|
||||
} else {
|
||||
// Go to specified tab page, or next one if not clicking
|
||||
// on a label.
|
||||
goto_tabpage(c1);
|
||||
|
||||
// It's like clicking on the status line of a window.
|
||||
if (curwin != old_curwin) {
|
||||
end_visual_mode();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
FALLTHROUGH;
|
||||
case kStlClickTabClose:
|
||||
mouse_tab_close(c1);
|
||||
break;
|
||||
case kStlClickFuncRun:
|
||||
call_click_def_func(tab_page_click_defs, mouse_col, which_button);
|
||||
|
Reference in New Issue
Block a user