comparison src/os_unix.c @ 18354:9f51d0cef8da v8.1.2171

patch 8.1.2171: mouse support not always available Commit: https://github.com/vim/vim/commit/a1cb1d1dce14dd005797590721f1bcd0e7c3b35f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 17 23:00:07 2019 +0200 patch 8.1.2171: mouse support not always available Problem: Mouse support not always available. Solution: Enable mouse support also in tiny version. Do not define FEAT_MOUSE_XTERM on MS-Windows (didn't really work).
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Oct 2019 23:15:04 +0200
parents df5778d73320
children 9f7a2cfabfba
comparison
equal deleted inserted replaced
18353:c3a0f5d3c9d4 18354:9f51d0cef8da
2280 || STRNICMP(name, "st-", 3) == 0 2280 || STRNICMP(name, "st-", 3) == 0
2281 || STRNICMP(name, "stterm", 6) == 0)); 2281 || STRNICMP(name, "stterm", 6) == 0));
2282 } 2282 }
2283 #endif 2283 #endif
2284 2284
2285 #if defined(FEAT_MOUSE_TTY) || defined(PROTO)
2286 /* 2285 /*
2287 * Return non-zero when using an xterm mouse, according to 'ttymouse'. 2286 * Return non-zero when using an xterm mouse, according to 'ttymouse'.
2288 * Return 1 for "xterm". 2287 * Return 1 for "xterm".
2289 * Return 2 for "xterm2". 2288 * Return 2 for "xterm2".
2290 * Return 3 for "urxvt". 2289 * Return 3 for "urxvt".
2301 return 2; 2300 return 2;
2302 if (ttym_flags == TTYM_XTERM) 2301 if (ttym_flags == TTYM_XTERM)
2303 return 1; 2302 return 1;
2304 return 0; 2303 return 0;
2305 } 2304 }
2306 #endif
2307 2305
2308 int 2306 int
2309 vim_is_iris(char_u *name) 2307 vim_is_iris(char_u *name)
2310 { 2308 {
2311 if (name == NULL) 2309 if (name == NULL)
3590 return FAIL; 3588 return FAIL;
3591 } 3589 }
3592 3590
3593 #endif /* VMS */ 3591 #endif /* VMS */
3594 3592
3595 #if defined(FEAT_MOUSE_TTY) || defined(PROTO)
3596 static int mouse_ison = FALSE; 3593 static int mouse_ison = FALSE;
3597 3594
3598 /* 3595 /*
3599 * Set mouse clicks on or off. 3596 * Set mouse clicks on or off.
3600 */ 3597 */
3601 void 3598 void
3602 mch_setmouse(int on) 3599 mch_setmouse(int on)
3603 { 3600 {
3604 # ifdef FEAT_BEVAL_TERM 3601 #ifdef FEAT_BEVAL_TERM
3605 static int bevalterm_ison = FALSE; 3602 static int bevalterm_ison = FALSE;
3606 # endif 3603 #endif
3607 int xterm_mouse_vers; 3604 int xterm_mouse_vers;
3608 3605
3609 # if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) 3606 #if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
3610 if (!on) 3607 if (!on)
3611 // Make sure not tracing mouse movements. Important when a button-down 3608 // Make sure not tracing mouse movements. Important when a button-down
3612 // was received but no release yet. 3609 // was received but no release yet.
3613 stop_xterm_trace(); 3610 stop_xterm_trace();
3614 # endif 3611 #endif
3615 3612
3616 if (on == mouse_ison 3613 if (on == mouse_ison
3617 # ifdef FEAT_BEVAL_TERM 3614 #ifdef FEAT_BEVAL_TERM
3618 && p_bevalterm == bevalterm_ison 3615 && p_bevalterm == bevalterm_ison
3619 # endif 3616 #endif
3620 ) 3617 )
3621 /* return quickly if nothing to do */ 3618 /* return quickly if nothing to do */
3622 return; 3619 return;
3623 3620
3624 xterm_mouse_vers = use_xterm_mouse(); 3621 xterm_mouse_vers = use_xterm_mouse();
3625 3622
3626 # ifdef FEAT_MOUSE_URXVT 3623 #ifdef FEAT_MOUSE_URXVT
3627 if (ttym_flags == TTYM_URXVT) 3624 if (ttym_flags == TTYM_URXVT)
3628 { 3625 {
3629 out_str_nf((char_u *) 3626 out_str_nf((char_u *)
3630 (on 3627 (on
3631 ? IF_EB("\033[?1015h", ESC_STR "[?1015h") 3628 ? IF_EB("\033[?1015h", ESC_STR "[?1015h")
3632 : IF_EB("\033[?1015l", ESC_STR "[?1015l"))); 3629 : IF_EB("\033[?1015l", ESC_STR "[?1015l")));
3633 mouse_ison = on; 3630 mouse_ison = on;
3634 } 3631 }
3635 # endif 3632 #endif
3636 3633
3637 if (ttym_flags == TTYM_SGR) 3634 if (ttym_flags == TTYM_SGR)
3638 { 3635 {
3639 /* SGR mode supports columns above 223 */ 3636 /* SGR mode supports columns above 223 */
3640 out_str_nf((char_u *) 3637 out_str_nf((char_u *)
3642 ? IF_EB("\033[?1006h", ESC_STR "[?1006h") 3639 ? IF_EB("\033[?1006h", ESC_STR "[?1006h")
3643 : IF_EB("\033[?1006l", ESC_STR "[?1006l"))); 3640 : IF_EB("\033[?1006l", ESC_STR "[?1006l")));
3644 mouse_ison = on; 3641 mouse_ison = on;
3645 } 3642 }
3646 3643
3647 # ifdef FEAT_BEVAL_TERM 3644 #ifdef FEAT_BEVAL_TERM
3648 if (bevalterm_ison != (p_bevalterm && on)) 3645 if (bevalterm_ison != (p_bevalterm && on))
3649 { 3646 {
3650 bevalterm_ison = (p_bevalterm && on); 3647 bevalterm_ison = (p_bevalterm && on);
3651 if (xterm_mouse_vers > 1 && !bevalterm_ison) 3648 if (xterm_mouse_vers > 1 && !bevalterm_ison)
3652 /* disable mouse movement events, enabling is below */ 3649 /* disable mouse movement events, enabling is below */
3653 out_str_nf((char_u *) 3650 out_str_nf((char_u *)
3654 (IF_EB("\033[?1003l", ESC_STR "[?1003l"))); 3651 (IF_EB("\033[?1003l", ESC_STR "[?1003l")));
3655 } 3652 }
3656 # endif 3653 #endif
3657 3654
3658 if (xterm_mouse_vers > 0) 3655 if (xterm_mouse_vers > 0)
3659 { 3656 {
3660 if (on) /* enable mouse events, use mouse tracking if available */ 3657 if (on) /* enable mouse events, use mouse tracking if available */
3661 out_str_nf((char_u *) 3658 out_str_nf((char_u *)
3662 (xterm_mouse_vers > 1 3659 (xterm_mouse_vers > 1
3663 ? ( 3660 ? (
3664 # ifdef FEAT_BEVAL_TERM 3661 #ifdef FEAT_BEVAL_TERM
3665 bevalterm_ison 3662 bevalterm_ison
3666 ? IF_EB("\033[?1003h", ESC_STR "[?1003h") : 3663 ? IF_EB("\033[?1003h", ESC_STR "[?1003h") :
3667 # endif 3664 #endif
3668 IF_EB("\033[?1002h", ESC_STR "[?1002h")) 3665 IF_EB("\033[?1002h", ESC_STR "[?1002h"))
3669 : IF_EB("\033[?1000h", ESC_STR "[?1000h"))); 3666 : IF_EB("\033[?1000h", ESC_STR "[?1000h")));
3670 else /* disable mouse events, could probably always send the same */ 3667 else /* disable mouse events, could probably always send the same */
3671 out_str_nf((char_u *) 3668 out_str_nf((char_u *)
3672 (xterm_mouse_vers > 1 3669 (xterm_mouse_vers > 1
3673 ? IF_EB("\033[?1002l", ESC_STR "[?1002l") 3670 ? IF_EB("\033[?1002l", ESC_STR "[?1002l")
3674 : IF_EB("\033[?1000l", ESC_STR "[?1000l"))); 3671 : IF_EB("\033[?1000l", ESC_STR "[?1000l")));
3675 mouse_ison = on; 3672 mouse_ison = on;
3676 } 3673 }
3677 3674
3678 # ifdef FEAT_MOUSE_DEC 3675 #ifdef FEAT_MOUSE_DEC
3679 else if (ttym_flags == TTYM_DEC) 3676 else if (ttym_flags == TTYM_DEC)
3680 { 3677 {
3681 if (on) /* enable mouse events */ 3678 if (on) /* enable mouse events */
3682 out_str_nf((char_u *)"\033[1;2'z\033[1;3'{"); 3679 out_str_nf((char_u *)"\033[1;2'z\033[1;3'{");
3683 else /* disable mouse events */ 3680 else /* disable mouse events */
3684 out_str_nf((char_u *)"\033['z"); 3681 out_str_nf((char_u *)"\033['z");
3685 mouse_ison = on; 3682 mouse_ison = on;
3686 } 3683 }
3687 # endif 3684 #endif
3688 3685
3689 # ifdef FEAT_MOUSE_GPM 3686 #ifdef FEAT_MOUSE_GPM
3690 else 3687 else
3691 { 3688 {
3692 if (on) 3689 if (on)
3693 { 3690 {
3694 if (gpm_open()) 3691 if (gpm_open())
3698 { 3695 {
3699 gpm_close(); 3696 gpm_close();
3700 mouse_ison = FALSE; 3697 mouse_ison = FALSE;
3701 } 3698 }
3702 } 3699 }
3703 # endif 3700 #endif
3704 3701
3705 # ifdef FEAT_SYSMOUSE 3702 #ifdef FEAT_SYSMOUSE
3706 else 3703 else
3707 { 3704 {
3708 if (on) 3705 if (on)
3709 { 3706 {
3710 if (sysmouse_open() == OK) 3707 if (sysmouse_open() == OK)
3714 { 3711 {
3715 sysmouse_close(); 3712 sysmouse_close();
3716 mouse_ison = FALSE; 3713 mouse_ison = FALSE;
3717 } 3714 }
3718 } 3715 }
3719 # endif 3716 #endif
3720 3717
3721 # ifdef FEAT_MOUSE_JSB 3718 #ifdef FEAT_MOUSE_JSB
3722 else 3719 else
3723 { 3720 {
3724 if (on) 3721 if (on)
3725 { 3722 {
3726 /* D - Enable Mouse up/down messages 3723 /* D - Enable Mouse up/down messages
3736 * 2 = Windows I Beam 3733 * 2 = Windows I Beam
3737 * 3 = Windows Hour Glass 3734 * 3 = Windows Hour Glass
3738 * 4 = Windows Cross Hair 3735 * 4 = Windows Cross Hair
3739 * 5 = Windows UP Arrow 3736 * 5 = Windows UP Arrow
3740 */ 3737 */
3741 # ifdef JSBTERM_MOUSE_NONADVANCED 3738 # ifdef JSBTERM_MOUSE_NONADVANCED
3742 /* Disables full feedback of pointer movements */ 3739 /* Disables full feedback of pointer movements */
3743 out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK1Q\033\\", 3740 out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK1Q\033\\",
3744 ESC_STR "[0~ZwLMRK1Q" ESC_STR "\\")); 3741 ESC_STR "[0~ZwLMRK1Q" ESC_STR "\\"));
3745 # else 3742 # else
3746 out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK+1Q\033\\", 3743 out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK+1Q\033\\",
3747 ESC_STR "[0~ZwLMRK+1Q" ESC_STR "\\")); 3744 ESC_STR "[0~ZwLMRK+1Q" ESC_STR "\\"));
3748 # endif 3745 # endif
3749 mouse_ison = TRUE; 3746 mouse_ison = TRUE;
3750 } 3747 }
3751 else 3748 else
3752 { 3749 {
3753 out_str_nf((char_u *)IF_EB("\033[0~ZwQ\033\\", 3750 out_str_nf((char_u *)IF_EB("\033[0~ZwQ\033\\",
3754 ESC_STR "[0~ZwQ" ESC_STR "\\")); 3751 ESC_STR "[0~ZwQ" ESC_STR "\\"));
3755 mouse_ison = FALSE; 3752 mouse_ison = FALSE;
3756 } 3753 }
3757 } 3754 }
3758 # endif 3755 #endif
3759 # ifdef FEAT_MOUSE_PTERM 3756 #ifdef FEAT_MOUSE_PTERM
3760 else 3757 else
3761 { 3758 {
3762 /* 1 = button press, 6 = release, 7 = drag, 1h...9l = right button */ 3759 /* 1 = button press, 6 = release, 7 = drag, 1h...9l = right button */
3763 if (on) 3760 if (on)
3764 out_str_nf("\033[>1h\033[>6h\033[>7h\033[>1h\033[>9l"); 3761 out_str_nf("\033[>1h\033[>6h\033[>7h\033[>1h\033[>9l");
3765 else 3762 else
3766 out_str_nf("\033[>1l\033[>6l\033[>7l\033[>1l\033[>9h"); 3763 out_str_nf("\033[>1l\033[>6l\033[>7l\033[>1l\033[>9h");
3767 mouse_ison = on; 3764 mouse_ison = on;
3768 } 3765 }
3769 # endif 3766 #endif
3770 } 3767 }
3771 3768
3772 #if defined(FEAT_BEVAL_TERM) || defined(PROTO) 3769 #if defined(FEAT_BEVAL_TERM) || defined(PROTO)
3773 /* 3770 /*
3774 * Called when 'balloonevalterm' changed. 3771 * Called when 'balloonevalterm' changed.
3927 { 3924 {
3928 del_mouse_termcode(KS_SGR_MOUSE); 3925 del_mouse_termcode(KS_SGR_MOUSE);
3929 del_mouse_termcode(KS_SGR_MOUSE_RELEASE); 3926 del_mouse_termcode(KS_SGR_MOUSE_RELEASE);
3930 } 3927 }
3931 } 3928 }
3932 #endif
3933 3929
3934 /* 3930 /*
3935 * set screen mode, always fails. 3931 * set screen mode, always fails.
3936 */ 3932 */
3937 int 3933 int