commit bae23585084d6f8ed84cb8d71633caa8cba6b9a0
Author: наб <nabijaczleweli_AT_nabijaczleweli.xyz>
Date: Sat Jul 6 01:29:16 2024 +0200
[st][patches][scrollback] Add mark patch
This patch adds a \e[ m escape,
such that Ctrl+PgUp can go directly to the past PS1
diff --git a/st.suckless.org/patches/scrollback/index.md b/st.suckless.org/patches/scrollback/index.md
index 748d870c..3ce3fbaf 100644
--- a/st.suckless.org/patches/scrollback/index.md
+++ b/st.suckless.org/patches/scrollback/index.md
_AT_@ -58,6 +58,10 @@ Apply the following patch on top of the first two to allow changing how fast the
* [st-scrollback-mouse-increment-0.8.2.diff](st-scrollback-mouse-increment-0.8.2.diff)
* [st-scrollback-mouse-increment-0.9.2.diff](st-scrollback-mouse-increment-0.9.2.diff)
+Apply the following patch on top of the first two to allow a `\e[ m` escape,
+marking the line to quickly scroll to with Control+{PageUp, PageDown}.
+* [st-scrollback-mark-0.9.2.diff](st-scrollback-mark-0.9.2.diff)
+
Notes
-----
* Patches modify config.def.h, you need to add mkeys to your own config.h
diff --git a/st.suckless.org/patches/scrollback/st-scrollback-mark-0.9.2.diff b/st.suckless.org/patches/scrollback/st-scrollback-mark-0.9.2.diff
new file mode 100644
index 00000000..c3ac2ac8
--- /dev/null
+++ b/st.suckless.org/patches/scrollback/st-scrollback-mark-0.9.2.diff
_AT_@ -0,0 +1,115 @@
+From eed328240d04caedfaeef83342cf219758e20ded Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli_AT_nabijaczleweli.xyz>
+Date: Sat, 6 Jul 2024 01:00:30 +0200
+Subject: [PATCH] Add \e[ m escape to mark a line. Ctrl+PgUp/+PgDn scroll to
+ marked lines
+
+Primarily useful for C++ enthusiasts so if you get a megabyte of errors
+you can go back to the first one
+
+Recommended usage: PS1="$PS1\e[ m"
+
+Ref:
https://101010.pl/_AT_atax1a@infosec.exchange/112734806523834451
+---
+ config.def.h | 2 ++
+ st.c | 41 +++++++++++++++++++++++++++++++++++++++++
+ st.h | 3 +++
+ 3 files changed, 46 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index fc3079e..5bf8132 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -226,7 +226,9 @@ static Shortcut shortcuts[] = {
+ { ShiftMask, XK_Insert, selpaste, {.i = 0} },
+ { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
+ { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
++ { ControlMask, XK_Page_Up, kscrolltoprevmark },
+ { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
++ { ControlMask, XK_Page_Down, kscrolltonextmark },
+ { TERMMOD, XK_I, iso14755, {.i = 0} },
+ };
+
+diff --git a/st.c b/st.c
+index ddd14c1..353d6c6 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -1104,6 +1104,44 @@ kscrollup(const Arg* a)
+ }
+ }
+
++void
++kscrolltonextmark(const Arg* a)
++{
++ int orig_scr = term.scr;
++
++ while (--term.scr >= 0)
++ if (TLINE(0)->mode & ATTR_MARKED) {
++ found:
++ if (term.scr != orig_scr) {
++ selscroll(0, term.scr - orig_scr);
++ tfulldirt();
++ }
++ return;
++ }
++
++ term.scr = 0;
++ for(int i = 0; i < term.row; ++i)
++ if (TLINE(i)->mode & ATTR_MARKED)
++ goto found;
++
++ term.scr = orig_scr;
++}
++
++void
++kscrolltoprevmark(const Arg* a)
++{
++ int orig_scr = term.scr;
++
++ while (++term.scr <= HISTSIZE)
++ if (TLINE(0)->mode & ATTR_MARKED) {
++ selscroll(0, term.scr - orig_scr);
++ tfulldirt();
++ return;
++ }
++
++ term.scr = orig_scr;
++}
++
+ void
+ tscrolldown(int orig, int n, int copyhist)
+ {
+_AT_@ -1881,6 +1919,9 @@ csihandle(void)
+ if (xsetcursor(csiescseq.arg[0]))
+ goto unknown;
+ break;
++ case 'm': /* mark line to quickly scroll back to later */
++ term.line[term.c.y]->mode |= ATTR_MARKED;
++ break;
+ default:
+ goto unknown;
+ }
+diff --git a/st.h b/st.h
+index 9dba57d..469e5c4 100644
+--- a/st.h
++++ b/st.h
+_AT_@ -35,6 +35,7 @@ enum glyph_attribute {
+ ATTR_WDUMMY = 1 << 10,
+ ATTR_BOXDRAW = 1 << 11,
+ ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
++ ATTR_MARKED = 1 << 12,
+ };
+
+ enum selection_mode {
+_AT_@ -84,6 +85,8 @@ void draw(void);
+
+ void kscrolldown(const Arg *);
+ void kscrollup(const Arg *);
++void kscrolltonextmark(const Arg *);
++void kscrolltoprevmark(const Arg *);
+ void iso14755(const Arg *);
+ void printscreen(const Arg *);
+ void printsel(const Arg *);
+--
+2.39.2
+
Received on Sat Jul 06 2024 - 01:30:44 CEST