diff options
| author | Bram Moolenaar <Bram@vim.org> | 2017-11-18 18:52:04 +0100 |
|---|---|---|
| committer | Bram Moolenaar <Bram@vim.org> | 2017-11-18 18:52:04 +0100 |
| commit | 51b0f3701ecb440aa72ab6017c1df6940c0e0f6f (patch) | |
| tree | 9cfd3546d8e52be2b1425dcc65095f8e650eadde /src/os_unix.c | |
| parent | 234d16286a2733adedef56784c17415ae169b9ad (diff) | |
| download | vim-git-51b0f3701ecb440aa72ab6017c1df6940c0e0f6f.tar.gz | |
patch 8.0.1309: cannot use 'balloonexpr' in a terminalv8.0.1309
Problem: Cannot use 'balloonexpr' in a terminal.
Solution: Add 'balloonevalterm' and add code to handle mouse movements in a
terminal. Initial implementation for Unix with GUI.
Diffstat (limited to 'src/os_unix.c')
| -rw-r--r-- | src/os_unix.c | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index d2f080529..1c2a90276 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3564,16 +3564,25 @@ get_tty_info(int fd, ttyinfo_T *info) #endif /* VMS */ #if defined(FEAT_MOUSE_TTY) || defined(PROTO) +static int mouse_ison = FALSE; + /* * Set mouse clicks on or off. */ void mch_setmouse(int on) { - static int ison = FALSE; +# ifdef FEAT_BEVALTERM + static int bevalterm_ison = FALSE; +# endif int xterm_mouse_vers; - if (on == ison) /* return quickly if nothing to do */ + if (on == mouse_ison +# ifdef FEAT_BEVALTERM + && p_bevalterm == bevalterm_ison +# endif + ) + /* return quickly if nothing to do */ return; xterm_mouse_vers = use_xterm_mouse(); @@ -3585,18 +3594,30 @@ mch_setmouse(int on) (on ? IF_EB("\033[?1015h", ESC_STR "[?1015h") : IF_EB("\033[?1015l", ESC_STR "[?1015l"))); - ison = on; + mouse_ison = on; } # endif # ifdef FEAT_MOUSE_SGR if (ttym_flags == TTYM_SGR) { + /* SGR mode supports columns above 223 */ out_str_nf((char_u *) (on ? IF_EB("\033[?1006h", ESC_STR "[?1006h") : IF_EB("\033[?1006l", ESC_STR "[?1006l"))); - ison = on; + mouse_ison = on; + } +# endif + +# ifdef FEAT_BEVALTERM + if (bevalterm_ison != (p_bevalterm && on)) + { + bevalterm_ison = (p_bevalterm && on); + if (xterm_mouse_vers > 1 && !bevalterm_ison) + /* disable mouse movement events, enabling is below */ + out_str_nf((char_u *) + (IF_EB("\033[?1003l", ESC_STR "[?1003l"))); } # endif @@ -3605,14 +3626,19 @@ mch_setmouse(int on) if (on) /* enable mouse events, use mouse tracking if available */ out_str_nf((char_u *) (xterm_mouse_vers > 1 - ? IF_EB("\033[?1002h", ESC_STR "[?1002h") + ? ( +# ifdef FEAT_BEVALTERM + bevalterm_ison + ? IF_EB("\033[?1003h", ESC_STR "[?1003h") : +# endif + IF_EB("\033[?1002h", ESC_STR "[?1002h")) : IF_EB("\033[?1000h", ESC_STR "[?1000h"))); else /* disable mouse events, could probably always send the same */ out_str_nf((char_u *) (xterm_mouse_vers > 1 ? IF_EB("\033[?1002l", ESC_STR "[?1002l") : IF_EB("\033[?1000l", ESC_STR "[?1000l"))); - ison = on; + mouse_ison = on; } # ifdef FEAT_MOUSE_DEC @@ -3622,7 +3648,7 @@ mch_setmouse(int on) out_str_nf((char_u *)"\033[1;2'z\033[1;3'{"); else /* disable mouse events */ out_str_nf((char_u *)"\033['z"); - ison = on; + mouse_ison = on; } # endif @@ -3632,12 +3658,12 @@ mch_setmouse(int on) if (on) { if (gpm_open()) - ison = TRUE; + mouse_ison = TRUE; } else { gpm_close(); - ison = FALSE; + mouse_ison = FALSE; } } # endif @@ -3648,12 +3674,12 @@ mch_setmouse(int on) if (on) { if (sysmouse_open() == OK) - ison = TRUE; + mouse_ison = TRUE; } else { sysmouse_close(); - ison = FALSE; + mouse_ison = FALSE; } } # endif @@ -3686,13 +3712,13 @@ mch_setmouse(int on) out_str_nf((char_u *)IF_EB("\033[0~ZwLMRK+1Q\033\\", ESC_STR "[0~ZwLMRK+1Q" ESC_STR "\\")); # endif - ison = TRUE; + mouse_ison = TRUE; } else { out_str_nf((char_u *)IF_EB("\033[0~ZwQ\033\\", ESC_STR "[0~ZwQ" ESC_STR "\\")); - ison = FALSE; + mouse_ison = FALSE; } } # endif @@ -3704,11 +3730,22 @@ mch_setmouse(int on) out_str_nf("\033[>1h\033[>6h\033[>7h\033[>1h\033[>9l"); else out_str_nf("\033[>1l\033[>6l\033[>7l\033[>1l\033[>9h"); - ison = on; + mouse_ison = on; } # endif } +#if defined(FEAT_BEVALTERM) || defined(PROTO) +/* + * Called when 'balloonevalterm' changed. + */ + void +mch_bevalterm_changed(void) +{ + mch_setmouse(mouse_ison); +} +#endif + /* * Set the mouse termcode, depending on the 'term' and 'ttymouse' options. */ |
