st-flexipatch
st-flexipatch copied to clipboard
osc133: initial patch implementation
This patch introduces support for OSC133 as discussed in #126. It borrows veltza's st-sx implementation and introduces two new key bindings, <ctrl+shift+z/x>
to scroll between prompts.
I'm wondering if the OSC 133 should be a core feature since it doesn't do anything by itself. Only certain patches such as the scrollback and externalpipe can take advantage of it.
I'd propose these changes as the patch seems to specifically depend on the reflow patch. I think technically it would be feasible to make it work with the scrollback patch as well, but that can be added later if need be.
diff --git a/config.def.h b/config.def.h
index 18df30f..fe1584a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -457,7 +457,7 @@ static Shortcut shortcuts[] = {
#if INVERT_PATCH
{ TERMMOD, XK_X, invert, { 0 } },
#endif // INVERT_PATCH
- #if OSC133_PATCH
+ #if OSC133_PATCH && REFLOW_PATCH
{ TERMMOD, XK_Z, scrolltoprompt, {.i = -1}, S_PRI },
{ TERMMOD, XK_X, scrolltoprompt, {.i = 1}, S_PRI },
#endif // OSC133_PATCH
diff --git a/patch/x_include.c b/patch/x_include.c
index 30b77da..62664b1 100644
--- a/patch/x_include.c
+++ b/patch/x_include.c
@@ -47,6 +47,6 @@
#if XRESOURCES_PATCH
#include "xresources.c"
#endif
-#if OSC133_PATCH
+#if OSC133_PATCH && REFLOW_PATCH
#include "osc133.c"
#endif
diff --git a/patch/x_include.h b/patch/x_include.h
index 859a58a..6908792 100644
--- a/patch/x_include.h
+++ b/patch/x_include.h
@@ -41,6 +41,6 @@
#if XRESOURCES_PATCH
#include "xresources.h"
#endif
-#if OSC133_PATCH
+#if OSC133_PATCH && REFLOW_PATCH
#include "osc133.h"
-#endif // OSC133_PATCH
+#endif
diff --git a/patches.def.h b/patches.def.h
index c4d613c..a0384eb 100644
--- a/patches.def.h
+++ b/patches.def.h
@@ -295,7 +295,7 @@
#define OPENURLONCLICK_PATCH 0
/* This patch allows jumping between prompts by utilizing the OSC 133 escape sequence
- * emitted by shells.
+ * emitted by shells. This patch depends on the reflow patch.
*
* https://codeberg.org/dnkl/foot#jumping-between-prompts
*/
I'd propose these changes as the patch seems to specifically depend on the reflow patch. I think technically it would be feasible to make it work with the scrollback patch as well, but that can be added later if need be.
True, reflow uses term.histf
and scrollback uses term.histn
variable. Same purpose, but different name. It's easy to fix:
diff --git a/patch/osc133.c b/patch/osc133.c
index 30c3e35..6d72453 100644
--- a/patch/osc133.c
+++ b/patch/osc133.c
@@ -1,6 +1,10 @@
void scrolltoprompt(const Arg *arg) {
int x, y;
+ #if REFLOW_PATCH
int top = term.scr - term.histf;
+ #else
+ int top = term.scr - term.histn;
+ #endif // REFLOW_PATCH
int bot = term.scr + term.row-1;
int dy = arg->i;
Line line;
@bakkeby @veltza I have incorporated your changes and have tested it with both scrollback and reflow patches. It works. Please let me know if anything else is required.
I just noticed that ctrl+shift+x
clashes with the invert patch. So, maybe we should change the default keys to ctrl+shift+a/z
?
Fine with me. I'll wait for bakkeby.
Ok, let him decide. But either way, I give this the green light.
I am not too concerned about what the default keybindings are. Using A/Z may be suitable for QUERTY and AZERTY, while less so for QUERTZ. Probably not something to think too much about.
Alternatively one could use Ctrl+XK_Page_Up / XK_Page_Down as the default and users can optimise as they please in their own configuration.
Being able to scroll to the previous prompt(s) is a really cool feature.
Since everyone is onboard. Please feel free to merge the PR @bakkeby.
Having given it some thought I think that it makes sense to move the default configuration to use Ctrl + PgUp/Down for this scroll feature. It aligns well with the scrollback's keybindings of Shift + PgUp/Down.
I'll merge and apply that.
Thanks a lot to both of you. This is a really handy feature!