mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-22 04:21:24 -08:00
Add the same margin-column handling for term and image glyphs (bug#80025)
* src/term.c (append_glyph): * src/xdisp.c (produce_image_glyph): Copy the margin-column random-access indexing with space-padding from 'append_glyph' in xdisp.c. Also copy code from the end of these functions before return after handling the margin column.
This commit is contained in:
parent
1c55ea07fa
commit
7dd94923ef
2 changed files with 149 additions and 9 deletions
83
src/term.c
83
src/term.c
|
|
@ -1543,16 +1543,85 @@ static void
|
|||
append_glyph (struct it *it)
|
||||
{
|
||||
struct glyph *glyph, *end;
|
||||
enum glyph_row_area area = it->area;
|
||||
int margin_column = -1;
|
||||
int i;
|
||||
|
||||
eassert (it->glyph_row);
|
||||
glyph = (it->glyph_row->glyphs[it->area]
|
||||
+ it->glyph_row->used[it->area]);
|
||||
end = it->glyph_row->glyphs[1 + it->area];
|
||||
|
||||
if ((area == LEFT_MARGIN_AREA || area == RIGHT_MARGIN_AREA)
|
||||
&& it->margin_column >= 0)
|
||||
{
|
||||
margin_column = it->margin_column;
|
||||
}
|
||||
|
||||
if (margin_column >= 0
|
||||
&& margin_column < (area == LEFT_MARGIN_AREA
|
||||
? WINDOW_LEFT_MARGIN_WIDTH (it->w)
|
||||
: WINDOW_RIGHT_MARGIN_WIDTH (it->w)))
|
||||
{
|
||||
/* Fill gaps between current position and target column with spaces. */
|
||||
int face_id = lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID);
|
||||
while (it->glyph_row->used[area] < margin_column
|
||||
&& it->glyph_row->glyphs[area] + it->glyph_row->used[area]
|
||||
< it->glyph_row->glyphs[area + 1])
|
||||
{
|
||||
struct glyph *fill_glyph =
|
||||
it->glyph_row->glyphs[area] + it->glyph_row->used[area];
|
||||
*fill_glyph = space_glyph;
|
||||
fill_glyph->pixel_width = 1;
|
||||
fill_glyph->face_id = face_id;
|
||||
fill_glyph->frame = it->f;
|
||||
++it->glyph_row->used[area];
|
||||
}
|
||||
|
||||
glyph = it->glyph_row->glyphs[area] + margin_column;
|
||||
end = it->glyph_row->glyphs[1 + area];
|
||||
|
||||
/* Increment used counter only after filling with spaces,
|
||||
but not when changing existing column value. */
|
||||
if (margin_column >= it->glyph_row->used[area])
|
||||
it->glyph_row->used[area] = margin_column + 1;
|
||||
|
||||
/* Reset the margin column for next use. */
|
||||
it->margin_column = -1;
|
||||
|
||||
/* Do the same glyph filling as below and return. */
|
||||
if (glyph < end)
|
||||
{
|
||||
glyph->type = CHAR_GLYPH;
|
||||
glyph->pixel_width = 1;
|
||||
glyph->u.ch = it->char_to_display;
|
||||
glyph->frame = it->f;
|
||||
glyph->face_id = it->face_id;
|
||||
glyph->avoid_cursor_p = it->avoid_cursor_p;
|
||||
glyph->multibyte_p = it->multibyte_p;
|
||||
glyph->padding_p = false;
|
||||
glyph->charpos = CHARPOS (it->position);
|
||||
glyph->object = it->object;
|
||||
if (it->bidi_p)
|
||||
{
|
||||
glyph->resolved_level = it->bidi_it.resolved_level;
|
||||
eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
|
||||
glyph->bidi_type = it->bidi_it.type;
|
||||
}
|
||||
else
|
||||
{
|
||||
glyph->resolved_level = 0;
|
||||
glyph->bidi_type = UNKNOWN_BT;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Continue with the default sequential appending. */
|
||||
glyph = it->glyph_row->glyphs[area]
|
||||
+ it->glyph_row->used[area];
|
||||
end = it->glyph_row->glyphs[1 + area];
|
||||
|
||||
/* If the glyph row is reversed, we need to prepend the glyph rather
|
||||
than append it. */
|
||||
if (it->glyph_row->reversed_p && it->area == TEXT_AREA)
|
||||
if (it->glyph_row->reversed_p && area == TEXT_AREA)
|
||||
{
|
||||
struct glyph *g;
|
||||
int move_by = it->pixel_width;
|
||||
|
|
@ -1560,9 +1629,9 @@ append_glyph (struct it *it)
|
|||
/* Make room for the new glyphs. */
|
||||
if (move_by > end - glyph) /* don't overstep end of this area */
|
||||
move_by = end - glyph;
|
||||
for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--)
|
||||
for (g = glyph - 1; g >= it->glyph_row->glyphs[area]; g--)
|
||||
g[move_by] = *g;
|
||||
glyph = it->glyph_row->glyphs[it->area];
|
||||
glyph = it->glyph_row->glyphs[area];
|
||||
end = glyph + move_by;
|
||||
}
|
||||
|
||||
|
|
@ -1596,7 +1665,7 @@ append_glyph (struct it *it)
|
|||
glyph->bidi_type = UNKNOWN_BT;
|
||||
}
|
||||
|
||||
++it->glyph_row->used[it->area];
|
||||
++it->glyph_row->used[area];
|
||||
++glyph;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
75
src/xdisp.c
75
src/xdisp.c
|
|
@ -32234,16 +32234,87 @@ produce_image_glyph (struct it *it)
|
|||
{
|
||||
struct glyph *glyph;
|
||||
enum glyph_row_area area = it->area;
|
||||
int margin_column = -1;
|
||||
|
||||
|
||||
if ((area == LEFT_MARGIN_AREA || area == RIGHT_MARGIN_AREA)
|
||||
&& it->margin_column >= 0)
|
||||
{
|
||||
margin_column = it->margin_column;
|
||||
}
|
||||
|
||||
if (margin_column >= 0
|
||||
&& margin_column < (area == LEFT_MARGIN_AREA
|
||||
? WINDOW_LEFT_MARGIN_WIDTH (it->w)
|
||||
: WINDOW_RIGHT_MARGIN_WIDTH (it->w)))
|
||||
{
|
||||
/* Fill gaps between current position and target column with spaces. */
|
||||
int face_id = lookup_basic_face (it->w, it->f, DEFAULT_FACE_ID);
|
||||
while (it->glyph_row->used[area] < margin_column
|
||||
&& it->glyph_row->glyphs[area] + it->glyph_row->used[area]
|
||||
< it->glyph_row->glyphs[area + 1])
|
||||
{
|
||||
struct glyph *fill_glyph =
|
||||
it->glyph_row->glyphs[area] + it->glyph_row->used[area];
|
||||
*fill_glyph = space_glyph;
|
||||
fill_glyph->pixel_width = FRAME_COLUMN_WIDTH (it->f);
|
||||
fill_glyph->face_id = face_id;
|
||||
fill_glyph->frame = it->f;
|
||||
++it->glyph_row->used[area];
|
||||
}
|
||||
|
||||
glyph = it->glyph_row->glyphs[area] + margin_column;
|
||||
|
||||
/* Increment used counter only after filling with spaces,
|
||||
but not when changing existing column value. */
|
||||
if (margin_column >= it->glyph_row->used[area])
|
||||
it->glyph_row->used[area] = margin_column + 1;
|
||||
|
||||
/* Reset the margin column for next use. */
|
||||
it->margin_column = -1;
|
||||
|
||||
/* Do the same glyph filling as below and return. */
|
||||
if (glyph < it->glyph_row->glyphs[area + 1])
|
||||
{
|
||||
glyph->charpos = CHARPOS (it->position);
|
||||
glyph->object = it->object;
|
||||
glyph->pixel_width = clip_to_bounds (-1, it->pixel_width, SHRT_MAX);
|
||||
glyph->ascent = glyph_ascent;
|
||||
glyph->descent = it->descent;
|
||||
glyph->voffset = it->voffset;
|
||||
glyph->type = IMAGE_GLYPH;
|
||||
glyph->avoid_cursor_p = it->avoid_cursor_p;
|
||||
glyph->multibyte_p = it->multibyte_p;
|
||||
glyph->left_box_line_p = it->start_of_box_run_p;
|
||||
glyph->right_box_line_p = it->end_of_box_run_p;
|
||||
glyph->overlaps_vertically_p = false;
|
||||
glyph->padding_p = false;
|
||||
glyph->glyph_not_available_p = false;
|
||||
glyph->face_id = it->face_id;
|
||||
glyph->u.img_id = img->id;
|
||||
glyph->slice.img = slice;
|
||||
glyph->font_type = FONT_TYPE_UNKNOWN;
|
||||
if (it->bidi_p)
|
||||
{
|
||||
glyph->resolved_level = it->bidi_it.resolved_level;
|
||||
eassert ((it->bidi_it.type & 7) == it->bidi_it.type);
|
||||
glyph->bidi_type = it->bidi_it.type;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Continue with the default sequential appending. */
|
||||
glyph = it->glyph_row->glyphs[area] + it->glyph_row->used[area];
|
||||
if (it->glyph_row->reversed_p)
|
||||
{
|
||||
struct glyph *g;
|
||||
|
||||
/* Make room for the new glyph. */
|
||||
for (g = glyph - 1; g >= it->glyph_row->glyphs[it->area]; g--)
|
||||
for (g = glyph - 1; g >= it->glyph_row->glyphs[area]; g--)
|
||||
g[1] = *g;
|
||||
glyph = it->glyph_row->glyphs[it->area];
|
||||
glyph = it->glyph_row->glyphs[area];
|
||||
}
|
||||
if (glyph < it->glyph_row->glyphs[area + 1])
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue