From 667857211072a0d80192e49cf9788ccdbfa856c5 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 17 Nov 2022 11:21:01 +0200 Subject: [PATCH] Fix display of mode line when the right divider is used * src/xdisp.c (init_iterator): For the mode-line, adjust last_visible_x due to the right divider and the 'box' attribute, if any, of the mode-line face. (display_min_width): Update current_x after producing the stretch glyph, to mimic PRODUCE_GLYPHS. (display_mode_line): Widen the last glyph to account for adding the right box line to it. (Bug#5930) --- src/xdisp.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/xdisp.c b/src/xdisp.c index f6a279636a0..3b4f0b39569 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -3342,7 +3342,8 @@ init_iterator (struct it *it, struct window *w, { /* Mode lines, menu bar in terminal frames. */ it->first_visible_x = 0; - it->last_visible_x = body_width = WINDOW_PIXEL_WIDTH (w); + it->last_visible_x = + WINDOW_PIXEL_WIDTH (w) - WINDOW_RIGHT_DIVIDER_WIDTH (w); } else { @@ -3410,8 +3411,13 @@ init_iterator (struct it *it, struct window *w, face = FACE_FROM_ID_OR_NULL (it->f, remapped_base_face_id); if (face && face->box != FACE_NO_BOX) { + int box_thickness = face->box_vertical_line_width; it->face_box_p = true; it->start_of_box_run_p = true; + /* Make sure we will have enough horizontal space to add the + right box line at the end. */ + if (box_thickness > 0) + it->last_visible_x -= box_thickness; } } @@ -5324,6 +5330,8 @@ display_min_width (struct it *it, ptrdiff_t bufpos, /* Insert the stretch glyph. */ it->object = list3 (Qspace, QCwidth, w); produce_stretch_glyph (it); + if (it->area == TEXT_AREA) + it->current_x += it->pixel_width; it->min_width_property = Qnil; } } @@ -26718,7 +26726,17 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format) { struct glyph *last = (it.glyph_row->glyphs[TEXT_AREA] + it.glyph_row->used[TEXT_AREA] - 1); + int box_thickness = face->box_vertical_line_width; last->right_box_line_p = true; + /* Add back the space for the right box line we subtracted in + init_iterator, since the right_box_line_p flag will make the + glyph wider. We actually add only as much space as is + available for the last glyph of the modeline and whatever + space is left beyond it, since that glyph could be only + partially visible */ + if (box_thickness > 0) + last->pixel_width += max (0, (box_thickness + - (it.current_x - it.last_visible_x))); } return it.glyph_row->height; -- 2.39.2