aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorKim F. Storm2004-04-20 22:18:33 +0000
committerKim F. Storm2004-04-20 22:18:33 +0000
commit0cc1039fe1775b251cd9aa4c1ffd935eeb93acd3 (patch)
tree79b090e7695f59f80232868901f6f54cb90bf68a /src/window.c
parentcb0b194af078526844a64859d247976d8f31f313 (diff)
downloademacs-0cc1039fe1775b251cd9aa4c1ffd935eeb93acd3.tar.gz
emacs-0cc1039fe1775b251cd9aa4c1ffd935eeb93acd3.zip
(Fpos_visible_in_window_p): Return pixel position if
PARTIALLY arg is non-nil. Simplify. Doc fix. (Fwindow_vscroll, Fset_window_vscroll): Add optional PIXEL_P arg to return/set vscroll in pixels.
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c95
1 files changed, 44 insertions, 51 deletions
diff --git a/src/window.c b/src/window.c
index 9f0bbaff093..f830c88bb18 100644
--- a/src/window.c
+++ b/src/window.c
@@ -322,7 +322,11 @@ DEFUN ("pos-visible-in-window-p", Fpos_visible_in_window_p,
322Return nil if that position is scrolled vertically out of view. 322Return nil if that position is scrolled vertically out of view.
323If a character is only partially visible, nil is returned, unless the 323If a character is only partially visible, nil is returned, unless the
324optional argument PARTIALLY is non-nil. 324optional argument PARTIALLY is non-nil.
325POS defaults to point in WINDOW; WINDOW defaults to the selected window. */) 325POS defaults to point in WINDOW; WINDOW defaults to the selected window.
326
327If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
328return value is a list (X Y PARTIAL) where X and Y are the pixel relative
329coordinate */)
326 (pos, window, partially) 330 (pos, window, partially)
327 Lisp_Object pos, window, partially; 331 Lisp_Object pos, window, partially;
328{ 332{
@@ -330,8 +334,9 @@ POS defaults to point in WINDOW; WINDOW defaults to the selected window. */)
330 register int posint; 334 register int posint;
331 register struct buffer *buf; 335 register struct buffer *buf;
332 struct text_pos top; 336 struct text_pos top;
333 Lisp_Object in_window; 337 Lisp_Object in_window = Qnil;
334 int fully_p; 338 int fully_p = 1;
339 int x, y;
335 340
336 w = decode_window (window); 341 w = decode_window (window);
337 buf = XBUFFER (w->buffer); 342 buf = XBUFFER (w->buffer);
@@ -347,38 +352,20 @@ POS defaults to point in WINDOW; WINDOW defaults to the selected window. */)
347 else 352 else
348 posint = XMARKER (w->pointm)->charpos; 353 posint = XMARKER (w->pointm)->charpos;
349 354
350 /* If position is above window start, it's not visible. */ 355 /* If position is above window start or outside buffer boundaries,
351 if (posint < CHARPOS (top)) 356 or if window start is out of range, position is not visible. */
352 in_window = Qnil; 357 if (posint >= CHARPOS (top)
353 else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf) 358 && posint <= BUF_ZV (buf)
354 && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf) 359 && CHARPOS (top) >= BUF_BEGV (buf)
355 && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos)) 360 && CHARPOS (top) <= BUF_ZV (buf)
356 { 361 && pos_visible_p (w, posint, &fully_p, &x, &y, NILP (partially))
357 /* If frame is up-to-date, and POSINT is < window end pos, use 362 && (!NILP (partially) || fully_p))
358 that info. This doesn't work for POSINT == end pos, because 363 in_window = Qt;
359 the window end pos is actually the position _after_ the last 364
360 char in the window. */ 365 if (!NILP (in_window) && !NILP (partially))
361 if (NILP (partially)) 366 in_window = Fcons (make_number (x),
362 { 367 Fcons (make_number (y),
363 pos_visible_p (w, posint, &fully_p, NILP (partially)); 368 Fcons (fully_p ? Qt : Qnil, Qnil)));
364 in_window = fully_p ? Qt : Qnil;
365 }
366 else
367 in_window = Qt;
368 }
369 else if (posint > BUF_ZV (buf))
370 in_window = Qnil;
371 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf))
372 /* If window start is out of range, do something reasonable. */
373 in_window = Qnil;
374 else
375 {
376 if (pos_visible_p (w, posint, &fully_p, NILP (partially)))
377 in_window = !NILP (partially) || fully_p ? Qt : Qnil;
378 else
379 in_window = Qnil;
380 }
381
382 return in_window; 369 return in_window;
383} 370}
384 371
@@ -3460,7 +3447,7 @@ DEFUN ("force-window-update", Fforce_window_update, Sforce_window_update,
3460 0, 1, 0, 3447 0, 1, 0,
3461 doc: /* Force redisplay of all windows. 3448 doc: /* Force redisplay of all windows.
3462If optional arg OBJECT is a window, force redisplay of that window only. 3449If optional arg OBJECT is a window, force redisplay of that window only.
3463If OBJECT is a buffer or buffer name, force redisplay of all windows 3450If OBJECT is a buffer or buffer name, force redisplay of all windows
3464displaying that buffer. */) 3451displaying that buffer. */)
3465 (object) 3452 (object)
3466 Lisp_Object object; 3453 Lisp_Object object;
@@ -3482,7 +3469,7 @@ displaying that buffer. */)
3482 ++update_mode_lines; 3469 ++update_mode_lines;
3483 return Qt; 3470 return Qt;
3484 } 3471 }
3485 3472
3486 if (STRINGP (object)) 3473 if (STRINGP (object))
3487 object = Fget_buffer (object); 3474 object = Fget_buffer (object);
3488 if (BUFFERP (object) && !NILP (XBUFFER (object)->name)) 3475 if (BUFFERP (object) && !NILP (XBUFFER (object)->name))
@@ -3547,7 +3534,7 @@ temp_output_buffer_show (buf)
3547 Lisp_Object prev_window, prev_buffer; 3534 Lisp_Object prev_window, prev_buffer;
3548 prev_window = selected_window; 3535 prev_window = selected_window;
3549 XSETBUFFER (prev_buffer, old); 3536 XSETBUFFER (prev_buffer, old);
3550 3537
3551 /* Select the window that was chosen, for running the hook. 3538 /* Select the window that was chosen, for running the hook.
3552 Note: Both Fselect_window and select_window_norecord may 3539 Note: Both Fselect_window and select_window_norecord may
3553 set-buffer to the buffer displayed in the window, 3540 set-buffer to the buffer displayed in the window,
@@ -6067,7 +6054,7 @@ If TYPE is t, use the frame's scroll-bar type. */)
6067 vertical_type = Qnil; 6054 vertical_type = Qnil;
6068 6055
6069 if (!(EQ (vertical_type, Qnil) 6056 if (!(EQ (vertical_type, Qnil)
6070 || EQ (vertical_type, Qleft) 6057 || EQ (vertical_type, Qleft)
6071 || EQ (vertical_type, Qright) 6058 || EQ (vertical_type, Qright)
6072 || EQ (vertical_type, Qt))) 6059 || EQ (vertical_type, Qt)))
6073 error ("Invalid type of vertical scroll bar"); 6060 error ("Invalid type of vertical scroll bar");
@@ -6116,12 +6103,13 @@ value. */)
6116 Smooth scrolling 6103 Smooth scrolling
6117 ***********************************************************************/ 6104 ***********************************************************************/
6118 6105
6119DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 1, 0, 6106DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0,
6120 doc: /* Return the amount by which WINDOW is scrolled vertically. 6107 doc: /* Return the amount by which WINDOW is scrolled vertically.
6121Use the selected window if WINDOW is nil or omitted. 6108Use the selected window if WINDOW is nil or omitted.
6122Value is a multiple of the canonical character height of WINDOW. */) 6109Normally, value is a multiple of the canonical character height of WINDOW;
6123 (window) 6110optional second arg PIXELS_P means value is measured in pixels. */)
6124 Lisp_Object window; 6111 (window, pixels_p)
6112 Lisp_Object window, pixels_p;
6125{ 6113{
6126 Lisp_Object result; 6114 Lisp_Object result;
6127 struct frame *f; 6115 struct frame *f;
@@ -6135,7 +6123,9 @@ Value is a multiple of the canonical character height of WINDOW. */)
6135 f = XFRAME (w->frame); 6123 f = XFRAME (w->frame);
6136 6124
6137 if (FRAME_WINDOW_P (f)) 6125 if (FRAME_WINDOW_P (f))
6138 result = FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll); 6126 result = (NILP (pixels_p)
6127 ? FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll)
6128 : make_number (-w->vscroll));
6139 else 6129 else
6140 result = make_number (0); 6130 result = make_number (0);
6141 return result; 6131 return result;
@@ -6143,12 +6133,13 @@ Value is a multiple of the canonical character height of WINDOW. */)
6143 6133
6144 6134
6145DEFUN ("set-window-vscroll", Fset_window_vscroll, Sset_window_vscroll, 6135DEFUN ("set-window-vscroll", Fset_window_vscroll, Sset_window_vscroll,
6146 2, 2, 0, 6136 2, 3, 0,
6147 doc: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL. 6137 doc: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL.
6148WINDOW nil means use the selected window. VSCROLL is a non-negative 6138WINDOW nil means use the selected window. Normally, VSCROLL is a
6149multiple of the canonical character height of WINDOW. */) 6139non-negative multiple of the canonical character height of WINDOW;
6150 (window, vscroll) 6140optional third arg PIXELS_P non-nil means that VSCROLL is in pixels. */)
6151 Lisp_Object window, vscroll; 6141 (window, vscroll, pixels_p)
6142 Lisp_Object window, vscroll, pixels_p;
6152{ 6143{
6153 struct window *w; 6144 struct window *w;
6154 struct frame *f; 6145 struct frame *f;
@@ -6166,7 +6157,9 @@ multiple of the canonical character height of WINDOW. */)
6166 { 6157 {
6167 int old_dy = w->vscroll; 6158 int old_dy = w->vscroll;
6168 6159
6169 w->vscroll = - FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll); 6160 w->vscroll = - (NILP (pixels_p)
6161 ? FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll)
6162 : XFLOATINT (vscroll));
6170 w->vscroll = min (w->vscroll, 0); 6163 w->vscroll = min (w->vscroll, 0);
6171 6164
6172 /* Adjust glyph matrix of the frame if the virtual display 6165 /* Adjust glyph matrix of the frame if the virtual display
@@ -6178,7 +6171,7 @@ multiple of the canonical character height of WINDOW. */)
6178 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 6171 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
6179 } 6172 }
6180 6173
6181 return Fwindow_vscroll (window); 6174 return Fwindow_vscroll (window, pixels_p);
6182} 6175}
6183 6176
6184 6177