aboutsummaryrefslogtreecommitdiffstats
path: root/src/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c90
1 files changed, 46 insertions, 44 deletions
diff --git a/src/window.c b/src/window.c
index 3c867145620..d39efa8071d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -56,7 +56,7 @@ Lisp_Object Qwindowp, Qwindow_live_p;
56static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer; 56static Lisp_Object Qwindow_configuration_p, Qrecord_window_buffer;
57static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer; 57static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
58static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; 58static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
59static Lisp_Object Qresize_root_window, Qresize_root_window_vertically; 59static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically;
60static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; 60static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
61static Lisp_Object Qsafe, Qabove, Qbelow; 61static Lisp_Object Qsafe, Qabove, Qbelow;
62static Lisp_Object Qauto_buffer_name; 62static Lisp_Object Qauto_buffer_name;
@@ -410,14 +410,6 @@ buffer of the selected window before each command. */)
410 return select_window (window, norecord, 0); 410 return select_window (window, norecord, 0);
411} 411}
412 412
413DEFUN ("window-clone-number", Fwindow_clone_number, Swindow_clone_number, 0, 1, 0,
414 doc: /* Return WINDOW's clone number.
415WINDOW can be any window and defaults to the selected one. */)
416 (Lisp_Object window)
417{
418 return decode_any_window (window)->clone_number;
419}
420
421DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0, 413DEFUN ("window-buffer", Fwindow_buffer, Swindow_buffer, 0, 1, 0,
422 doc: /* Return the buffer that WINDOW is displaying. 414 doc: /* Return the buffer that WINDOW is displaying.
423WINDOW can be any window and defaults to the selected one. 415WINDOW can be any window and defaults to the selected one.
@@ -693,6 +685,7 @@ WINDOW must be a live window and defaults to the selected one. */)
693 685
694DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0, 686DEFUN ("set-window-hscroll", Fset_window_hscroll, Sset_window_hscroll, 2, 2, 0,
695 doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL. 687 doc: /* Set number of columns WINDOW is scrolled from left margin to NCOL.
688If WINDOW is nil, the selected window is used.
696Return NCOL. NCOL should be zero or positive. 689Return NCOL. NCOL should be zero or positive.
697 690
698Note that if `automatic-hscrolling' is non-nil, you cannot scroll the 691Note that if `automatic-hscrolling' is non-nil, you cannot scroll the
@@ -1360,6 +1353,7 @@ if it isn't already recorded. */)
1360 struct text_pos startp; 1353 struct text_pos startp;
1361 struct it it; 1354 struct it it;
1362 struct buffer *old_buffer = NULL; 1355 struct buffer *old_buffer = NULL;
1356 void *itdata = NULL;
1363 1357
1364 /* Cannot use Fvertical_motion because that function doesn't 1358 /* Cannot use Fvertical_motion because that function doesn't
1365 cope with variable-height lines. */ 1359 cope with variable-height lines. */
@@ -1381,11 +1375,13 @@ if it isn't already recorded. */)
1381 else 1375 else
1382 SET_TEXT_POS_FROM_MARKER (startp, w->start); 1376 SET_TEXT_POS_FROM_MARKER (startp, w->start);
1383 1377
1378 itdata = bidi_shelve_cache ();
1384 start_display (&it, w, startp); 1379 start_display (&it, w, startp);
1385 move_it_vertically (&it, window_box_height (w)); 1380 move_it_vertically (&it, window_box_height (w));
1386 if (it.current_y < it.last_visible_y) 1381 if (it.current_y < it.last_visible_y)
1387 move_it_past_eol (&it); 1382 move_it_past_eol (&it);
1388 value = make_number (IT_CHARPOS (it)); 1383 value = make_number (IT_CHARPOS (it));
1384 bidi_unshelve_cache (itdata);
1389 1385
1390 if (old_buffer) 1386 if (old_buffer)
1391 set_buffer_internal (old_buffer); 1387 set_buffer_internal (old_buffer);
@@ -1420,7 +1416,7 @@ Return POS. */)
1420 1416
1421DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0, 1417DEFUN ("set-window-start", Fset_window_start, Sset_window_start, 2, 3, 0,
1422 doc: /* Make display in WINDOW start at position POS in WINDOW's buffer. 1418 doc: /* Make display in WINDOW start at position POS in WINDOW's buffer.
1423WINDOW defaults to the selected window. Return POS. 1419If WINDOW is nil, the selected window is used. Return POS.
1424Optional third arg NOFORCE non-nil inhibits next redisplay from 1420Optional third arg NOFORCE non-nil inhibits next redisplay from
1425overriding motion of point in order to display at this exact start. */) 1421overriding motion of point in order to display at this exact start. */)
1426 (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce) 1422 (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce)
@@ -2578,7 +2574,7 @@ selected frame and no others. */)
2578static Lisp_Object 2574static Lisp_Object
2579resize_root_window (Lisp_Object window, Lisp_Object delta, Lisp_Object horizontal, Lisp_Object ignore) 2575resize_root_window (Lisp_Object window, Lisp_Object delta, Lisp_Object horizontal, Lisp_Object ignore)
2580{ 2576{
2581 return call4 (Qresize_root_window, window, delta, horizontal, ignore); 2577 return call4 (Qwindow_resize_root_window, window, delta, horizontal, ignore);
2582} 2578}
2583 2579
2584 2580
@@ -3089,18 +3085,6 @@ set_window_buffer (Lisp_Object window, Lisp_Object buffer, int run_hooks_p, int
3089 unbind_to (count, Qnil); 3085 unbind_to (count, Qnil);
3090} 3086}
3091 3087
3092DEFUN ("set-window-clone-number", Fset_window_clone_number, Sset_window_clone_number, 2, 2, 0,
3093 doc: /* Set WINDOW's clone number to CLONE-NUMBER.
3094WINDOW can be any window and defaults to the selected one. */)
3095 (Lisp_Object window, Lisp_Object clone_number)
3096{
3097 register struct window *w = decode_any_window (window);
3098
3099 CHECK_NUMBER (clone_number);
3100 w->clone_number = clone_number;
3101 return w->clone_number;
3102}
3103
3104DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0, 3088DEFUN ("set-window-buffer", Fset_window_buffer, Sset_window_buffer, 2, 3, 0,
3105 doc: /* Make WINDOW display BUFFER-OR-NAME as its contents. 3089 doc: /* Make WINDOW display BUFFER-OR-NAME as its contents.
3106WINDOW has to be a live window and defaults to the selected one. 3090WINDOW has to be a live window and defaults to the selected one.
@@ -3291,7 +3275,6 @@ make_parent_window (Lisp_Object window, int horflag)
3291 3275
3292 ++sequence_number; 3276 ++sequence_number;
3293 XSETFASTINT (p->sequence_number, sequence_number); 3277 XSETFASTINT (p->sequence_number, sequence_number);
3294 XSETFASTINT (p->clone_number, sequence_number);
3295 3278
3296 replace_window (window, parent, 1); 3279 replace_window (window, parent, 1);
3297 3280
@@ -3337,7 +3320,6 @@ make_window (void)
3337 XSETFASTINT (w->use_time, 0); 3320 XSETFASTINT (w->use_time, 0);
3338 ++sequence_number; 3321 ++sequence_number;
3339 XSETFASTINT (w->sequence_number, sequence_number); 3322 XSETFASTINT (w->sequence_number, sequence_number);
3340 XSETFASTINT (w->clone_number, sequence_number);
3341 w->temslot = w->last_modified = w->last_overlay_modified = Qnil; 3323 w->temslot = w->last_modified = w->last_overlay_modified = Qnil;
3342 XSETFASTINT (w->last_point, 0); 3324 XSETFASTINT (w->last_point, 0);
3343 w->last_had_star = w->vertical_scroll_bar = Qnil; 3325 w->last_had_star = w->vertical_scroll_bar = Qnil;
@@ -4076,7 +4058,8 @@ grow_mini_window (struct window *w, int delta)
4076 4058
4077 root = FRAME_ROOT_WINDOW (f); 4059 root = FRAME_ROOT_WINDOW (f);
4078 r = XWINDOW (root); 4060 r = XWINDOW (root);
4079 value = call2 (Qresize_root_window_vertically, root, make_number (- delta)); 4061 value = call2 (Qwindow_resize_root_window_vertically,
4062 root, make_number (- delta));
4080 if (INTEGERP (value) && window_resize_check (r, 0)) 4063 if (INTEGERP (value) && window_resize_check (r, 0))
4081 { 4064 {
4082 BLOCK_INPUT; 4065 BLOCK_INPUT;
@@ -4110,7 +4093,7 @@ shrink_mini_window (struct window *w)
4110 { 4093 {
4111 root = FRAME_ROOT_WINDOW (f); 4094 root = FRAME_ROOT_WINDOW (f);
4112 r = XWINDOW (root); 4095 r = XWINDOW (root);
4113 value = call2 (Qresize_root_window_vertically, 4096 value = call2 (Qwindow_resize_root_window_vertically,
4114 root, make_number (size - 1)); 4097 root, make_number (size - 1));
4115 if (INTEGERP (value) && window_resize_check (r, 0)) 4098 if (INTEGERP (value) && window_resize_check (r, 0))
4116 { 4099 {
@@ -4261,6 +4244,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4261 /* True if we fiddled the window vscroll field without really scrolling. */ 4244 /* True if we fiddled the window vscroll field without really scrolling. */
4262 int vscrolled = 0; 4245 int vscrolled = 0;
4263 int x, y, rtop, rbot, rowh, vpos; 4246 int x, y, rtop, rbot, rowh, vpos;
4247 void *itdata = NULL;
4264 4248
4265 SET_TEXT_POS_FROM_MARKER (start, w->start); 4249 SET_TEXT_POS_FROM_MARKER (start, w->start);
4266 4250
@@ -4271,6 +4255,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4271 4255
4272 if (!pos_visible_p (w, PT, &x, &y, &rtop, &rbot, &rowh, &vpos)) 4256 if (!pos_visible_p (w, PT, &x, &y, &rtop, &rbot, &rowh, &vpos))
4273 { 4257 {
4258 itdata = bidi_shelve_cache ();
4274 /* Move backward half the height of the window. Performance note: 4259 /* Move backward half the height of the window. Performance note:
4275 vmotion used here is about 10% faster, but would give wrong 4260 vmotion used here is about 10% faster, but would give wrong
4276 results for variable height lines. */ 4261 results for variable height lines. */
@@ -4291,6 +4276,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4291 } 4276 }
4292 4277
4293 start = it.current.pos; 4278 start = it.current.pos;
4279 bidi_unshelve_cache (itdata);
4294 } 4280 }
4295 else if (auto_window_vscroll_p) 4281 else if (auto_window_vscroll_p)
4296 { 4282 {
@@ -4353,6 +4339,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4353 Fset_window_vscroll (window, make_number (0), Qt); 4339 Fset_window_vscroll (window, make_number (0), Qt);
4354 } 4340 }
4355 4341
4342 itdata = bidi_shelve_cache ();
4356 /* If scroll_preserve_screen_position is non-nil, we try to set 4343 /* If scroll_preserve_screen_position is non-nil, we try to set
4357 point in the same window line as it is now, so get that line. */ 4344 point in the same window line as it is now, so get that line. */
4358 if (!NILP (Vscroll_preserve_screen_position)) 4345 if (!NILP (Vscroll_preserve_screen_position))
@@ -4431,12 +4418,16 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4431 - it.current_y + it.max_ascent + it.max_descent); 4418 - it.current_y + it.max_ascent + it.max_descent);
4432 adjust_glyphs (it.f); 4419 adjust_glyphs (it.f);
4433 } 4420 }
4434 else if (noerror)
4435 return;
4436 else if (n < 0) /* could happen with empty buffers */
4437 xsignal0 (Qbeginning_of_buffer);
4438 else 4421 else
4439 xsignal0 (Qend_of_buffer); 4422 {
4423 bidi_unshelve_cache (itdata);
4424 if (noerror)
4425 return;
4426 else if (n < 0) /* could happen with empty buffers */
4427 xsignal0 (Qbeginning_of_buffer);
4428 else
4429 xsignal0 (Qend_of_buffer);
4430 }
4440 } 4431 }
4441 else 4432 else
4442 { 4433 {
@@ -4444,10 +4435,14 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4444 /* The first line was only partially visible, make it fully 4435 /* The first line was only partially visible, make it fully
4445 visible. */ 4436 visible. */
4446 w->vscroll = 0; 4437 w->vscroll = 0;
4447 else if (noerror)
4448 return;
4449 else 4438 else
4450 xsignal0 (Qbeginning_of_buffer); 4439 {
4440 bidi_unshelve_cache (itdata);
4441 if (noerror)
4442 return;
4443 else
4444 xsignal0 (Qbeginning_of_buffer);
4445 }
4451 } 4446 }
4452 4447
4453 /* If control gets here, then we vscrolled. */ 4448 /* If control gets here, then we vscrolled. */
@@ -4591,6 +4586,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, int whole, int noerror)
4591 SET_PT_BOTH (charpos, bytepos); 4586 SET_PT_BOTH (charpos, bytepos);
4592 } 4587 }
4593 } 4588 }
4589 bidi_unshelve_cache (itdata);
4594} 4590}
4595 4591
4596 4592
@@ -4993,6 +4989,7 @@ displayed_window_lines (struct window *w)
4993 int height = window_box_height (w); 4989 int height = window_box_height (w);
4994 struct buffer *old_buffer; 4990 struct buffer *old_buffer;
4995 int bottom_y; 4991 int bottom_y;
4992 void *itdata = NULL;
4996 4993
4997 if (XBUFFER (w->buffer) != current_buffer) 4994 if (XBUFFER (w->buffer) != current_buffer)
4998 { 4995 {
@@ -5012,9 +5009,11 @@ displayed_window_lines (struct window *w)
5012 else 5009 else
5013 SET_TEXT_POS_FROM_MARKER (start, w->start); 5010 SET_TEXT_POS_FROM_MARKER (start, w->start);
5014 5011
5012 itdata = bidi_shelve_cache ();
5015 start_display (&it, w, start); 5013 start_display (&it, w, start);
5016 move_it_vertically (&it, height); 5014 move_it_vertically (&it, height);
5017 bottom_y = line_bottom_y (&it); 5015 bottom_y = line_bottom_y (&it);
5016 bidi_unshelve_cache (itdata);
5018 5017
5019 /* rms: On a non-window display, 5018 /* rms: On a non-window display,
5020 the value of it.vpos at the bottom of the screen 5019 the value of it.vpos at the bottom of the screen
@@ -5113,12 +5112,14 @@ and redisplay normally--don't erase and redraw the frame. */)
5113 { 5112 {
5114 struct it it; 5113 struct it it;
5115 struct text_pos pt; 5114 struct text_pos pt;
5115 void *itdata = bidi_shelve_cache ();
5116 5116
5117 SET_TEXT_POS (pt, PT, PT_BYTE); 5117 SET_TEXT_POS (pt, PT, PT_BYTE);
5118 start_display (&it, w, pt); 5118 start_display (&it, w, pt);
5119 move_it_vertically_backward (&it, window_box_height (w) / 2); 5119 move_it_vertically_backward (&it, window_box_height (w) / 2);
5120 charpos = IT_CHARPOS (it); 5120 charpos = IT_CHARPOS (it);
5121 bytepos = IT_BYTEPOS (it); 5121 bytepos = IT_BYTEPOS (it);
5122 bidi_unshelve_cache (itdata);
5122 } 5123 }
5123 else if (iarg < 0) 5124 else if (iarg < 0)
5124 { 5125 {
@@ -5127,6 +5128,7 @@ and redisplay normally--don't erase and redraw the frame. */)
5127 int nlines = -iarg; 5128 int nlines = -iarg;
5128 int extra_line_spacing; 5129 int extra_line_spacing;
5129 int h = window_box_height (w); 5130 int h = window_box_height (w);
5131 void *itdata = bidi_shelve_cache ();
5130 5132
5131 iarg = - max (-iarg, this_scroll_margin); 5133 iarg = - max (-iarg, this_scroll_margin);
5132 5134
@@ -5164,7 +5166,10 @@ and redisplay normally--don't erase and redraw the frame. */)
5164 h -= nlines * (FRAME_LINE_HEIGHT (it.f) + extra_line_spacing); 5166 h -= nlines * (FRAME_LINE_HEIGHT (it.f) + extra_line_spacing);
5165 } 5167 }
5166 if (h <= 0) 5168 if (h <= 0)
5167 return Qnil; 5169 {
5170 bidi_unshelve_cache (itdata);
5171 return Qnil;
5172 }
5168 5173
5169 /* Now find the new top line (starting position) of the window. */ 5174 /* Now find the new top line (starting position) of the window. */
5170 start_display (&it, w, pt); 5175 start_display (&it, w, pt);
@@ -5184,6 +5189,8 @@ and redisplay normally--don't erase and redraw the frame. */)
5184 5189
5185 charpos = IT_CHARPOS (it); 5190 charpos = IT_CHARPOS (it);
5186 bytepos = IT_BYTEPOS (it); 5191 bytepos = IT_BYTEPOS (it);
5192
5193 bidi_unshelve_cache (itdata);
5187 } 5194 }
5188 else 5195 else
5189 { 5196 {
@@ -5350,8 +5357,7 @@ struct saved_window
5350{ 5357{
5351 struct vectorlike_header header; 5358 struct vectorlike_header header;
5352 5359
5353 Lisp_Object window, clone_number; 5360 Lisp_Object window, buffer, start, pointm, mark;
5354 Lisp_Object buffer, start, pointm, mark;
5355 Lisp_Object left_col, top_line, total_cols, total_lines; 5361 Lisp_Object left_col, top_line, total_cols, total_lines;
5356 Lisp_Object normal_cols, normal_lines; 5362 Lisp_Object normal_cols, normal_lines;
5357 Lisp_Object hscroll, min_hscroll; 5363 Lisp_Object hscroll, min_hscroll;
@@ -5570,7 +5576,6 @@ the return value is nil. Otherwise the value is t. */)
5570 } 5576 }
5571 } 5577 }
5572 5578
5573 w->clone_number = p->clone_number;
5574 /* If we squirreled away the buffer in the window's height, 5579 /* If we squirreled away the buffer in the window's height,
5575 restore it now. */ 5580 restore it now. */
5576 if (BUFFERP (w->total_lines)) 5581 if (BUFFERP (w->total_lines))
@@ -5853,7 +5858,6 @@ save_window_save (Lisp_Object window, struct Lisp_Vector *vector, int i)
5853 5858
5854 XSETFASTINT (w->temslot, i); i++; 5859 XSETFASTINT (w->temslot, i); i++;
5855 p->window = window; 5860 p->window = window;
5856 p->clone_number = w->clone_number;
5857 p->buffer = w->buffer; 5861 p->buffer = w->buffer;
5858 p->left_col = w->left_col; 5862 p->left_col = w->left_col;
5859 p->top_line = w->top_line; 5863 p->top_line = w->top_line;
@@ -6457,8 +6461,8 @@ syms_of_window (void)
6457 DEFSYM (Qwindow_live_p, "window-live-p"); 6461 DEFSYM (Qwindow_live_p, "window-live-p");
6458 DEFSYM (Qwindow_deletable_p, "window-deletable-p"); 6462 DEFSYM (Qwindow_deletable_p, "window-deletable-p");
6459 DEFSYM (Qdelete_window, "delete-window"); 6463 DEFSYM (Qdelete_window, "delete-window");
6460 DEFSYM (Qresize_root_window, "resize-root-window"); 6464 DEFSYM (Qwindow_resize_root_window, "window--resize-root-window");
6461 DEFSYM (Qresize_root_window_vertically, "resize-root-window-vertically"); 6465 DEFSYM (Qwindow_resize_root_window_vertically, "window--resize-root-window-vertically");
6462 DEFSYM (Qsafe, "safe"); 6466 DEFSYM (Qsafe, "safe");
6463 DEFSYM (Qdisplay_buffer, "display-buffer"); 6467 DEFSYM (Qdisplay_buffer, "display-buffer");
6464 DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows"); 6468 DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows");
@@ -6598,7 +6602,6 @@ function `window-nest' and altered by the function `set-window-nest'. */);
6598 defsubr (&Sset_frame_selected_window); 6602 defsubr (&Sset_frame_selected_window);
6599 defsubr (&Spos_visible_in_window_p); 6603 defsubr (&Spos_visible_in_window_p);
6600 defsubr (&Swindow_line_height); 6604 defsubr (&Swindow_line_height);
6601 defsubr (&Swindow_clone_number);
6602 defsubr (&Swindow_buffer); 6605 defsubr (&Swindow_buffer);
6603 defsubr (&Swindow_parent); 6606 defsubr (&Swindow_parent);
6604 defsubr (&Swindow_top_child); 6607 defsubr (&Swindow_top_child);
@@ -6648,7 +6651,6 @@ function `window-nest' and altered by the function `set-window-nest'. */);
6648 defsubr (&Sdelete_window_internal); 6651 defsubr (&Sdelete_window_internal);
6649 defsubr (&Sresize_mini_window_internal); 6652 defsubr (&Sresize_mini_window_internal);
6650 defsubr (&Sset_window_buffer); 6653 defsubr (&Sset_window_buffer);
6651 defsubr (&Sset_window_clone_number);
6652 defsubr (&Srun_window_configuration_change_hook); 6654 defsubr (&Srun_window_configuration_change_hook);
6653 defsubr (&Sselect_window); 6655 defsubr (&Sselect_window);
6654 defsubr (&Sforce_window_update); 6656 defsubr (&Sforce_window_update);