mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
osc133: initial patch implementation (#127)
* osc133: initial patch implementation * Specify dependency on reflow or scrollback patch
This commit is contained in:
parent
e7bdaa65d7
commit
fe065cc366
@ -467,6 +467,10 @@ static Shortcut shortcuts[] = {
|
|||||||
#if INVERT_PATCH
|
#if INVERT_PATCH
|
||||||
{ TERMMOD, XK_X, invert, { 0 } },
|
{ TERMMOD, XK_X, invert, { 0 } },
|
||||||
#endif // INVERT_PATCH
|
#endif // INVERT_PATCH
|
||||||
|
#if OSC133_PATCH
|
||||||
|
{ TERMMOD, XK_Z, scrolltoprompt, {.i = -1}, S_PRI },
|
||||||
|
{ TERMMOD, XK_X, scrolltoprompt, {.i = 1}, S_PRI },
|
||||||
|
#endif // OSC133_PATCH
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
27
patch/osc133.c
Normal file
27
patch/osc133.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
if (!dy || tisaltscr())
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (y = dy; y >= top && y <= bot; y += dy) {
|
||||||
|
for (line = TLINE(y), x = 0; x < term.col; x++) {
|
||||||
|
if (line[x].mode & ATTR_FTCS_PROMPT)
|
||||||
|
goto scroll;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scroll:
|
||||||
|
if (dy < 0)
|
||||||
|
kscrollup(&((Arg){ .i = -y }));
|
||||||
|
else
|
||||||
|
kscrolldown(&((Arg){ .i = y }));
|
||||||
|
}
|
1
patch/osc133.h
Normal file
1
patch/osc133.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
static void scrolltoprompt(const Arg *);
|
@ -47,3 +47,6 @@
|
|||||||
#if XRESOURCES_PATCH
|
#if XRESOURCES_PATCH
|
||||||
#include "xresources.c"
|
#include "xresources.c"
|
||||||
#endif
|
#endif
|
||||||
|
#if OSC133_PATCH
|
||||||
|
#include "osc133.c"
|
||||||
|
#endif
|
||||||
|
@ -41,3 +41,6 @@
|
|||||||
#if XRESOURCES_PATCH
|
#if XRESOURCES_PATCH
|
||||||
#include "xresources.h"
|
#include "xresources.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if OSC133_PATCH
|
||||||
|
#include "osc133.h"
|
||||||
|
#endif
|
||||||
|
@ -301,6 +301,13 @@
|
|||||||
*/
|
*/
|
||||||
#define OPENURLONCLICK_PATCH 0
|
#define OPENURLONCLICK_PATCH 0
|
||||||
|
|
||||||
|
/* This patch allows jumping between prompts by utilizing the OSC 133 escape sequence
|
||||||
|
* emitted by shells. Must be used with either reflow or scrollback patch.
|
||||||
|
*
|
||||||
|
* https://codeberg.org/dnkl/foot#jumping-between-prompts
|
||||||
|
*/
|
||||||
|
#define OSC133_PATCH 0
|
||||||
|
|
||||||
/* Reflow.
|
/* Reflow.
|
||||||
* Allows st to be resized without cutting off text when the terminal window is made larger again.
|
* Allows st to be resized without cutting off text when the terminal window is made larger again.
|
||||||
* Text wraps when the terminal window is made smaller.
|
* Text wraps when the terminal window is made smaller.
|
||||||
|
22
st.c
22
st.c
@ -2699,6 +2699,25 @@ strhandle(void)
|
|||||||
tfulldirt();
|
tfulldirt();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
#if OSC133_PATCH
|
||||||
|
case 133:
|
||||||
|
if (narg < 2)
|
||||||
|
break;
|
||||||
|
switch (*strescseq.args[1]) {
|
||||||
|
case 'A':
|
||||||
|
term.c.attr.mode |= ATTR_FTCS_PROMPT;
|
||||||
|
break;
|
||||||
|
/* We don't handle these arguments yet */
|
||||||
|
case 'B':
|
||||||
|
case 'C':
|
||||||
|
case 'D':
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "erresc: unknown OSC 133 argument: %c\n", *strescseq.args[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
#endif // OSC133_PATCH
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'k': /* old title set compatibility */
|
case 'k': /* old title set compatibility */
|
||||||
@ -3449,6 +3468,9 @@ check_control_code:
|
|||||||
}
|
}
|
||||||
|
|
||||||
tsetchar(u, &term.c.attr, term.c.x, term.c.y);
|
tsetchar(u, &term.c.attr, term.c.x, term.c.y);
|
||||||
|
#if OSC133_PATCH
|
||||||
|
term.c.attr.mode &= ~ATTR_FTCS_PROMPT;
|
||||||
|
#endif // OSC133_PATCH
|
||||||
term.lastc = u;
|
term.lastc = u;
|
||||||
|
|
||||||
if (width == 2) {
|
if (width == 2) {
|
||||||
|
3
st.h
3
st.h
@ -70,6 +70,9 @@ enum glyph_attribute {
|
|||||||
ATTR_HIGHLIGHT = 1 << 17,
|
ATTR_HIGHLIGHT = 1 << 17,
|
||||||
#endif // KEYBOARDSELECT_PATCH
|
#endif // KEYBOARDSELECT_PATCH
|
||||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||||
|
#if OSC133_PATCH
|
||||||
|
ATTR_FTCS_PROMPT = 1 << 18, /* OSC 133 ; A ST */
|
||||||
|
#endif // OSC133_PATCH
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SIXEL_PATCH
|
#if SIXEL_PATCH
|
||||||
|
Loading…
Reference in New Issue
Block a user