comparison src/move.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 08f1dd29550e
children 66964658cc3c
comparison
equal deleted inserted replaced
18353:c3a0f5d3c9d4 18354:9f51d0cef8da
188 linenr_T lnum; 188 linenr_T lnum;
189 #endif 189 #endif
190 int check_topline = FALSE; 190 int check_topline = FALSE;
191 int check_botline = FALSE; 191 int check_botline = FALSE;
192 long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so; 192 long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
193 #ifdef FEAT_MOUSE
194 int save_so = *so_ptr; 193 int save_so = *so_ptr;
195 #endif
196 194
197 /* If there is no valid screen and when the window height is zero just use 195 /* If there is no valid screen and when the window height is zero just use
198 * the cursor line. */ 196 * the cursor line. */
199 if (!screen_valid(TRUE) || curwin->w_height == 0) 197 if (!screen_valid(TRUE) || curwin->w_height == 0)
200 { 198 {
207 205
208 check_cursor_moved(curwin); 206 check_cursor_moved(curwin);
209 if (curwin->w_valid & VALID_TOPLINE) 207 if (curwin->w_valid & VALID_TOPLINE)
210 return; 208 return;
211 209
212 #ifdef FEAT_MOUSE
213 /* When dragging with the mouse, don't scroll that quickly */ 210 /* When dragging with the mouse, don't scroll that quickly */
214 if (mouse_dragging > 0) 211 if (mouse_dragging > 0)
215 *so_ptr = mouse_dragging - 1; 212 *so_ptr = mouse_dragging - 1;
216 #endif
217 213
218 old_topline = curwin->w_topline; 214 old_topline = curwin->w_topline;
219 #ifdef FEAT_DIFF 215 #ifdef FEAT_DIFF
220 old_topfill = curwin->w_topfill; 216 old_topfill = curwin->w_topfill;
221 #endif 217 #endif
416 /* May need to set w_skipcol when cursor in w_topline. */ 412 /* May need to set w_skipcol when cursor in w_topline. */
417 if (curwin->w_cursor.lnum == curwin->w_topline) 413 if (curwin->w_cursor.lnum == curwin->w_topline)
418 validate_cursor(); 414 validate_cursor();
419 } 415 }
420 416
421 #ifdef FEAT_MOUSE
422 *so_ptr = save_so; 417 *so_ptr = save_so;
423 #endif
424 } 418 }
425 419
426 /* 420 /*
427 * Return the scrolljump value to use for the current window. 421 * Return the scrolljump value to use for the current window.
428 * When 'scrolljump' is positive use it as-is. 422 * When 'scrolljump' is positive use it as-is.
1749 linenr_T old_topfill = curwin->w_topfill; 1743 linenr_T old_topfill = curwin->w_topfill;
1750 #endif 1744 #endif
1751 linenr_T new_topline; 1745 linenr_T new_topline;
1752 int off = get_scrolloff_value(); 1746 int off = get_scrolloff_value();
1753 1747
1754 #ifdef FEAT_MOUSE
1755 if (mouse_dragging > 0) 1748 if (mouse_dragging > 0)
1756 off = mouse_dragging - 1; 1749 off = mouse_dragging - 1;
1757 #endif
1758 1750
1759 /* 1751 /*
1760 * Decrease topline until: 1752 * Decrease topline until:
1761 * - it has become 1 1753 * - it has become 1
1762 * - (part of) the cursor line is moved off the screen or 1754 * - (part of) the cursor line is moved off the screen or
2002 while (loff.lnum > 1) 1994 while (loff.lnum > 1)
2003 { 1995 {
2004 /* Stop when scrolled nothing or at least "min_scroll", found "extra" 1996 /* Stop when scrolled nothing or at least "min_scroll", found "extra"
2005 * context for 'scrolloff' and counted all lines below the window. */ 1997 * context for 'scrolloff' and counted all lines below the window. */
2006 if ((((scrolled <= 0 || scrolled >= min_scroll) 1998 if ((((scrolled <= 0 || scrolled >= min_scroll)
2007 && extra >= ( 1999 && extra >= (mouse_dragging > 0 ? mouse_dragging - 1 : so))
2008 #ifdef FEAT_MOUSE
2009 mouse_dragging > 0 ? mouse_dragging - 1 :
2010 #endif
2011 so))
2012 || boff.lnum + 1 > curbuf->b_ml.ml_line_count) 2000 || boff.lnum + 1 > curbuf->b_ml.ml_line_count)
2013 && loff.lnum <= curwin->w_botline 2001 && loff.lnum <= curwin->w_botline
2014 #ifdef FEAT_DIFF 2002 #ifdef FEAT_DIFF
2015 && (loff.lnum < curwin->w_botline 2003 && (loff.lnum < curwin->w_botline
2016 || loff.fill >= fill_below_window) 2004 || loff.fill >= fill_below_window)
2048 /* Add one line below */ 2036 /* Add one line below */
2049 botline_forw(&boff); 2037 botline_forw(&boff);
2050 used += boff.height; 2038 used += boff.height;
2051 if (used > curwin->w_height) 2039 if (used > curwin->w_height)
2052 break; 2040 break;
2053 if (extra < ( 2041 if (extra < ( mouse_dragging > 0 ? mouse_dragging - 1 : so)
2054 #ifdef FEAT_MOUSE 2042 || scrolled < min_scroll)
2055 mouse_dragging > 0 ? mouse_dragging - 1 :
2056 #endif
2057 so) || scrolled < min_scroll)
2058 { 2043 {
2059 extra += boff.height; 2044 extra += boff.height;
2060 if (boff.lnum >= curwin->w_botline 2045 if (boff.lnum >= curwin->w_botline
2061 #ifdef FEAT_DIFF 2046 #ifdef FEAT_DIFF
2062 || (boff.lnum + 1 == curwin->w_botline 2047 || (boff.lnum + 1 == curwin->w_botline
2228 * How many lines we would like to have above/below the cursor depends on 2213 * How many lines we would like to have above/below the cursor depends on
2229 * whether the first/last line of the file is on screen. 2214 * whether the first/last line of the file is on screen.
2230 */ 2215 */
2231 above_wanted = so; 2216 above_wanted = so;
2232 below_wanted = so; 2217 below_wanted = so;
2233 #ifdef FEAT_MOUSE
2234 if (mouse_dragging > 0) 2218 if (mouse_dragging > 0)
2235 { 2219 {
2236 above_wanted = mouse_dragging - 1; 2220 above_wanted = mouse_dragging - 1;
2237 below_wanted = mouse_dragging - 1; 2221 below_wanted = mouse_dragging - 1;
2238 } 2222 }
2239 #endif
2240 if (curwin->w_topline == 1) 2223 if (curwin->w_topline == 1)
2241 { 2224 {
2242 above_wanted = 0; 2225 above_wanted = 0;
2243 max_off = curwin->w_height / 2; 2226 max_off = curwin->w_height / 2;
2244 if (below_wanted > max_off) 2227 if (below_wanted > max_off)
2245 below_wanted = max_off; 2228 below_wanted = max_off;
2246 } 2229 }
2247 validate_botline(); 2230 validate_botline();
2248 if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1 2231 if (curwin->w_botline == curbuf->b_ml.ml_line_count + 1
2249 #ifdef FEAT_MOUSE 2232 && mouse_dragging == 0)
2250 && mouse_dragging == 0
2251 #endif
2252 )
2253 { 2233 {
2254 below_wanted = 0; 2234 below_wanted = 0;
2255 max_off = (curwin->w_height - 1) / 2; 2235 max_off = (curwin->w_height - 1) / 2;
2256 if (above_wanted > max_off) 2236 if (above_wanted > max_off)
2257 above_wanted = max_off; 2237 above_wanted = max_off;