Commit db600ab1 authored by Kim F. Storm's avatar Kim F. Storm
Browse files

(next_overlay_string): Fix assert.

(push_it, pop_it): Handle composition and stretch specific values.
Only handle it->slice in image (for now).
(back_to_previous_visible_line_start): Continue search if newline is
part of a compisition.  Simplify.
(reseat_1): Set it->object to buffer.
(set_iterator_to_next): Set it->object to string or buffer, when
setting it->method to GET_FROM_STRING or GET_FROM_BUFFER.
(next_element_from_composition): Set it->object to buffer if not
from string.
(set_cursor_from_row): Only save start of string if not already
done to handle multiple strings in a row.
parent fd00a1e8
......@@ -4556,6 +4556,7 @@ next_overlay_string (it)
 
pop_it (it);
xassert (it->sp > 0
|| it->method == GET_FROM_COMPOSITION
|| (NILP (it->string)
&& it->method == GET_FROM_BUFFER
&& it->stop_charpos >= BEGV
......@@ -4903,18 +4904,31 @@ push_it (it)
p->stop_charpos = it->stop_charpos;
xassert (it->face_id >= 0);
p->face_id = it->face_id;
p->image_id = it->image_id;
p->string = it->string;
p->method = it->method;
if (it->method == GET_FROM_IMAGE)
p->string = it->object;
else
p->string = it->string;
switch (p->method)
{
case GET_FROM_IMAGE:
p->u.image.object = it->object;
p->u.image.image_id = it->image_id;
p->u.image.slice = it->slice;
break;
case GET_FROM_COMPOSITION:
p->u.comp.object = it->object;
p->u.comp.c = it->c;
p->u.comp.len = it->len;
p->u.comp.cmp_id = it->cmp_id;
p->u.comp.cmp_len = it->cmp_len;
break;
case GET_FROM_STRETCH:
p->u.stretch.object = it->object;
break;
}
p->pos = it->current;
p->end_charpos = it->end_charpos;
p->string_nchars = it->string_nchars;
p->area = it->area;
p->multibyte_p = it->multibyte_p;
p->slice = it->slice;
p->space_width = it->space_width;
p->font_height = it->font_height;
p->voffset = it->voffset;
......@@ -4941,23 +4955,33 @@ pop_it (it)
p = it->stack + it->sp;
it->stop_charpos = p->stop_charpos;
it->face_id = p->face_id;
it->method = p->method;
it->image_id = p->image_id;
it->current = p->pos;
if (it->method == GET_FROM_IMAGE)
{
it->object = it->string;
it->string = Qnil;
}
else
it->string = p->string;
it->string = p->string;
if (NILP (it->string))
SET_TEXT_POS (it->current.string_pos, -1, -1);
it->method = p->method;
switch (it->method)
{
case GET_FROM_IMAGE:
it->image_id = p->u.image.image_id;
it->object = p->u.image.object;
it->slice = p->u.image.slice;
break;
case GET_FROM_COMPOSITION:
it->object = p->u.comp.object;
it->c = p->u.comp.c;
it->len = p->u.comp.len;
it->cmp_id = p->u.comp.cmp_id;
it->cmp_len = p->u.comp.cmp_len;
break;
case GET_FROM_STRETCH:
it->object = p->u.comp.object;
break;
}
it->end_charpos = p->end_charpos;
it->string_nchars = p->string_nchars;
it->area = p->area;
it->multibyte_p = p->multibyte_p;
it->slice = p->slice;
it->space_width = p->space_width;
it->font_height = p->font_height;
it->voffset = p->voffset;
......@@ -5108,35 +5132,43 @@ back_to_previous_visible_line_start (it)
continue;
}
 
/* If newline has a display property that replaces the newline with something
else (image or text), find start of overlay or interval and continue search
from that point. */
if (IT_CHARPOS (*it) > BEGV)
{
struct it it2 = *it;
int pos;
int beg, end;
Lisp_Object val, overlay;
pos = --IT_CHARPOS (it2);
--IT_BYTEPOS (it2);
it2.sp = 0;
if (handle_display_prop (&it2) == HANDLED_RETURN
&& !NILP (val = get_char_property_and_overlay
(make_number (pos), Qdisplay, Qnil, &overlay))
&& (OVERLAYP (overlay)
? (beg = OVERLAY_POSITION (OVERLAY_START (overlay)))
: get_property_and_range (pos, Qdisplay, &val, &beg, &end, Qnil)))
{
if (beg < BEGV)
beg = BEGV;
IT_CHARPOS (*it) = beg;
IT_BYTEPOS (*it) = buf_charpos_to_bytepos (current_buffer, beg);
continue;
}
}
if (IT_CHARPOS (*it) <= BEGV)
break;
 
break;
{
struct it it2;
int pos;
int beg, end;
Lisp_Object val, overlay;
/* If newline is part of a composition, continue from start of composition */
if (find_composition (IT_CHARPOS (*it), -1, &beg, &end, &val, Qnil)
&& beg < IT_CHARPOS (*it))
goto replaced;
/* If newline is replaced by a display property, find start of overlay
or interval and continue search from that point. */
it2 = *it;
pos = --IT_CHARPOS (it2);
--IT_BYTEPOS (it2);
it2.sp = 0;
if (handle_display_prop (&it2) == HANDLED_RETURN
&& !NILP (val = get_char_property_and_overlay
(make_number (pos), Qdisplay, Qnil, &overlay))
&& (OVERLAYP (overlay)
? (beg = OVERLAY_POSITION (OVERLAY_START (overlay)))
: get_property_and_range (pos, Qdisplay, &val, &beg, &end, Qnil)))
goto replaced;
/* Newline is not replaced by anything -- so we are done. */
break;
replaced:
if (beg < BEGV)
beg = BEGV;
IT_CHARPOS (*it) = beg;
IT_BYTEPOS (*it) = buf_charpos_to_bytepos (current_buffer, beg);
}
}
 
