/[emacs]/emacs/src/window.c
ViewVC logotype

Diff of /emacs/src/window.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.445.2.2 by handa, Fri Apr 16 12:50:51 2004 UTC revision 1.445.2.3 by miles, Mon Jun 28 07:29:24 2004 UTC
# Line 1  Line 1 
1  /* Window creation, deletion and examination for GNU Emacs.  /* Window creation, deletion and examination for GNU Emacs.
2     Does not include redisplay.     Does not include redisplay.
3     Copyright (C) 1985,86,87,93,94,95,96,97,1998,2000, 2001, 2002, 2003     Copyright (C) 1985,86,87, 1993,94,95,96,97,98, 2000,01,02,03,04
4     Free Software Foundation, Inc.     Free Software Foundation, Inc.
5    
6  This file is part of GNU Emacs.  This file is part of GNU Emacs.
# Line 322  DEFUN ("pos-visible-in-window-p", Fpos_v Line 322  DEFUN ("pos-visible-in-window-p", Fpos_v
322  Return nil if that position is scrolled vertically out of view.  Return nil if that position is scrolled vertically out of view.
323  If a character is only partially visible, nil is returned, unless the  If a character is only partially visible, nil is returned, unless the
324  optional argument PARTIALLY is non-nil.  optional argument PARTIALLY is non-nil.
325  POS defaults to point in WINDOW; WINDOW defaults to the selected window.  */)  POS defaults to point in WINDOW; WINDOW defaults to the selected window.
326    
327    If POS is visible, return t if PARTIALLY is nil; if PARTIALLY is non-nil,
328    return value is a list (X Y PARTIAL) where X and Y are the pixel relative
329    coordinate  */)
330       (pos, window, partially)       (pos, window, partially)
331       Lisp_Object pos, window, partially;       Lisp_Object pos, window, partially;
332  {  {
# Line 330  POS defaults to point in WINDOW; WINDOW Line 334  POS defaults to point in WINDOW; WINDOW
334    register int posint;    register int posint;
335    register struct buffer *buf;    register struct buffer *buf;
336    struct text_pos top;    struct text_pos top;
337    Lisp_Object in_window;    Lisp_Object in_window = Qnil;
338    int fully_p;    int fully_p = 1;
339      int x, y;
340    
341    w = decode_window (window);    w = decode_window (window);
342    buf = XBUFFER (w->buffer);    buf = XBUFFER (w->buffer);
# Line 347  POS defaults to point in WINDOW; WINDOW Line 352  POS defaults to point in WINDOW; WINDOW
352    else    else
353      posint = XMARKER (w->pointm)->charpos;      posint = XMARKER (w->pointm)->charpos;
354    
355    /* If position is above window start, it's not visible.  */    /* If position is above window start or outside buffer boundaries,
356    if (posint < CHARPOS (top))       or if window start is out of range, position is not visible.  */
357      in_window = Qnil;    if (posint >= CHARPOS (top)
358    else if (XFASTINT (w->last_modified) >= BUF_MODIFF (buf)        && posint <= BUF_ZV (buf)
359             && XFASTINT (w->last_overlay_modified) >= BUF_OVERLAY_MODIFF (buf)        && CHARPOS (top) >= BUF_BEGV (buf)
360             && posint < BUF_Z (buf) - XFASTINT (w->window_end_pos))        && CHARPOS (top) <= BUF_ZV (buf)
361      {        && pos_visible_p (w, posint, &fully_p, &x, &y, NILP (partially))
362        /* If frame is up-to-date, and POSINT is < window end pos, use        && (!NILP (partially) || fully_p))
363           that info.  This doesn't work for POSINT == end pos, because      in_window = Qt;
364           the window end pos is actually the position _after_ the last  
365           char in the window.  */    if (!NILP (in_window) && !NILP (partially))
366        if (NILP (partially))      in_window = Fcons (make_number (x),
367          {                         Fcons (make_number (y),
368            pos_visible_p (w, posint, &fully_p, NILP (partially));                                Fcons (fully_p ? Qt : Qnil, Qnil)));
           in_window = fully_p ? Qt : Qnil;  
         }  
       else  
         in_window = Qt;  
     }  
   else if (posint > BUF_ZV (buf))  
     in_window = Qnil;  
   else if (CHARPOS (top) < BUF_BEGV (buf) || CHARPOS (top) > BUF_ZV (buf))  
     /* If window start is out of range, do something reasonable.  */  
     in_window = Qnil;  
   else  
     {  
       if (pos_visible_p (w, posint, &fully_p, NILP (partially)))  
         in_window = !NILP (partially) || fully_p ? Qt : Qnil;  
       else  
         in_window = Qnil;  
     }  
   
369    return in_window;    return in_window;
370  }  }
371    
# Line 3036  set_window_buffer (window, buffer, run_h Line 3023  set_window_buffer (window, buffer, run_h
3023  DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,  DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,
3024         doc: /* Make WINDOW display BUFFER as its contents.         doc: /* Make WINDOW display BUFFER as its contents.
3025  BUFFER can be a buffer or buffer name.  BUFFER can be a buffer or buffer name.
3026  Optional third arg KEEP_MARGINS non-nil means that WINDOW's current  Optional third arg KEEP-MARGINS non-nil means that WINDOW's current
3027  display margins, fringe widths, and scroll bar settings are maintained;  display margins, fringe widths, and scroll bar settings are maintained;
3028  the default is to reset these from BUFFER's local settings or the frame  the default is to reset these from BUFFER's local settings or the frame
3029  defaults.  */)  defaults.  */)
# Line 3075  defaults.  */) Line 3062  defaults.  */)
3062    
3063  DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,  DEFUN ("select-window", Fselect_window, Sselect_window, 1, 2, 0,
3064         doc: /* Select WINDOW.  Most editing will apply to WINDOW's buffer.         doc: /* Select WINDOW.  Most editing will apply to WINDOW's buffer.
3065  If WINDOW is not already selected, also make WINDOW's buffer current.  If WINDOW is not already selected, make WINDOW's buffer current
3066  Also make WINDOW the frame's selected window.  and make WINDOW the frame's selected window.
3067  Optional second arg NORECORD non-nil means  Optional second arg NORECORD non-nil means
3068  do not put this buffer at the front of the list of recently selected ones.  do not put this buffer at the front of the list of recently selected ones.
3069    
# Line 3283  If FRAME is nil, search only the selecte Line 3270  If FRAME is nil, search only the selecte
3270   unless `pop-up-frames' or `display-buffer-reuse-frames' is non-nil,   unless `pop-up-frames' or `display-buffer-reuse-frames' is non-nil,
3271   which means search visible and iconified frames.   which means search visible and iconified frames.
3272    
3273    If a full-width window on a splittable frame is available to display
3274    the buffer, it may be split, subject to the value of the variable
3275    `split-height-threshold'.
3276    
3277  If `even-window-heights' is non-nil, window heights will be evened out  If `even-window-heights' is non-nil, window heights will be evened out
3278  if displaying the buffer causes two vertically adjacent windows to be  if displaying the buffer causes two vertically adjacent windows to be
3279  displayed.  */)  displayed.  */)
# Line 3460  DEFUN ("force-window-update", Fforce_win Line 3451  DEFUN ("force-window-update", Fforce_win
3451         0, 1, 0,         0, 1, 0,
3452         doc: /* Force redisplay of all windows.         doc: /* Force redisplay of all windows.
3453  If optional arg OBJECT is a window, force redisplay of that window only.  If optional arg OBJECT is a window, force redisplay of that window only.
3454  If OBJECT is a buffer or buffer name, force redisplay of all windows  If OBJECT is a buffer or buffer name, force redisplay of all windows
3455  displaying that buffer.  */)  displaying that buffer.  */)
3456       (object)       (object)
3457       Lisp_Object object;       Lisp_Object object;
# Line 3482  displaying that buffer.  */) Line 3473  displaying that buffer.  */)
3473        ++update_mode_lines;        ++update_mode_lines;
3474        return Qt;        return Qt;
3475      }      }
3476        
3477    if (STRINGP (object))    if (STRINGP (object))
3478      object = Fget_buffer (object);      object = Fget_buffer (object);
3479    if (BUFFERP (object) && !NILP (XBUFFER (object)->name))    if (BUFFERP (object) && !NILP (XBUFFER (object)->name))
# Line 3547  temp_output_buffer_show (buf) Line 3538  temp_output_buffer_show (buf)
3538            Lisp_Object prev_window, prev_buffer;            Lisp_Object prev_window, prev_buffer;
3539            prev_window = selected_window;            prev_window = selected_window;
3540            XSETBUFFER (prev_buffer, old);            XSETBUFFER (prev_buffer, old);
3541              
3542            /* Select the window that was chosen, for running the hook.            /* Select the window that was chosen, for running the hook.
3543               Note: Both Fselect_window and select_window_norecord may               Note: Both Fselect_window and select_window_norecord may
3544               set-buffer to the buffer displayed in the window,               set-buffer to the buffer displayed in the window,
# Line 3598  DEFUN ("split-window", Fsplit_window, Ss Line 3589  DEFUN ("split-window", Fsplit_window, Ss
3589  WINDOW defaults to selected one and SIZE to half its size.  WINDOW defaults to selected one and SIZE to half its size.
3590  If optional third arg HORFLAG is non-nil, split side by side  If optional third arg HORFLAG is non-nil, split side by side
3591  and put SIZE columns in the first of the pair.  In that case,  and put SIZE columns in the first of the pair.  In that case,
3592  SIZE includes that window's scroll bar, or the divider column to its right.  */)  SIZE includes that window's scroll bar, or the divider column to its right.
3593    Returns the newly-created window.  */)
3594       (window, size, horflag)       (window, size, horflag)
3595       Lisp_Object window, size, horflag;       Lisp_Object window, size, horflag;
3596  {  {
# Line 6067  If TYPE is t, use the frame's scroll-bar Line 6059  If TYPE is t, use the frame's scroll-bar
6059      vertical_type = Qnil;      vertical_type = Qnil;
6060    
6061    if (!(EQ (vertical_type, Qnil)    if (!(EQ (vertical_type, Qnil)
6062          || EQ (vertical_type, Qleft)          || EQ (vertical_type, Qleft)
6063          || EQ (vertical_type, Qright)          || EQ (vertical_type, Qright)
6064          || EQ (vertical_type, Qt)))          || EQ (vertical_type, Qt)))
6065      error ("Invalid type of vertical scroll bar");      error ("Invalid type of vertical scroll bar");
# Line 6116  value.  */) Line 6108  value.  */)
6108                             Smooth scrolling                             Smooth scrolling
6109   ***********************************************************************/   ***********************************************************************/
6110    
6111  DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 1, 0,  DEFUN ("window-vscroll", Fwindow_vscroll, Swindow_vscroll, 0, 2, 0,
6112         doc: /* Return the amount by which WINDOW is scrolled vertically.         doc: /* Return the amount by which WINDOW is scrolled vertically.
6113  Use the selected window if WINDOW is nil or omitted.  Use the selected window if WINDOW is nil or omitted.
6114  Value is a multiple of the canonical character height of WINDOW.  */)  Normally, value is a multiple of the canonical character height of WINDOW;
6115       (window)  optional second arg PIXELS_P means value is measured in pixels.  */)
6116       Lisp_Object window;    (window, pixels_p)
6117         Lisp_Object window, pixels_p;
6118  {  {
6119    Lisp_Object result;    Lisp_Object result;
6120    struct frame *f;    struct frame *f;
# Line 6135  Value is a multiple of the canonical cha Line 6128  Value is a multiple of the canonical cha
6128    f = XFRAME (w->frame);    f = XFRAME (w->frame);
6129    
6130    if (FRAME_WINDOW_P (f))    if (FRAME_WINDOW_P (f))
6131      result = FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll);      result = (NILP (pixels_p)
6132                  ? FRAME_CANON_Y_FROM_PIXEL_Y (f, -w->vscroll)
6133                  : make_number (-w->vscroll));
6134    else    else
6135      result = make_number (0);      result = make_number (0);
6136    return result;    return result;
# Line 6143  Value is a multiple of the canonical cha Line 6138  Value is a multiple of the canonical cha
6138    
6139    
6140  DEFUN ("set-window-vscroll", Fset_window_vscroll, Sset_window_vscroll,  DEFUN ("set-window-vscroll", Fset_window_vscroll, Sset_window_vscroll,
6141         2, 2, 0,         2, 3, 0,
6142         doc: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL.         doc: /* Set amount by which WINDOW should be scrolled vertically to VSCROLL.
6143  WINDOW nil means use the selected window.  VSCROLL is a non-negative  WINDOW nil means use the selected window.  Normally, VSCROLL is a
6144  multiple of the canonical character height of WINDOW.  */)  non-negative multiple of the canonical character height of WINDOW;
6145       (window, vscroll)  optional third arg PIXELS_P non-nil means that VSCROLL is in pixels.  */)
6146       Lisp_Object window, vscroll;    (window, vscroll, pixels_p)
6147         Lisp_Object window, vscroll, pixels_p;
6148  {  {
6149    struct window *w;    struct window *w;
6150    struct frame *f;    struct frame *f;
# Line 6166  multiple of the canonical character heig Line 6162  multiple of the canonical character heig
6162      {      {
6163        int old_dy = w->vscroll;        int old_dy = w->vscroll;
6164    
6165        w->vscroll = - FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll);        w->vscroll = - (NILP (pixels_p)
6166                          ? FRAME_LINE_HEIGHT (f) * XFLOATINT (vscroll)
6167                          : XFLOATINT (vscroll));
6168        w->vscroll = min (w->vscroll, 0);        w->vscroll = min (w->vscroll, 0);
6169    
6170        /* Adjust glyph matrix of the frame if the virtual display        /* Adjust glyph matrix of the frame if the virtual display
# Line 6178  multiple of the canonical character heig Line 6176  multiple of the canonical character heig
6176        XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;        XBUFFER (w->buffer)->prevent_redisplay_optimizations_p = 1;
6177      }      }
6178    
6179    return Fwindow_vscroll (window);    return Fwindow_vscroll (window, pixels_p);
6180  }  }
6181    
6182    
# Line 6506  using `special-display-function'.  See a Line 6504  using `special-display-function'.  See a
6504  An element of the list can be a list instead of just a string.  An element of the list can be a list instead of just a string.
6505  There are two ways to use a list as an element:  There are two ways to use a list as an element:
6506    (BUFFER FRAME-PARAMETERS...)   (BUFFER FUNCTION OTHER-ARGS...)    (BUFFER FRAME-PARAMETERS...)   (BUFFER FUNCTION OTHER-ARGS...)
6507  In the first case, FRAME-PARAMETERS are used to create the frame.  In the first case, the FRAME-PARAMETERS are pairs of the form
6508  In the latter case, FUNCTION is called with BUFFER as the first argument,  \(PARAMETER . VALUE); these parameter values are used to create the frame.
6509  followed by OTHER-ARGS--it can display BUFFER in any way it likes.  In the second case, FUNCTION is called with BUFFER as the first argument,
6510    followed by the OTHER-ARGS--it can display BUFFER in any way it likes.
6511  All this is done by the function found in `special-display-function'.  All this is done by the function found in `special-display-function'.
6512    
6513  If the specified frame parameters include (same-buffer . t), the  If the specified frame parameters include (same-buffer . t), the
# Line 6531  using `special-display-function'. Line 6530  using `special-display-function'.
6530  An element of the list can be a list instead of just a string.  An element of the list can be a list instead of just a string.
6531  There are two ways to use a list as an element:  There are two ways to use a list as an element:
6532    (REGEXP FRAME-PARAMETERS...)   (REGEXP FUNCTION OTHER-ARGS...)    (REGEXP FRAME-PARAMETERS...)   (REGEXP FUNCTION OTHER-ARGS...)
6533  In the first case, FRAME-PARAMETERS are used to create the frame.  In the first case, the FRAME-PARAMETERS are pairs of the form
6534  In the latter case, FUNCTION is called with the buffer as first argument,  \(PARAMETER . VALUE); these parameter values are used to create the frame.
6535  followed by OTHER-ARGS--it can display the buffer in any way it likes.  In the second case, FUNCTION is called with BUFFER as the first argument,
6536    followed by the OTHER-ARGS--it can display the buffer in any way it likes.
6537  All this is done by the function found in `special-display-function'.  All this is done by the function found in `special-display-function'.
6538    
6539  If the specified frame parameters include (same-buffer . t), the  If the specified frame parameters include (same-buffer . t), the
# Line 6599  See also `same-window-buffer-names'.  */ Line 6599  See also `same-window-buffer-names'.  */
6599    next_screen_context_lines = 2;    next_screen_context_lines = 2;
6600    
6601    DEFVAR_INT ("split-height-threshold", &split_height_threshold,    DEFVAR_INT ("split-height-threshold", &split_height_threshold,
6602                doc: /* *display-buffer would prefer to split the largest window if this large.                doc: /* *A window must be at least this tall to be eligible for splitting by `display-buffer'.
6603  If there is only one window, it is split regardless of this value.  */);  If there is only one window, it is split regardless of this value.  */);
6604    split_height_threshold = 500;    split_height_threshold = 500;
6605    

Legend:
Removed from v.1.445.2.2  
changed lines
  Added in v.1.445.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26