Compare commits

..

29 commits

Author SHA1 Message Date
Antoine Vaure
042af42400 change colors for light theme 2025-10-03 13:21:56 +02:00
Bakkeby
02627756f1 Bump to 98610fc 2025-08-20 16:27:46 +02:00
Laurent Cheylus
51d32a9a77 Do not interpret CSI ? u as DECRC (#181)
The kitty keyboard protocol docs recommend CSI ? u to query support for
that protocol, see https://sw.kovidgoyal.net/kitty/keyboard-protocol/

For better or worse, fish shell uses this query to work around bugs
in other terminals triggered by requesting that protocol via CSI = 5 u.

Unfortunately, st interprets CSI ? u as DECRC (restore cursor
position). reproduce with 'printf "\x1b[?u"; cat'.

fish could work around this by switching to the alternate screen
before running this query; but that might cause tearing on terminals
that don't support Synchronized Output. I'm not sure.

In the meantime, let's correct our parser.

This adds a redundant else-after-return, for consistency with the
surrounding code.

ref. https://git.suckless.org/st/commit/98610fcd37f655d44586323dc86c1d013c2798ce.html

Signed-off-by: Laurent Cheylus <foxy@free.fr>
2025-08-20 16:27:46 +02:00
Bakkeby
ad3c3e774c sync: add support for DECRQM queries for synchronization ref. #179 2025-08-20 16:27:46 +02:00
Bakkeby
9be6da0370 sync: mode 2026 correction ref. #179 2025-08-20 16:27:46 +02:00
Bakkeby
f7354190f7 sync: adding mode 2026 for the sync patch to allow syncing to be controlled by programs ref. #179 2025-08-20 16:27:46 +02:00
Bakkeby
4da3d6d87c boxdraw: fix for rendering errors following commit f8e451e ref. #180 2025-08-20 16:27:46 +02:00
Bakkeby
821244c2ae OpenBSD compatibility changes 2025-08-20 16:27:46 +02:00
Bakkeby
a12b73a36f Refactoring Xft clipping ref. #175 2025-08-20 16:27:46 +02:00
veltza
49ac4d1e14 Prevent SelectionRequests from interfering with blinking cursor (#173)
Some old clipboard managers, such as greenclip and parcellite,
constantly poll applications with SelectionRequest events, which breaks
the internal timer and blinking cursor. This fix prevents these events
from causing any disruption.

Fixes #172
2025-08-20 16:27:46 +02:00
Bakkeby
0aad70af58 dynamic padding - add explicit dependency on the ANYSIZE_PATCH ref. #168 2025-08-20 16:27:46 +02:00
Bakkeby
5d5fe76795 dynamic cursor color: visual bug on selection ref. #169 2025-08-20 16:27:46 +02:00
Bakkeby
9860867e10 Adding dynamic padding patch - a variant of anysize that do not alter size hints ref. #168 2025-08-20 16:27:46 +02:00
Bakkeby
3c7bcf616d selection colors vs dynamic cursor color patch compatibility issue ref. #167 2025-08-20 16:27:46 +02:00
Bakkeby
50286bb861 reflow: addressing selection clearing bug when selection includes the prompt ref. #166 2025-08-20 16:27:46 +02:00
Bakkeby
c7503f5737 Adding open selected text patch 2025-08-20 16:27:46 +02:00
Bakkeby
137bb152b3 Adding drag-n-drop patch 2025-08-20 16:27:46 +02:00
Antoine Vaure
48f696499d add keybinnds to scroll 2025-07-18 00:25:00 +02:00
Antoine Vaure
cae36041b4 decrease default font size 2025-06-02 09:17:07 +02:00
ant
304293d4e1 Enable alpha patch 2025-05-21 20:50:08 +02:00
ant
5a65d4a512 enable boxdraw 2025-05-21 20:50:08 +02:00
ant
0f0f929022 Add a nix flake 2025-01-12 16:30:56 +01:00
ant
2a20129a48 enable patches I want 2025-01-12 16:30:51 +01:00
ant
f2c7f80738 change keys to keyboard select and zoom 2025-01-12 16:09:02 +01:00
ant
0b4c1084f0 change default colors 2025-01-12 16:07:50 +01:00
ant
816061be47 Add darkman patch
a patch to choose between two color themes by executing a command
2025-01-12 16:07:23 +01:00
ant
292f3ae44d font default to caskadia 2025-01-12 16:07:23 +01:00
Antoine Vaure
c87ded477c config: increase scroll speed 2025-01-12 16:07:23 +01:00
ant
4397a1814f fontfeature patch 2025-01-12 16:07:18 +01:00
8 changed files with 63 additions and 97 deletions

View file

@ -1,4 +1,4 @@
Similar to [dwm-flexipatch](https://github.com/bakkeby/dwm-flexipatch) this st 0.9.3 (6e97047, 2025-08-09) project has a different take on st patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more.
Similar to [dwm-flexipatch](https://github.com/bakkeby/dwm-flexipatch) this st 0.9.2 (98610fc, 2025-01-26) project has a different take on st patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more.
For example to include the `alpha` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/st-flexipatch/blob/master/patches.def.h):
```c
@ -15,8 +15,6 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog:
2025-10-28 - Added the selectionbg-alpha patch
2025-02-20 - Added the drag-n-drop and open-selected-text patches
2024-05-31 - Added the anygeometry patch
@ -262,10 +260,6 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- [right-click-to-plumb](https://st.suckless.org/patches/right_click_to_plumb/)
- allows you to right-click on some selected text to send it to the plumbing program of choice
- [selectionbg-alpha](https://st.suckless.org/patches/selectionbg-alpha/)
- allows for the selection to have a transparent background when combined with the alpha
and selection colors patches
- [scrollback](https://st.suckless.org/patches/scrollback/)
- allows you scroll back through terminal output using keyboard shortcuts or mousewheel

View file

@ -162,7 +162,7 @@ unsigned int tabspaces = 8;
#if ALPHA_PATCH
/* bg opacity */
float alpha = 0.8;
float alpha = 0.9;
#if ALPHA_GRADIENT_PATCH
float grad_alpha = 0.54; //alpha value that'll change
float stat_alpha = 0.46; //constant alpha value that'll get added to grad_alpha
@ -183,28 +183,28 @@ char *xdndescchar = " !\"#$&'()*;<>?[\\]^`{|}~";
/* Terminal colors (16 first used in escape sequence) */
static char *colorname[] = {
"#011627", /* hard contrast: #1d2021 / soft contrast: #32302f */
"#d3423e",
"#2aa298",
"#daaa01",
"#4876d6",
"#403f53",
"#08916a",
"#7a8181",
"#7a8181",
"#f76e6e",
"#49d0c5",
"#dac26b",
"#5ca7e4",
"#697098",
"#00c990",
"#989fb1",
"#000000",
"#ff3333",
"#86b200",
"#f19618",
"#41a6d9",
"#f07078",
"#4cbe99",
"#ffffff",
"#323232",
"#ff6565",
"#b8e532",
"#ffc849",
"#73d7ff",
"#ffa3aa",
"#7ff0cb",
"#ffffff",
[255] = 0,
/* more colors can be added after 255 to use with DefaultXX */
"#403f53", /* 256 -> cursor */
"#f2f2f2", /* 257 -> rev cursor*/
"#ffffff", /* 258 -> bg */
"#403f53", /* 259 -> fg */
"#f0ede4", /* 257 -> rev cursor*/
"#fafafa", /* 258 -> bg */
"#5b6673", /* 259 -> fg */
};
#if DARKMAN_PATCH
@ -469,14 +469,14 @@ static Shortcut shortcuts[] = {
{ XK_NO_MOD, XK_F11, fullscreen, {.i = 0} },
{ MODKEY, XK_Return, fullscreen, {.i = 0} },
#endif // FULLSCREEN_PATCH
#if SCROLLBACK_PATCH || REFLOW_PATCH
#if SCROLLBACK_PATCH
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1}, S_PRI },
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1}, S_PRI },
{ TERMMOD, XK_U, kscrollup, {.i = -1}, S_PRI },
{ TERMMOD, XK_D, kscrolldown, {.i = -1}, S_PRI },
{ TERMMOD, XK_K, kscrollup, {.i = 4}, S_PRI },
{ TERMMOD, XK_J, kscrolldown, {.i = 4}, S_PRI },
#endif // SCROLLBACK_PATCH || REFLOW_PATCH
#endif // SCROLLBACK_PATCH
#if CLIPBOARD_PATCH
{ TERMMOD, XK_Y, clippaste, {.i = 0} },
{ ShiftMask, XK_Insert, clippaste, {.i = 0} },

