diff options
| author | Joakim Verona | 2011-12-28 04:12:56 +0100 |
|---|---|---|
| committer | Joakim Verona | 2011-12-28 04:12:56 +0100 |
| commit | bb29f044aa967831cd664c54eba0de0c701436ce (patch) | |
| tree | 1398cc9780bbae0fdad071a3a3765a571c3f6d7b /src/xdisp.c | |
| parent | 3c935a7e996701244d166f684119f0ff97e25496 (diff) | |
| parent | 5e605a2e528955721fc6f2bd7b9f174c15075fb1 (diff) | |
| download | emacs-bb29f044aa967831cd664c54eba0de0c701436ce.tar.gz emacs-bb29f044aa967831cd664c54eba0de0c701436ce.zip | |
upstream i think
Diffstat (limited to 'src/xdisp.c')
| -rw-r--r-- | src/xdisp.c | 97 |
1 files changed, 69 insertions, 28 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 7c415e485b5..530373a4436 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -2851,8 +2851,14 @@ start_display (struct it *it, struct window *w, struct text_pos pos) | |||
| 2851 | || (new_x == it->last_visible_x | 2851 | || (new_x == it->last_visible_x |
| 2852 | && FRAME_WINDOW_P (it->f)))) | 2852 | && FRAME_WINDOW_P (it->f)))) |
| 2853 | { | 2853 | { |
| 2854 | if (it->current.dpvec_index >= 0 | 2854 | if ((it->current.dpvec_index >= 0 |
| 2855 | || it->current.overlay_string_index >= 0) | 2855 | || it->current.overlay_string_index >= 0) |
| 2856 | /* If we are on a newline from a display vector or | ||
| 2857 | overlay string, then we are already at the end of | ||
| 2858 | a screen line; no need to go to the next line in | ||
| 2859 | that case, as this line is not really continued. | ||
| 2860 | (If we do go to the next line, C-e will not DTRT.) */ | ||
| 2861 | && it->c != '\n') | ||
| 2856 | { | 2862 | { |
| 2857 | set_iterator_to_next (it, 1); | 2863 | set_iterator_to_next (it, 1); |
| 2858 | move_it_in_display_line_to (it, -1, -1, 0); | 2864 | move_it_in_display_line_to (it, -1, -1, 0); |
| @@ -3171,13 +3177,11 @@ compute_stop_pos (struct it *it) | |||
| 3171 | Lisp_Object object, limit, position; | 3177 | Lisp_Object object, limit, position; |
| 3172 | EMACS_INT charpos, bytepos; | 3178 | EMACS_INT charpos, bytepos; |
| 3173 | 3179 | ||
| 3174 | /* If nowhere else, stop at the end. */ | ||
| 3175 | it->stop_charpos = it->end_charpos; | ||
| 3176 | |||
| 3177 | if (STRINGP (it->string)) | 3180 | if (STRINGP (it->string)) |
| 3178 | { | 3181 | { |
| 3179 | /* Strings are usually short, so don't limit the search for | 3182 | /* Strings are usually short, so don't limit the search for |
| 3180 | properties. */ | 3183 | properties. */ |
| 3184 | it->stop_charpos = it->end_charpos; | ||
| 3181 | object = it->string; | 3185 | object = it->string; |
| 3182 | limit = Qnil; | 3186 | limit = Qnil; |
| 3183 | charpos = IT_STRING_CHARPOS (*it); | 3187 | charpos = IT_STRING_CHARPOS (*it); |
| @@ -3187,6 +3191,12 @@ compute_stop_pos (struct it *it) | |||
| 3187 | { | 3191 | { |
| 3188 | EMACS_INT pos; | 3192 | EMACS_INT pos; |
| 3189 | 3193 | ||
| 3194 | /* If end_charpos is out of range for some reason, such as a | ||
| 3195 | misbehaving display function, rationalize it (Bug#5984). */ | ||
| 3196 | if (it->end_charpos > ZV) | ||
| 3197 | it->end_charpos = ZV; | ||
| 3198 | it->stop_charpos = it->end_charpos; | ||
| 3199 | |||
| 3190 | /* If next overlay change is in front of the current stop pos | 3200 | /* If next overlay change is in front of the current stop pos |
| 3191 | (which is IT->end_charpos), stop there. Note: value of | 3201 | (which is IT->end_charpos), stop there. Note: value of |
| 3192 | next_overlay_change is point-max if no overlay change | 3202 | next_overlay_change is point-max if no overlay change |
| @@ -4088,26 +4098,37 @@ handle_invisible_prop (struct it *it) | |||
| 4088 | if (it->bidi_p && newpos < ZV) | 4098 | if (it->bidi_p && newpos < ZV) |
| 4089 | { | 4099 | { |
| 4090 | EMACS_INT bpos = CHAR_TO_BYTE (newpos); | 4100 | EMACS_INT bpos = CHAR_TO_BYTE (newpos); |
| 4091 | 4101 | int on_newline = FETCH_BYTE (bpos) == '\n'; | |
| 4092 | if (FETCH_BYTE (bpos) == '\n' | 4102 | int after_newline = |
| 4093 | || (newpos > BEGV && FETCH_BYTE (bpos - 1) == '\n')) | 4103 | newpos <= BEGV || FETCH_BYTE (bpos - 1) == '\n'; |
| 4104 | |||
| 4105 | /* If the invisible text ends on a newline or on a | ||
| 4106 | character after a newline, we can avoid the costly, | ||
| 4107 | character by character, bidi iteration to NEWPOS, and | ||
| 4108 | instead simply reseat the iterator there. That's | ||
| 4109 | because all bidi reordering information is tossed at | ||
| 4110 | the newline. This is a big win for modes that hide | ||
| 4111 | complete lines, like Outline, Org, etc. */ | ||
| 4112 | if (on_newline || after_newline) | ||
| 4094 | { | 4113 | { |
| 4095 | /* If the invisible text ends on a newline or the | ||
| 4096 | character after a newline, we can avoid the | ||
| 4097 | costly, character by character, bidi iteration to | ||
| 4098 | newpos, and instead simply reseat the iterator | ||
| 4099 | there. That's because all bidi reordering | ||
| 4100 | information is tossed at the newline. This is a | ||
| 4101 | big win for modes that hide complete lines, like | ||
| 4102 | Outline, Org, etc. (Implementation note: the | ||
| 4103 | call to reseat_1 is necessary, because it signals | ||
| 4104 | to the bidi iterator that it needs to reinit its | ||
| 4105 | internal information when the next element for | ||
| 4106 | display is requested. */ | ||
| 4107 | struct text_pos tpos; | 4114 | struct text_pos tpos; |
| 4115 | bidi_dir_t pdir = it->bidi_it.paragraph_dir; | ||
| 4108 | 4116 | ||
| 4109 | SET_TEXT_POS (tpos, newpos, bpos); | 4117 | SET_TEXT_POS (tpos, newpos, bpos); |
| 4110 | reseat_1 (it, tpos, 0); | 4118 | reseat_1 (it, tpos, 0); |
| 4119 | /* If we reseat on a newline, we need to prep the | ||
| 4120 | bidi iterator for advancing to the next character | ||
| 4121 | after the newline, keeping the current paragraph | ||
| 4122 | direction (so that PRODUCE_GLYPHS does TRT wrt | ||
| 4123 | prepending/appending glyphs to a glyph row). */ | ||
| 4124 | if (on_newline) | ||
| 4125 | { | ||
| 4126 | it->bidi_it.first_elt = 0; | ||
| 4127 | it->bidi_it.paragraph_dir = pdir; | ||
| 4128 | it->bidi_it.ch = '\n'; | ||
| 4129 | it->bidi_it.nchars = 1; | ||
| 4130 | it->bidi_it.ch_len = 1; | ||
| 4131 | } | ||
| 4111 | } | 4132 | } |
| 4112 | else /* Must use the slow method. */ | 4133 | else /* Must use the slow method. */ |
| 4113 | { | 4134 | { |
| @@ -4116,11 +4137,11 @@ handle_invisible_prop (struct it *it) | |||
| 4116 | non-base embedding level. Therefore, we need to | 4137 | non-base embedding level. Therefore, we need to |
| 4117 | skip invisible text using the bidi iterator, | 4138 | skip invisible text using the bidi iterator, |
| 4118 | starting at IT's current position, until we find | 4139 | starting at IT's current position, until we find |
| 4119 | ourselves outside the invisible text. Skipping | 4140 | ourselves outside of the invisible text. |
| 4120 | invisible text _after_ bidi iteration avoids | 4141 | Skipping invisible text _after_ bidi iteration |
| 4121 | affecting the visual order of the displayed text | 4142 | avoids affecting the visual order of the |
| 4122 | when invisible properties are added or | 4143 | displayed text when invisible properties are |
| 4123 | removed. */ | 4144 | added or removed. */ |
| 4124 | if (it->bidi_it.first_elt && it->bidi_it.charpos < ZV) | 4145 | if (it->bidi_it.first_elt && it->bidi_it.charpos < ZV) |
| 4125 | { | 4146 | { |
| 4126 | /* If we were `reseat'ed to a new paragraph, | 4147 | /* If we were `reseat'ed to a new paragraph, |
| @@ -15614,8 +15635,8 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 15614 | ? min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) | 15635 | ? min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) |
| 15615 | : 0; | 15636 | : 0; |
| 15616 | EMACS_INT margin_pos = CHARPOS (startp); | 15637 | EMACS_INT margin_pos = CHARPOS (startp); |
| 15617 | int scrolling_up; | ||
| 15618 | Lisp_Object aggressive; | 15638 | Lisp_Object aggressive; |
| 15639 | int scrolling_up; | ||
| 15619 | 15640 | ||
| 15620 | /* If there is a scroll margin at the top of the window, find | 15641 | /* If there is a scroll margin at the top of the window, find |
| 15621 | its character position. */ | 15642 | its character position. */ |
| @@ -15657,7 +15678,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 15657 | pt_offset = float_amount * WINDOW_BOX_TEXT_HEIGHT (w); | 15678 | pt_offset = float_amount * WINDOW_BOX_TEXT_HEIGHT (w); |
| 15658 | if (pt_offset == 0 && float_amount > 0) | 15679 | if (pt_offset == 0 && float_amount > 0) |
| 15659 | pt_offset = 1; | 15680 | pt_offset = 1; |
| 15660 | if (pt_offset) | 15681 | if (pt_offset && margin > 0) |
| 15661 | margin -= 1; | 15682 | margin -= 1; |
| 15662 | } | 15683 | } |
| 15663 | /* Compute how much to move the window start backward from | 15684 | /* Compute how much to move the window start backward from |
| @@ -15777,6 +15798,25 @@ redisplay_window (Lisp_Object window, int just_this_one_p) | |||
| 15777 | goto recenter; | 15798 | goto recenter; |
| 15778 | } | 15799 | } |
| 15779 | 15800 | ||
| 15801 | /* Users who set scroll-conservatively to a large number want | ||
| 15802 | point just above/below the scroll margin. If we ended up | ||
| 15803 | with point's row partially visible, move the window start to | ||
| 15804 | make that row fully visible and out of the margin. */ | ||
| 15805 | if (scroll_conservatively > SCROLL_LIMIT) | ||
| 15806 | { | ||
| 15807 | int margin = | ||
| 15808 | scroll_margin > 0 | ||
| 15809 | ? min (scroll_margin, WINDOW_TOTAL_LINES (w) / 4) | ||
| 15810 | : 0; | ||
| 15811 | int move_down = w->cursor.vpos >= WINDOW_TOTAL_LINES (w) / 2; | ||
| 15812 | |||
| 15813 | move_it_by_lines (&it, move_down ? margin + 1 : -(margin + 1)); | ||
| 15814 | clear_glyph_matrix (w->desired_matrix); | ||
| 15815 | if (1 == try_window (window, it.current.pos, | ||
| 15816 | TRY_WINDOW_CHECK_MARGINS)) | ||
| 15817 | goto done; | ||
| 15818 | } | ||
| 15819 | |||
| 15780 | /* If centering point failed to make the whole line visible, | 15820 | /* If centering point failed to make the whole line visible, |
| 15781 | put point at the top instead. That has to make the whole line | 15821 | put point at the top instead. That has to make the whole line |
| 15782 | visible, if it can be done. */ | 15822 | visible, if it can be done. */ |
| @@ -28871,7 +28911,8 @@ init_xdisp (void) | |||
| 28871 | 28911 | ||
| 28872 | /* Platform-independent portion of hourglass implementation. */ | 28912 | /* Platform-independent portion of hourglass implementation. */ |
| 28873 | 28913 | ||
| 28874 | /* Return non-zero if houglass timer has been started or hourglass is shown. */ | 28914 | /* Return non-zero if hourglass timer has been started or hourglass is |
| 28915 | shown. */ | ||
| 28875 | int | 28916 | int |
| 28876 | hourglass_started (void) | 28917 | hourglass_started (void) |
| 28877 | { | 28918 | { |