@@ -2286,12 +2286,12 @@ op_function(oparg_T *oap UNUSED)
22862286 * Do the appropriate action for the current mouse click in the current mode.
22872287 * Not used for Command-line mode.
22882288 *
2289- * Normal Mode:
2289+ * Normal and Visual Mode:
22902290 * event modi- position visual change action
22912291 * fier cursor window
22922292 * left press - yes end yes
22932293 * left press C yes end yes "^]" (2)
2294- * left press S yes end yes "*" (2)
2294+ * left press S yes end (popup: extend) yes "*" (2)
22952295 * left drag - yes start if moved no
22962296 * left relse - yes start if moved no
22972297 * middle press - yes if not active no put register
@@ -2670,82 +2670,94 @@ do_mouse(
26702670 if (which_button == MOUSE_RIGHT
26712671 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL )))
26722672 {
2673- /*
2674- * NOTE: Ignore right button down and drag mouse events.
2675- * Windows only shows the popup menu on the button up event.
2676- */
26772673#if defined(FEAT_GUI_MOTIF ) || defined(FEAT_GUI_GTK ) \
2674+ || defined(FEAT_GUI_ATHENA ) || defined(FEAT_GUI_MSWIN ) \
2675+ || defined(FEAT_GUI_MAC ) || defined(FEAT_GUI_PHOTON ) \
2676+ || defined(FEAT_TERM_POPUP_MENU )
2677+ # ifdef FEAT_GUI
2678+ if (gui .in_use )
2679+ {
2680+ # if defined(FEAT_GUI_MOTIF ) || defined(FEAT_GUI_GTK ) \
26782681 || defined(FEAT_GUI_PHOTON ) || defined(FEAT_GUI_MAC )
2682+ if (!is_click )
2683+ /* Ignore right button release events, only shows the popup
2684+ * menu on the button down event. */
2685+ return FALSE;
2686+ # endif
2687+ # if defined(FEAT_GUI_ATHENA ) || defined(FEAT_GUI_MSWIN )
2688+ if (is_click || is_drag )
2689+ /* Ignore right button down and drag mouse events. Windows
2690+ * only shows the popup menu on the button up event. */
2691+ return FALSE;
2692+ # endif
2693+ }
2694+ # endif
2695+ # if defined(FEAT_GUI ) && defined(FEAT_TERM_POPUP_MENU )
2696+ else
2697+ # endif
2698+ # if defined(FEAT_TERM_POPUP_MENU )
26792699 if (!is_click )
2700+ /* Ignore right button release events, only shows the popup
2701+ * menu on the button down event. */
26802702 return FALSE;
26812703#endif
2682- #if defined(FEAT_GUI_ATHENA ) || defined(FEAT_GUI_MSWIN )
2683- if (is_click || is_drag )
2684- return FALSE;
2685- #endif
2686- #if defined(FEAT_GUI_MOTIF ) || defined(FEAT_GUI_GTK ) \
2687- || defined(FEAT_GUI_ATHENA ) || defined(FEAT_GUI_MSWIN ) \
2688- || defined(FEAT_GUI_MAC ) || defined(FEAT_GUI_PHOTON )
2689- if (gui .in_use )
2704+
2705+ jump_flags = 0 ;
2706+ if (STRCMP (p_mousem , "popup_setpos" ) == 0 )
26902707 {
2691- jump_flags = 0 ;
2692- if (STRCMP (p_mousem , "popup_setpos" ) == 0 )
2708+ /* First set the cursor position before showing the popup
2709+ * menu. */
2710+ if (VIsual_active )
26932711 {
2694- /* First set the cursor position before showing the popup
2695- * menu. */
2696- if (VIsual_active )
2712+ pos_T m_pos ;
2713+
2714+ /*
2715+ * set MOUSE_MAY_STOP_VIS if we are outside the
2716+ * selection or the current window (might have false
2717+ * negative here)
2718+ */
2719+ if (mouse_row < curwin -> w_winrow
2720+ || mouse_row
2721+ > (curwin -> w_winrow + curwin -> w_height ))
2722+ jump_flags = MOUSE_MAY_STOP_VIS ;
2723+ else if (get_fpos_of_mouse (& m_pos ) != IN_BUFFER )
2724+ jump_flags = MOUSE_MAY_STOP_VIS ;
2725+ else
26972726 {
2698- pos_T m_pos ;
2699-
2700- /*
2701- * set MOUSE_MAY_STOP_VIS if we are outside the
2702- * selection or the current window (might have false
2703- * negative here)
2704- */
2705- if (mouse_row < curwin -> w_winrow
2706- || mouse_row
2707- > (curwin -> w_winrow + curwin -> w_height ))
2708- jump_flags = MOUSE_MAY_STOP_VIS ;
2709- else if (get_fpos_of_mouse (& m_pos ) != IN_BUFFER )
2727+ if ((LT_POS (curwin -> w_cursor , VIsual )
2728+ && (LT_POS (m_pos , curwin -> w_cursor )
2729+ || LT_POS (VIsual , m_pos )))
2730+ || (LT_POS (VIsual , curwin -> w_cursor )
2731+ && (LT_POS (m_pos , VIsual )
2732+ || LT_POS (curwin -> w_cursor , m_pos ))))
2733+ {
27102734 jump_flags = MOUSE_MAY_STOP_VIS ;
2711- else
2735+ }
2736+ else if (VIsual_mode == Ctrl_V )
27122737 {
2713- if ((LT_POS (curwin -> w_cursor , VIsual )
2714- && (LT_POS (m_pos , curwin -> w_cursor )
2715- || LT_POS (VIsual , m_pos )))
2716- || (LT_POS (VIsual , curwin -> w_cursor )
2717- && (LT_POS (m_pos , VIsual )
2718- || LT_POS (curwin -> w_cursor , m_pos ))))
2719- {
2738+ getvcols (curwin , & curwin -> w_cursor , & VIsual ,
2739+ & leftcol , & rightcol );
2740+ getvcol (curwin , & m_pos , NULL , & m_pos .col , NULL );
2741+ if (m_pos .col < leftcol || m_pos .col > rightcol )
27202742 jump_flags = MOUSE_MAY_STOP_VIS ;
2721- }
2722- else if (VIsual_mode == Ctrl_V )
2723- {
2724- getvcols (curwin , & curwin -> w_cursor , & VIsual ,
2725- & leftcol , & rightcol );
2726- getvcol (curwin , & m_pos , NULL , & m_pos .col , NULL );
2727- if (m_pos .col < leftcol || m_pos .col > rightcol )
2728- jump_flags = MOUSE_MAY_STOP_VIS ;
2729- }
27302743 }
27312744 }
2732- else
2733- jump_flags = MOUSE_MAY_STOP_VIS ;
2734- }
2735- if (jump_flags )
2736- {
2737- jump_flags = jump_to_mouse (jump_flags , NULL , which_button );
2738- update_curbuf (VIsual_active ? INVERTED : VALID );
2739- setcursor ();
2740- out_flush (); /* Update before showing popup menu */
27412745 }
2746+ else
2747+ jump_flags = MOUSE_MAY_STOP_VIS ;
2748+ }
2749+ if (jump_flags )
2750+ {
2751+ jump_flags = jump_to_mouse (jump_flags , NULL , which_button );
2752+ update_curbuf (VIsual_active ? INVERTED : VALID );
2753+ setcursor ();
2754+ out_flush (); /* Update before showing popup menu */
2755+ }
27422756# ifdef FEAT_MENU
2743- gui_show_popupmenu ();
2757+ show_popupmenu ();
2758+ got_click = FALSE; /* ignore release events */
27442759# endif
2745- return (jump_flags & CURSOR_MOVED ) != 0 ;
2746- }
2747- else
2748- return FALSE;
2760+ return (jump_flags & CURSOR_MOVED ) != 0 ;
27492761#else
27502762 return FALSE;
27512763#endif
0 commit comments