it->continuation_lines_width = 0;
......@@ -5272,6 +5304,7 @@ reseat_1 (it, pos, set_stop_p)
IT_STRING_BYTEPOS (*it) = -1;
it->string = Qnil;
it->method = GET_FROM_BUFFER;
it->object = it->w->buffer;
it->area = TEXT_AREA;
it->multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
it->sp = 0;
......@@ -5759,6 +5792,7 @@ set_iterator_to_next (it, reseat_p)
IT_STRING_BYTEPOS (*it) += it->len;
IT_STRING_CHARPOS (*it) += it->cmp_len;
it->method = GET_FROM_STRING;
it->object = it->string;
goto consider_string_end;
}
else
......@@ -5766,6 +5800,7 @@ set_iterator_to_next (it, reseat_p)
IT_BYTEPOS (*it) += it->len;
IT_CHARPOS (*it) += it->cmp_len;
it->method = GET_FROM_BUFFER;
it->object = it->w->buffer;
}
break;
 
......@@ -5795,7 +5830,10 @@ set_iterator_to_next (it, reseat_p)
else if (STRINGP (it->string))
it->method = GET_FROM_STRING;
else
it->method = GET_FROM_BUFFER;
{
it->method = GET_FROM_BUFFER;
it->object = it->w->buffer;
}
 
it->dpvec = NULL;
it->current.dpvec_index = -1;
......@@ -6080,6 +6118,7 @@ next_element_from_ellipsis (it)
setting face_before_selective_p. */
it->saved_face_id = it->face_id;
it->method = GET_FROM_BUFFER;
it->object = it->w->buffer;
reseat_at_next_visible_line_start (it, 1);
it->face_before_selective_p = 1;
}
......@@ -6268,6 +6307,8 @@ next_element_from_composition (it)
: it->current.pos);
if (STRINGP (it->string))
it->object = it->string;
else
it->object = it->w->buffer;
return 1;
}
 
......@@ -11709,9 +11750,12 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos)
}
else
{
string_before_pos = last_pos;
string_start = glyph;
string_start_x = x;
if (string_start == NULL)
{
string_before_pos = last_pos;
string_start = glyph;
string_start_x = x;
}
/* Skip all glyphs from string. */
do
{
......
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