Commit 87e67904 authored by Eli Zaretskii's avatar Eli Zaretskii

Started work on string reordering. Just compiled, not yet tested.

 src/bidi.c (bidi_paragraph_info): Delete unused struct.
 (bidi_cache_idx, bidi_cache_last_idx): Declare EMACS_INT.
 (bidi_cache_start): New variable.
 (bidi_cache_reset): Reset bidi_cache_idx to bidi_cache_start, not
 to zero.
 (bidi_cache_fetch_state, bidi_cache_search)
 (bidi_cache_find_level_change, bidi_cache_iterator_state)
 (bidi_cache_find, bidi_peek_at_next_level)
 (bidi_level_of_next_char, bidi_find_other_level_edge)
 (bidi_move_to_visually_next): Compare cache index with
 bidi_cache_start rather than with zero.
 (bidi_fetch_char): Accept new argument STRING; all callers
 changed.  Support iteration over a string.
 (bidi_paragraph_init, bidi_resolve_explicit_1)
 (bidi_resolve_explicit, bidi_resolve_weak)
 (bidi_level_of_next_char, bidi_move_to_visually_next): Support
 iteration over a string.
 (bidi_set_sor_type, bidi_resolve_explicit_1)
 (bidi_resolve_explicit, bidi_type_of_next_char): ignore_bn_limit
 can now be zero (for strings); special values 0 and -1 were
 changed to -1 and -2, respectively.
 (bidi_char_at_pos): New function.
 (bidi_paragraph_init, bidi_resolve_explicit, bidi_resolve_weak):
 Call it instead of FETCH_MULTIBYTE_CHAR.
 (bidi_move_to_visually_next): Abort if charpos or bytepos were not
 initialized to valid values.
 (bidi_init_it): Don't initialize charpos and bytepos with invalid
 values.
 src/xdisp.c (compute_display_string_pos)
 (compute_display_string_end): Accept additional argument STRING.
 (init_iterator, reseat_1): Initialize bidi_it->string.s to NULL.
 (reseat_to_string): Initialize bidi_it->string.s and
 bidi_it->string.schars.
 src/dispextern.h (struct bidi_string_data): New structure.
 (struct bidi_it): New member `string'.  Make flag members be 1-bit
 fields, and put them last in the struct.
 (compute_display_string_pos, compute_display_string_end): Update
 prototypes.
parent 9d68c2a9
2011-06-08 Eli Zaretskii <eliz@gnu.org>
* bidi.c (bidi_paragraph_info): Delete unused struct.
(bidi_cache_idx, bidi_cache_last_idx): Declare EMACS_INT.
(bidi_cache_start): New variable.
(bidi_cache_reset): Reset bidi_cache_idx to bidi_cache_start, not
to zero.
(bidi_cache_fetch_state, bidi_cache_search)
(bidi_cache_find_level_change, bidi_cache_iterator_state)
(bidi_cache_find, bidi_peek_at_next_level)
(bidi_level_of_next_char, bidi_find_other_level_edge)
(bidi_move_to_visually_next): Compare cache index with
bidi_cache_start rather than with zero.
(bidi_fetch_char): Accept new argument STRING; all callers
changed. Support iteration over a string.
(bidi_paragraph_init, bidi_resolve_explicit_1)
(bidi_resolve_explicit, bidi_resolve_weak)
(bidi_level_of_next_char, bidi_move_to_visually_next): Support
iteration over a string.
(bidi_set_sor_type, bidi_resolve_explicit_1)
(bidi_resolve_explicit, bidi_type_of_next_char): ignore_bn_limit
can now be zero (for strings); special values 0 and -1 were
changed to -1 and -2, respectively.
(bidi_char_at_pos): New function.
(bidi_paragraph_init, bidi_resolve_explicit, bidi_resolve_weak):
Call it instead of FETCH_MULTIBYTE_CHAR.
(bidi_move_to_visually_next): Abort if charpos or bytepos were not
initialized to valid values.
(bidi_init_it): Don't initialize charpos and bytepos with invalid
values.
* xdisp.c (compute_display_string_pos)
(compute_display_string_end): Accept additional argument STRING.
(init_iterator, reseat_1): Initialize bidi_it->string.s to NULL.
(reseat_to_string): Initialize bidi_it->string.s and
bidi_it->string.schars.
* dispextern.h (struct bidi_string_data): New structure.
(struct bidi_it): New member `string'. Make flag members be 1-bit
fields, and put them last in the struct.
(compute_display_string_pos, compute_display_string_end): Update
prototypes.
2011-06-04 Eli Zaretskii <eliz@gnu.org>
* bidi.c (bidi_level_of_next_char): clen should be EMACS_NT, not int.
......
This diff is collapsed.
......@@ -1812,9 +1812,18 @@ struct bidi_stack {
bidi_dir_t override;
};
/* Data type for storing information about a string being iterated on. */
struct bidi_string_data {
const unsigned char *s; /* the string, or NULL if reordering buffer */
EMACS_INT schars; /* the number of characters in the string,
excluding the terminating null */
unsigned from_disp_str : 1; /* 1 means the string comes from a
display property */
};
/* Data type for reordering bidirectional text. */
struct bidi_it {
EMACS_INT bytepos; /* iterator's position in buffer */
EMACS_INT bytepos; /* iterator's position in buffer/string */
EMACS_INT charpos;
int ch; /* character at that position, or u+FFFC
("object replacement character") for a run
......@@ -1844,12 +1853,13 @@ struct bidi_it {
iterator state is saved, pushed, or popped. So only put here
stuff that is not part of the bidi iterator's state! */
struct bidi_stack level_stack[BIDI_MAXLEVEL]; /* stack of embedding levels */
int first_elt; /* if non-zero, examine current char first */
struct bidi_string_data string; /* string to reorder */
bidi_dir_t paragraph_dir; /* current paragraph direction */
int new_paragraph; /* if non-zero, we expect a new paragraph */
int frame_window_p; /* non-zero if displaying on a GUI frame */
EMACS_INT separator_limit; /* where paragraph separator should end */
EMACS_INT disp_pos; /* position of display string after ch */
unsigned first_elt : 1; /* if non-zero, examine current char first */
unsigned new_paragraph : 1; /* if non-zero, we expect a new paragraph */
unsigned frame_window_p : 1; /* non-zero if displaying on a GUI frame */
};
/* Value is non-zero when the bidi iterator is at base paragraph
......@@ -3007,8 +3017,10 @@ extern void reseat_at_previous_visible_line_start (struct it *);
extern Lisp_Object lookup_glyphless_char_display (int, struct it *);
extern int calc_pixel_width_or_height (double *, struct it *, Lisp_Object,
struct font *, int, int *);
extern EMACS_INT compute_display_string_pos (EMACS_INT, int);
extern EMACS_INT compute_display_string_end (EMACS_INT);
extern EMACS_INT compute_display_string_pos (EMACS_INT,
struct bidi_string_data *, int);
extern EMACS_INT compute_display_string_end (EMACS_INT,
struct bidi_string_data *);
#ifdef HAVE_WINDOW_SYSTEM
......
......@@ -2342,6 +2342,7 @@ init_iterator (struct it *it, struct window *w,
it->base_face_id = remapped_base_face_id;
it->string = Qnil;
IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = -1;
it->bidi_it.string.s = NULL;
/* The window in which we iterate over current_buffer: */
XSETWINDOW (it->window, w);
......@@ -3087,14 +3088,16 @@ next_overlay_change (EMACS_INT pos)
return endpos;
}
/* Return the character position of a display string at or after CHARPOS.
If no display string exists at or after CHARPOS, return ZV. A
display string is either an overlay with `display' property whose
value is a string, or a `display' text property whose value is a
string. FRAME_WINDOW_P is non-zero when we are displaying a window
on a GUI frame. */
/* Return the character position of a display string at or after
CHARPOS. If no display string exists at or after CHARPOS, return
ZV. A display string is either an overlay with `display' property
whose value is a string, or a `display' text property whose value
is a string. STRING is the string to iterate; if STRING->s is
NULL, we are iterating a buffer. FRAME_WINDOW_P is non-zero when
we are displaying a window on a GUI frame. */
EMACS_INT
compute_display_string_pos (EMACS_INT charpos, int frame_window_p)
compute_display_string_pos (EMACS_INT charpos, struct bidi_string_data *string,
int frame_window_p)
{
/* FIXME: Support display properties on strings (object = Qnil means
current buffer). */
......@@ -3143,7 +3146,7 @@ compute_display_string_pos (EMACS_INT charpos, int frame_window_p)
`display' property whose value is a string or a `display' text
property whose value is a string. */
EMACS_INT
compute_display_string_end (EMACS_INT charpos)
compute_display_string_end (EMACS_INT charpos, struct bidi_string_data *string)
{
/* FIXME: Support display properties on strings (object = Qnil means
current buffer). */
......@@ -5482,6 +5485,7 @@ reseat_1 (struct it *it, struct text_pos pos, int set_stop_p)
it->bidi_it.first_elt = 1;
it->bidi_it.paragraph_dir = NEUTRAL_DIR;
it->bidi_it.disp_pos = -1;
it->bidi_it.string.s = NULL;
}
if (set_stop_p)
......@@ -5531,6 +5535,10 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
setting of MULTIBYTE, if specified. */
if (multibyte >= 0)
it->multibyte_p = multibyte > 0;
#if 0
it->bidi_p =
it->multibyte_p && BVAR (&buffer_defaults, bidi_display_reordering);
#endif
if (s == NULL)
{
......@@ -5540,6 +5548,12 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
it->end_charpos = it->string_nchars = SCHARS (string);
it->method = GET_FROM_STRING;
it->current.string_pos = string_pos (charpos, string);
#if 0
if (it->bidi_p)
bidi_init_it ();
it->bidi_it.string.s = SDATA (string);
it->bidi_it.string.schars = it->end_charpos;
#endif
}
else
{
......@@ -5553,11 +5567,20 @@ reseat_to_string (struct it *it, const char *s, Lisp_Object string,
{
it->current.pos = c_string_pos (charpos, s, 1);
it->end_charpos = it->string_nchars = number_of_chars (s, 1);
#if 0
if (it->bidi_p)
bidi_init_it ();
it->bidi_it.string.s = s;
it->bidi_it.string.schars = it->end_charpos;
#endif
}
else
{
IT_CHARPOS (*it) = IT_BYTEPOS (*it) = charpos;
it->end_charpos = it->string_nchars = strlen (s);
#if 0
it->bidi_p = 0;
#endif
}
it->method = GET_FROM_C_STRING;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment