aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGerd Moellmann2001-06-26 09:47:11 +0000
committerGerd Moellmann2001-06-26 09:47:11 +0000
commit5a08cbaf3b02a0d036790cbdacdb4695c63e6084 (patch)
tree84a975589f0f5bcffda49ace727163b9e85d3bb4 /src
parent88378b0ddb7ced9b625c9b3fe59cc8a344f0de47 (diff)
downloademacs-5a08cbaf3b02a0d036790cbdacdb4695c63e6084.tar.gz
emacs-5a08cbaf3b02a0d036790cbdacdb4695c63e6084.zip
(handle_invisible_prop): Deal with overlay strings at
the start of invisible text. (setup_for_ellipsis): New function. (next_overlay_string): After all overlay strings have been processed, display an ellipsis if necessary. (load_overlay_strings, get_overlay_strings): Add parameter CHARPOS. (push_it): Initialize display_ellipsis_p on the iterator's stack.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c116
1 files changed, 75 insertions, 41 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 28208b32cab..bab134e2ef9 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -659,6 +659,7 @@ enum move_it_result
659 659
660/* Function prototypes. */ 660/* Function prototypes. */
661 661
662static void setup_for_ellipsis P_ ((struct it *));
662static void mark_window_display_accurate_1 P_ ((struct window *, int)); 663static void mark_window_display_accurate_1 P_ ((struct window *, int));
663static int single_display_prop_string_p P_ ((Lisp_Object, Lisp_Object)); 664static int single_display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
664static int display_prop_string_p P_ ((Lisp_Object, Lisp_Object)); 665static int display_prop_string_p P_ ((Lisp_Object, Lisp_Object));
@@ -732,7 +733,7 @@ static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object,
732 int, int, struct it *, int, int, int, int)); 733 int, int, struct it *, int, int, int, int));
733static void compute_line_metrics P_ ((struct it *)); 734static void compute_line_metrics P_ ((struct it *));
734static void run_redisplay_end_trigger_hook P_ ((struct it *)); 735static void run_redisplay_end_trigger_hook P_ ((struct it *));
735static int get_overlay_strings P_ ((struct it *)); 736static int get_overlay_strings P_ ((struct it *, int));
736static void next_overlay_string P_ ((struct it *)); 737static void next_overlay_string P_ ((struct it *));
737static void reseat P_ ((struct it *, struct text_pos, int)); 738static void reseat P_ ((struct it *, struct text_pos, int));
738static void reseat_1 P_ ((struct it *, struct text_pos, int)); 739static void reseat_1 P_ ((struct it *, struct text_pos, int));
@@ -746,7 +747,7 @@ static int next_element_from_buffer P_ ((struct it *));
746static int next_element_from_composition P_ ((struct it *)); 747static int next_element_from_composition P_ ((struct it *));
747static int next_element_from_image P_ ((struct it *)); 748static int next_element_from_image P_ ((struct it *));
748static int next_element_from_stretch P_ ((struct it *)); 749static int next_element_from_stretch P_ ((struct it *));
749static void load_overlay_strings P_ ((struct it *)); 750static void load_overlay_strings P_ ((struct it *, int));
750static void init_from_display_pos P_ ((struct it *, struct window *, 751static void init_from_display_pos P_ ((struct it *, struct window *,
751 struct display_pos *)); 752 struct display_pos *));
752static void reseat_to_string P_ ((struct it *, unsigned char *, 753static void reseat_to_string P_ ((struct it *, unsigned char *,
@@ -1848,7 +1849,7 @@ init_from_display_pos (it, w, pos)
1848 it->current.overlay_string_index = 0; 1849 it->current.overlay_string_index = 0;
1849 while (n--) 1850 while (n--)
1850 { 1851 {
1851 load_overlay_strings (it); 1852 load_overlay_strings (it, 0);
1852 it->current.overlay_string_index += OVERLAY_STRING_CHUNK_SIZE; 1853 it->current.overlay_string_index += OVERLAY_STRING_CHUNK_SIZE;
1853 } 1854 }
1854 } 1855 }
@@ -2531,12 +2532,14 @@ handle_invisible_prop (it)
2531 } 2532 }
2532 else 2533 else
2533 { 2534 {
2534 int visible_p, newpos, next_stop; 2535 int visible_p, newpos, next_stop, start_charpos;
2535 Lisp_Object pos, prop; 2536 Lisp_Object pos, prop, overlay;
2536 2537
2537 /* First of all, is there invisible text at this position? */ 2538 /* First of all, is there invisible text at this position? */
2539 start_charpos = IT_CHARPOS (*it);
2538 pos = make_number (IT_CHARPOS (*it)); 2540 pos = make_number (IT_CHARPOS (*it));
2539 prop = Fget_char_property (pos, Qinvisible, it->window); 2541 prop = get_char_property_and_overlay (pos, Qinvisible, it->window,
2542 &overlay);
2540 2543
2541 /* If we are on invisible text, skip over it. */ 2544 /* If we are on invisible text, skip over it. */
2542 if (TEXT_PROP_MEANS_INVISIBLE (prop) 2545 if (TEXT_PROP_MEANS_INVISIBLE (prop)
@@ -2585,36 +2588,25 @@ handle_invisible_prop (it)
2585 IT_CHARPOS (*it) = next_stop; 2588 IT_CHARPOS (*it) = next_stop;
2586 } 2589 }
2587 while (!visible_p); 2590 while (!visible_p);
2588 2591
2589 /* The position newpos is now either ZV or on visible text. */ 2592 /* The position newpos is now either ZV or on visible text. */
2590 IT_CHARPOS (*it) = newpos; 2593 IT_CHARPOS (*it) = newpos;
2591 IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos); 2594 IT_BYTEPOS (*it) = CHAR_TO_BYTE (newpos);
2592 2595
2593 /* Maybe return `...' next for the end of the invisible text. */ 2596 /* If there are before-strings at the start of invisible
2594 if (display_ellipsis_p) 2597 text, and the text is invisible because of a text
2598 property, arrange to show before-strings because 20.x did
2599 it that way. (If the text is invisible because of an
2600 overlay property instead of a text property, this is
2601 already handled in the overlay code.) */
2602 if (NILP (overlay)
2603 && get_overlay_strings (it, start_charpos))
2595 { 2604 {
2596 if (it->dp 2605 handled = HANDLED_RECOMPUTE_PROPS;
2597 && VECTORP (DISP_INVIS_VECTOR (it->dp))) 2606 it->stack[it->sp - 1].display_ellipsis_p = display_ellipsis_p;
2598 {
2599 struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
2600 it->dpvec = v->contents;
2601 it->dpend = v->contents + v->size;
2602 }
2603 else
2604 {
2605 /* Default `...'. */
2606 it->dpvec = default_invis_vector;
2607 it->dpend = default_invis_vector + 3;
2608 }
2609
2610 /* The ellipsis display does not replace the display of
2611 the character at the new position. Indicate this by
2612 setting IT->dpvec_char_len to zero. */
2613 it->dpvec_char_len = 0;
2614
2615 it->current.dpvec_index = 0;
2616 it->method = next_element_from_display_vector;
2617 } 2607 }
2608 else if (display_ellipsis_p)
2609 setup_for_ellipsis (it);
2618 } 2610 }
2619 } 2611 }
2620 2612
@@ -2622,6 +2614,36 @@ handle_invisible_prop (it)
2622} 2614}
2623 2615
2624 2616
2617/* Make iterator IT return `...' next. */
2618
2619static void
2620setup_for_ellipsis (it)
2621 struct it *it;
2622{
2623 if (it->dp
2624 && VECTORP (DISP_INVIS_VECTOR (it->dp)))
2625 {
2626 struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
2627 it->dpvec = v->contents;
2628 it->dpend = v->contents + v->size;
2629 }
2630 else
2631 {
2632 /* Default `...'. */
2633 it->dpvec = default_invis_vector;
2634 it->dpend = default_invis_vector + 3;
2635 }
2636
2637 /* The ellipsis display does not replace the display of the
2638 character at the new position. Indicate this by setting
2639 IT->dpvec_char_len to zero. */
2640 it->dpvec_char_len = 0;
2641
2642 it->current.dpvec_index = 0;
2643 it->method = next_element_from_display_vector;
2644}
2645
2646
2625 2647
2626/*********************************************************************** 2648/***********************************************************************
2627 'display' property 2649 'display' property
@@ -3285,7 +3307,7 @@ static enum prop_handled
3285handle_overlay_change (it) 3307handle_overlay_change (it)
3286 struct it *it; 3308 struct it *it;
3287{ 3309{
3288 if (!STRINGP (it->string) && get_overlay_strings (it)) 3310 if (!STRINGP (it->string) && get_overlay_strings (it, 0))
3289 return HANDLED_RECOMPUTE_PROPS; 3311 return HANDLED_RECOMPUTE_PROPS;
3290 else 3312 else
3291 return HANDLED_NORMALLY; 3313 return HANDLED_NORMALLY;
@@ -3309,6 +3331,8 @@ next_overlay_string (it)
3309 /* No more overlay strings. Restore IT's settings to what 3331 /* No more overlay strings. Restore IT's settings to what
3310 they were before overlay strings were processed, and 3332 they were before overlay strings were processed, and
3311 continue to deliver from current_buffer. */ 3333 continue to deliver from current_buffer. */
3334 int display_ellipsis_p = it->stack[it->sp - 1].display_ellipsis_p;
3335
3312 pop_it (it); 3336 pop_it (it);
3313 xassert (it->stop_charpos >= BEGV 3337 xassert (it->stop_charpos >= BEGV
3314 && it->stop_charpos <= it->end_charpos); 3338 && it->stop_charpos <= it->end_charpos);
@@ -3323,6 +3347,11 @@ next_overlay_string (it)
3323 next_element_from_buffer doesn't try it again. */ 3347 next_element_from_buffer doesn't try it again. */
3324 if (IT_CHARPOS (*it) >= it->end_charpos) 3348 if (IT_CHARPOS (*it) >= it->end_charpos)
3325 it->overlay_strings_at_end_processed_p = 1; 3349 it->overlay_strings_at_end_processed_p = 1;
3350
3351 /* If we have to display `...' for invisible text, set
3352 the iterator up for that. */
3353 if (display_ellipsis_p)
3354 setup_for_ellipsis (it);
3326 } 3355 }
3327 else 3356 else
3328 { 3357 {
@@ -3333,7 +3362,7 @@ next_overlay_string (it)
3333 int i = it->current.overlay_string_index % OVERLAY_STRING_CHUNK_SIZE; 3362 int i = it->current.overlay_string_index % OVERLAY_STRING_CHUNK_SIZE;
3334 3363
3335 if (it->current.overlay_string_index && i == 0) 3364 if (it->current.overlay_string_index && i == 0)
3336 load_overlay_strings (it); 3365 load_overlay_strings (it, 0);
3337 3366
3338 /* Initialize IT to deliver display elements from the overlay 3367 /* Initialize IT to deliver display elements from the overlay
3339 string. */ 3368 string. */
@@ -3393,8 +3422,8 @@ compare_overlay_entries (e1, e2)
3393 3422
3394 3423
3395/* Load the vector IT->overlay_strings with overlay strings from IT's 3424/* Load the vector IT->overlay_strings with overlay strings from IT's
3396 current buffer position. Set IT->n_overlays to the total number of 3425 current buffer position, or from CHARPOS if that is > 0. Set
3397 overlay strings found. 3426 IT->n_overlays to the total number of overlay strings found.
3398 3427
3399 Overlay strings are processed OVERLAY_STRING_CHUNK_SIZE strings at 3428 Overlay strings are processed OVERLAY_STRING_CHUNK_SIZE strings at
3400 a time. On entry into load_overlay_strings, 3429 a time. On entry into load_overlay_strings,
@@ -3417,8 +3446,9 @@ compare_overlay_entries (e1, e2)
3417 compare_overlay_entries. */ 3446 compare_overlay_entries. */
3418 3447
3419static void 3448static void
3420load_overlay_strings (it) 3449load_overlay_strings (it, charpos)
3421 struct it *it; 3450 struct it *it;
3451 int charpos;
3422{ 3452{
3423 extern Lisp_Object Qafter_string, Qbefore_string, Qwindow, Qpriority; 3453 extern Lisp_Object Qafter_string, Qbefore_string, Qwindow, Qpriority;
3424 Lisp_Object ov, overlay, window, str, invisible; 3454 Lisp_Object ov, overlay, window, str, invisible;
@@ -3427,7 +3457,9 @@ load_overlay_strings (it)
3427 int n = 0, i, j, invis_p; 3457 int n = 0, i, j, invis_p;
3428 struct overlay_entry *entries 3458 struct overlay_entry *entries
3429 = (struct overlay_entry *) alloca (size * sizeof *entries); 3459 = (struct overlay_entry *) alloca (size * sizeof *entries);
3430 int charpos = IT_CHARPOS (*it); 3460
3461 if (charpos <= 0)
3462 charpos = IT_CHARPOS (*it);
3431 3463
3432 /* Append the overlay string STRING of overlay OVERLAY to vector 3464 /* Append the overlay string STRING of overlay OVERLAY to vector
3433 `entries' which has size `size' and currently contains `n' 3465 `entries' which has size `size' and currently contains `n'
@@ -3559,12 +3591,13 @@ load_overlay_strings (it)
3559 3591
3560 3592
3561/* Get the first chunk of overlay strings at IT's current buffer 3593/* Get the first chunk of overlay strings at IT's current buffer
3562 position. Value is non-zero if at least one overlay string was 3594 position, or at CHARPOS if that is > 0. Value is non-zero if at
3563 found. */ 3595 least one overlay string was found. */
3564 3596
3565static int 3597static int
3566get_overlay_strings (it) 3598get_overlay_strings (it, charpos)
3567 struct it *it; 3599 struct it *it;
3600 int charpos;
3568{ 3601{
3569 /* Get the first OVERLAY_STRING_CHUNK_SIZE overlay strings to 3602 /* Get the first OVERLAY_STRING_CHUNK_SIZE overlay strings to
3570 process. This fills IT->overlay_strings with strings, and sets 3603 process. This fills IT->overlay_strings with strings, and sets
@@ -3574,7 +3607,7 @@ get_overlay_strings (it)
3574 when no overlay strings are found because a zero value would 3607 when no overlay strings are found because a zero value would
3575 indicate a position in the first overlay string. */ 3608 indicate a position in the first overlay string. */
3576 it->current.overlay_string_index = 0; 3609 it->current.overlay_string_index = 0;
3577 load_overlay_strings (it); 3610 load_overlay_strings (it, charpos);
3578 3611
3579 /* If we found overlay strings, set up IT to deliver display 3612 /* If we found overlay strings, set up IT to deliver display
3580 elements from the first one. Otherwise set up IT to deliver 3613 elements from the first one. Otherwise set up IT to deliver
@@ -3648,6 +3681,7 @@ push_it (it)
3648 p->font_height = it->font_height; 3681 p->font_height = it->font_height;
3649 p->voffset = it->voffset; 3682 p->voffset = it->voffset;
3650 p->string_from_display_prop_p = it->string_from_display_prop_p; 3683 p->string_from_display_prop_p = it->string_from_display_prop_p;
3684 p->display_ellipsis_p = 0;
3651 ++it->sp; 3685 ++it->sp;
3652} 3686}
3653 3687
@@ -4702,7 +4736,7 @@ next_element_from_buffer (it)
4702 else 4736 else
4703 { 4737 {
4704 it->overlay_strings_at_end_processed_p = 1; 4738 it->overlay_strings_at_end_processed_p = 1;
4705 overlay_strings_follow_p = get_overlay_strings (it); 4739 overlay_strings_follow_p = get_overlay_strings (it, 0);
4706 } 4740 }
4707 4741
4708 if (overlay_strings_follow_p) 4742 if (overlay_strings_follow_p)