aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog17
-rw-r--r--src/bidi.c12
-rw-r--r--src/dispextern.h3
-rw-r--r--src/xdisp.c81
4 files changed, 77 insertions, 36 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 51e4561f8db..2f305d0daf4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,22 @@
12011-06-09 Eli Zaretskii <eliz@gnu.org> 12011-06-09 Eli Zaretskii <eliz@gnu.org>
2 2
3 * xdisp.c (compute_display_string_pos): First arg is now struct
4 `text_pos *'; all callers changed. Support display properties on
5 Lisp strings.
6 (compute_display_string_end): Support display properties on Lisp
7 strings.
8 (init_iterator, reseat_1, reseat_to_string): Initialize the
9 string.bufpos member to 0 (zero, for compatibility with IT_CHARPOS
10 when iterating on a string not from display properties).
11
12 * bidi.c (bidi_fetch_char): Support strings with display
13 properties.
14
15 * dispextern.h (struct bidi_string_data): New member bufpos.
16 (compute_display_string_pos): Update prototype.
17
182011-06-09 Eli Zaretskii <eliz@gnu.org>
19
3 * bidi.c (bidi_level_of_next_char): Allow the sentinel "position" 20 * bidi.c (bidi_level_of_next_char): Allow the sentinel "position"
4 to pass the test for valid cached positions. 21 to pass the test for valid cached positions.
5 22
diff --git a/src/bidi.c b/src/bidi.c
index a0a57b4c681..ffa2c771ed3 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -624,11 +624,15 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
624{ 624{
625 int ch; 625 int ch;
626 EMACS_INT endpos = string->s ? string->schars : ZV; 626 EMACS_INT endpos = string->s ? string->schars : ZV;
627 struct text_pos pos;
627 628
628 /* If we got past the last known position of display string, compute 629 /* If we got past the last known position of display string, compute
629 the position of the next one. That position could be at CHARPOS. */ 630 the position of the next one. That position could be at CHARPOS. */
630 if (charpos < endpos && charpos > *disp_pos) 631 if (charpos < endpos && charpos > *disp_pos)
631 *disp_pos = compute_display_string_pos (charpos, string, frame_window_p); 632 {
633 SET_TEXT_POS (pos, charpos, bytepos);
634 *disp_pos = compute_display_string_pos (&pos, string, frame_window_p);
635 }
632 636
633 /* Fetch the character at BYTEPOS. */ 637 /* Fetch the character at BYTEPOS. */
634 if (charpos >= endpos) 638 if (charpos >= endpos)
@@ -677,8 +681,10 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
677 /* If we just entered a run of characters covered by a display 681 /* If we just entered a run of characters covered by a display
678 string, compute the position of the next display string. */ 682 string, compute the position of the next display string. */
679 if (charpos + *nchars <= endpos && charpos + *nchars > *disp_pos) 683 if (charpos + *nchars <= endpos && charpos + *nchars > *disp_pos)
680 *disp_pos = compute_display_string_pos (charpos + *nchars, string, 684 {
681 frame_window_p); 685 SET_TEXT_POS (pos, charpos + *nchars, bytepos + *ch_len);
686 *disp_pos = compute_display_string_pos (&pos, string, frame_window_p);
687 }
682 688
683 return ch; 689 return ch;
684} 690}
diff --git a/src/dispextern.h b/src/dispextern.h
index 979cb43e98f..5cb28fa0f7a 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1818,6 +1818,7 @@ struct bidi_string_data {
1818 const unsigned char *s; /* string data, or NULL if reordering buffer */ 1818 const unsigned char *s; /* string data, or NULL if reordering buffer */
1819 EMACS_INT schars; /* the number of characters in the string, 1819 EMACS_INT schars; /* the number of characters in the string,
1820 excluding the terminating null */ 1820 excluding the terminating null */
1821 EMACS_INT bufpos; /* buffer position of lstring, or 0 if N/A */
1821 unsigned from_disp_str : 1; /* 1 means the string comes from a 1822 unsigned from_disp_str : 1; /* 1 means the string comes from a
1822 display property */ 1823 display property */
1823}; 1824};
@@ -3018,7 +3019,7 @@ extern void reseat_at_previous_visible_line_start (struct it *);
3018extern Lisp_Object lookup_glyphless_char_display (int, struct it *); 3019extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
3019extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object, 3020extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object,
3020 struct font *, int, int *); 3021 struct font *, int, int *);
3021extern EMACS_INT compute_display_string_pos (EMACS_INT, 3022extern EMACS_INT compute_display_string_pos (struct text_pos *,
3022 struct bidi_string_data *, int); 3023 struct bidi_string_data *, int);
3023extern EMACS_INT compute_display_string_end (EMACS_INT, 3024extern EMACS_INT compute_display_string_end (EMACS_INT,
3024 struct bidi_string_data *); 3025 struct bidi_string_data *);
diff --git a/src/xdisp.c b/src/xdisp.c
index 712088db324..1194cced38c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -2349,6 +2349,7 @@ init_iterator (struct it *it, struct window *w,
2349 it->paragraph_embedding = L2R; 2349 it->paragraph_embedding = L2R;
2350 it->bidi_it.string.lstring = Qnil; 2350 it->bidi_it.string.lstring = Qnil;
2351 it->bidi_it.string.s = NULL; 2351 it->bidi_it.string.s = NULL;
2352 it->bidi_it.string.bufpos = 0;
2352 2353
2353 /* The window in which we iterate over current_buffer: */ 2354 /* The window in which we iterate over current_buffer: */
2354 XSETWINDOW (it->window, w); 2355 XSETWINDOW (it->window, w);
@@ -3098,38 +3099,47 @@ next_overlay_change (EMACS_INT pos)
3098} 3099}
3099 3100
3100/* Return the character position of a display string at or after 3101/* Return the character position of a display string at or after
3101 CHARPOS. If no display string exists at or after CHARPOS, return 3102 position specified by POSITION. If no display string exists at or
3102 ZV. A display string is either an overlay with `display' property 3103 after POSITION, return ZV. A display string is either an overlay
3103 whose value is a string, or a `display' text property whose value 3104 with `display' property whose value is a string, or a `display'
3104 is a string. STRING is the string to iterate; if STRING->s is 3105 text property whose value is a string. STRING is data about the
3105 NULL, we are iterating a buffer. FRAME_WINDOW_P is non-zero when 3106 string to iterate; if STRING->lstring is nil, we are iterating a
3106 we are displaying a window on a GUI frame. */ 3107 buffer. FRAME_WINDOW_P is non-zero when we are displaying a window
3108 on a GUI frame. */
3107EMACS_INT 3109EMACS_INT
3108compute_display_string_pos (EMACS_INT charpos, struct bidi_string_data *string, 3110compute_display_string_pos (struct text_pos *position,
3109 int frame_window_p) 3111 struct bidi_string_data *string, int frame_window_p)
3110{ 3112{
3111 /* FIXME: Support display properties on strings (object = Qnil means 3113 /* OBJECT = nil means current buffer. */
3112 current buffer). */ 3114 Lisp_Object object = string ? string->lstring : Qnil;
3113 Lisp_Object object = Qnil;
3114 Lisp_Object pos, spec; 3115 Lisp_Object pos, spec;
3115 struct text_pos position; 3116 EMACS_INT eob = STRINGP (object) ? string->schars : ZV;
3116 EMACS_INT bufpos; 3117 EMACS_INT begb = STRINGP (object) ? 0 : BEGV;
3117 3118 EMACS_INT bufpos, charpos = CHARPOS (*position);
3118 if (charpos >= ZV) 3119 struct text_pos tpos;
3119 return ZV; 3120
3121 if (charpos >= eob
3122 /* We don't support display properties whose values are strings
3123 that have display string properties. */
3124 || string->from_disp_str
3125 /* C strings cannot have display properties. */
3126 || (string->s && !STRINGP (object)))
3127 return eob;
3120 3128
3121 /* If the character at CHARPOS is where the display string begins, 3129 /* If the character at CHARPOS is where the display string begins,
3122 return CHARPOS. */ 3130 return CHARPOS. */
3123 pos = make_number (charpos); 3131 pos = make_number (charpos);
3124 CHARPOS (position) = charpos; 3132 if (STRINGP (object))
3125 BYTEPOS (position) = CHAR_TO_BYTE (charpos); 3133 bufpos = string->bufpos;
3126 bufpos = charpos; /* FIXME! support strings as well */ 3134 else
3135 bufpos = charpos;
3136 tpos = *position;
3127 if (!NILP (spec = Fget_char_property (pos, Qdisplay, object)) 3137 if (!NILP (spec = Fget_char_property (pos, Qdisplay, object))
3128 && (charpos <= BEGV 3138 && (charpos <= begb
3129 || !EQ (Fget_char_property (make_number (charpos - 1), Qdisplay, 3139 || !EQ (Fget_char_property (make_number (charpos - 1), Qdisplay,
3130 object), 3140 object),
3131 spec)) 3141 spec))
3132 && handle_display_spec (NULL, spec, object, Qnil, &position, bufpos, 3142 && handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
3133 frame_window_p)) 3143 frame_window_p))
3134 return charpos; 3144 return charpos;
3135 3145
@@ -3137,17 +3147,21 @@ compute_display_string_pos (EMACS_INT charpos, struct bidi_string_data *string,
3137 that will replace the underlying text when displayed. */ 3147 that will replace the underlying text when displayed. */
3138 do { 3148 do {
3139 pos = Fnext_single_char_property_change (pos, Qdisplay, object, Qnil); 3149 pos = Fnext_single_char_property_change (pos, Qdisplay, object, Qnil);
3140 CHARPOS (position) = XFASTINT (pos); 3150 CHARPOS (tpos) = XFASTINT (pos);
3141 BYTEPOS (position) = CHAR_TO_BYTE (CHARPOS (position)); 3151 if (STRINGP (object))
3142 if (CHARPOS (position) >= ZV) 3152 BYTEPOS (tpos) = string_char_to_byte (object, CHARPOS (tpos));
3153 else
3154 BYTEPOS (tpos) = CHAR_TO_BYTE (CHARPOS (tpos));
3155 if (CHARPOS (tpos) >= eob)
3143 break; 3156 break;
3144 spec = Fget_char_property (pos, Qdisplay, object); 3157 spec = Fget_char_property (pos, Qdisplay, object);
3145 bufpos = CHARPOS (position); /* FIXME! support strings as well */ 3158 if (!STRINGP (object))
3159 bufpos = CHARPOS (tpos);
3146 } while (NILP (spec) 3160 } while (NILP (spec)
3147 || !handle_display_spec (NULL, spec, object, Qnil, &position, bufpos, 3161 || !handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
3148 frame_window_p)); 3162 frame_window_p));
3149 3163
3150 return CHARPOS (position); 3164 return CHARPOS (tpos);
3151} 3165}
3152 3166
3153/* Return the character position of the end of the display string that 3167/* Return the character position of the end of the display string that
@@ -3157,13 +3171,13 @@ compute_display_string_pos (EMACS_INT charpos, struct bidi_string_data *string,
3157EMACS_INT 3171EMACS_INT
3158compute_display_string_end (EMACS_INT charpos, struct bidi_string_data *string) 3172compute_display_string_end (EMACS_INT charpos, struct bidi_string_data *string)
3159{ 3173{
3160 /* FIXME: Support display properties on strings (object = Qnil means 3174 /* OBJECT = nil means current buffer. */
3161 current buffer). */ 3175 Lisp_Object object = string ? string->lstring : Qnil;
3162 Lisp_Object object = Qnil;
3163 Lisp_Object pos = make_number (charpos); 3176 Lisp_Object pos = make_number (charpos);
3177 EMACS_INT eob = STRINGP (object) ? string->schars : ZV;
3164 3178
3165 if (charpos >= ZV) 3179 if (charpos >= eob)
3166 return ZV; 3180 return eob;
3167 3181
3168 if (NILP (Fget_char_property (pos, Qdisplay, object))) 3182 if (NILP (Fget_char_property (pos, Qdisplay, object)))
3169 abort (); 3183 abort ();
@@ -5496,6 +5510,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
5496 it->bidi_it.disp_pos = -1; 5510 it->bidi_it.disp_pos = -1;
5497 it->bidi_it.string.s = NULL; 5511 it->bidi_it.string.s = NULL;
5498 it->bidi_it.string.lstring = Qnil; 5512 it->bidi_it.string.lstring = Qnil;
5513 it->bidi_it.string.bufpos = 0;
5499 } 5514 }
5500 5515
5501 if (set_stop_p) 5516 if (set_stop_p)
@@ -5567,6 +5582,7 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
5567 it->bidi_it.string.lstring = string; 5582 it->bidi_it.string.lstring = string;
5568 it->bidi_it.string.s = SDATA (string); 5583 it->bidi_it.string.s = SDATA (string);
5569 it->bidi_it.string.schars = it->end_charpos; 5584 it->bidi_it.string.schars = it->end_charpos;
5585 it->bidi_it.string.bufpos = 0;
5570 it->bidi_it.string.from_disp_str = 0; 5586 it->bidi_it.string.from_disp_str = 0;
5571 bidi_init_it (charpos, IT_STRING_BYTEPOS (*it), 5587 bidi_init_it (charpos, IT_STRING_BYTEPOS (*it),
5572 FRAME_WINDOW_P (it->f), &it->bidi_it); 5588 FRAME_WINDOW_P (it->f), &it->bidi_it);
@@ -5592,6 +5608,7 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
5592 it->bidi_it.string.lstring = Qnil; 5608 it->bidi_it.string.lstring = Qnil;
5593 it->bidi_it.string.s = s; 5609 it->bidi_it.string.s = s;
5594 it->bidi_it.string.schars = it->end_charpos; 5610 it->bidi_it.string.schars = it->end_charpos;
5611 it->bidi_it.string.bufpos = 0;
5595 it->bidi_it.string.from_disp_str = 0; 5612 it->bidi_it.string.from_disp_str = 0;
5596 bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f), 5613 bidi_init_it (charpos, IT_BYTEPOS (*it), FRAME_WINDOW_P (it->f),
5597 &it->bidi_it); 5614 &it->bidi_it);