View file

@ -1,5 +1,5 @@
# st version
VERSION = 0.9.3
VERSION = 0.9.2
# Customize below to fit your system

23
patch/utils.h Normal file
View file

@ -0,0 +1,23 @@
/// Dynamic memory-chunk, with (1) datatype size, (2/3) initialized / allocated chunk, (4) content
typedef struct { uint8_t const elSize; uint32_t init, alloc; char* content; } DynamicArray;
#define UTF8_ARRAY {4, 0, 0, NULL}
static inline int p_alloc(DynamicArray *s, uint32_t amount) {
uint32_t const diff=s->init+s->elSize*amount-s->alloc, nas=s->alloc+max(diff,15)*s->elSize;
if (s->alloc < s->init + s->elSize * amount) {
char* tmp = realloc(s->content, nas);
if (!tmp) return 0;
s->alloc = nas, s->content = tmp;
}
return 1;
}
static inline char *view(DynamicArray * s, uint32_t i) { return s->content + i*s->elSize; }
static inline char *end(DynamicArray *s, uint32_t i) { return s->content +s->init-(i+1)*s->elSize; }
static inline uint32_t getU32(DynamicArray* s, uint32_t i, int b) { return *((uint32_t*) (b ?view(s,i) :end(s,i))); }
static char *expand(DynamicArray *s) { if (!p_alloc(s, 1)) return NULL; s->init += s->elSize; return end(s, 0); }
static inline void pop(DynamicArray* s) { s->init -= s->elSize; }
static inline void empty(DynamicArray* s) { s->init = 0; }
static inline int size(DynamicArray const * s) { return s->init / s->elSize; }
static inline void assign(DynamicArray* s, DynamicArray const *o) {
if (p_alloc(s, size(o))) memcpy(s->content, o->content, (s->init=o->init));
}

