# HG changeset patch # User Eli Zaretskii # Date 1262347059 18000 # Node ID d44bdcba4457cc666d550d4d90d71a50401ebe2b # Parent ee023eee6207e508730f1adf9f29e788cf873920 Retrospective commit from 2009-11-14. Resurrect support for integer values of `cursor' property. Rename paragraph-direction to bidi-paragraph-direction. xdisp.c (init_iterator, text_outside_line_unchanged_p) (try_window_id): Rename paragraph_direction to bidi_paragraph_direction. (set_cursor_from_row): Handle integer values of `cursor' property on display strings. buffer.c (init_buffer_once, syms_of_buffer): Rename paragraph_direction to bidi_paragraph_direction. buffer.h (struct buffer): Rename paragraph_direction to bidi_paragraph_direction. diff -r ee023eee6207 -r d44bdcba4457 src/ChangeLog.bidi --- a/src/ChangeLog.bidi Fri Jan 01 06:54:22 2010 -0500 +++ b/src/ChangeLog.bidi Fri Jan 01 06:57:39 2010 -0500 @@ -1,3 +1,17 @@ +2009-11-14 Eli Zaretskii + + * xdisp.c (init_iterator, text_outside_line_unchanged_p) + (try_window_id): Rename paragraph_direction to + bidi_paragraph_direction. + (set_cursor_from_row): Handle integer values of `cursor' property + on display strings. + + * buffer.c (init_buffer_once, syms_of_buffer): Rename + paragraph_direction to bidi_paragraph_direction. + + * buffer.h (struct buffer): Rename paragraph_direction to + bidi_paragraph_direction. + 2009-11-07 Eli Zaretskii * bidi.c (bidi_paragraph_init): Don't overstep end of buffer. diff -r ee023eee6207 -r d44bdcba4457 src/buffer.c --- a/src/buffer.c Fri Jan 01 06:54:22 2010 -0500 +++ b/src/buffer.c Fri Jan 01 06:57:39 2010 -0500 @@ -5188,7 +5188,7 @@ buffer_defaults.ctl_arrow = Qt; buffer_defaults.bidi_display_reordering = Qnil; buffer_defaults.direction_reversed = Qnil; - buffer_defaults.paragraph_direction = Qnil; + buffer_defaults.bidi_paragraph_direction = Qnil; buffer_defaults.cursor_type = Qt; buffer_defaults.extra_line_spacing = Qnil; buffer_defaults.cursor_in_non_selected_windows = Qt; @@ -5275,7 +5275,7 @@ XSETFASTINT (buffer_local_flags.category_table, idx); ++idx; XSETFASTINT (buffer_local_flags.bidi_display_reordering, idx); ++idx; XSETFASTINT (buffer_local_flags.direction_reversed, idx); ++idx; - XSETFASTINT (buffer_local_flags.paragraph_direction, idx); ++idx; + XSETFASTINT (buffer_local_flags.bidi_paragraph_direction, idx); ++idx; XSETFASTINT (buffer_local_flags.buffer_file_coding_system, idx); /* Make this one a permanent local. */ buffer_permanent_local_flags[idx++] = 1; @@ -5798,8 +5798,8 @@ doc: /* Non-nil means reorder bidirectional text for display in the visual order. See also the variable `direction-reversed'. */); - DEFVAR_PER_BUFFER ("paragraph-direction", - ¤t_buffer->paragraph_direction, Qnil, + DEFVAR_PER_BUFFER ("bidi-paragraph-direction", + ¤t_buffer->bidi_paragraph_direction, Qnil, doc: /* *If non-nil, forces directionality of text paragraphs in the buffer. If this is nil (the default), the direction of each paragraph is diff -r ee023eee6207 -r d44bdcba4457 src/buffer.h --- a/src/buffer.h Fri Jan 01 06:54:22 2010 -0500 +++ b/src/buffer.h Fri Jan 01 06:57:39 2010 -0500 @@ -667,7 +667,7 @@ /* If non-nil, specifies which direction of text to force in all the paragraphs of the buffer. Nil means determine paragraph direction dynamically for each paragraph. */ - Lisp_Object paragraph_direction; + Lisp_Object bidi_paragraph_direction; /* Non-nil means do selective display; see doc string in syms_of_buffer (buffer.c) for details. */ Lisp_Object selective_display; diff -r ee023eee6207 -r d44bdcba4457 src/xdisp.c --- a/src/xdisp.c Fri Jan 01 06:54:22 2010 -0500 +++ b/src/xdisp.c Fri Jan 01 06:57:39 2010 -0500 @@ -2813,9 +2813,9 @@ { /* Note the paragraph direction that this buffer wants to use. */ - if (EQ (current_buffer->paragraph_direction, Qleft_to_right)) + if (EQ (current_buffer->bidi_paragraph_direction, Qleft_to_right)) it->paragraph_embedding = L2R; - else if (EQ (current_buffer->paragraph_direction, Qright_to_left)) + else if (EQ (current_buffer->bidi_paragraph_direction, Qright_to_left)) it->paragraph_embedding = R2L; else it->paragraph_embedding = NEUTRAL_DIR; @@ -11162,7 +11162,7 @@ to find the paragraph limits and widen the range of redisplayed lines to that, but for now just give up this optimization. */ if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering) - && NILP (XBUFFER (w->buffer)->paragraph_direction)) + && NILP (XBUFFER (w->buffer)->bidi_paragraph_direction)) unchanged_p = 0; } @@ -12468,6 +12468,11 @@ /* Non-zero means we've seen at least one glyph that came from a display string. */ int string_seen = 0; + /* Largest buffer position seen during scan of glyph row. */ + EMACS_INT bpos_max = 0; + /* Last buffer position covered by an overlay string with an integer + `cursor' property. */ + EMACS_INT bpos_covered = 0; /* Skip over glyphs not having an object at the start and the end of the row. These are special glyphs like truncation marks on @@ -12548,6 +12553,8 @@ { EMACS_INT dpos = glyph->charpos - pt_old; + if (glyph->charpos > bpos_max) + bpos_max = glyph->charpos; if (!glyph->avoid_cursor_p) { /* If we hit point, we've found the glyph on which to @@ -12577,7 +12584,27 @@ match_with_avoid_cursor = 1; } else if (STRINGP (glyph->object)) - string_seen = 1; + { + Lisp_Object chprop; + int glyph_pos = glyph->charpos; + + chprop = Fget_char_property (make_number (glyph_pos), Qcursor, + glyph->object); + if (INTEGERP (chprop)) + { + bpos_covered = bpos_max + XINT (chprop); + /* If the `cursor' property covers buffer positions up + to and including point, we should display cursor on + this glyph. */ + if (bpos_covered >= pt_old) + { + cursor = glyph; + break; + } + } + + string_seen = 1; + } x += glyph->pixel_width; ++glyph; } @@ -12588,6 +12615,8 @@ { EMACS_INT dpos = glyph->charpos - pt_old; + if (glyph->charpos > bpos_max) + bpos_max = glyph->charpos; if (!glyph->avoid_cursor_p) { if (dpos == 0) @@ -12610,7 +12639,26 @@ match_with_avoid_cursor = 1; } else if (STRINGP (glyph->object)) - string_seen = 1; + { + Lisp_Object chprop; + int glyph_pos = glyph->charpos; + + chprop = Fget_char_property (make_number (glyph_pos), Qcursor, + glyph->object); + if (INTEGERP (chprop)) + { + bpos_covered = bpos_max + XINT (chprop); + /* If the `cursor' property covers buffer positions up + to and including point, we should display cursor on + this glyph. */ + if (bpos_covered >= pt_old) + { + cursor = glyph; + break; + } + } + string_seen = 1; + } --glyph; if (glyph == end) break; @@ -12620,7 +12668,8 @@ /* Step 2: If we didn't find an exact match for point, we need to look for a proper place to put the cursor among glyphs between GLYPH_BEFORE and GLYPH_AFTER. */ - if (glyph->charpos != pt_old) + if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old) + && bpos_covered < pt_old) { if (row->ends_in_ellipsis_p && pos_after == last_pos) { @@ -12707,9 +12756,6 @@ cprop = Fget_char_property (make_number (gpos), Qcursor, glyph->object); - /* FIXME: This loses the feature of the - unidirectional redisplay when the - property value was an integer. */ if (!NILP (cprop)) { cursor = glyph; @@ -15242,7 +15288,7 @@ lines to that, but for now just give up this optimization and redisplay from scratch. */ if (!NILP (XBUFFER (w->buffer)->bidi_display_reordering) - && NILP (XBUFFER (w->buffer)->paragraph_direction)) + && NILP (XBUFFER (w->buffer)->bidi_paragraph_direction)) GIVE_UP (22); /* Make sure beg_unchanged and end_unchanged are up to date. Do it