On Fri, Jan 4, 2019 at 5:18 AM 'Olivia smith 444' via vim_dev < vim_dev@googlegroups.com> wrote:
> In Firefox and other applications, you can close a tab by pressing down > (clicking) the scroll wheel (or middle button) of a mouse. (Pressing the > left and right mouse keys on a laptop achieves the same effect.) > > Could gvim do the same? > IIRC, someone asked a very simple question at GitHub, and I gave it a comment that it's not technically hard to implement the feature. Strangely, I can't find the issue and am unable to quote it. In fact, the feature can be implemented with a following patch: of a naive approach diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 898e2af5f..bf729b9b2 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -3464,6 +3464,40 @@ gui_mch_showing_tabline(void) && gtk_notebook_get_show_tabs(GTK_NOTEBOOK(gui.tabline)); } +/* + * A callback for the event box under a tabline label to receive the + * button-press-event signal. + */ + static gboolean +tabline_event_box_button_press_cb(GtkWidget *widget, + GdkEvent *event, + gpointer user_data UNUSED) +{ +#define LOC_BUFSIZ 16 + const GdkEventButton *button_event = (GdkEventButton *)event; + + if (button_event->button == 2 && button_event->state == 0) + { + gint tab_num; + + tab_num = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "tab_num")); + if (tab_num != 0) + { + char buf[LOC_BUFSIZ]; + + vim_snprintf(buf, LOC_BUFSIZ, "tabclose %d", tab_num); + do_cmdline_cmd((char_u *)buf); + + gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), tab_num - 1); + gui_update_tabline(); + + return TRUE; /* to stop propagating the event further */ + } + } + return FALSE; /* to propagate the event further */ +#undef LOC_BUfSIZ +} + /* * Update the labels of the tabline. */ @@ -3479,6 +3513,7 @@ gui_mch_update_tabline(void) int curtabidx = 0; char_u *labeltext; + if (gui.tabline == NULL) return; @@ -3540,6 +3575,10 @@ gui_mch_update_tabline(void) (const char *)labeltext, NULL); # endif CONVERT_TO_UTF8_FREE(labeltext); + + /* Make the event box receive the button-press-event signal */ + g_signal_connect(G_OBJECT(event_box), "button-press-event", + G_CALLBACK(tabline_event_box_button_press_cb), NULL); } /* Remove any old labels. */ Then, once this patch is included, how should we do with the rest of the shortcuts of https://support.mozilla.org/en-US/kb/mouse-shortcuts-perform-common-tasks ? > > > Thanks, > Olivia > > > > -- > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- -- 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. For more options, visit https://groups.google.com/d/optout.