comparison src/window.c @ 83112:30dd490f06f2

Merged in changes from CVS trunk. Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-231 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-232 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-233 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-234 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-235 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-236 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-237 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-238 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-239 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-240 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-152
author Karoly Lorentey <lorentey@elte.hu>
date Fri, 23 Apr 2004 14:44:11 +0000
parents 0643dc72a250 91ab946dfd86
children 46882e012e30
comparison
equal deleted inserted replaced
83111:fd147ed0d1b8 83112:30dd490f06f2
322 Spos_visible_in_window_p, 0, 3, 0, 322 Spos_visible_in_window_p, 0, 3, 0,
323 doc: /* Return t if position POS is currently on the frame in WINDOW. 323 doc: /* Return t if position POS is currently on the frame in WINDOW.
324 Return nil if that position is scrolled vertically out of view. 324 Return nil if that position is scrolled vertically out of view.
325 If a character is only partially visible, nil is returned, unless the 325 If a character is only partially visible, nil is returned, unless the
326 optional argument PARTIALLY is non-nil. 326 optional argument PARTIALLY is non-nil.
327 POS defaults to point in WINDOW; WINDOW defaults to the selected window. */) 327 POS defaults to point in WINDOW; WINDOW defaults to the selected window.
328
329 If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
330 return value is a list (X Y PARTIAL) where X and Y are the pixel relative
331 coordinate */)
328 (pos, window, partially) 332 (pos, window, partially)
329 Lisp_Object pos, window, partially; 333 Lisp_Object pos, window, partially;
330 { 334 {
331 register struct window *w; 335 register struct window *w;
332 register int posint; 336 register int posint;
333 register struct buffer *buf; 337 register struct buffer *buf;
334 struct text_pos top; 338 struct text_pos top;
335 Lisp_Object in_window; 339 Lisp_Object in_window = Qnil;
336 int fully_p; 340 int fully_p = 1;
341 int x, y;
337 342
338 w = decode_window (window); 343 w = decode_window (window);
339 buf = XBUFFER (w->buffer); 344 buf = XBUFFER (w->buffer);
340 SET_TEXT_POS_FROM_MARKER (top, w->start); 345 SET_TEXT_POS_FROM_MARKER (top, w->start);
341 346
347 else if (w == XWINDOW (selected_window)) 352 else if (w == XWINDOW (selected_window))
348 posint = PT; 353 posint = PT;
349 else 354 else
350 posint = XMARKER (w->pointm)->charpos; 355 posint = XMARKER (w->pointm)->charpos;
351 356
352 /* If position is above window start, it's not visible. */ 357 /* If position is above window start or outside buffer boundaries,
353 if (posint < CHARPOS (top)) 358 or if window start is out of range, position is not visible. */
354 in_window = Qnil; 359 if (posint >= CHARPOS (top)
355 else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf) 360 && posint <= BUF_ZV (buf)
356 && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf) 361 && CHARPOS (top) >= BUF_BEGV (buf)
357 && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos)) 362 && CHARPOS (top) <= BUF_ZV (buf)
358 { 363 && pos_visible_p (w, posint, &fully_p, &x, &y, NILP (partially))
359 /* If frame is up-to-date, and POSINT is < window end pos, use 364 && (!NILP (partially) || fully_p))
360 that info. This doesn't work for POSINT == end pos, because 365 in_window = Qt;
361 the window end pos is actually the position _after_ the last 366
362 char in the window. */ 367 if (!NILP (in_window) && !NILP (partially))
363 if (NILP (partially)) 368 in_window = Fcons (make_number (x),
364 { 369 Fcons (make_number (y),
365 pos_visible_p (w, posint, &fully_p, NILP (partially)); 370 Fcons (fully_p ? Qt : Qnil, Qnil)));
366 in_window = fully_p ? Qt : Qnil;
367 }
368 else
369 in_window = Qt;
370 }
371 else if (posint > BUF_ZV (buf))
372 in_window = Qnil;
373 else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf))
374 /* If window start is out of range, do something reasonable. */
375 in_window = Qnil;
376 else
377 {
378 if (pos_visible_p (w, posint, &fully_p, NILP (partially)))
379 in_window = !NILP (partially) || fully_p ? Qt : Qnil;
380 else
381 in_window = Qnil;
382 }
383
384 return in_window; 371 return in_window;
385 } 372 }
386 373
387 374
388 static struct window * 375 static struct window *
3460 3447
3461 DEFUN ("force-window-update", Fforce_window_update, Sforce_window_update, 3448 DEFUN ("force-window-update", Fforce_window_update, Sforce_window_update,
3462 0, 1, 0, 3449 0, 1, 0,
3463 doc: /* Force redisplay of all windows. 3450 doc: /* Force redisplay of all windows.
3464 If optional arg OBJECT is a window, force redisplay of that window only. 3451 If optional arg OBJECT is a window, force redisplay of that window only.
3465 If OBJECT is a buffer or buffer name, force redisplay of all windows 3452 If OBJECT is a buffer or buffer name, force redisplay of all windows
3466 displaying that buffer. */) 3453 displaying that buffer. */)
3467 (object) 3454 (object)
3468 Lisp_Object object; 3455 Lisp_Object object;
3469 { 3456 {
3470 if (NILP (object)) 3457 if (NILP (object))
3482 if (BUFFERP (w->buffer)) 3469 if (BUFFERP (w->buffer))
3483 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 3470 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
3484 ++update_mode_lines; 3471 ++update_mode_lines;
3485 return Qt; 3472 return Qt;
3486 } 3473 }
3487 3474
3488 if (STRINGP (object)) 3475 if (STRINGP (object))
3489 object = Fget_buffer (object); 3476 object = Fget_buffer (object);
3490 if (BUFFERP (object) && !NILP (XBUFFER (object)->name)) 3477 if (BUFFERP (object) && !NILP (XBUFFER (object)->name))
3491 { 3478 {
3492 /* Walk all windows looking for buffer, and force update 3479 /* Walk all windows looking for buffer, and force update
3547 { 3534 {
3548 int count = SPECPDL_INDEX (); 3535 int count = SPECPDL_INDEX ();
3549 Lisp_Object prev_window, prev_buffer; 3536 Lisp_Object prev_window, prev_buffer;
3550 prev_window = selected_window; 3537 prev_window = selected_window;
3551 XSETBUFFER (prev_buffer, old); 3538 XSETBUFFER (prev_buffer, old);
3552 3539
3553 /* Select the window that was chosen, for running the hook. 3540 /* Select the window that was chosen, for running the hook.
3554 Note: Both Fselect_window and select_window_norecord may 3541 Note: Both Fselect_window and select_window_norecord may
3555 set-buffer to the buffer displayed in the window, 3542 set-buffer to the buffer displayed in the window,
3556 so we need to save the current buffer. --stef */ 3543 so we need to save the current buffer. --stef */
3557 record_unwind_protect (Fset_buffer, prev_buffer); 3544 record_unwind_protect (Fset_buffer, prev_buffer);
6067 6054
6068 if (XINT (width) == 0) 6055 if (XINT (width) == 0)
6069 vertical_type = Qnil; 6056 vertical_type = Qnil;
6070 6057
6071 if (!(EQ (vertical_type, Qnil) 6058 if (!(EQ (vertical_type, Qnil)
6072 || EQ (vertical_type, Qleft) 6059 || EQ (vertical_type, Qleft)
6073 || EQ (vertical_type, Qright) 6060 || EQ (vertical_type, Qright)
6074 || EQ (vertical_type, Qt))) 6061 || EQ (vertical_type, Qt)))
6075 error ("Invalid type of vertical scroll bar"); 6062 error ("Invalid type of vertical scroll bar");
6076 6063
6077 if (!EQ (w->scroll_bar_width, width) 6064 if (!EQ (w->scroll_bar_width, width)
6116 6103
6117 /*********************************************************************** 6104 /***********************************************************************
6118 Smooth scrolling 6105 Smooth scrolling
6119 ***********************************************************************/ 6106 ***********************************************************************/
6120 6107
6121 DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 1, 0, 6108 DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0,
6122 doc: /* Return the amount by which WINDOW is scrolled vertically. 6109 doc: /* Return the amount by which WINDOW is scrolled vertically.
6123 Use the selected window if WINDOW is nil or omitted. 6110 Use the selected window if WINDOW is nil or omitted.
6124 Value is a multiple of the canonical character height of WINDOW. */) 6111 Normally, value is a multiple of the canonical character height of WINDOW;
6125 (window) 6112 optional second arg PIXELS_P means value is measured in pixels. */)
6126 Lisp_Object window; 6113 (window, pixels_p)
6114 Lisp_Object window, pixels_p;
6127 { 6115 {
6128 Lisp_Object result; 6116 Lisp_Object result;
6129 struct frame *f; 6117 struct frame *f;
6130 struct window *w; 6118 struct window *w;
6131 6119
6135 CHECK_WINDOW (window); 6123 CHECK_WINDOW (window);
6136 w = XWINDOW (window); 6124 w = XWINDOW (window);
6137 f = XFRAME (w->frame); 6125 f = XFRAME (w->frame);
6138 6126
6139 if (FRAME_WINDOW_P (f)) 6127 if (FRAME_WINDOW_P (f))
6140 result = FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll); 6128 result = (NILP (pixels_p)
6129 ? FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll)
6130 : make_number (-w->vscroll));
6141 else 6131 else
6142 result = make_number (0); 6132 result = make_number (0);
6143 return result; 6133 return result;
6144 } 6134 }
6145 6135
6146 6136
6147 DEFUN ("set-window-vscroll", Fset_window_vscroll, Sset_window_vscroll, 6137 DEFUN ("set-window-vscroll", Fset_window_vscroll, Sset_window_vscroll,
6148 2, 2, 0, 6138 2, 3, 0,
6149 doc: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL. 6139 doc: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL.
6150 WINDOW nil means use the selected window. VSCROLL is a non-negative 6140 WINDOW nil means use the selected window. Normally, VSCROLL is a
6151 multiple of the canonical character height of WINDOW. */) 6141 non-negative multiple of the canonical character height of WINDOW;
6152 (window, vscroll) 6142 optional third arg PIXELS_P non-nil means that VSCROLL is in pixels. */)
6153 Lisp_Object window, vscroll; 6143 (window, vscroll, pixels_p)
6144 Lisp_Object window, vscroll, pixels_p;
6154 { 6145 {
6155 struct window *w; 6146 struct window *w;
6156 struct frame *f; 6147 struct frame *f;
6157 6148
6158 if (NILP (window)) 6149 if (NILP (window))
6166 6157
6167 if (FRAME_WINDOW_P (f)) 6158 if (FRAME_WINDOW_P (f))
6168 { 6159 {
6169 int old_dy = w->vscroll; 6160 int old_dy = w->vscroll;
6170 6161
6171 w->vscroll = - FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll); 6162 w->vscroll = - (NILP (pixels_p)
6163 ? FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll)
6164 : XFLOATINT (vscroll));
6172 w->vscroll = min (w->vscroll, 0); 6165 w->vscroll = min (w->vscroll, 0);
6173 6166
6174 /* Adjust glyph matrix of the frame if the virtual display 6167 /* Adjust glyph matrix of the frame if the virtual display
6175 area becomes larger than before. */ 6168 area becomes larger than before. */
6176 if (w->vscroll < 0 && w->vscroll < old_dy) 6169 if (w->vscroll < 0 && w->vscroll < old_dy)
6178 6171
6179 /* Prevent redisplay shortcuts. */ 6172 /* Prevent redisplay shortcuts. */
6180 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1; 6173 XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
6181 } 6174 }
6182 6175
6183 return Fwindow_vscroll (window); 6176 return Fwindow_vscroll (window, pixels_p);
6184 } 6177 }
6185 6178
6186 6179
6187 /* Call FN for all leaf windows on frame F. FN is called with the 6180 /* Call FN for all leaf windows on frame F. FN is called with the
6188 first argument being a pointer to the leaf window, and with 6181 first argument being a pointer to the leaf window, and with