comparison src/term.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 94e1a49b879e
children e460e6878406
comparison
equal deleted inserted replaced
18353:c3a0f5d3c9d4 18354:9f51d0cef8da
1960 #ifdef FEAT_TERMRESPONSE 1960 #ifdef FEAT_TERMRESPONSE
1961 is_not_xterm = FALSE; 1961 is_not_xterm = FALSE;
1962 is_mac_terminal = FALSE; 1962 is_mac_terminal = FALSE;
1963 #endif 1963 #endif
1964 1964
1965 #ifdef FEAT_MOUSE 1965 #if defined(UNIX) || defined(VMS)
1966 # if defined(UNIX) || defined(VMS)
1967 # ifdef FEAT_MOUSE_TTY
1968 /* 1966 /*
1969 * For Unix, set the 'ttymouse' option to the type of mouse to be used. 1967 * For Unix, set the 'ttymouse' option to the type of mouse to be used.
1970 * The termcode for the mouse is added as a side effect in option.c. 1968 * The termcode for the mouse is added as a side effect in option.c.
1971 */ 1969 */
1972 { 1970 {
1973 char_u *p = (char_u *)""; 1971 char_u *p = (char_u *)"";
1974 1972
1975 # ifdef FEAT_MOUSE_XTERM 1973 # ifdef FEAT_MOUSE_XTERM
1976 if (use_xterm_like_mouse(term)) 1974 if (use_xterm_like_mouse(term))
1977 { 1975 {
1978 if (use_xterm_mouse()) 1976 if (use_xterm_mouse())
1979 p = NULL; /* keep existing value, might be "xterm2" */ 1977 p = NULL; /* keep existing value, might be "xterm2" */
1980 else 1978 else
1981 p = (char_u *)"xterm"; 1979 p = (char_u *)"xterm";
1982 } 1980 }
1983 # endif 1981 # endif
1984 if (p != NULL) 1982 if (p != NULL)
1985 { 1983 {
1986 set_option_value((char_u *)"ttym", 0L, p, 0); 1984 set_option_value((char_u *)"ttym", 0L, p, 0);
1987 /* Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or 1985 /* Reset the WAS_SET flag, 'ttymouse' can be set to "sgr" or
1988 * "xterm2" in check_termcode(). */ 1986 * "xterm2" in check_termcode(). */
1989 reset_option_was_set((char_u *)"ttym"); 1987 reset_option_was_set((char_u *)"ttym");
1990 } 1988 }
1991 if (p == NULL 1989 if (p == NULL
1992 # ifdef FEAT_GUI 1990 # ifdef FEAT_GUI
1993 || gui.in_use 1991 || gui.in_use
1994 # endif 1992 # endif
1995 ) 1993 )
1996 check_mouse_termcode(); /* set mouse termcode anyway */ 1994 check_mouse_termcode(); /* set mouse termcode anyway */
1997 } 1995 }
1998 # endif 1996 #else
1999 # else
2000 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M"); 1997 set_mouse_termcode(KS_MOUSE, (char_u *)"\233M");
2001 # endif 1998 #endif
2002 #endif /* FEAT_MOUSE */
2003 1999
2004 #ifdef USE_TERM_CONSOLE 2000 #ifdef USE_TERM_CONSOLE
2005 /* DEFAULT_TERM indicates that it is the machine console. */ 2001 /* DEFAULT_TERM indicates that it is the machine console. */
2006 if (STRCMP(term, DEFAULT_TERM) != 0) 2002 if (STRCMP(term, DEFAULT_TERM) != 0)
2007 term_console = FALSE; 2003 term_console = FALSE;
2563 2559
2564 if (out_pos >= OUT_SIZE) 2560 if (out_pos >= OUT_SIZE)
2565 out_flush(); 2561 out_flush();
2566 } 2562 }
2567 2563
2568 #if defined(FEAT_TITLE) || defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI) \
2569 || defined(FEAT_TERMRESPONSE) || defined(PROTO)
2570 /* 2564 /*
2571 * A never-padding out_str. 2565 * A never-padding out_str.
2572 * use this whenever you don't want to run the string through tputs. 2566 * use this whenever you don't want to run the string through tputs.
2573 * tputs above is harmless, but tputs from the termcap library 2567 * tputs above is harmless, but tputs from the termcap library
2574 * is likely to strip off leading digits, that it mistakes for padding 2568 * is likely to strip off leading digits, that it mistakes for padding
2588 2582
2589 // For testing we write one string at a time. 2583 // For testing we write one string at a time.
2590 if (p_wd) 2584 if (p_wd)
2591 out_flush(); 2585 out_flush();
2592 } 2586 }
2593 #endif
2594 2587
2595 /* 2588 /*
2596 * A conditional-flushing out_str, mainly for visualbell. 2589 * A conditional-flushing out_str, mainly for visualbell.
2597 * Handles a delay internally, because termlib may not respect the delay or do 2590 * Handles a delay internally, because termlib may not respect the delay or do
2598 * it at the wrong time. 2591 * it at the wrong time.
3149 } 3142 }
3150 return len; 3143 return len;
3151 } 3144 }
3152 #endif 3145 #endif
3153 3146
3154 #if defined(FEAT_GUI) \
3155 || (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \
3156 || defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE)))
3157 /* 3147 /*
3158 * Read the next num_bytes bytes from buf, and store them in bytes. Assume 3148 * Read the next num_bytes bytes from buf, and store them in bytes. Assume
3159 * that buf has been through inchar(). Returns the actual number of bytes used 3149 * that buf has been through inchar(). Returns the actual number of bytes used
3160 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were 3150 * from buf (between num_bytes and num_bytes*2), or -1 if not enough bytes were
3161 * available. 3151 * available.
3189 len += 2; 3179 len += 2;
3190 bytes[i] = c; 3180 bytes[i] = c;
3191 } 3181 }
3192 return len; 3182 return len;
3193 } 3183 }
3194 #endif
3195 3184
3196 /* 3185 /*
3197 * Check if the new shell size is valid, correct it if it's too small or way 3186 * Check if the new shell size is valid, correct it if it's too small or way
3198 * too big. 3187 * too big.
3199 */ 3188 */
3434 if (tmode != TMODE_RAW && termrequest_any_pending()) 3423 if (tmode != TMODE_RAW && termrequest_any_pending())
3435 (void)vpeekc_nomap(); 3424 (void)vpeekc_nomap();
3436 check_for_codes_from_term(); 3425 check_for_codes_from_term();
3437 } 3426 }
3438 #endif 3427 #endif
3439 #ifdef FEAT_MOUSE_TTY
3440 if (tmode != TMODE_RAW) 3428 if (tmode != TMODE_RAW)
3441 mch_setmouse(FALSE); // switch mouse off 3429 mch_setmouse(FALSE); // switch mouse off
3442 #endif
3443 if (termcap_active) 3430 if (termcap_active)
3444 { 3431 {
3445 if (tmode != TMODE_RAW) 3432 if (tmode != TMODE_RAW)
3446 out_str(T_BD); // disable bracketed paste mode 3433 out_str(T_BD); // disable bracketed paste mode
3447 else 3434 else
5082 if (key_name[0] == NUL) 5069 if (key_name[0] == NUL)
5083 continue; /* No match at this position, try next one */ 5070 continue; /* No match at this position, try next one */
5084 5071
5085 /* We only get here when we have a complete termcode match */ 5072 /* We only get here when we have a complete termcode match */
5086 5073
5087 #ifdef FEAT_MOUSE 5074 #ifdef FEAT_GUI
5088 # ifdef FEAT_GUI
5089 /* 5075 /*
5090 * Only in the GUI: Fetch the pointer coordinates of the scroll event 5076 * Only in the GUI: Fetch the pointer coordinates of the scroll event
5091 * so that we know which window to scroll later. 5077 * so that we know which window to scroll later.
5092 */ 5078 */
5093 if (gui.in_use 5079 if (gui.in_use
5107 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1; 5093 mouse_col = 128 * (bytes[0] - ' ' - 1) + bytes[1] - ' ' - 1;
5108 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1; 5094 mouse_row = 128 * (bytes[2] - ' ' - 1) + bytes[3] - ' ' - 1;
5109 slen += num_bytes; 5095 slen += num_bytes;
5110 } 5096 }
5111 else 5097 else
5112 # endif 5098 #endif
5113 /* 5099 /*
5114 * If it is a mouse click, get the coordinates. 5100 * If it is a mouse click, get the coordinates.
5115 */ 5101 */
5116 if (key_name[0] == KS_MOUSE 5102 if (key_name[0] == KS_MOUSE
5117 # ifdef FEAT_MOUSE_GPM 5103 #ifdef FEAT_MOUSE_GPM
5118 || key_name[0] == KS_GPM_MOUSE 5104 || key_name[0] == KS_GPM_MOUSE
5119 # endif 5105 #endif
5120 # ifdef FEAT_MOUSE_JSB 5106 #ifdef FEAT_MOUSE_JSB
5121 || key_name[0] == KS_JSBTERM_MOUSE 5107 || key_name[0] == KS_JSBTERM_MOUSE
5122 # endif 5108 #endif
5123 # ifdef FEAT_MOUSE_NET 5109 #ifdef FEAT_MOUSE_NET
5124 || key_name[0] == KS_NETTERM_MOUSE 5110 || key_name[0] == KS_NETTERM_MOUSE
5125 # endif 5111 #endif
5126 # ifdef FEAT_MOUSE_DEC 5112 #ifdef FEAT_MOUSE_DEC
5127 || key_name[0] == KS_DEC_MOUSE 5113 || key_name[0] == KS_DEC_MOUSE
5128 # endif 5114 #endif
5129 # ifdef FEAT_MOUSE_PTERM 5115 #ifdef FEAT_MOUSE_PTERM
5130 || key_name[0] == KS_PTERM_MOUSE 5116 || key_name[0] == KS_PTERM_MOUSE
5131 # endif 5117 #endif
5132 # ifdef FEAT_MOUSE_URXVT 5118 #ifdef FEAT_MOUSE_URXVT
5133 || key_name[0] == KS_URXVT_MOUSE 5119 || key_name[0] == KS_URXVT_MOUSE
5134 # endif 5120 #endif
5135 || key_name[0] == KS_SGR_MOUSE 5121 || key_name[0] == KS_SGR_MOUSE
5136 || key_name[0] == KS_SGR_MOUSE_RELEASE) 5122 || key_name[0] == KS_SGR_MOUSE_RELEASE)
5137 { 5123 {
5138 if (check_termcode_mouse(tp, &slen, key_name, modifiers_start, idx, 5124 if (check_termcode_mouse(tp, &slen, key_name, modifiers_start, idx,
5139 &modifiers) == -1) 5125 &modifiers) == -1)
5140 return -1; 5126 return -1;
5141 } 5127 }
5142 #endif /* FEAT_MOUSE */
5143 5128
5144 #ifdef FEAT_GUI 5129 #ifdef FEAT_GUI
5145 /* 5130 /*
5146 * If using the GUI, then we get menu and scrollbar events. 5131 * If using the GUI, then we get menu and scrollbar events.
5147 * 5132 *