From 6ce9ec69ade63fd32c3768cfc96ff1bdad4f5076 Mon Sep 17 00:00:00 2001 From: badarg1 <96699566+badarg1@users.noreply.github.com> Date: Mon, 17 Oct 2022 13:39:34 +0200 Subject: [PATCH] Fixed a glitch when using using the keyboardselect and scrollback patches. (#48) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Scrolling back and then entering keyboardselect's copy mode causes glitched text to appear when moving the cursor. This is because the keyboardselect patch is not aware of the scrollback history (term.hist), so it takes the text from the last displayed screen (term.line). Co-authored-by: Àlex Ramírez --- patch/keyboardselect_st.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/patch/keyboardselect_st.c b/patch/keyboardselect_st.c index d6faac2..7599d9d 100644 --- a/patch/keyboardselect_st.c +++ b/patch/keyboardselect_st.c @@ -33,6 +33,21 @@ void set_notifmode(int type, KeySym ksym) drawregion(0, bot, col, bot + 1); } +#if SCROLLBACK_PATCH && KEYBOARDSELECT_PATCH +Glyph getglyph(Term term, int y, int x) +{ + Glyph g; + int realy = y - term.scr; + if(realy >= 0) { + g = term.line[realy][x]; + } else { + realy = term.histi - term.scr + y + 1; + g = term.hist[realy][x]; + } + return g; +} +#endif + void select_or_drawcursor(int selectsearch_mode, int type) { int done = 0; @@ -45,6 +60,9 @@ void select_or_drawcursor(int selectsearch_mode, int type) xdrawcursor(term.c.x, term.c.y, term.line[term.c.y][term.c.x], term.ocx, term.ocy, term.line[term.ocy][term.ocx], term.line[term.ocy], term.col); + #elif SCROLLBACK_PATCH && KEYBOARDSELECT_PATCH + xdrawcursor(term.c.x, term.c.y, getglyph(term, term.c.y, term.c.x), + term.ocx, term.ocy, getglyph(term, term.ocy, term.ocx)); #else xdrawcursor(term.c.x, term.c.y, term.line[term.c.y][term.c.x], term.ocx, term.ocy, term.line[term.ocy][term.ocx]); @@ -219,4 +237,4 @@ int trt_kbdselect(KeySym ksym, char *buf, int len) } quant = 0; return 0; -} \ No newline at end of file +}