[wiki] [sites] [st][patches][scrollback] Add patch Use float argument in kscrollup/kscrolldown instead of int so page can be scrolled more smoothly || SanyaNya

From: <git_AT_suckless.org>
Date: Mon, 13 May 2024 17:27:39 +0200

commit 27a88bd39f26fbc1dee15ffe460fb52ec6ffb797
Author: SanyaNya <sanyanya4ever_AT_gmail.com>
Date: Mon May 13 18:14:53 2024 +0300

    [st][patches][scrollback] Add patch
    Use float argument in kscrollup/kscrolldown instead of int
    so page can be scrolled more smoothly

diff --git a/st.suckless.org/patches/scrollback/index.md b/st.suckless.org/patches/scrollback/index.md
index 661db1eb..763899ce 100644
--- a/st.suckless.org/patches/scrollback/index.md
+++ b/st.suckless.org/patches/scrollback/index.md
_AT_@ -19,6 +19,11 @@ efficient scrolling:
 * [st-scrollback-ringbuffer-0.9.2.diff](st-scrollback-ringbuffer-0.9.2.diff)
 * [st-scrollback-ringbuffer-0.8.5.diff](st-scrollback-ringbuffer-0.8.5.diff)
 
+Apply the following patch on top of the previous to use float argument in
+kscrollup/kscrolldown.
+
+* [st-scrollback-float-0.9.2.diff](st-scrollback-float-0.9.2.diff)
+
 Apply the following patch on top of the previous to allow column and row reflow.
 
 * [st-scrollback-reflow-0.8.5.diff](st-scrollback-reflow-0.8.5.diff)
diff --git a/st.suckless.org/patches/scrollback/st-scrollback-float-0.9.2.diff b/st.suckless.org/patches/scrollback/st-scrollback-float-0.9.2.diff
new file mode 100644
index 00000000..e4243dc9
--- /dev/null
+++ b/st.suckless.org/patches/scrollback/st-scrollback-float-0.9.2.diff
_AT_@ -0,0 +1,52 @@
+diff --git a/config.def.h b/config.def.h
+index 8b25d40..6769f99 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -201,8 +201,8 @@ static Shortcut shortcuts[] = {
+ { TERMMOD, XK_Y, selpaste, {.i = 0} },
+ { ShiftMask, XK_Insert, selpaste, {.i = 0} },
+ { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
+- { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
+- { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
++ { ShiftMask, XK_Page_Up, kscrollup, {.f = -0.1} },
++ { ShiftMask, XK_Page_Down, kscrolldown, {.f = -0.1} },
+ };
+
+ /*
+diff --git a/st.c b/st.c
+index a3b3c9d..5a93594 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -1087,14 +1087,14 @@ tswapscreen(void)
+ void
+ kscrollup(const Arg *a)
+ {
+- int n = a->i;
++ float n = a->f;
+
+ if (IS_SET(MODE_ALTSCREEN))
+ return;
+
+- if (n < 0) n = (-n) * term.row;
++ if (n < 0) n = MAX((-n) * term.row, 1);
+ if (n > TSCREEN.size - term.row - TSCREEN.off) n = TSCREEN.size - term.row - TSCREEN.off;
+- while (!TLINE(-n)) --n;
++ while (!TLINE((int)-n)) --n;
+ TSCREEN.off += n;
+ selscroll(0, n);
+ tfulldirt();
+_AT_@ -1104,12 +1104,12 @@ void
+ kscrolldown(const Arg *a)
+ {
+
+- int n = a->i;
++ float n = a->f;
+
+ if (IS_SET(MODE_ALTSCREEN))
+ return;
+
+- if (n < 0) n = (-n) * term.row;
++ if (n < 0) n = MAX((-n) * term.row, 1);
+ if (n > TSCREEN.off) n = TSCREEN.off;
+ TSCREEN.off -= n;
+ selscroll(0, -n);
Received on Mon May 13 2024 - 17:27:39 CEST

This archive was generated by hypermail 2.3.0 : Mon May 13 2024 - 17:36:53 CEST