diff options
| author | Stefan Monnier | 2008-06-05 03:57:09 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-06-05 03:57:09 +0000 |
| commit | c876b227d9b0cbd09bbb8c07db0a3cb0d85fae78 (patch) | |
| tree | 36b9cdbe3c2af0181b8e074c80a98e1119597f03 /src/window.c | |
| parent | 927abf37e2793fae653540cca8b4c324c65e448f (diff) | |
| download | emacs-c876b227d9b0cbd09bbb8c07db0a3cb0d85fae78.tar.gz emacs-c876b227d9b0cbd09bbb8c07db0a3cb0d85fae78.zip | |
* window.c (window_scroll_pixel_based_preserve_x)
(window_scroll_preserve_hpos, window_scroll_preserve_vpos): New vars.
(window_scroll_pixel_based, window_scroll_line_based):
Use them to preserve column positions.
(syms_of_window): Initialize them.
* indent.c (Fvertical_motion): Extend first arg to allow passing an
(HPOS . VPOS) pair.
* xdisp.c (move_it_in_display_line_to): Improve the type of its args.
(move_it_in_display_line): New wrapper.
* dispextern.h (move_it_in_display_line): Declare.
Diffstat (limited to 'src/window.c')
| -rw-r--r-- | src/window.c | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/src/window.c b/src/window.c index 095e8412aa8..9385b307b9e 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -224,8 +224,14 @@ int window_deletion_count; | |||
| 224 | 224 | ||
| 225 | /* Used by the function window_scroll_pixel_based */ | 225 | /* Used by the function window_scroll_pixel_based */ |
| 226 | 226 | ||
| 227 | static int window_scroll_pixel_based_preserve_x; | ||
| 227 | static int window_scroll_pixel_based_preserve_y; | 228 | static int window_scroll_pixel_based_preserve_y; |
| 228 | 229 | ||
| 230 | /* Same for window_scroll_line_based. */ | ||
| 231 | |||
| 232 | static int window_scroll_preserve_hpos; | ||
| 233 | static int window_scroll_preserve_vpos; | ||
| 234 | |||
| 229 | #if 0 /* This isn't used anywhere. */ | 235 | #if 0 /* This isn't used anywhere. */ |
| 230 | /* Nonzero means we can split a frame even if it is "unsplittable". */ | 236 | /* Nonzero means we can split a frame even if it is "unsplittable". */ |
| 231 | static int inhibit_frame_unsplittable; | 237 | static int inhibit_frame_unsplittable; |
| @@ -5216,10 +5222,12 @@ window_scroll_pixel_based (window, n, whole, noerror) | |||
| 5216 | start_display (&it, w, start); | 5222 | start_display (&it, w, start); |
| 5217 | move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); | 5223 | move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS); |
| 5218 | window_scroll_pixel_based_preserve_y = it.current_y; | 5224 | window_scroll_pixel_based_preserve_y = it.current_y; |
| 5225 | window_scroll_pixel_based_preserve_x = it.current_x; | ||
| 5219 | } | 5226 | } |
| 5220 | } | 5227 | } |
| 5221 | else | 5228 | else |
| 5222 | window_scroll_pixel_based_preserve_y = -1; | 5229 | window_scroll_pixel_based_preserve_y |
| 5230 | = window_scroll_pixel_based_preserve_x = -1; | ||
| 5223 | 5231 | ||
| 5224 | /* Move iterator it from start the specified distance forward or | 5232 | /* Move iterator it from start the specified distance forward or |
| 5225 | backward. The result is the new window start. */ | 5233 | backward. The result is the new window start. */ |
| @@ -5355,10 +5363,11 @@ window_scroll_pixel_based (window, n, whole, noerror) | |||
| 5355 | { | 5363 | { |
| 5356 | /* If we have a header line, take account of it. | 5364 | /* If we have a header line, take account of it. |
| 5357 | This is necessary because we set it.current_y to 0, above. */ | 5365 | This is necessary because we set it.current_y to 0, above. */ |
| 5358 | move_it_to (&it, -1, -1, | 5366 | move_it_to (&it, -1, |
| 5367 | window_scroll_pixel_based_preserve_x, | ||
| 5359 | window_scroll_pixel_based_preserve_y | 5368 | window_scroll_pixel_based_preserve_y |
| 5360 | - (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0 ), | 5369 | - (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0 ), |
| 5361 | -1, MOVE_TO_Y); | 5370 | -1, MOVE_TO_Y | MOVE_TO_X); |
| 5362 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 5371 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
| 5363 | } | 5372 | } |
| 5364 | else | 5373 | else |
| @@ -5416,8 +5425,9 @@ window_scroll_pixel_based (window, n, whole, noerror) | |||
| 5416 | /* It would be wrong to subtract CURRENT_HEADER_LINE_HEIGHT | 5425 | /* It would be wrong to subtract CURRENT_HEADER_LINE_HEIGHT |
| 5417 | here because we called start_display again and did not | 5426 | here because we called start_display again and did not |
| 5418 | alter it.current_y this time. */ | 5427 | alter it.current_y this time. */ |
| 5419 | move_it_to (&it, -1, -1, window_scroll_pixel_based_preserve_y, -1, | 5428 | move_it_to (&it, -1, window_scroll_pixel_based_preserve_x, |
| 5420 | MOVE_TO_Y); | 5429 | window_scroll_pixel_based_preserve_y, -1, |
| 5430 | MOVE_TO_Y | MOVE_TO_X); | ||
| 5421 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); | 5431 | SET_PT_BOTH (IT_CHARPOS (it), IT_BYTEPOS (it)); |
| 5422 | } | 5432 | } |
| 5423 | else | 5433 | else |
| @@ -5455,8 +5465,7 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5455 | int lose; | 5465 | int lose; |
| 5456 | Lisp_Object bolp; | 5466 | Lisp_Object bolp; |
| 5457 | int startpos; | 5467 | int startpos; |
| 5458 | struct position posit; | 5468 | Lisp_Object original_pos = Qnil; |
| 5459 | int original_vpos; | ||
| 5460 | 5469 | ||
| 5461 | /* If scrolling screen-fulls, compute the number of lines to | 5470 | /* If scrolling screen-fulls, compute the number of lines to |
| 5462 | scroll from the window's height. */ | 5471 | scroll from the window's height. */ |
| @@ -5465,11 +5474,24 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5465 | 5474 | ||
| 5466 | startpos = marker_position (w->start); | 5475 | startpos = marker_position (w->start); |
| 5467 | 5476 | ||
| 5468 | posit = *compute_motion (startpos, 0, 0, 0, | 5477 | if (!NILP (Vscroll_preserve_screen_position)) |
| 5469 | PT, ht, 0, | 5478 | { |
| 5470 | -1, XINT (w->hscroll), | 5479 | if (window_scroll_preserve_vpos <= 0 |
| 5471 | 0, w); | 5480 | || (!EQ (current_kboard->Vlast_command, Qscroll_up) |
| 5472 | original_vpos = posit.vpos; | 5481 | && !EQ (current_kboard->Vlast_command, Qscroll_down))) |
| 5482 | { | ||
| 5483 | struct position posit | ||
| 5484 | = *compute_motion (startpos, 0, 0, 0, | ||
| 5485 | PT, ht, 0, | ||
| 5486 | -1, XINT (w->hscroll), | ||
| 5487 | 0, w); | ||
| 5488 | window_scroll_preserve_vpos = posit.vpos; | ||
| 5489 | window_scroll_preserve_hpos = posit.hpos + XINT (w->hscroll); | ||
| 5490 | } | ||
| 5491 | |||
| 5492 | original_pos = Fcons (make_number (window_scroll_preserve_hpos), | ||
| 5493 | make_number (window_scroll_preserve_vpos)); | ||
| 5494 | } | ||
| 5473 | 5495 | ||
| 5474 | XSETFASTINT (tem, PT); | 5496 | XSETFASTINT (tem, PT); |
| 5475 | tem = Fpos_visible_in_window_p (tem, window, Qnil); | 5497 | tem = Fpos_visible_in_window_p (tem, window, Qnil); |
| @@ -5520,7 +5542,7 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5520 | && (whole || !EQ (Vscroll_preserve_screen_position, Qt))) | 5542 | && (whole || !EQ (Vscroll_preserve_screen_position, Qt))) |
| 5521 | { | 5543 | { |
| 5522 | SET_PT_BOTH (pos, pos_byte); | 5544 | SET_PT_BOTH (pos, pos_byte); |
| 5523 | Fvertical_motion (make_number (original_vpos), window); | 5545 | Fvertical_motion (original_pos, window); |
| 5524 | } | 5546 | } |
| 5525 | /* If we scrolled forward, put point enough lines down | 5547 | /* If we scrolled forward, put point enough lines down |
| 5526 | that it is outside the scroll margin. */ | 5548 | that it is outside the scroll margin. */ |
| @@ -5542,7 +5564,7 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5542 | else if (!NILP (Vscroll_preserve_screen_position)) | 5564 | else if (!NILP (Vscroll_preserve_screen_position)) |
| 5543 | { | 5565 | { |
| 5544 | SET_PT_BOTH (pos, pos_byte); | 5566 | SET_PT_BOTH (pos, pos_byte); |
| 5545 | Fvertical_motion (make_number (original_vpos), window); | 5567 | Fvertical_motion (original_pos, window); |
| 5546 | } | 5568 | } |
| 5547 | else | 5569 | else |
| 5548 | SET_PT (top_margin); | 5570 | SET_PT (top_margin); |
| @@ -5567,7 +5589,7 @@ window_scroll_line_based (window, n, whole, noerror) | |||
| 5567 | if (!NILP (Vscroll_preserve_screen_position)) | 5589 | if (!NILP (Vscroll_preserve_screen_position)) |
| 5568 | { | 5590 | { |
| 5569 | SET_PT_BOTH (pos, pos_byte); | 5591 | SET_PT_BOTH (pos, pos_byte); |
| 5570 | Fvertical_motion (make_number (original_vpos), window); | 5592 | Fvertical_motion (original_pos, window); |
| 5571 | } | 5593 | } |
| 5572 | else | 5594 | else |
| 5573 | Fvertical_motion (make_number (-1), window); | 5595 | Fvertical_motion (make_number (-1), window); |
| @@ -7439,7 +7461,10 @@ syms_of_window () | |||
| 7439 | minibuf_selected_window = Qnil; | 7461 | minibuf_selected_window = Qnil; |
| 7440 | staticpro (&minibuf_selected_window); | 7462 | staticpro (&minibuf_selected_window); |
| 7441 | 7463 | ||
| 7464 | window_scroll_pixel_based_preserve_x = -1; | ||
| 7442 | window_scroll_pixel_based_preserve_y = -1; | 7465 | window_scroll_pixel_based_preserve_y = -1; |
| 7466 | window_scroll_preserve_hpos = -1; | ||
| 7467 | window_scroll_preserve_vpos = -1; | ||
| 7443 | 7468 | ||
| 7444 | DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, | 7469 | DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, |
| 7445 | doc: /* Non-nil means call as function to display a help buffer. | 7470 | doc: /* Non-nil means call as function to display a help buffer. |
| @@ -7640,7 +7665,7 @@ windows horizontally. A value less than 2 is invalid. */); | |||
| 7640 | 7665 | ||
| 7641 | DEFVAR_LISP ("scroll-preserve-screen-position", | 7666 | DEFVAR_LISP ("scroll-preserve-screen-position", |
| 7642 | &Vscroll_preserve_screen_position, | 7667 | &Vscroll_preserve_screen_position, |
| 7643 | doc: /* *Controls if scroll commands move point to keep its screen line unchanged. | 7668 | doc: /* *Controls if scroll commands move point to keep its screen position unchanged. |
| 7644 | A value of nil means point does not keep its screen position except | 7669 | A value of nil means point does not keep its screen position except |
| 7645 | at the scroll margin or window boundary respectively. | 7670 | at the scroll margin or window boundary respectively. |
| 7646 | A value of t means point keeps its screen position if the scroll | 7671 | A value of t means point keeps its screen position if the scroll |