Mercurial > emacs
comparison src/xterm.c @ 7651:1569a13efdcd
(x_set_window_size): If cursor outside new size, mark it off.
(note_mouse_highlight): Handle case of highlight extending
past end of window.
(fast_find_position): Fix bugs when no text on screen
and when the mouse is on an empty line.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 23 May 1994 06:47:51 +0000 |
parents | 136819b017fc |
children | 8212755ff793 |
comparison
equal
deleted
inserted
replaced
7650:f6d9c3187245 | 7651:1569a13efdcd |
---|---|
282 in its mouse-face, together with the window they apply to. | 282 in its mouse-face, together with the window they apply to. |
283 As long as the mouse stays within this range, we need not | 283 As long as the mouse stays within this range, we need not |
284 redraw anything on its account. */ | 284 redraw anything on its account. */ |
285 static int mouse_face_beg_row, mouse_face_beg_col; | 285 static int mouse_face_beg_row, mouse_face_beg_col; |
286 static int mouse_face_end_row, mouse_face_end_col; | 286 static int mouse_face_end_row, mouse_face_end_col; |
287 static int mouse_face_past_end; | |
287 static Lisp_Object mouse_face_window; | 288 static Lisp_Object mouse_face_window; |
288 static int mouse_face_face_id; | 289 static int mouse_face_face_id; |
289 | 290 |
290 /* 1 if a mouse motion event came and we didn't handle it right away because | 291 /* 1 if a mouse motion event came and we didn't handle it right away because |
291 gc was in progress. */ | 292 gc was in progress. */ |
2182 clear_mouse_face (); | 2183 clear_mouse_face (); |
2183 else if (! (EQ (window, mouse_face_window) | 2184 else if (! (EQ (window, mouse_face_window) |
2184 && row >= mouse_face_beg_row | 2185 && row >= mouse_face_beg_row |
2185 && row <= mouse_face_end_row | 2186 && row <= mouse_face_end_row |
2186 && (row > mouse_face_beg_row || column >= mouse_face_beg_col) | 2187 && (row > mouse_face_beg_row || column >= mouse_face_beg_col) |
2187 && (row < mouse_face_end_row || column < mouse_face_end_col))) | 2188 && (row < mouse_face_end_row || column < mouse_face_end_col |
2189 || mouse_face_past_end))) | |
2188 { | 2190 { |
2189 Lisp_Object mouse_face, overlay, position; | 2191 Lisp_Object mouse_face, overlay, position; |
2190 Lisp_Object *overlay_vec; | 2192 Lisp_Object *overlay_vec; |
2191 int len, noverlays, ignor1; | 2193 int len, noverlays, ignor1; |
2192 struct buffer *obuf; | 2194 struct buffer *obuf; |
2244 int ignore; | 2246 int ignore; |
2245 | 2247 |
2246 before = Foverlay_start (overlay); | 2248 before = Foverlay_start (overlay); |
2247 after = Foverlay_end (overlay); | 2249 after = Foverlay_end (overlay); |
2248 /* Record this as the current active region. */ | 2250 /* Record this as the current active region. */ |
2249 fast_find_position (window, before, | 2251 fast_find_position (window, before, &mouse_face_beg_col, |
2250 &mouse_face_beg_col, &mouse_face_beg_row); | 2252 &mouse_face_beg_row); |
2251 fast_find_position (window, after, | 2253 mouse_face_past_end |
2252 &mouse_face_end_col, &mouse_face_end_row); | 2254 = !fast_find_position (window, after, &mouse_face_end_col, |
2255 &mouse_face_end_row); | |
2253 mouse_face_window = window; | 2256 mouse_face_window = window; |
2254 mouse_face_face_id = compute_char_face (f, w, pos, 0, 0, | 2257 mouse_face_face_id = compute_char_face (f, w, pos, 0, 0, |
2255 &ignore, pos + 1, 1); | 2258 &ignore, pos + 1, 1); |
2256 | 2259 |
2257 /* Display it as active. */ | 2260 /* Display it as active. */ |
2275 w->buffer, beginning); | 2278 w->buffer, beginning); |
2276 after | 2279 after |
2277 = Fnext_single_property_change (position, Qmouse_face, | 2280 = Fnext_single_property_change (position, Qmouse_face, |
2278 w->buffer, end); | 2281 w->buffer, end); |
2279 /* Record this as the current active region. */ | 2282 /* Record this as the current active region. */ |
2280 fast_find_position (window, before, | 2283 fast_find_position (window, before, &mouse_face_beg_col, |
2281 &mouse_face_beg_col, &mouse_face_beg_row); | 2284 &mouse_face_beg_row); |
2282 fast_find_position (window, after, | 2285 mouse_face_past_end |
2283 &mouse_face_end_col, &mouse_face_end_row); | 2286 = !fast_find_position (window, after, &mouse_face_end_col, |
2287 &mouse_face_end_row); | |
2284 mouse_face_window = window; | 2288 mouse_face_window = window; |
2285 mouse_face_face_id | 2289 mouse_face_face_id |
2286 = compute_char_face (f, w, pos, 0, 0, | 2290 = compute_char_face (f, w, pos, 0, 0, |
2287 &ignore, pos + 1, 1); | 2291 &ignore, pos + 1, 1); |
2288 | 2292 |
2299 /* Find the row and column of position POS in window WINDOW. | 2303 /* Find the row and column of position POS in window WINDOW. |
2300 Store them in *COLUMNP and *ROWP. | 2304 Store them in *COLUMNP and *ROWP. |
2301 This assumes display in WINDOW is up to date. | 2305 This assumes display in WINDOW is up to date. |
2302 If POS is above start of WINDOW, return coords | 2306 If POS is above start of WINDOW, return coords |
2303 of start of first screen line. | 2307 of start of first screen line. |
2304 If POS is after end of WINDOW, return coords of end of last screen line. */ | 2308 If POS is after end of WINDOW, return coords of end of last screen line. |
2309 | |
2310 Value is 1 if POS is in range, 0 if it was off screen. */ | |
2305 | 2311 |
2306 static int | 2312 static int |
2307 fast_find_position (window, pos, columnp, rowp) | 2313 fast_find_position (window, pos, columnp, rowp) |
2308 Lisp_Object window; | 2314 Lisp_Object window; |
2309 int pos; | 2315 int pos; |
2310 int *columnp, *rowp; | 2316 int *columnp, *rowp; |
2311 { | 2317 { |
2312 struct window *w = XWINDOW (window); | 2318 struct window *w = XWINDOW (window); |
2313 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); | 2319 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); |
2314 int i; | 2320 int i; |
2315 int row; | 2321 int row = 0; |
2316 int left = w->left; | 2322 int left = w->left; |
2317 int top = w->top; | 2323 int top = w->top; |
2318 int height = XFASTINT (w->height) - ! MINI_WINDOW_P (w); | 2324 int height = XFASTINT (w->height) - ! MINI_WINDOW_P (w); |
2319 int width = window_internal_width (w); | 2325 int width = window_internal_width (w); |
2320 int *charstarts; | 2326 int *charstarts; |
2321 int lastcol; | 2327 int lastcol; |
2322 | 2328 |
2329 /* Find the right row. */ | |
2323 for (i = 0; | 2330 for (i = 0; |
2324 i < height; | 2331 i < height; |
2325 i++) | 2332 i++) |
2326 { | 2333 { |
2327 int linestart = FRAME_CURRENT_GLYPHS (f)->charstarts[top + i][left]; | 2334 int linestart = FRAME_CURRENT_GLYPHS (f)->charstarts[top + i][left]; |
2329 break; | 2336 break; |
2330 if (linestart > 0) | 2337 if (linestart > 0) |
2331 row = i; | 2338 row = i; |
2332 } | 2339 } |
2333 | 2340 |
2341 /* Find the right column with in it. */ | |
2334 charstarts = FRAME_CURRENT_GLYPHS (f)->charstarts[top + row]; | 2342 charstarts = FRAME_CURRENT_GLYPHS (f)->charstarts[top + row]; |
2335 lastcol = left; | 2343 lastcol = left; |
2336 for (i = 0; i < width; i++) | 2344 for (i = 0; i < width; i++) |
2337 { | 2345 { |
2338 if (charstarts[left + i] == pos) | 2346 if (charstarts[left + i] == pos) |
2340 *rowp = row + top; | 2348 *rowp = row + top; |
2341 *columnp = i + left; | 2349 *columnp = i + left; |
2342 return 1; | 2350 return 1; |
2343 } | 2351 } |
2344 else if (charstarts[left + i] > pos) | 2352 else if (charstarts[left + i] > pos) |
2353 break; | |
2354 else if (charstarts[left + i] > 0) | |
2345 lastcol = left + i; | 2355 lastcol = left + i; |
2346 } | 2356 } |
2347 | 2357 |
2348 *rowp = row + top; | 2358 *rowp = row + top; |
2349 *columnp = lastcol; | 2359 *columnp = lastcol; |
5317 point in the future when the ConfigureNotify event arrives. */ | 5327 point in the future when the ConfigureNotify event arrives. */ |
5318 change_frame_size (f, rows, cols, 0, 0); | 5328 change_frame_size (f, rows, cols, 0, 0); |
5319 PIXEL_WIDTH (f) = pixelwidth; | 5329 PIXEL_WIDTH (f) = pixelwidth; |
5320 PIXEL_HEIGHT (f) = pixelheight; | 5330 PIXEL_HEIGHT (f) = pixelheight; |
5321 | 5331 |
5332 /* If cursor was outside the new size, mark it as off. */ | |
5333 if (f->phys_cursor_y >= rows | |
5334 || f->phys_cursor_x >= cols) | |
5335 { | |
5336 f->phys_cursor_x = -1; | |
5337 f->phys_cursor_y = -1; | |
5338 } | |
5339 | |
5322 /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to | 5340 /* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to |
5323 receive in the ConfigureNotify event; if we get what we asked | 5341 receive in the ConfigureNotify event; if we get what we asked |
5324 for, then the event won't cause the screen to become garbaged, so | 5342 for, then the event won't cause the screen to become garbaged, so |
5325 we have to make sure to do it here. */ | 5343 we have to make sure to do it here. */ |
5326 SET_FRAME_GARBAGED (f); | 5344 SET_FRAME_GARBAGED (f); |