comparison src/window.c @ 32871:361743be1fa8

(pos_fully_visible_p): Removed. (Fpos_visible_in_window_p): Use pos_visible_p to determine if position is visible and/or fully visible.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 25 Oct 2000 11:53:54 +0000
parents 6521cc146e8e
children 859adc7ac97d
comparison
equal deleted inserted replaced
32870:cc5f38852c1d 32871:361743be1fa8
288 "Returns non-nil if WINDOW is a minibuffer window.") 288 "Returns non-nil if WINDOW is a minibuffer window.")
289 (window) 289 (window)
290 Lisp_Object window; 290 Lisp_Object window;
291 { 291 {
292 struct window *w = decode_window (window); 292 struct window *w = decode_window (window);
293 return (MINI_WINDOW_P (w) ? Qt : Qnil); 293 return MINI_WINDOW_P (w) ? Qt : Qnil;
294 }
295
296
297 /* Return true if POS is fully visible in the window W. If W's end
298 position is not known, then return false. */
299
300 static int
301 pos_fully_visible_in_window_p (pos, w)
302 int pos;
303 struct window *w;
304 {
305 struct glyph_row *first_row = &w->desired_matrix->rows[0];
306 struct glyph_row *last_row;
307
308 if (pos < first_row->start.pos.charpos)
309 /* POS is before the beginning of W. */
310 return 0;
311 else if (pos < first_row->end.pos.charpos)
312 /* POS is on the first row of W, so see if that row is fully visible. */
313 return !MATRIX_ROW_PARTIALLY_VISIBLE_P (first_row);
314
315 if (NILP (w->window_end_valid))
316 /* We can't determine where the end is, so we don't know. */
317 return 0;
318
319 last_row = &w->desired_matrix->rows[XFASTINT (w->window_end_vpos)];
320
321 if (pos < last_row->start.pos.charpos)
322 /* POS is somewhere in the middle of the window, not on the first or
323 last row, so it must be visible. */
324 return 1;
325 else if (pos >= last_row->end.pos.charpos)
326 /* POS is after the end of W. */
327 return 0;
328 else
329 /* POS is on the last row of W, so see if that row is fully visible. */
330 return !MATRIX_ROW_PARTIALLY_VISIBLE_P (last_row);
331 } 294 }
332 295
333 296
334 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p, 297 DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p,
335 Spos_visible_in_window_p, 0, 3, 0, 298 Spos_visible_in_window_p, 0, 3, 0,
336 "Return t if position POS is currently on the frame in WINDOW.\n\ 299 "Return t if position POS is currently on the frame in WINDOW.\n\
337 Returns nil if that position is scrolled vertically out of view.\n\ 300 Return nil if that position is scrolled vertically out of view.\n\
338 If FULLY is non-nil, then only return t when POS is completely visible.\n\ 301 If FULLY is non-nil, then only return t when POS is completely visible.\n\
339 POS defaults to point; WINDOW, to the selected window.") 302 POS defaults to point; WINDOW defaults to the selected window.")
340 (pos, window, fully) 303 (pos, window, fully)
341 Lisp_Object pos, window, fully; 304 Lisp_Object pos, window, fully;
342 { 305 {
343 register struct window *w; 306 register struct window *w;
344 register int posint; 307 register int posint;
345 register struct buffer *buf; 308 register struct buffer *buf;
346 struct text_pos top; 309 struct text_pos top;
347 Lisp_Object in_window; 310 Lisp_Object in_window;
311 int fully_p;
348 312
349 if (NILP (pos)) 313 if (NILP (pos))
350 posint = PT; 314 posint = PT;
351 else 315 else
352 { 316 {
356 320
357 w = decode_window (window); 321 w = decode_window (window);
358 buf = XBUFFER (w->buffer); 322 buf = XBUFFER (w->buffer);
359 SET_TEXT_POS_FROM_MARKER (top, w->start); 323 SET_TEXT_POS_FROM_MARKER (top, w->start);
360 324
361 /* If position above window, it's not visible. */ 325 /* If position is above window start, it's not visible. */
362 if (posint < CHARPOS (top)) 326 if (posint < CHARPOS (top))
363 in_window = Qnil; 327 in_window = Qnil;
364 else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf) 328 else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf)
365 && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf) 329 && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf)
366 && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos)) 330 && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos))
367 /* If frame is up to date, and POSINT is < window end pos, use 331 {
368 that info. This doesn't work for POSINT == end pos, because 332 /* If frame is up-to-date, and POSINT is < window end pos, use
369 the window end pos is actually the position _after_ the last 333 that info. This doesn't work for POSINT == end pos, because
370 char in the window. */ 334 the window end pos is actually the position _after_ the last
371 { 335 char in the window. */
372 if (NILP (fully) || pos_fully_visible_in_window_p (posint, w)) 336 if (!NILP (fully))
337 {
338 pos_visible_p (w, posint, &fully_p);
339 in_window = fully_p ? Qt : Qnil;
340 }
341 else
373 in_window = Qt; 342 in_window = Qt;
374 else
375 in_window = Qnil;
376 } 343 }
377 else if (posint > BUF_ZV (buf)) 344 else if (posint > BUF_ZV (buf))
378 in_window = Qnil; 345 in_window = Qnil;
379 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf)) 346 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf))
380 /* If window start is out of range, do something reasonable. */ 347 /* If window start is out of range, do something reasonable. */
381 in_window = Qnil; 348 in_window = Qnil;
382 else 349 else
383 { 350 {
384 struct it it; 351 if (pos_visible_p (w, posint, &fully_p))
385 start_display (&it, w, top); 352 in_window = NILP (fully) || fully_p ? Qt : Qnil;
386 move_it_to (&it, posint, 0, it.last_visible_y, -1,
387 MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
388 if (IT_CHARPOS (it) == posint)
389 {
390 if (NILP (fully))
391 in_window = Qt;
392 else
393 {
394 struct glyph_row *pos_row = &w->desired_matrix->rows[it.vpos];
395 return MATRIX_ROW_PARTIALLY_VISIBLE_P(pos_row) ? Qnil : Qt;
396 }
397 }
398 else 353 else
399 in_window = Qnil; 354 in_window = Qnil;
400 } 355 }
401 356
402 return in_window; 357 return in_window;
403 } 358 }
359
404 360
405 static struct window * 361 static struct window *
406 decode_window (window) 362 decode_window (window)
407 register Lisp_Object window; 363 register Lisp_Object window;
408 { 364 {