From 9bf9f1632bb0b1ac3203056a27ceb69a3fdcb022 Mon Sep 17 00:00:00 2001 From: thatguynoe Date: Mon, 9 Jan 2023 15:01:53 -0500 Subject: [PATCH] improve the glyph-wide-support patch Wide glyph truncation still occurs with the glyph-wide-support patch; see https://github.com/LukeSmithxyz/st/pull/349#issuecomment-1373109437. The code provided by https://github.com/LukeSmithxyz/st/pull/349#issuecomment-1374333271 completely fixes truncation. --- st.c | 3 ++- win.h | 2 +- x.c | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/st.c b/st.c index 1d54c79..62424a1 100644 --- a/st.c +++ b/st.c @@ -2837,7 +2837,8 @@ draw(void) drawregion(0, 0, term.col, term.row); if (term.scr == 0) xdrawcursor(cx, term.c.y, term.line[term.c.y][cx], - term.ocx, term.ocy, term.line[term.ocy][term.ocx]); + term.ocx, term.ocy, term.line[term.ocy][term.ocx], + term.line[term.ocy], term.col); term.ocx = cx; term.ocy = term.c.y; xfinishdraw(); diff --git a/win.h b/win.h index f73088b..31f1ebc 100644 --- a/win.h +++ b/win.h @@ -25,7 +25,7 @@ enum win_mode { void xbell(void); void xclipcopy(void); -void xdrawcursor(int, int, Glyph, int, int, Glyph); +void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int); void xdrawline(Line, int, int, int); void xfinishdraw(void); void xloadcols(void); diff --git a/x.c b/x.c index ca47655..fc4b813 100644 --- a/x.c +++ b/x.c @@ -1670,14 +1670,17 @@ xdrawglyph(Glyph g, int x, int y) } void -xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) +xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int len) { Color drawcol; /* remove the old cursor */ if (selected(ox, oy)) og.mode ^= ATTR_REVERSE; - xdrawglyph(og, ox, oy); + + /* Redraw the line where cursor was previously. + * It will restore wide glyphs broken by the cursor. */ + xdrawline(line, 0, oy, len); if (IS_SET(MODE_HIDE)) return;