View file

@ -74,5 +74,9 @@ reload_config(int sig)
xhints();
XCloseDisplay(dpy);
/* from https://st.suckless.org/patches/xresources-with-reload-signal */
/* triggers re-render if we're visible */
ttywrite("\033[O", 3, 1);
}
#endif // XRESOURCES_RELOAD_PATCH

View file

@ -387,12 +387,6 @@
*/
#define SELECTION_COLORS_PATCH 0
/* This patch works with selectioncolors and alpha patches to make selection
* background color transparent.
* https://st.suckless.org/patches/selectionbg-alpha/
*/
#define SELECTIONBG_ALPHA_PATCH 0
/* This is the single drawable buffer patch as outlined in the FAQ to get images
* in w3m to display. While this patch does not break the alpha patch it images
* are not shown in w3m if the alpha patch is applied.

56
st.c
View file

@ -1837,7 +1837,7 @@ tsetattr(const int *attr, int l)
term.c.attr.fg = idx;
#endif // MONOCHROME_PATCH
break;
case 39: /* set foreground color to default */
case 39:
term.c.attr.fg = defaultfg;
break;
case 48:
@ -1848,7 +1848,7 @@ tsetattr(const int *attr, int l)
term.c.attr.bg = idx;
#endif // MONOCHROME_PATCH
break;
case 49: /* set background color to default */
case 49:
term.c.attr.bg = defaultbg;
break;
#if UNDERCURL_PATCH
@ -1864,13 +1864,6 @@ tsetattr(const int *attr, int l)
term.c.attr.ucolor[2] = -1;
term.c.attr.mode ^= ATTR_DIRTYUNDERLINE;
break;
#else
case 58:
/* This starts a sequence to change the color of
* "underline" pixels. We don't support that and
* instead eat up a following "5;n" or "2;r;g;b". */
tdefcolor(attr, &i, l);
break;
#endif // UNDERCURL_PATCH
default:
if (BETWEEN(attr[i], 30, 37)) {
@ -1985,7 +1978,7 @@ tsetmode(int priv, int set, const int *args, int narg)
case 1006: /* 1006: extended reporting mode */
xsetmode(set, MODE_MOUSESGR);
break;
case 1034: /* 1034: enable 8-bit mode for keyboard input */
case 1034:
xsetmode(set, MODE_8BIT);
break;
case 1049: /* swap screen & set/restore cursor as xterm */
@ -1993,8 +1986,8 @@ tsetmode(int priv, int set, const int *args, int narg)
break;
tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
/* FALLTHROUGH */
case 47: /* swap screen buffer */
case 1047: /* swap screen buffer */
case 47: /* swap screen */
case 1047:
if (!allowaltscreen)
break;
#if REFLOW_PATCH
@ -2018,7 +2011,7 @@ tsetmode(int priv, int set, const int *args, int narg)
break;
/* FALLTHROUGH */
#endif // REFLOW_PATCH
case 1048: /* save/restore cursor (like DECSC/DECRC) */
case 1048:
#if REFLOW_PATCH
if (!allowaltscreen)
break;
@ -2451,22 +2444,10 @@ csihandle(void)
goto unknown;
}
break;
#if SYNC_PATCH || SIXEL_PATCH
#if SYNC_PATCH
case '$': /* DECRQM -- DEC Request Mode (private) */
if (csiescseq.mode[1] == 'p' && csiescseq.priv) {
switch (csiescseq.arg[0]) {
#if SIXEL_PATCH
case 80:
/* Sixel Display Mode */
ttywrite(IS_SET(MODE_SIXEL_SDM) ? "\033[?80;1$y"
: "\033[?80;2$y", 9, 0);
break;
case 8452:
/* Sixel scrolling leaves cursor to right of graphic */
ttywrite(IS_SET(MODE_SIXEL_CUR_RT) ? "\033[?8452;1$y"
: "\033[?8452;2$y", 11, 0);
break;
#endif // SIXEL_PATCH
#if SYNC_PATCH
case 2026:
/* https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036 */
@ -2479,7 +2460,7 @@ csihandle(void)
break;
}
goto unknown;
#endif // SYNC_PATCH | SIXEL_PATCH
#endif // SYNC_PATCH
case 'r': /* DECSTBM -- Set Scrolling Region */
if (csiescseq.priv) {
goto unknown;
@ -2668,7 +2649,7 @@ strhandle(void)
xsettitle(strescseq.args[1]);
#endif // CSI_22_23_PATCH
return;
case 52: /* manipulate selection data */
case 52:
if (narg > 2 && allowwindowops) {
dec = base64dec(strescseq.args[2]);
if (dec) {
@ -2686,9 +2667,9 @@ strhandle(void)
#endif // OSC7_PATCH
case 8: /* Clear Hyperlinks */
return;
case 10: /* set dynamic VT100 text foreground color */
case 11: /* set dynamic VT100 text background color */
case 12: /* set dynamic text cursor color */
case 10:
case 11:
case 12:
if (narg < 2)
break;
p = strescseq.args[1];
@ -2729,19 +2710,6 @@ strhandle(void)
tfulldirt();
}
return;
case 110: /* reset dynamic VT100 text foreground color */
case 111: /* reset dynamic VT100 text background color */
case 112: /* reset dynamic text cursor color */
if (narg != 1)
break;
if ((j = par - 110) < 0 || j >= LEN(osc_table))
break; /* shouldn't be possible */
if (xsetcolorname(osc_table[j].idx, NULL)) {
fprintf(stderr, "erresc: %s color not found\n", osc_table[j].str);
} else {
tfulldirt();
}
return;
#if OSC133_PATCH
case 133:
if (narg < 2)

17
x.c
View file

@ -983,11 +983,6 @@ xloadalpha(void)
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
dc.col[defaultbg].pixel &= 0x00FFFFFF;
dc.col[defaultbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
#if SELECTION_COLORS_PATCH && SELECTIONBG_ALPHA_PATCH
dc.col[selectionbg].color.alpha = (unsigned short)(0xffff * usedAlpha);
dc.col[selectionbg].pixel &= 0x00FFFFFF;
dc.col[selectionbg].pixel |= (unsigned char)(0xff * usedAlpha) << 24;
#endif // SELECTION_COLORS_PATCH && SELECTIONBG_ALPHA_PATCH
}
#endif // ALPHA_FOCUS_HIGHLIGHT_PATCH
@ -1073,18 +1068,6 @@ xloadcols(void)
dc.col[defaultbg].color.red *= alpha;
dc.col[defaultbg].color.green *= alpha;
dc.col[defaultbg].color.blue *= alpha;
#if SELECTION_COLORS_PATCH && SELECTIONBG_ALPHA_PATCH
/* set alpha value of selbg color */
dc.col[selectionbg].color.alpha = (unsigned short)(0xffff * alpha);
dc.col[selectionbg].pixel &= 0x00FFFFFF;
dc.col[selectionbg].pixel |= (unsigned char)(0xff * alpha) << 24;
dc.col[selectionbg].color.red =
((unsigned short)(dc.col[selectionbg].color.red * alpha)) & 0xff00;
dc.col[selectionbg].color.green =
((unsigned short)(dc.col[selectionbg].color.green * alpha)) & 0xff00;
dc.col[selectionbg].color.blue =
((unsigned short)(dc.col[selectionbg].color.blue * alpha)) & 0xff00;
#endif // SELECTION_COLORS_PATCH && SELECTIONBG_ALPHA_PATCH
#endif // ALPHA_PATCH
loaded = 1;
}