Skip to content

Commit

Permalink
Add preliminary support for OSC "133;A"
Browse files Browse the repository at this point in the history
  • Loading branch information
veltza committed Mar 17, 2024
1 parent 2b577c6 commit b696051
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ static Shortcut shortcuts[] = {
{ TERMMOD, XK_space, keyboard_select, { 0 } },
{ TERMMOD, XK_F, searchforward, { 0 } },
{ TERMMOD, XK_B, searchbackward, { 0 } },
{ TERMMOD, XK_Z, scrolltoprompt, {.i = -1}, S_PRI },
{ TERMMOD, XK_X, scrolltoprompt, {.i = 1}, S_PRI },
};

/*
Expand Down
13 changes: 13 additions & 0 deletions st.c
Original file line number Diff line number Diff line change
Expand Up @@ -2409,6 +2409,18 @@ strhandle(void)
tfulldirt();
}
return;
case 133: /* OSC 133 */
if (narg < 2)
break;
switch (*strescseq.args[1]) {
case 'A':
term.c.attr.mode |= ATTR_FTCS_PROMPT;
break;
default:
fprintf(stderr, "erresc: unknown OSC 133 argument: %c\n", *strescseq.args[1]);
break;
}
return;
}
break;
case 'k': /* old title set compatibility */
Expand Down Expand Up @@ -3072,6 +3084,7 @@ tputc(Rune u)
}

tsetchar(u, &term.c.attr, term.c.x, term.c.y);
term.c.attr.mode &= ~ATTR_FTCS_PROMPT;
term.lastc = u;

if (width == 2) {
Expand Down
1 change: 1 addition & 0 deletions st.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ enum glyph_attribute {
ATTR_BOXDRAW = 1 << 13,
ATTR_DIRTYUNDERLINE = 1 << 14,
ATTR_HIGHLIGHT = 1 << 15,
ATTR_FTCS_PROMPT = 1 << 16, /* OSC "133;A" */
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
ATTR_SIXEL = 1 << 31,
};
Expand Down
27 changes: 27 additions & 0 deletions x.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static void ttysend(const Arg *);
static void zoom(const Arg *);
static void zoomabs(const Arg *);
static void zoomreset(const Arg *);
static void scrolltoprompt(const Arg *);

char *font2_xresources[FONT2_XRESOURCES_SIZE];

Expand Down Expand Up @@ -291,6 +292,32 @@ zoomreset(const Arg *arg)
}
}

void
scrolltoprompt(const Arg *arg)
{
int x, y;
int top = term.scr - term.histf;
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 }));
}

int
evcol(XEvent *e)
{
Expand Down

0 comments on commit b696051

Please sign in to comment.