comparison src/window.c @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 84b14dcb0985
children abe6d1db359e
comparison
equal deleted inserted replaced
439:357dd071b03c 440:8de8e3f6228a
708 708
709 int 709 int
710 window_truncation_on (struct window *w) 710 window_truncation_on (struct window *w)
711 { 711 {
712 /* Minibuffer windows are never truncated. 712 /* Minibuffer windows are never truncated.
713 ### is this the right way ? */ 713 #### is this the right way ? */
714 if (MINI_WINDOW_P (w)) 714 if (MINI_WINDOW_P (w))
715 return 0; 715 return 0;
716 716
717 /* Horizontally scrolled windows are truncated. */ 717 /* Horizontally scrolled windows are truncated. */
718 if (w->hscroll) 718 if (w->hscroll)
2603 { 2603 {
2604 Lisp_Object new_buffer; 2604 Lisp_Object new_buffer;
2605 new_buffer = Fother_buffer (obj, Qnil, Qnil); 2605 new_buffer = Fother_buffer (obj, Qnil, Qnil);
2606 if (NILP (new_buffer)) 2606 if (NILP (new_buffer))
2607 new_buffer = Fget_buffer_create (QSscratch); 2607 new_buffer = Fget_buffer_create (QSscratch);
2608 Fset_window_buffer (w, new_buffer); 2608 Fset_window_buffer (w, new_buffer, Qnil);
2609 if (EQ (w, Fselected_window (Qnil))) 2609 if (EQ (w, Fselected_window (Qnil)))
2610 Fset_buffer (p->buffer); 2610 Fset_buffer (p->buffer);
2611 } 2611 }
2612 else 2612 else
2613 Fdelete_window (w, Qnil); 2613 Fdelete_window (w, Qnil);
2675 else 2675 else
2676 { 2676 {
2677 /* Otherwise show a different buffer in the 2677 /* Otherwise show a different buffer in the
2678 window. */ 2678 window. */
2679 p->dedicated = Qnil; 2679 p->dedicated = Qnil;
2680 Fset_window_buffer (w, another_buffer); 2680 Fset_window_buffer (w, another_buffer, Qnil);
2681 if (EQ (w, Fselected_window (Qnil))) 2681 if (EQ (w, Fselected_window (Qnil)))
2682 Fset_buffer (p->buffer); 2682 Fset_buffer (p->buffer);
2683 } 2683 }
2684 } 2684 }
2685 break; 2685 break;
2976 window_min_width = MIN_SAFE_WINDOW_WIDTH; 2976 window_min_width = MIN_SAFE_WINDOW_WIDTH;
2977 if (window_min_height < MIN_SAFE_WINDOW_HEIGHT) 2977 if (window_min_height < MIN_SAFE_WINDOW_HEIGHT)
2978 window_min_height = MIN_SAFE_WINDOW_HEIGHT; 2978 window_min_height = MIN_SAFE_WINDOW_HEIGHT;
2979 } 2979 }
2980 2980
2981 static int
2982 frame_min_height (struct frame *frame)
2983 {
2984 /* For height, we have to see whether the frame has a minibuffer, and
2985 whether it wants a modeline. */
2986 return (FRAME_MINIBUF_ONLY_P (frame) ? MIN_SAFE_WINDOW_HEIGHT - 1
2987 : (! FRAME_HAS_MINIBUF_P (frame)) ? MIN_SAFE_WINDOW_HEIGHT
2988 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1);
2989 }
2990
2991 /* Return non-zero if both frame sizes are less than or equal to
2992 minimal allowed values. ROWS and COLS are in characters */
2993 int
2994 frame_size_valid_p (struct frame *frame, int rows, int cols)
2995 {
2996 return (rows >= frame_min_height (frame)
2997 && cols >= MIN_SAFE_WINDOW_WIDTH);
2998 }
2999
3000 /* Return non-zero if both frame sizes are less than or equal to
3001 minimal allowed values. WIDTH and HEIGHT are in pixels */
3002 int
3003 frame_pixsize_valid_p (struct frame *frame, int width, int height)
3004 {
3005 int rows, cols;
3006 pixel_to_real_char_size (frame, width, height, &cols, &rows);
3007 return frame_size_valid_p (frame, rows, cols);
3008 }
3009
2981 /* If *ROWS or *COLS are too small a size for FRAME, set them to the 3010 /* If *ROWS or *COLS are too small a size for FRAME, set them to the
2982 minimum allowable size. */ 3011 minimum allowable size. */
2983 void 3012 void
2984 check_frame_size (struct frame *frame, int *rows, int *cols) 3013 check_frame_size (struct frame *frame, int *rows, int *cols)
2985 { 3014 {
2986 /* For height, we have to see whether the frame has a minibuffer, and 3015 int min_height = frame_min_height (frame);
2987 whether it wants a modeline. */
2988 int min_height =
2989 (FRAME_MINIBUF_ONLY_P (frame) ? MIN_SAFE_WINDOW_HEIGHT - 1
2990 : (! FRAME_HAS_MINIBUF_P (frame)) ? MIN_SAFE_WINDOW_HEIGHT
2991 : 2 * MIN_SAFE_WINDOW_HEIGHT - 1);
2992 3016
2993 if (*rows < min_height) 3017 if (*rows < min_height)
2994 *rows = min_height; 3018 *rows = min_height;
2995 if (*cols < MIN_SAFE_WINDOW_WIDTH) 3019 if (*cols < MIN_SAFE_WINDOW_WIDTH)
2996 *cols = MIN_SAFE_WINDOW_WIDTH; 3020 *cols = MIN_SAFE_WINDOW_WIDTH;
3136 } 3160 }
3137 3161
3138 3162
3139 static int window_select_count; 3163 static int window_select_count;
3140 3164
3141 DEFUN ("set-window-buffer", Fset_window_buffer, 2, 2, 0, /* 3165 DEFUN ("set-window-buffer", Fset_window_buffer, 2, 3, 0, /*
3142 Make WINDOW display BUFFER as its contents. 3166 Make WINDOW display BUFFER as its contents.
3143 BUFFER can be a buffer or buffer name. 3167 BUFFER can be a buffer or buffer name.
3144 */ 3168
3145 (window, buffer)) 3169 With non-nil optional argument `norecord', do not modify the
3170 global or per-frame buffer ordering.
3171 */
3172 (window, buffer, norecord))
3146 { 3173 {
3147 Lisp_Object tem; 3174 Lisp_Object tem;
3148 struct window *w = decode_window (window); 3175 struct window *w = decode_window (window);
3149 3176
3150 buffer = Fget_buffer (buffer); 3177 buffer = Fget_buffer (buffer);
3199 SET_LAST_FACECHANGE (w); 3226 SET_LAST_FACECHANGE (w);
3200 MARK_WINDOWS_CHANGED (w); 3227 MARK_WINDOWS_CHANGED (w);
3201 recompute_all_cached_specifiers_in_window (w); 3228 recompute_all_cached_specifiers_in_window (w);
3202 if (EQ (window, Fselected_window (Qnil))) 3229 if (EQ (window, Fselected_window (Qnil)))
3203 { 3230 {
3231 if (NILP (norecord))
3232 Frecord_buffer (buffer);
3233
3204 Fset_buffer (buffer); 3234 Fset_buffer (buffer);
3205 } 3235 }
3206 return Qnil; 3236 return Qnil;
3207 } 3237 }
3208 3238
3501 3531
3502 XFRAME (p->frame)->mirror_dirty = 1; 3532 XFRAME (p->frame)->mirror_dirty = 1;
3503 /* do this last (after the window is completely initialized and 3533 /* do this last (after the window is completely initialized and
3504 the mirror-dirty flag is set) so that specifier recomputation 3534 the mirror-dirty flag is set) so that specifier recomputation
3505 caused as a result of this will work properly and not abort. */ 3535 caused as a result of this will work properly and not abort. */
3506 Fset_window_buffer (new, o->buffer); 3536 Fset_window_buffer (new, o->buffer, Qt);
3507 return new; 3537 return new;
3508 } 3538 }
3509 3539
3510 3540
3511 DEFUN ("enlarge-window", Fenlarge_window, 1, 3, "_p", /* 3541 DEFUN ("enlarge-window", Fenlarge_window, 1, 3, "_p", /*
4049 /* Determine parameters to test for partial line scrolling with. */ 4079 /* Determine parameters to test for partial line scrolling with. */
4050 dla = window_display_lines (w, CURRENT_DISP); 4080 dla = window_display_lines (w, CURRENT_DISP);
4051 4081
4052 if (INTP (Vwindow_pixel_scroll_increment)) 4082 if (INTP (Vwindow_pixel_scroll_increment))
4053 fheight = XINT (Vwindow_pixel_scroll_increment); 4083 fheight = XINT (Vwindow_pixel_scroll_increment);
4054 else if (!NILP (Vwindow_pixel_scroll_increment)); 4084 else if (!NILP (Vwindow_pixel_scroll_increment))
4055 default_face_height_and_width (window, &fheight, &fwidth); 4085 default_face_height_and_width (window, &fheight, &fwidth);
4056 4086
4057 if (Dynarr_length (dla) >= 1) 4087 if (Dynarr_length (dla) >= 1)
4058 modeline = Dynarr_atp (dla, 0)->modeline; 4088 modeline = Dynarr_atp (dla, 0)->modeline;
4059 4089
4156 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp), 4186 set_marker_restricted (w->start[CURRENT_DISP], make_int (startp),
4157 w->buffer); 4187 w->buffer);
4158 w->force_start = 1; 4188 w->force_start = 1;
4159 w->start_at_line_beg = beginning_of_line_p (b, startp); 4189 w->start_at_line_beg = beginning_of_line_p (b, startp);
4160 MARK_WINDOWS_CHANGED (w); 4190 MARK_WINDOWS_CHANGED (w);
4191
4192 /* #### Scroll back by less than a line. This code was
4193 originally for scrolling over large pixmaps and it
4194 loses when a line being *exposed* at the top of the
4195 window is bigger than the current one. However, for
4196 pixel based scrolling in general we can guess that
4197 the line we are going to display is probably the same
4198 size as the one we are on. In that instance we can
4199 have a reasonable stab at a suitable top clip. Fixing
4200 this properly is hard (and probably slow) as we would
4201 have to call redisplay to figure out the exposed line
4202 size. */
4203 if (!NILP (Vwindow_pixel_scroll_increment)
4204 && Dynarr_length (dla) >= (1 + modeline)
4205 && dl->ascent + fheight * value > 0)
4206 {
4207 WINDOW_TEXT_TOP_CLIP (w) = (dl->ascent + fheight * value);
4208 }
4161 4209
4162 if (!point_would_be_visible (w, startp, XINT (point))) 4210 if (!point_would_be_visible (w, startp, XINT (point)))
4163 { 4211 {
4164 Bufpos new_point; 4212 Bufpos new_point;
4165 4213