aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2011-05-14 16:41:52 +0300
committerEli Zaretskii2011-05-14 16:41:52 +0300
commit7b60010279ef966ed79de968c918e3e9f4b42e3b (patch)
tree7879bd0da97c5afd9556a448e24134f756dfafe6 /src
parent102ebb00791ec617cfff4b1e351bc32bf8d71a9f (diff)
downloademacs-7b60010279ef966ed79de968c918e3e9f4b42e3b.tar.gz
emacs-7b60010279ef966ed79de968c918e3e9f4b42e3b.zip
Text covered by `display' overlays is correctly reordered.
Cursor positioning is not yet right near the overlay. src/xdisp.c (compute_display_string_pos): Non-trivial implementation. (compute_display_string_end): New function. src/dispextern.h (compute_display_string_end): Declare prototype. src/bidi.c (bidi_resolve_explicit_1): Use ZV for disp_pos. (bidi_fetch_char): Implement support for runs of characters covered by display strings.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/bidi.c22
-rw-r--r--src/dispextern.h3
-rw-r--r--src/xdisp.c50
4 files changed, 76 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index decde924b09..b122f0612b2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,7 +1,17 @@
12011-05-14 Eli Zaretskii <eliz@gnu.org> 12011-05-14 Eli Zaretskii <eliz@gnu.org>
2 2
3 * xdisp.c (compute_display_string_pos): Non-trivial implementation.
4 (compute_display_string_end): New function.
5
6 * dispextern.h (compute_display_string_end): Declare prototype.
7
8 * bidi.c (bidi_resolve_explicit_1): Use ZV for disp_pos.
9 (bidi_fetch_char): Implement support for runs of characters
10 covered by display strings.
11
3 * bidi.c (bidi_fetch_char): Accept also character position 12 * bidi.c (bidi_fetch_char): Accept also character position
4 corresponding to BYTEPOS. All callers changed. 13 corresponding to BYTEPOS. DISP_POS is now a character position,
14 not a byte position. All callers changed.
5 (bidi_cache_iterator_state, bidi_resolve_explicit_1) 15 (bidi_cache_iterator_state, bidi_resolve_explicit_1)
6 (bidi_resolve_explicit, bidi_resolve_weak) 16 (bidi_resolve_explicit, bidi_resolve_weak)
7 (bidi_level_of_next_char, bidi_move_to_visually_next): Abort if 17 (bidi_level_of_next_char, bidi_move_to_visually_next): Abort if
diff --git a/src/bidi.c b/src/bidi.c
index c1422a9d9a4..742224607e4 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -597,19 +597,29 @@ bidi_fetch_char (EMACS_INT bytepos, EMACS_INT charpos, EMACS_INT *disp_pos,
597 ch = BIDI_EOB; 597 ch = BIDI_EOB;
598 *ch_len = 1; 598 *ch_len = 1;
599 *nchars = 1; 599 *nchars = 1;
600 *disp_pos = ZV;
600 } 601 }
601#if 0
602 else if (charpos >= *disp_pos) 602 else if (charpos >= *disp_pos)
603 { 603 {
604 /* support characters covered by a display string */ 604 EMACS_INT disp_end_pos;
605 ch = 0xFFFC; /* Unicode Object Replacement Character */ 605
606 /* We don't expect to find ourselves in the middle of a display
607 property. Hopefully, it will never be needed. */
608 if (charpos > *disp_pos)
609 abort ();
610 /* Return the Unicode Object Replacement Character to represent
611 the entire run of characters covered by the display
612 string. */
613 ch = 0xFFFC;
614 disp_end_pos = compute_display_string_end (*disp_pos);
615 *nchars = disp_end_pos - *disp_pos;
616 *ch_len = CHAR_TO_BYTE (disp_end_pos) - bytepos;
606 } 617 }
607#endif
608 else 618 else
609 { 619 {
610 ch = FETCH_MULTIBYTE_CHAR (bytepos); 620 ch = FETCH_MULTIBYTE_CHAR (bytepos);
611 *ch_len = CHAR_BYTES (ch);
612 *nchars = 1; 621 *nchars = 1;
622 *ch_len = CHAR_BYTES (ch);
613 } 623 }
614 624
615 /* If we just entered a run of characters covered by a display 625 /* If we just entered a run of characters covered by a display
@@ -978,7 +988,7 @@ bidi_resolve_explicit_1 (struct bidi_it *bidi_it)
978 curchar = BIDI_EOB; 988 curchar = BIDI_EOB;
979 bidi_it->ch_len = 1; 989 bidi_it->ch_len = 1;
980 bidi_it->nchars = 1; 990 bidi_it->nchars = 1;
981 bidi_it->disp_pos = ZV_BYTE; 991 bidi_it->disp_pos = ZV;
982 } 992 }
983 else 993 else
984 { 994 {
diff --git a/src/dispextern.h b/src/dispextern.h
index f94723099f9..f5036169f75 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1848,7 +1848,7 @@ struct bidi_it {
1848 bidi_dir_t paragraph_dir; /* current paragraph direction */ 1848 bidi_dir_t paragraph_dir; /* current paragraph direction */
1849 int new_paragraph; /* if non-zero, we expect a new paragraph */ 1849 int new_paragraph; /* if non-zero, we expect a new paragraph */
1850 EMACS_INT separator_limit; /* where paragraph separator should end */ 1850 EMACS_INT separator_limit; /* where paragraph separator should end */
1851 EMACS_INT disp_pos; /* byte position of display string after ch */ 1851 EMACS_INT disp_pos; /* position of display string after ch */
1852}; 1852};
1853 1853
1854/* Value is non-zero when the bidi iterator is at base paragraph 1854/* Value is non-zero when the bidi iterator is at base paragraph
@@ -3007,6 +3007,7 @@ extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
3007extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object, 3007extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object,
3008 struct font *, int, int *); 3008 struct font *, int, int *);
3009extern EMACS_INT compute_display_string_pos (EMACS_INT); 3009extern EMACS_INT compute_display_string_pos (EMACS_INT);
3010extern EMACS_INT compute_display_string_end (EMACS_INT);
3010 3011
3011#ifdef HAVE_WINDOW_SYSTEM 3012#ifdef HAVE_WINDOW_SYSTEM
3012 3013
diff --git a/src/xdisp.c b/src/xdisp.c
index fc2a80c115f..508728d95f8 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -3093,11 +3093,55 @@ next_overlay_change (EMACS_INT pos)
3093EMACS_INT 3093EMACS_INT
3094compute_display_string_pos (EMACS_INT charpos) 3094compute_display_string_pos (EMACS_INT charpos)
3095{ 3095{
3096 /* FIXME: Support display properties on strings. */ 3096 /* FIXME: Support display properties on strings (object = Qnil means
3097 current buffer). */
3098 Lisp_Object object = Qnil;
3099 Lisp_Object pos = make_number (charpos);
3100
3097 if (charpos >= ZV) 3101 if (charpos >= ZV)
3098 return ZV; 3102 return ZV;
3099 /* FIXME! */ 3103
3100 return ZV; 3104 /* If the character at CHARPOS is where the display string begins,
3105 return CHARPOS. */
3106 if (!NILP (Fget_char_property (pos, Qdisplay, object))
3107 && (charpos <= BEGV
3108 || NILP (Fget_char_property (make_number (charpos - 1), Qdisplay,
3109 object))))
3110 return charpos;
3111
3112 /* Look forward for the first character where the `display' property
3113 changes from nil to non-nil. */
3114 do {
3115 pos = Fnext_single_char_property_change (pos, Qdisplay, object, Qnil);
3116 } while (XFASTINT (pos) < ZV
3117 && NILP (Fget_char_property (pos, Qdisplay, object)));
3118
3119 return XFASTINT (pos);
3120}
3121
3122/* Return the character position of the end of the display string that
3123 started at CHARPOS. A display string is either an overlay with
3124 `display' property whose value is a string or a `display' text
3125 property whose value is a string. */
3126EMACS_INT
3127compute_display_string_end (EMACS_INT charpos)
3128{
3129 /* FIXME: Support display properties on strings (object = Qnil means
3130 current buffer). */
3131 Lisp_Object object = Qnil;
3132 Lisp_Object pos = make_number (charpos);
3133
3134 if (charpos >= ZV)
3135 return ZV;
3136
3137 if (NILP (Fget_char_property (pos, Qdisplay, object)))
3138 abort ();
3139
3140 /* Look forward for the first character where the `display' property
3141 changes. */
3142 pos = Fnext_single_char_property_change (pos, Qdisplay, object, Qnil);
3143
3144 return XFASTINT (pos);
3101} 3145}
3102 3146
3103 3147