Mercurial > vim
comparison src/normal.c @ 13369:244ff1b6d2ad v8.0.1558
patch 8.0.1558: no right-click menu in a terminal
commit https://github.com/vim/vim/commit/aef8c3da2ba59285b7cfde559ae21cdce6ba6919
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 3 18:59:16 2018 +0100
patch 8.0.1558: no right-click menu in a terminal
Problem: No right-click menu in a terminal.
Solution: Implement the right click menu for the terminal.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 03 Mar 2018 19:00:06 +0100 |
parents | a88c5e12b860 |
children | 69517d67421f |
comparison
equal
deleted
inserted
replaced
13368:a68814ee7449 | 13369:244ff1b6d2ad |
---|---|
2284 #if defined(FEAT_MOUSE) || defined(PROTO) | 2284 #if defined(FEAT_MOUSE) || defined(PROTO) |
2285 /* | 2285 /* |
2286 * Do the appropriate action for the current mouse click in the current mode. | 2286 * Do the appropriate action for the current mouse click in the current mode. |
2287 * Not used for Command-line mode. | 2287 * Not used for Command-line mode. |
2288 * | 2288 * |
2289 * Normal Mode: | 2289 * Normal and Visual Mode: |
2290 * event modi- position visual change action | 2290 * event modi- position visual change action |
2291 * fier cursor window | 2291 * fier cursor window |
2292 * left press - yes end yes | 2292 * left press - yes end yes |
2293 * left press C yes end yes "^]" (2) | 2293 * 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) |
2295 * left drag - yes start if moved no | 2295 * left drag - yes start if moved no |
2296 * left relse - yes start if moved no | 2296 * left relse - yes start if moved no |
2297 * middle press - yes if not active no put register | 2297 * middle press - yes if not active no put register |
2298 * middle press - yes if active no yank and put | 2298 * middle press - yes if active no yank and put |
2299 * right press - yes start or extend yes | 2299 * right press - yes start or extend yes |
2668 if (mouse_model_popup()) | 2668 if (mouse_model_popup()) |
2669 { | 2669 { |
2670 if (which_button == MOUSE_RIGHT | 2670 if (which_button == MOUSE_RIGHT |
2671 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) | 2671 && !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))) |
2672 { | 2672 { |
2673 /* | |
2674 * NOTE: Ignore right button down and drag mouse events. | |
2675 * Windows only shows the popup menu on the button up event. | |
2676 */ | |
2677 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ | |
2678 || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC) | |
2679 if (!is_click) | |
2680 return FALSE; | |
2681 #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) \ | 2673 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ |
2687 || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ | 2674 || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ |
2688 || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON) | 2675 || defined(FEAT_GUI_MAC) || defined(FEAT_GUI_PHOTON) \ |
2676 || defined(FEAT_TERM_POPUP_MENU) | |
2677 # ifdef FEAT_GUI | |
2689 if (gui.in_use) | 2678 if (gui.in_use) |
2690 { | 2679 { |
2691 jump_flags = 0; | 2680 # if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ |
2692 if (STRCMP(p_mousem, "popup_setpos") == 0) | 2681 || 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) | |
2699 if (!is_click) | |
2700 /* Ignore right button release events, only shows the popup | |
2701 * menu on the button down event. */ | |
2702 return FALSE; | |
2703 #endif | |
2704 | |
2705 jump_flags = 0; | |
2706 if (STRCMP(p_mousem, "popup_setpos") == 0) | |
2707 { | |
2708 /* First set the cursor position before showing the popup | |
2709 * menu. */ | |
2710 if (VIsual_active) | |
2693 { | 2711 { |
2694 /* First set the cursor position before showing the popup | 2712 pos_T m_pos; |
2695 * menu. */ | 2713 |
2696 if (VIsual_active) | 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 | |
2697 { | 2726 { |
2698 pos_T m_pos; | 2727 if ((LT_POS(curwin->w_cursor, VIsual) |
2699 | 2728 && (LT_POS(m_pos, curwin->w_cursor) |
2700 /* | 2729 || LT_POS(VIsual, m_pos))) |
2701 * set MOUSE_MAY_STOP_VIS if we are outside the | 2730 || (LT_POS(VIsual, curwin->w_cursor) |
2702 * selection or the current window (might have false | 2731 && (LT_POS(m_pos, VIsual) |
2703 * negative here) | 2732 || LT_POS(curwin->w_cursor, m_pos)))) |
2704 */ | 2733 { |
2705 if (mouse_row < curwin->w_winrow | |
2706 || mouse_row | |
2707 > (curwin->w_winrow + curwin->w_height)) | |
2708 jump_flags = MOUSE_MAY_STOP_VIS; | 2734 jump_flags = MOUSE_MAY_STOP_VIS; |
2709 else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER) | 2735 } |
2710 jump_flags = MOUSE_MAY_STOP_VIS; | 2736 else if (VIsual_mode == Ctrl_V) |
2711 else | |
2712 { | 2737 { |
2713 if ((LT_POS(curwin->w_cursor, VIsual) | 2738 getvcols(curwin, &curwin->w_cursor, &VIsual, |
2714 && (LT_POS(m_pos, curwin->w_cursor) | 2739 &leftcol, &rightcol); |
2715 || LT_POS(VIsual, m_pos))) | 2740 getvcol(curwin, &m_pos, NULL, &m_pos.col, NULL); |
2716 || (LT_POS(VIsual, curwin->w_cursor) | 2741 if (m_pos.col < leftcol || m_pos.col > rightcol) |
2717 && (LT_POS(m_pos, VIsual) | |
2718 || LT_POS(curwin->w_cursor, m_pos)))) | |
2719 { | |
2720 jump_flags = MOUSE_MAY_STOP_VIS; | 2742 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 } | |
2730 } | 2743 } |
2731 } | 2744 } |
2732 else | |
2733 jump_flags = MOUSE_MAY_STOP_VIS; | |
2734 } | 2745 } |
2735 if (jump_flags) | 2746 else |
2736 { | 2747 jump_flags = MOUSE_MAY_STOP_VIS; |
2737 jump_flags = jump_to_mouse(jump_flags, NULL, which_button); | 2748 } |
2738 update_curbuf(VIsual_active ? INVERTED : VALID); | 2749 if (jump_flags) |
2739 setcursor(); | 2750 { |
2740 out_flush(); /* Update before showing popup menu */ | 2751 jump_flags = jump_to_mouse(jump_flags, NULL, which_button); |
2741 } | 2752 update_curbuf(VIsual_active ? INVERTED : VALID); |
2753 setcursor(); | |
2754 out_flush(); /* Update before showing popup menu */ | |
2755 } | |
2742 # ifdef FEAT_MENU | 2756 # ifdef FEAT_MENU |
2743 gui_show_popupmenu(); | 2757 show_popupmenu(); |
2758 got_click = FALSE; /* ignore release events */ | |
2744 # endif | 2759 # endif |
2745 return (jump_flags & CURSOR_MOVED) != 0; | 2760 return (jump_flags & CURSOR_MOVED) != 0; |
2746 } | |
2747 else | |
2748 return FALSE; | |
2749 #else | 2761 #else |
2750 return FALSE; | 2762 return FALSE; |
2751 #endif | 2763 #endif |
2752 } | 2764 } |
2753 if (which_button == MOUSE_LEFT | 2765 if (which_button == MOUSE_LEFT |