commit 6ce9ec69ade63fd32c3768cfc96ff1bdad4f5076
parent d58abd56384f977152ed32ce3cdaeb634cde5a58
Author: badarg1 <96699566+badarg1@users.noreply.github.com>
Date: Mon, 17 Oct 2022 13:39:34 +0200
Fixed a glitch when using using the keyboardselect and scrollback patches. (#48)
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 <aramirez@verbio.com>
Diffstat:
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git 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
+}