aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
authorMiles Bader2004-11-19 06:55:13 +0000
committerMiles Bader2004-11-19 06:55:13 +0000
commit148396568043f50499340911c656c7234cefd50d (patch)
tree6bb3c035d0194f7e26bc8254a5189cb5a8722ce2 /src/window.c
parent77229aad98d5c81a559fb1ba5161ed2a7f13aec4 (diff)
parent6dd06769a945f59e048d8328e37a77b41f8c798f (diff)
downloademacs-148396568043f50499340911c656c7234cefd50d.tar.gz
emacs-148396568043f50499340911c656c7234cefd50d.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-72
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-693 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-695 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-696 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-697 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-702 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-703 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-704 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-708 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-72 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-73 Merge from emacs--cvs-trunk--0
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c98
1 files changed, 83 insertions, 15 deletions
diff --git a/src/window.c b/src/window.c
index 976e2b505cf..3f8fa513619 100644
--- a/src/window.c
+++ b/src/window.c
@@ -241,7 +241,8 @@ make_window ()
241 register struct window *p; 241 register struct window *p;
242 242
243 p = allocate_window (); 243 p = allocate_window ();
244 XSETFASTINT (p->sequence_number, ++sequence_number); 244 ++sequence_number;
245 XSETFASTINT (p->sequence_number, sequence_number);
245 XSETFASTINT (p->left_col, 0); 246 XSETFASTINT (p->left_col, 0);
246 XSETFASTINT (p->top_line, 0); 247 XSETFASTINT (p->top_line, 0);
247 XSETFASTINT (p->total_lines, 0); 248 XSETFASTINT (p->total_lines, 0);
@@ -2657,6 +2658,9 @@ shrink_windows (total, size, nchildren, shrinkable,
2657 --shrinkable; 2658 --shrinkable;
2658 total_removed += smallest; 2659 total_removed += smallest;
2659 2660
2661 /* We don't know what the smallest is now. */
2662 smallest = total;
2663
2660 /* Out of for, just remove one window at the time and 2664 /* Out of for, just remove one window at the time and
2661 check again if we have enough space. */ 2665 check again if we have enough space. */
2662 break; 2666 break;
@@ -2681,6 +2685,16 @@ shrink_windows (total, size, nchildren, shrinkable,
2681 that are left and still can be shrunk. */ 2685 that are left and still can be shrunk. */
2682 while (total_shrink > total_removed) 2686 while (total_shrink > total_removed)
2683 { 2687 {
2688 int nonzero_sizes = 0;
2689 int nonzero_idx = -1;
2690
2691 for (i = 0; i < nchildren; ++i)
2692 if (new_sizes[i] > 0)
2693 {
2694 ++nonzero_sizes;
2695 nonzero_idx = i;
2696 }
2697
2684 for (i = 0; i < nchildren; ++i) 2698 for (i = 0; i < nchildren; ++i)
2685 if (new_sizes[i] > min_size) 2699 if (new_sizes[i] > min_size)
2686 { 2700 {
@@ -2691,6 +2705,25 @@ shrink_windows (total, size, nchildren, shrinkable,
2691 check again if we have enough space. */ 2705 check again if we have enough space. */
2692 break; 2706 break;
2693 } 2707 }
2708
2709
2710 /* Special case, only one window left. */
2711 if (nonzero_sizes == 1)
2712 break;
2713 }
2714
2715 /* Any surplus due to rounding, we add to windows that are left. */
2716 while (total_shrink < total_removed)
2717 {
2718 for (i = 0; i < nchildren; ++i)
2719 {
2720 if (new_sizes[i] != 0 && total_shrink < total_removed)
2721 {
2722 ++new_sizes[i];
2723 --total_removed;
2724 break;
2725 }
2726 }
2694 } 2727 }
2695 2728
2696 return new_sizes; 2729 return new_sizes;
@@ -3117,7 +3150,8 @@ selects the buffer of the selected window before each command. */)
3117 w = XWINDOW (window); 3150 w = XWINDOW (window);
3118 w->frozen_window_start_p = 0; 3151 w->frozen_window_start_p = 0;
3119 3152
3120 XSETFASTINT (w->use_time, ++window_select_count); 3153 ++window_select_count;
3154 XSETFASTINT (w->use_time, window_select_count);
3121 if (EQ (window, selected_window)) 3155 if (EQ (window, selected_window))
3122 return window; 3156 return window;
3123 3157
@@ -3608,7 +3642,8 @@ make_dummy_parent (window)
3608 = ((struct Lisp_Vector *)o)->contents[i]; 3642 = ((struct Lisp_Vector *)o)->contents[i];
3609 XSETWINDOW (new, p); 3643 XSETWINDOW (new, p);
3610 3644
3611 XSETFASTINT (p->sequence_number, ++sequence_number); 3645 ++sequence_number;
3646 XSETFASTINT (p->sequence_number, sequence_number);
3612 3647
3613 /* Put new into window structure in place of window */ 3648 /* Put new into window structure in place of window */
3614 replace_window (window, new); 3649 replace_window (window, new);
@@ -4506,7 +4541,7 @@ window_scroll_pixel_based (window, n, whole, noerror)
4506 results for variable height lines. */ 4541 results for variable height lines. */
4507 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); 4542 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID);
4508 it.current_y = it.last_visible_y; 4543 it.current_y = it.last_visible_y;
4509 move_it_vertically (&it, - window_box_height (w) / 2); 4544 move_it_vertically_backward (&it, window_box_height (w) / 2);
4510 4545
4511 /* The function move_iterator_vertically may move over more than 4546 /* The function move_iterator_vertically may move over more than
4512 the specified y-distance. If it->w is small, e.g. a 4547 the specified y-distance. If it->w is small, e.g. a
@@ -4516,7 +4551,7 @@ window_scroll_pixel_based (window, n, whole, noerror)
4516 if (it.current_y <= 0) 4551 if (it.current_y <= 0)
4517 { 4552 {
4518 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID); 4553 init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID);
4519 move_it_vertically (&it, 0); 4554 move_it_vertically_backward (&it, 0);
4520 it.current_y = 0; 4555 it.current_y = 0;
4521 } 4556 }
4522 4557
@@ -5185,7 +5220,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5185 5220
5186 SET_TEXT_POS (pt, PT, PT_BYTE); 5221 SET_TEXT_POS (pt, PT, PT_BYTE);
5187 start_display (&it, w, pt); 5222 start_display (&it, w, pt);
5188 move_it_vertically (&it, - window_box_height (w) / 2); 5223 move_it_vertically_backward (&it, window_box_height (w) / 2);
5189 charpos = IT_CHARPOS (it); 5224 charpos = IT_CHARPOS (it);
5190 bytepos = IT_BYTEPOS (it); 5225 bytepos = IT_BYTEPOS (it);
5191 } 5226 }
@@ -5193,29 +5228,62 @@ and redisplay normally--don't erase and redraw the frame. */)
5193 { 5228 {
5194 struct it it; 5229 struct it it;
5195 struct text_pos pt; 5230 struct text_pos pt;
5196 int y0, y1, h, nlines; 5231 int nlines = - XINT (arg);
5232 int extra_line_spacing;
5233 int h = window_box_height (w);
5197 5234
5198 SET_TEXT_POS (pt, PT, PT_BYTE); 5235 SET_TEXT_POS (pt, PT, PT_BYTE);
5199 start_display (&it, w, pt); 5236 start_display (&it, w, pt);
5200 y0 = it.current_y; 5237
5238 /* Be sure we have the exact height of the full line containing PT. */
5239 move_it_by_lines (&it, 0, 1);
5201 5240
5202 /* The amount of pixels we have to move back is the window 5241 /* The amount of pixels we have to move back is the window
5203 height minus what's displayed in the line containing PT, 5242 height minus what's displayed in the line containing PT,
5204 and the lines below. */ 5243 and the lines below. */
5205 nlines = - XINT (arg) - 1; 5244 it.current_y = 0;
5245 it.vpos = 0;
5206 move_it_by_lines (&it, nlines, 1); 5246 move_it_by_lines (&it, nlines, 1);
5207 5247
5208 y1 = line_bottom_y (&it); 5248 if (it.vpos == nlines)
5249 h -= it.current_y;
5250 else
5251 {
5252 /* Last line has no newline */
5253 h -= line_bottom_y (&it);
5254 it.vpos++;
5255 }
5256
5257 /* Don't reserve space for extra line spacing of last line. */
5258 extra_line_spacing = it.max_extra_line_spacing;
5209 5259
5210 /* If we can't move down NLINES lines because we hit 5260 /* If we can't move down NLINES lines because we hit
5211 the end of the buffer, count in some empty lines. */ 5261 the end of the buffer, count in some empty lines. */
5212 if (it.vpos < nlines) 5262 if (it.vpos < nlines)
5213 y1 += (nlines - it.vpos) * FRAME_LINE_HEIGHT (it.f); 5263 {
5214 5264 nlines -= it.vpos;
5215 h = window_box_height (w) - (y1 - y0); 5265 extra_line_spacing = it.extra_line_spacing;
5266 h -= nlines * (FRAME_LINE_HEIGHT (it.f) + extra_line_spacing);
5267 }
5268 if (h <= 0)
5269 return Qnil;
5216 5270
5271 /* Now find the new top line (starting position) of the window. */
5217 start_display (&it, w, pt); 5272 start_display (&it, w, pt);
5218 move_it_vertically (&it, - h); 5273 it.current_y = 0;
5274 move_it_vertically_backward (&it, h);
5275
5276 /* If extra line spacing is present, we may move too far
5277 back. This causes the last line to be only partially
5278 visible (which triggers redisplay to recenter that line
5279 in the middle), so move forward.
5280 But ignore extra line spacing on last line, as it is not
5281 considered to be part of the visible height of the line.
5282 */
5283 h += extra_line_spacing;
5284 while (-it.current_y > h)
5285 move_it_by_lines (&it, 1, 1);
5286
5219 charpos = IT_CHARPOS (it); 5287 charpos = IT_CHARPOS (it);
5220 bytepos = IT_BYTEPOS (it); 5288 bytepos = IT_BYTEPOS (it);
5221 } 5289 }
@@ -5817,7 +5885,7 @@ save_window_save (window, vector, i)
5817 p = SAVED_WINDOW_N (vector, i); 5885 p = SAVED_WINDOW_N (vector, i);
5818 w = XWINDOW (window); 5886 w = XWINDOW (window);
5819 5887
5820 XSETFASTINT (w->temslot, i++); 5888 XSETFASTINT (w->temslot, i); i++;
5821 p->window = window; 5889 p->window = window;
5822 p->buffer = w->buffer; 5890 p->buffer = w->buffer;
5823 p->left_col = w->left_col; 5891 p->left_col = w->left_col;