From 1252a3d79dcc679c16477c99b4df5a8217632581 Mon Sep 17 00:00:00 2001 From: ant Date: Sat, 4 Jan 2025 21:59:53 +0100 Subject: [PATCH 01/38] fontfeature patch --- hb.c | 13 +++++-------- hb.h | 4 ++++ patches.def.h | 6 +++++- x.c | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/hb.c b/hb.c index ae3dcc3..d2edd98 100644 --- a/hb.c +++ b/hb.c @@ -35,13 +35,6 @@ typedef struct { static RuneBuffer hbrunebuffer = { 0, NULL }; static hb_buffer_t *hbbuffer; -/* - * Poplulate the array with a list of font features, wrapped in FEATURE macro, - * e. g. - * FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g') - */ -hb_feature_t features[] = { }; - void hbcreatebuffer(void) { @@ -125,7 +118,11 @@ hbtransform(HbTransformData *data, XftFont *xfont, const Glyph *glyphs, int star hb_buffer_add_codepoints(buffer, hbrunebuffer.runes, length, 0, length); /* Shape the segment. */ - hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t)); + #if FONTFEATURES_PATCH + hb_shape(font, buffer, data->features, data->features_count); + #else + hb_shape(font, buffer, NULL, 0); + #endif /* Get new glyph info. */ hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, &glyph_count); diff --git a/hb.h b/hb.h index cb7ea48..3517855 100644 --- a/hb.h +++ b/hb.h @@ -7,6 +7,10 @@ typedef struct { hb_glyph_info_t *glyphs; hb_glyph_position_t *positions; unsigned int count; +#if FONTFEATURES_PATCH + hb_feature_t *features; + int features_count; +#endif // FONTFEATURES_PATCH } HbTransformData; void hbcreatebuffer(void); diff --git a/patches.def.h b/patches.def.h index 7bf33cc..896395f 100644 --- a/patches.def.h +++ b/patches.def.h @@ -249,7 +249,11 @@ * https://github.com/cog1to/st-ligatures * https://st.suckless.org/patches/ligatures/ */ -#define LIGATURES_PATCH 0 +#define LIGATURES_PATCH 1 + +/* This patch add support for custom font features. It depends on the LIGATURES_PATCH patch + */ +#define FONTFEATURES_PATCH 1 /* This patch makes st ignore terminal color attributes by forcing display of the default * foreground and background colors only - making for a monochrome look. Idea ref. diff --git a/x.c b/x.c index e761c84..faae7a4 100644 --- a/x.c +++ b/x.c @@ -1770,6 +1770,26 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x xp = winx, yp = winy + font->ascent; #endif // VERTCENTER_PATCH cluster_xp = xp; cluster_yp = yp; + #if FONTFEATURES_PATCH + { // Get font features + shaped.features = (hb_feature_t *) malloc(sizeof(hb_feature_t) * 128); + FcChar8 *s; + int feature_idx = 0; + while (FcPatternGetString(font->pattern, FC_FONT_FEATURES, feature_idx, &s) == FcResultMatch) { + if (strlen(s) != 4) + die("Invalid font feature tag"); + if (feature_idx >= 128) + die("Too many font features"); + shaped.features[feature_idx].tag = HB_TAG(s[0], s[1], s[2], s[3]); + shaped.features[feature_idx].value = 1; + shaped.features[feature_idx].start = HB_FEATURE_GLOBAL_START; + shaped.features[feature_idx].end = HB_FEATURE_GLOBAL_END; + feature_idx++; + } + shaped.features_count = feature_idx; + } + #endif // FONTFEATURES_PATCH + /* Shape the segment. */ hbtransform(&shaped, font->match, glyphs, 0, len); #endif // LIGATURES_PATCH From 8ced61c5e348916e27d70cc65f1ece0f20804849 Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Wed, 8 Jan 2025 14:05:15 +0100 Subject: [PATCH 02/38] config: increase scroll speed --- config.def.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index 7baab30..62b69c1 100644 --- a/config.def.h +++ b/config.def.h @@ -380,8 +380,8 @@ static MouseShortcut mshortcuts[] = { { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, #endif // CLIPBOARD_PATCH #if SCROLLBACK_MOUSE_PATCH - { ShiftMask, Button4, kscrollup, {.i = 1}, 0, S_PRI}, - { ShiftMask, Button5, kscrolldown, {.i = 1}, 0, S_PRI}, + { ShiftMask, Button4, kscrollup, {.i = 4}, 0, S_PRI}, + { ShiftMask, Button5, kscrolldown, {.i = 4}, 0, S_PRI}, #elif UNIVERSCROLL_PATCH { XK_ANY_MOD, Button4, ttysend, {.s = "\033[5;2~"}, 0, S_PRI }, { XK_ANY_MOD, Button5, ttysend, {.s = "\033[6;2~"}, 0, S_PRI }, @@ -390,8 +390,8 @@ static MouseShortcut mshortcuts[] = { { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} }, #endif // SCROLLBACK_MOUSE_PATCH #if SCROLLBACK_MOUSE_ALTSCREEN_PATCH || REFLOW_PATCH - { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, S_PRI }, - { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, S_PRI }, + { XK_ANY_MOD, Button4, kscrollup, {.i = 4}, 0, S_PRI }, + { XK_ANY_MOD, Button5, kscrolldown, {.i = 4}, 0, S_PRI }, { XK_ANY_MOD, Button4, ttysend, {.s = "\031"}, 0, S_ALT }, { XK_ANY_MOD, Button5, ttysend, {.s = "\005"}, 0, S_ALT }, #else From 81a9b451e9fe5141d0c6a7e5bb85c80d4176eaf3 Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:02:31 +0100 Subject: [PATCH 03/38] font default to caskadia --- config.def.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index 62b69c1..d824981 100644 --- a/config.def.h +++ b/config.def.h @@ -5,13 +5,10 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; +static char *font = "Cascadia Code NF:regular:pixelsize=16:fontfeatures=calt,ss01:antialias=true:autohint=true"; #if FONT2_PATCH /* Spare fonts */ -static char *font2[] = { -/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */ -/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */ -}; +static char *font2[] = { "CaskaydiaCove Nerd Font:pixelsize=16:antialias=true:autohint=true" }; #endif // FONT2_PATCH #if BACKGROUND_IMAGE_PATCH From d17eac914f872705b08988b69ae62f1aff070978 Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:05:02 +0100 Subject: [PATCH 04/38] Add darkman patch a patch to choose between two color themes by executing a command --- config.def.h | 38 ++++++++++++++++++++++++++++++++++++++ patches.def.h | 3 +++ x.c | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index d824981..fcf0487 100644 --- a/config.def.h +++ b/config.def.h @@ -212,6 +212,44 @@ static const char *colorname[] = { "#e5e5e5", /* 259 -> fg */ }; +#if DARKMAN_PATCH +#define colorname_len (sizeof(colorname) / sizeof(char *)) + +enum theme { + THEME_LIGHT, + THEME_DARK, + THEME_NUM, +}; + +/* Terminal colors (16 first used in escape sequence) */ +static const char *colornames[THEME_NUM][colorname_len] = { + { }, { + "#1a1a1a", /* hard contrast: #1d2021 / soft contrast: #32302f */ + "#f4005f", + "#98e024", + "#fa8419", + "#9d65ff", + "#f4005f", + "#58d1eb", + "#c4c5b5", + "#625e4c", + "#f4005f", + "#98e024", + "#e0d561", + "#9d65ff", + "#f4005f", + "#58d1eb", + "#f6f6ef", + [255] = 0, + /* more colors can be added after 255 to use with DefaultXX */ + "#aaaaaa", /* 256 -> cursor */ + "#555555", /* 257 -> rev cursor*/ + "#000000", /* 258 -> bg */ + "#ffffff", /* 259 -> fg */ +}}; + +#endif // DARKMAN_PATCH + /* * Default colors (colorname index) diff --git a/patches.def.h b/patches.def.h index 896395f..20bff47 100644 --- a/patches.def.h +++ b/patches.def.h @@ -255,6 +255,9 @@ */ #define FONTFEATURES_PATCH 1 +#define DARKMAN_PATCH 1 + + /* This patch makes st ignore terminal color attributes by forcing display of the default * foreground and background colors only - making for a monochrome look. Idea ref. * https://www.reddit.com/r/suckless/comments/ixbx6z/how_to_use_black_and_white_only_for_st/ diff --git a/x.c b/x.c index faae7a4..c80e772 100644 --- a/x.c +++ b/x.c @@ -802,10 +802,13 @@ setsel(char *str, Time t) #endif // CLIPBOARD_PATCH } -#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH +#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH || DARKMAN_PATCH void sigusr1_reload(int sig) { + #if DARKMAN_PATCH + xloadcols(); + #endif // DARKMAN_PATCH #if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH reload_config(sig); #endif // XRESOURCES_RELOAD_PATCH @@ -988,6 +991,28 @@ xloadalpha(void) } #endif // ALPHA_FOCUS_HIGHLIGHT_PATCH +#if DARKMAN_PATCH +void +darkmanThemeChoose() { + FILE *fp; + char path[128]; + + fp = popen("darkman get", "r"); + if (fp == NULL) { + memcpy(colorname, colornames[0], sizeof(colorname)); + } else { + /* match the stdout with the theme */ + while (fgets(path, sizeof(path)-1, fp) != NULL) { + if (strcmp(path, "light\n") == 0) { + memcpy(colorname, colornames[0], sizeof(colorname)); + } else if (strcmp(path, "dark\n") == 0) { + memcpy(colorname, colornames[1], sizeof(colorname)); + } + } + } +} +#endif // DARKMAN_PATCH + #if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH void xloadcols(void) @@ -1021,6 +1046,8 @@ xloadcols(void) static int loaded; Color *cp; + darkmanThemeChoose(); + if (loaded) { for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); @@ -4045,9 +4072,12 @@ run: setlocale(LC_CTYPE, ""); XSetLocaleModifiers(""); - #if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH + #if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH || DARKMAN_PATCH signal(SIGUSR1, sigusr1_reload); - #endif // XRESOURCES_RELOAD_PATCH | BACKGROUND_IMAGE_RELOAD_PATCH + #endif // XRESOURCES_RELOAD_PATCH | BACKGROUND_IMAGE_RELOAD_PATCH | DARKMAN_PATCH + #if DARKMAN_PATCH + memcpy(colornames[0], colorname, sizeof(colorname)); + #endif // DARKMAN_PATCH #if XRESOURCES_PATCH if (!(xw.dpy = XOpenDisplay(NULL))) die("Can't open display\n"); From 38dcc0e8661ecb98bee5e75ce529d3b97d2be147 Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:07:50 +0100 Subject: [PATCH 05/38] change default colors --- config.def.h | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/config.def.h b/config.def.h index fcf0487..bdaac0a 100644 --- a/config.def.h +++ b/config.def.h @@ -182,34 +182,29 @@ char *xdndescchar = " !\"#$&'()*;<>?[\\]^`{|}~"; #endif // DRAG_AND_DROP_PATCH /* Terminal colors (16 first used in escape sequence) */ -static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#add8e6", /* 256 -> cursor */ - "#555555", /* 257 -> rev cursor*/ - "#000000", /* 258 -> bg */ - "#e5e5e5", /* 259 -> fg */ +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", + [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 */ }; #if DARKMAN_PATCH From 4d18a5e1040cdb3166caf1b5b7f967ea139b96af Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:09:02 +0100 Subject: [PATCH 06/38] change keys to keyboard select and zoom --- config.def.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index bdaac0a..44813c9 100644 --- a/config.def.h +++ b/config.def.h @@ -452,8 +452,8 @@ static Shortcut shortcuts[] = { { ControlMask, XK_Print, toggleprinter, {.i = 0} }, { ShiftMask, XK_Print, printscreen, {.i = 0} }, { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, - { TERMMOD, XK_Prior, zoom, {.f = +1} }, - { TERMMOD, XK_Next, zoom, {.f = -1} }, + { MODKEY | ControlMask, XK_comma, zoom, {.f = +1} }, + { MODKEY | ControlMask, XK_semicolon, zoom, {.f = -1} }, { TERMMOD, XK_Home, zoomreset, {.f = 0} }, { TERMMOD, XK_C, clipcopy, {.i = 0} }, { TERMMOD, XK_V, clippaste, {.i = 0} }, @@ -497,7 +497,7 @@ static Shortcut shortcuts[] = { #endif // EXTERNALPIPEIN_PATCH #endif // EXTERNALPIPE_PATCH #if KEYBOARDSELECT_PATCH - { TERMMOD, XK_Escape, keyboard_select, { 0 } }, + { TERMMOD, XK_space, keyboard_select, { 0 } }, #endif // KEYBOARDSELECT_PATCH #if KEYBOARDSELECT_PATCH && REFLOW_PATCH { TERMMOD, XK_F, searchforward, { 0 } }, From 653e567b29aa9273a4c912675bbbf516b78a6bf1 Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:11:37 +0100 Subject: [PATCH 07/38] enable patches I want --- config.mk | 12 ++++++------ patches.def.h | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/config.mk b/config.mk index a3b94cd..fc54978 100644 --- a/config.mk +++ b/config.mk @@ -21,14 +21,14 @@ PKG_CONFIG = pkg-config #XCURSOR = `$(PKG_CONFIG) --libs xcursor` # Uncomment the lines below for the ligatures patch / LIGATURES_PATCH -#LIGATURES_C = hb.c -#LIGATURES_H = hb.h -#LIGATURES_INC = `$(PKG_CONFIG) --cflags harfbuzz` -#LIGATURES_LIBS = `$(PKG_CONFIG) --libs harfbuzz` +LIGATURES_C = hb.c +LIGATURES_H = hb.h +LIGATURES_INC = `$(PKG_CONFIG) --cflags harfbuzz` +LIGATURES_LIBS = `$(PKG_CONFIG) --libs harfbuzz` # Uncomment this for the SIXEL patch / SIXEL_PATCH -#SIXEL_C = sixel.c sixel_hls.c -#SIXEL_LIBS = `$(PKG_CONFIG) --libs imlib2` +SIXEL_C = sixel.c sixel_hls.c +SIXEL_LIBS = `$(PKG_CONFIG) --libs imlib2` # Uncomment for the netwmicon patch / NETWMICON_PATCH #NETWMICON_LIBS = `$(PKG_CONFIG) --libs gdlib` diff --git a/patches.def.h b/patches.def.h index 20bff47..5fd71db 100644 --- a/patches.def.h +++ b/patches.def.h @@ -70,12 +70,12 @@ * This patch makes bold text rendered simply as bold, leaving the color unaffected. * https://st.suckless.org/patches/bold-is-not-bright/ */ -#define BOLD_IS_NOT_BRIGHT_PATCH 0 +#define BOLD_IS_NOT_BRIGHT_PATCH 1 /* This patch adds custom rendering of lines/blocks/braille characters for gapless alignment. * https://st.suckless.org/patches/boxdraw/ */ -#define BOXDRAW_PATCH 0 +#define BOXDRAW_PATCH 1 /* By default st only sets PRIMARY on selection. * This patch makes st set CLIPBOARD on selection. @@ -192,7 +192,7 @@ * that are available to GUI applications. * https://st.suckless.org/patches/fix_keyboard_input/ */ -#define FIXKEYBOARDINPUT_PATCH 0 +#define FIXKEYBOARDINPUT_PATCH 1 /* This patch allows you to add spare font besides the default. Some glyphs can be not present in * the default font. For this glyphs st uses font-config and try to find them in font cache first. @@ -200,7 +200,7 @@ * So they will be used first for glyphs that are absent in the default font. * https://st.suckless.org/patches/font2/ */ -#define FONT2_PATCH 0 +#define FONT2_PATCH 1 /* This patch adds the ability to toggle st into fullscreen mode. * Two key bindings are defined: F11 which is typical with other applications and Alt+Enter @@ -239,7 +239,7 @@ * * https://st.suckless.org/patches/keyboard_select/ */ -#define KEYBOARDSELECT_PATCH 0 +#define KEYBOARDSELECT_PATCH 1 /* This patch adds support for drawing ligatures using the Harfbuzz library to transform * original text of a single line to a list of glyphs with ligatures included. @@ -302,7 +302,7 @@ * same CWD (current working directory) as the original st instance. * https://st.suckless.org/patches/newterm/ */ -#define NEWTERM_PATCH 0 +#define NEWTERM_PATCH 1 /* This patch will set the _MOTIF_WM_HINTS property for the st window which, if the window manager * respects it, will show the st window without window decorations. @@ -327,7 +327,7 @@ * * https://www.reddit.com/r/suckless/comments/cc83om/st_open_url/ */ -#define OPENURLONCLICK_PATCH 0 +#define OPENURLONCLICK_PATCH 1 /* This patch allows st to fetch the current working directory through the OSC 7 escape * sequence emitted by shells. Must be used with newterm patch. @@ -349,7 +349,7 @@ * Text wraps when the terminal window is made smaller. * Comes with scrollback. */ -#define REFLOW_PATCH 0 +#define REFLOW_PATCH 1 /* This patch allows you to specify a border that is relative in size to the width of a cell * in the terminal. @@ -366,19 +366,19 @@ /* Scroll back through terminal output using Shift+{PageUp, PageDown}. * https://st.suckless.org/patches/scrollback/ */ -#define SCROLLBACK_PATCH 0 +#define SCROLLBACK_PATCH 1 /* Scroll back through terminal output using Shift+MouseWheel. * This variant depends on SCROLLBACK_PATCH being enabled. * https://st.suckless.org/patches/scrollback/ */ -#define SCROLLBACK_MOUSE_PATCH 0 +#define SCROLLBACK_MOUSE_PATCH 1 /* Scroll back through terminal output using mouse wheel (when not in MODE_ALTSCREEN). * This variant depends on SCROLLBACK_PATCH being enabled. * https://st.suckless.org/patches/scrollback/ */ -#define SCROLLBACK_MOUSE_ALTSCREEN_PATCH 0 +#define SCROLLBACK_MOUSE_ALTSCREEN_PATCH 1 /* This patch adds the two color-settings selectionfg and selectionbg to config.def.h. * Those define the fore- and background colors which are used when text on the screen is selected @@ -412,7 +412,7 @@ * * https://gist.github.com/saitoha/70e0fdf22e3e8f63ce937c7f7da71809 */ -#define SIXEL_PATCH 0 +#define SIXEL_PATCH 1 /* This patch allows clients to embed into the st window and is useful if you tend to * start X applications from the terminal. For example: @@ -472,7 +472,7 @@ * * https://st.suckless.org/patches/undercurl/ */ -#define UNDERCURL_PATCH 0 +#define UNDERCURL_PATCH 1 /* Allows mouse scroll without modifier keys for regardless of alt screen using the external * scroll program. From bedf74d2ad1e34a9b07cddb95846e451167a62c2 Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:15:49 +0100 Subject: [PATCH 08/38] Add a nix flake --- default.nix | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..0450b6c --- /dev/null +++ b/default.nix @@ -0,0 +1,56 @@ +{ lib +, stdenv +, pkg-config +, fontconfig +, freetype +, libX11 +, libXft +, harfbuzz +, gd +, glib +, ncurses +, writeText +, conf ? null +, patches ? [] +, extraLibs ? [] +, nixosTests +, imlib2 +}: + +stdenv.mkDerivation rec { + pname = "st"; + version = "0.8.5"; + + src = ./.; + inherit patches; + + configFile = + lib.optionalString (conf != null) (writeText "config.def.h" conf); + + postPatch = lib.optionalString (conf != null) "cp ${configFile} config.def.h" + + lib.optionalString stdenv.isDarwin '' + substituteInPlace config.mk --replace "-lrt" "" + ''; + + strictDeps = true; + + makeFlags = [ "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" ]; + + nativeBuildInputs = [ pkg-config ncurses fontconfig freetype ]; + buildInputs = [ libX11 libXft harfbuzz gd glib imlib2 ] ++ extraLibs; + + preInstall = '' + export TERMINFO=$out/share/terminfo + ''; + + installFlags = [ "PREFIX=$(out)" ]; + + passthru.tests.test = nixosTests.terminal-emulators.st; + + meta = with lib; { + description = "st terminal"; + license = licenses.mit; + maintainers = with maintainers; [ sioodmy ]; + platforms = platforms.unix; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..586a00c --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1736549401, + "narHash": "sha256-ibkQrMHxF/7TqAYcQE+tOnIsSEzXmMegzyBWza6uHKM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1dab772dd4a68a7bba5d9460685547ff8e17d899", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a30e80d --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + description = "st terminal"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in rec { + packages = flake-utils.lib.flattenTree { + st = pkgs.callPackage ./default.nix { }; + }; + defaultPackage = packages.st; + apps.st = flake-utils.lib.mkApp { + drv = packages.st; + exePath = "/bin/st"; + }; + apps.default = apps.st; + defaultApp = apps.st; + devShell = pkgs.mkShell rec { + name = "st"; + packages = with pkgs; [ + pkg-config + xorg.libX11 + xorg.libXft + fontconfig + harfbuzz.dev + imlib2 + gd + glib + # ccls + # bear + # lldb + # gdb + # valgrind + ]; + }; + + }); +} From 568f306b14040bb55f802562125e6ac83bf8d483 Mon Sep 17 00:00:00 2001 From: ant Date: Wed, 21 May 2025 20:49:42 +0200 Subject: [PATCH 09/38] enable boxdraw --- config.def.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index 44813c9..bf02b2d 100644 --- a/config.def.h +++ b/config.def.h @@ -127,11 +127,11 @@ int hidecursor = 1; * Bold affects lines thickness if boxdraw_bold is not 0. Italic is ignored. * 0: disable (render all U25XX glyphs normally from the font). */ -const int boxdraw = 0; -const int boxdraw_bold = 0; +const int boxdraw = 1; +const int boxdraw_bold = 1; /* braille (U28XX): 1: render as adjacent "pixels", 0: use font */ -const int boxdraw_braille = 0; +const int boxdraw_braille = 1; #endif // BOXDRAW_PATCH /* From 4194b515ee7e7cc34d60754b105652be9d24ee23 Mon Sep 17 00:00:00 2001 From: ant Date: Wed, 21 May 2025 20:41:36 +0200 Subject: [PATCH 10/38] Enable alpha patch --- patches.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches.def.h b/patches.def.h index 5fd71db..d927446 100644 --- a/patches.def.h +++ b/patches.def.h @@ -14,7 +14,7 @@ * when including this patch. * https://st.suckless.org/patches/alpha/ */ -#define ALPHA_PATCH 0 +#define ALPHA_PATCH 1 /* The alpha focus highlight patch allows the user to specify two distinct opacity values or * background colors in order to easily differentiate between focused and unfocused terminal From ccaedf3fe98564fd1faa08fefa6b999d1dd2e55f Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Mon, 2 Jun 2025 09:17:07 +0200 Subject: [PATCH 11/38] decrease default font size --- config.def.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index bf02b2d..89b6319 100644 --- a/config.def.h +++ b/config.def.h @@ -5,10 +5,10 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "Cascadia Code NF:regular:pixelsize=16:fontfeatures=calt,ss01:antialias=true:autohint=true"; +static char *font = "Cascadia Code NF:regular:pixelsize=13.5:fontfeatures=calt,ss01:antialias=true:autohint=true"; #if FONT2_PATCH /* Spare fonts */ -static char *font2[] = { "CaskaydiaCove Nerd Font:pixelsize=16:antialias=true:autohint=true" }; +static char *font2[] = { "CaskaydiaCove Nerd Font:pixelsize=13.5:antialias=true:autohint=true" }; #endif // FONT2_PATCH #if BACKGROUND_IMAGE_PATCH From 659b803a409bb0a289d0b952b6e39cea74c54317 Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Fri, 18 Jul 2025 00:22:52 +0200 Subject: [PATCH 12/38] add keybinnds to scroll --- config.def.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.def.h b/config.def.h index 89b6319..6b3b9c9 100644 --- a/config.def.h +++ b/config.def.h @@ -472,6 +472,10 @@ static Shortcut shortcuts[] = { #if SCROLLBACK_PATCH || REFLOW_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 #if CLIPBOARD_PATCH { TERMMOD, XK_Y, clippaste, {.i = 0} }, From 87c6c244c4768d16a33513d3741c38b2b1179ae0 Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Fri, 3 Oct 2025 13:21:56 +0200 Subject: [PATCH 13/38] change colors for light theme --- config.def.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/config.def.h b/config.def.h index 6b3b9c9..c91e5bd 100644 --- a/config.def.h +++ b/config.def.h @@ -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 From df11aae8c32bf17858e4bd83e0936bd91a2b560a Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 30 Nov 2025 15:17:14 +0100 Subject: [PATCH 14/38] Revert "change colors for light theme" This reverts commit 042af42400e57abd9d1ad50f6094ea09b2679b2d. --- config.def.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/config.def.h b/config.def.h index c91e5bd..6b3b9c9 100644 --- a/config.def.h +++ b/config.def.h @@ -162,7 +162,7 @@ unsigned int tabspaces = 8; #if ALPHA_PATCH /* bg opacity */ -float alpha = 0.9; +float alpha = 0.8; #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[] = { - "#000000", - "#ff3333", - "#86b200", - "#f19618", - "#41a6d9", - "#f07078", - "#4cbe99", - "#ffffff", - "#323232", - "#ff6565", - "#b8e532", - "#ffc849", - "#73d7ff", - "#ffa3aa", - "#7ff0cb", - "#ffffff", + "#011627", /* hard contrast: #1d2021 / soft contrast: #32302f */ + "#d3423e", + "#2aa298", + "#daaa01", + "#4876d6", + "#403f53", + "#08916a", + "#7a8181", + "#7a8181", + "#f76e6e", + "#49d0c5", + "#dac26b", + "#5ca7e4", + "#697098", + "#00c990", + "#989fb1", [255] = 0, /* more colors can be added after 255 to use with DefaultXX */ "#403f53", /* 256 -> cursor */ - "#f0ede4", /* 257 -> rev cursor*/ - "#fafafa", /* 258 -> bg */ - "#5b6673", /* 259 -> fg */ + "#f2f2f2", /* 257 -> rev cursor*/ + "#ffffff", /* 258 -> bg */ + "#403f53", /* 259 -> fg */ }; #if DARKMAN_PATCH From 540ccc2b576256dc182e8bd427b64db92c3ec6ec Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Thu, 5 Feb 2026 11:02:35 +0100 Subject: [PATCH 15/38] fix: alt key with two bytes keys --- x.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x.c b/x.c index c80e772..c61ccbd 100644 --- a/x.c +++ b/x.c @@ -3740,6 +3740,13 @@ kpress(XEvent *ev) len = 2; } } + if (len > 1 && len != 64 && e->state & Mod1Mask) { + // TODO: does this work with MODE_8BIT ? + for (int i = len; i != 0; i -= 1) + buf[i] = buf[i-1]; + buf[0] = '\033'; + len += 1; + } ttywrite(buf, len, 1); } From cc852e9a86a734bacab5363fee8e6ad2324c3f8b Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Sat, 14 Feb 2026 21:09:51 +0100 Subject: [PATCH 16/38] Skip DCS escape sequences if buffer is full ref. #190 --- st.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/st.c b/st.c index 3f1fcd6..411c732 100644 --- a/st.c +++ b/st.c @@ -3466,6 +3466,11 @@ check_control_code: return; #if SIXEL_PATCH } else if (term.esc & ESC_DCS) { + /* Skip if DCS escape sequence buffer is full */ + if (csiescseq.len >= sizeof(csiescseq.buf) - 1) { + return; + } + csiescseq.buf[csiescseq.len++] = u; if (BETWEEN(u, 0x40, 0x7E) || csiescseq.len >= \ From 721a6908778d65301e1ad840e21455e40ac4ffc4 Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Wed, 18 Feb 2026 11:19:39 +0100 Subject: [PATCH 17/38] Bump to 0723b7e. Disable bracked paste in reset. Sadly, there are too many programs today that enable this mode and it is becoming very common to find the terminal adding characters before and after in every of your pastes. A reset should disable this mode. https://git.suckless.org/st/commit/0723b7e39e73b2bcfce047b047f6e795d6184028.html --- st.c | 1 + 1 file changed, 1 insertion(+) diff --git a/st.c b/st.c index 411c732..661926d 100644 --- a/st.c +++ b/st.c @@ -3332,6 +3332,7 @@ eschandle(uchar ascii) resettitle(); xloadcols(); xsetmode(0, MODE_HIDE); + xsetmode(0, MODE_BRCKTPASTE); #if SCROLLBACK_PATCH && !REFLOW_PATCH if (!IS_SET(MODE_ALTSCREEN)) { term.scr = 0; From dab1ddca8c5a93330528a3dde96b9b8a10a2ce01 Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Wed, 18 Feb 2026 11:21:22 +0100 Subject: [PATCH 18/38] Bump to 688f70a. st: guard tsetdirt() against zero-sized terminal tsetdirt() assumes term.row > 0. During early init or resize paths this may not hold, leading to out-of-bounds access. Bail out early if there are no rows. https://git.suckless.org/st/commit/688f70add0d1da8a416bf7df763328d694a24a3a.html --- README.md | 2 +- st.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a3d670a..8550a70 100644 --- a/README.md +++ b/README.md @@ -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.3 (688f70a, 2026-01-15) 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 diff --git a/st.c b/st.c index 661926d..ae436f3 100644 --- a/st.c +++ b/st.c @@ -1102,6 +1102,9 @@ tsetdirt(int top, int bot) { int i; + if (term.row <= 0) + return; + LIMIT(top, 0, term.row-1); LIMIT(bot, 0, term.row-1); From 3a062c2ba8d4b390090f53f6c38ce2c583098625 Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Tue, 10 Mar 2026 10:44:26 +0100 Subject: [PATCH 19/38] fix: missing else in previous commit --- x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x.c b/x.c index c61ccbd..da24e88 100644 --- a/x.c +++ b/x.c @@ -3740,7 +3740,7 @@ kpress(XEvent *ev) len = 2; } } - if (len > 1 && len != 64 && e->state & Mod1Mask) { + else if (len > 1 && len != 64 && e->state & Mod1Mask) { // TODO: does this work with MODE_8BIT ? for (int i = len; i != 0; i -= 1) buf[i] = buf[i-1]; From b9939ae1136ebfc2452cd9819a6b77c320935a14 Mon Sep 17 00:00:00 2001 From: ant Date: Thu, 12 Mar 2026 19:29:46 +0100 Subject: [PATCH 20/38] symplify nix flake --- default.nix | 56 -------------------------------------------------- flake.lock | 8 ++++---- flake.nix | 59 ++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 44 insertions(+), 79 deletions(-) delete mode 100644 default.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 0450b6c..0000000 --- a/default.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ lib -, stdenv -, pkg-config -, fontconfig -, freetype -, libX11 -, libXft -, harfbuzz -, gd -, glib -, ncurses -, writeText -, conf ? null -, patches ? [] -, extraLibs ? [] -, nixosTests -, imlib2 -}: - -stdenv.mkDerivation rec { - pname = "st"; - version = "0.8.5"; - - src = ./.; - inherit patches; - - configFile = - lib.optionalString (conf != null) (writeText "config.def.h" conf); - - postPatch = lib.optionalString (conf != null) "cp ${configFile} config.def.h" - + lib.optionalString stdenv.isDarwin '' - substituteInPlace config.mk --replace "-lrt" "" - ''; - - strictDeps = true; - - makeFlags = [ "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" ]; - - nativeBuildInputs = [ pkg-config ncurses fontconfig freetype ]; - buildInputs = [ libX11 libXft harfbuzz gd glib imlib2 ] ++ extraLibs; - - preInstall = '' - export TERMINFO=$out/share/terminfo - ''; - - installFlags = [ "PREFIX=$(out)" ]; - - passthru.tests.test = nixosTests.terminal-emulators.st; - - meta = with lib; { - description = "st terminal"; - license = licenses.mit; - maintainers = with maintainers; [ sioodmy ]; - platforms = platforms.unix; - }; -} diff --git a/flake.lock b/flake.lock index 586a00c..71aa6c8 100644 --- a/flake.lock +++ b/flake.lock @@ -20,16 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1736549401, - "narHash": "sha256-ibkQrMHxF/7TqAYcQE+tOnIsSEzXmMegzyBWza6uHKM=", + "lastModified": 1773122722, + "narHash": "sha256-FIqHByVqxCprNjor1NqF80F2QQoiiyqanNNefdlvOg4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1dab772dd4a68a7bba5d9460685547ff8e17d899", + "rev": "62dc67aa6a52b4364dd75994ec00b51fbf474e50", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-24.11", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index a30e80d..6d219c4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,39 +1,60 @@ { description = "st terminal"; - inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in rec { - packages = flake-utils.lib.flattenTree { - st = pkgs.callPackage ./default.nix { }; + packages.st = pkgs.stdenv.mkDerivation { + pname = "st"; + version = "ant"; + + src = ./.; + + postPatch = pkgs.lib.optionalString pkgs.stdenv.isDarwin '' + substituteInPlace config.mk --replace "-lrt" "" + ''; + + strictDeps = true; + + makeFlags = [ "PKG_CONFIG=${pkgs.stdenv.cc.targetPrefix}pkg-config" ]; + + nativeBuildInputs = with pkgs; [ pkg-config ncurses fontconfig freetype ]; + buildInputs = with pkgs; [ libx11 libxft harfbuzz gd glib imlib2 ]; + + preInstall = '' + export TERMINFO=$out/share/terminfo + ''; + + installFlags = [ "PREFIX=$(out)" ]; + + passthru.tests.test = pkgs.nixosTests.terminal-emulators.st; + + meta = with pkgs.lib; { + description = "st terminal"; + license = licenses.mit; + maintainers = [ "ant" ]; + platforms = platforms.unix; + }; }; - defaultPackage = packages.st; + apps.st = flake-utils.lib.mkApp { drv = packages.st; exePath = "/bin/st"; }; apps.default = apps.st; + packages.default = packages.st; defaultApp = apps.st; - devShell = pkgs.mkShell rec { - name = "st"; + + devShell = pkgs.mkShell { + inputsFrom = [ packages.st ]; packages = with pkgs; [ - pkg-config - xorg.libX11 - xorg.libXft - fontconfig - harfbuzz.dev - imlib2 - gd - glib - # ccls - # bear - # lldb - # gdb - # valgrind + bear + clang-tools + gdb ]; }; From a7d0ea2d33dc54a92ef56ce92e8269ef13af9ba1 Mon Sep 17 00:00:00 2001 From: ant Date: Sat, 4 Jan 2025 21:59:53 +0100 Subject: [PATCH 21/38] fontfeature patch --- hb.c | 13 +++++-------- hb.h | 4 ++++ patches.def.h | 6 +++++- x.c | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/hb.c b/hb.c index ae3dcc3..d2edd98 100644 --- a/hb.c +++ b/hb.c @@ -35,13 +35,6 @@ typedef struct { static RuneBuffer hbrunebuffer = { 0, NULL }; static hb_buffer_t *hbbuffer; -/* - * Poplulate the array with a list of font features, wrapped in FEATURE macro, - * e. g. - * FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g') - */ -hb_feature_t features[] = { }; - void hbcreatebuffer(void) { @@ -125,7 +118,11 @@ hbtransform(HbTransformData *data, XftFont *xfont, const Glyph *glyphs, int star hb_buffer_add_codepoints(buffer, hbrunebuffer.runes, length, 0, length); /* Shape the segment. */ - hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t)); + #if FONTFEATURES_PATCH + hb_shape(font, buffer, data->features, data->features_count); + #else + hb_shape(font, buffer, NULL, 0); + #endif /* Get new glyph info. */ hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, &glyph_count); diff --git a/hb.h b/hb.h index cb7ea48..3517855 100644 --- a/hb.h +++ b/hb.h @@ -7,6 +7,10 @@ typedef struct { hb_glyph_info_t *glyphs; hb_glyph_position_t *positions; unsigned int count; +#if FONTFEATURES_PATCH + hb_feature_t *features; + int features_count; +#endif // FONTFEATURES_PATCH } HbTransformData; void hbcreatebuffer(void); diff --git a/patches.def.h b/patches.def.h index 7bf33cc..896395f 100644 --- a/patches.def.h +++ b/patches.def.h @@ -249,7 +249,11 @@ * https://github.com/cog1to/st-ligatures * https://st.suckless.org/patches/ligatures/ */ -#define LIGATURES_PATCH 0 +#define LIGATURES_PATCH 1 + +/* This patch add support for custom font features. It depends on the LIGATURES_PATCH patch + */ +#define FONTFEATURES_PATCH 1 /* This patch makes st ignore terminal color attributes by forcing display of the default * foreground and background colors only - making for a monochrome look. Idea ref. diff --git a/x.c b/x.c index e761c84..faae7a4 100644 --- a/x.c +++ b/x.c @@ -1770,6 +1770,26 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x xp = winx, yp = winy + font->ascent; #endif // VERTCENTER_PATCH cluster_xp = xp; cluster_yp = yp; + #if FONTFEATURES_PATCH + { // Get font features + shaped.features = (hb_feature_t *) malloc(sizeof(hb_feature_t) * 128); + FcChar8 *s; + int feature_idx = 0; + while (FcPatternGetString(font->pattern, FC_FONT_FEATURES, feature_idx, &s) == FcResultMatch) { + if (strlen(s) != 4) + die("Invalid font feature tag"); + if (feature_idx >= 128) + die("Too many font features"); + shaped.features[feature_idx].tag = HB_TAG(s[0], s[1], s[2], s[3]); + shaped.features[feature_idx].value = 1; + shaped.features[feature_idx].start = HB_FEATURE_GLOBAL_START; + shaped.features[feature_idx].end = HB_FEATURE_GLOBAL_END; + feature_idx++; + } + shaped.features_count = feature_idx; + } + #endif // FONTFEATURES_PATCH + /* Shape the segment. */ hbtransform(&shaped, font->match, glyphs, 0, len); #endif // LIGATURES_PATCH From 51ba63e165dccfcd05f580ff9b8f95d47263151d Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Wed, 8 Jan 2025 14:05:15 +0100 Subject: [PATCH 22/38] config: increase scroll speed --- config.def.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index 7baab30..62b69c1 100644 --- a/config.def.h +++ b/config.def.h @@ -380,8 +380,8 @@ static MouseShortcut mshortcuts[] = { { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, #endif // CLIPBOARD_PATCH #if SCROLLBACK_MOUSE_PATCH - { ShiftMask, Button4, kscrollup, {.i = 1}, 0, S_PRI}, - { ShiftMask, Button5, kscrolldown, {.i = 1}, 0, S_PRI}, + { ShiftMask, Button4, kscrollup, {.i = 4}, 0, S_PRI}, + { ShiftMask, Button5, kscrolldown, {.i = 4}, 0, S_PRI}, #elif UNIVERSCROLL_PATCH { XK_ANY_MOD, Button4, ttysend, {.s = "\033[5;2~"}, 0, S_PRI }, { XK_ANY_MOD, Button5, ttysend, {.s = "\033[6;2~"}, 0, S_PRI }, @@ -390,8 +390,8 @@ static MouseShortcut mshortcuts[] = { { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} }, #endif // SCROLLBACK_MOUSE_PATCH #if SCROLLBACK_MOUSE_ALTSCREEN_PATCH || REFLOW_PATCH - { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, S_PRI }, - { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, S_PRI }, + { XK_ANY_MOD, Button4, kscrollup, {.i = 4}, 0, S_PRI }, + { XK_ANY_MOD, Button5, kscrolldown, {.i = 4}, 0, S_PRI }, { XK_ANY_MOD, Button4, ttysend, {.s = "\031"}, 0, S_ALT }, { XK_ANY_MOD, Button5, ttysend, {.s = "\005"}, 0, S_ALT }, #else From 74ca31c0ecd85200bf4c799c23d5e6f0271ffbee Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:02:31 +0100 Subject: [PATCH 23/38] font default to caskadia --- config.def.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index 62b69c1..d824981 100644 --- a/config.def.h +++ b/config.def.h @@ -5,13 +5,10 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; +static char *font = "Cascadia Code NF:regular:pixelsize=16:fontfeatures=calt,ss01:antialias=true:autohint=true"; #if FONT2_PATCH /* Spare fonts */ -static char *font2[] = { -/* "Inconsolata for Powerline:pixelsize=12:antialias=true:autohint=true", */ -/* "Hack Nerd Font Mono:pixelsize=11:antialias=true:autohint=true", */ -}; +static char *font2[] = { "CaskaydiaCove Nerd Font:pixelsize=16:antialias=true:autohint=true" }; #endif // FONT2_PATCH #if BACKGROUND_IMAGE_PATCH From d8bf6e236fbe465611479fbd9dadc72e9241fc1c Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:05:02 +0100 Subject: [PATCH 24/38] Add darkman patch a patch to choose between two color themes by executing a command --- config.def.h | 38 ++++++++++++++++++++++++++++++++++++++ patches.def.h | 3 +++ x.c | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index d824981..fcf0487 100644 --- a/config.def.h +++ b/config.def.h @@ -212,6 +212,44 @@ static const char *colorname[] = { "#e5e5e5", /* 259 -> fg */ }; +#if DARKMAN_PATCH +#define colorname_len (sizeof(colorname) / sizeof(char *)) + +enum theme { + THEME_LIGHT, + THEME_DARK, + THEME_NUM, +}; + +/* Terminal colors (16 first used in escape sequence) */ +static const char *colornames[THEME_NUM][colorname_len] = { + { }, { + "#1a1a1a", /* hard contrast: #1d2021 / soft contrast: #32302f */ + "#f4005f", + "#98e024", + "#fa8419", + "#9d65ff", + "#f4005f", + "#58d1eb", + "#c4c5b5", + "#625e4c", + "#f4005f", + "#98e024", + "#e0d561", + "#9d65ff", + "#f4005f", + "#58d1eb", + "#f6f6ef", + [255] = 0, + /* more colors can be added after 255 to use with DefaultXX */ + "#aaaaaa", /* 256 -> cursor */ + "#555555", /* 257 -> rev cursor*/ + "#000000", /* 258 -> bg */ + "#ffffff", /* 259 -> fg */ +}}; + +#endif // DARKMAN_PATCH + /* * Default colors (colorname index) diff --git a/patches.def.h b/patches.def.h index 896395f..20bff47 100644 --- a/patches.def.h +++ b/patches.def.h @@ -255,6 +255,9 @@ */ #define FONTFEATURES_PATCH 1 +#define DARKMAN_PATCH 1 + + /* This patch makes st ignore terminal color attributes by forcing display of the default * foreground and background colors only - making for a monochrome look. Idea ref. * https://www.reddit.com/r/suckless/comments/ixbx6z/how_to_use_black_and_white_only_for_st/ diff --git a/x.c b/x.c index faae7a4..c80e772 100644 --- a/x.c +++ b/x.c @@ -802,10 +802,13 @@ setsel(char *str, Time t) #endif // CLIPBOARD_PATCH } -#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH +#if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH || DARKMAN_PATCH void sigusr1_reload(int sig) { + #if DARKMAN_PATCH + xloadcols(); + #endif // DARKMAN_PATCH #if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH reload_config(sig); #endif // XRESOURCES_RELOAD_PATCH @@ -988,6 +991,28 @@ xloadalpha(void) } #endif // ALPHA_FOCUS_HIGHLIGHT_PATCH +#if DARKMAN_PATCH +void +darkmanThemeChoose() { + FILE *fp; + char path[128]; + + fp = popen("darkman get", "r"); + if (fp == NULL) { + memcpy(colorname, colornames[0], sizeof(colorname)); + } else { + /* match the stdout with the theme */ + while (fgets(path, sizeof(path)-1, fp) != NULL) { + if (strcmp(path, "light\n") == 0) { + memcpy(colorname, colornames[0], sizeof(colorname)); + } else if (strcmp(path, "dark\n") == 0) { + memcpy(colorname, colornames[1], sizeof(colorname)); + } + } + } +} +#endif // DARKMAN_PATCH + #if ALPHA_PATCH && ALPHA_FOCUS_HIGHLIGHT_PATCH void xloadcols(void) @@ -1021,6 +1046,8 @@ xloadcols(void) static int loaded; Color *cp; + darkmanThemeChoose(); + if (loaded) { for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); @@ -4045,9 +4072,12 @@ run: setlocale(LC_CTYPE, ""); XSetLocaleModifiers(""); - #if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH + #if XRESOURCES_PATCH && XRESOURCES_RELOAD_PATCH || BACKGROUND_IMAGE_PATCH && BACKGROUND_IMAGE_RELOAD_PATCH || DARKMAN_PATCH signal(SIGUSR1, sigusr1_reload); - #endif // XRESOURCES_RELOAD_PATCH | BACKGROUND_IMAGE_RELOAD_PATCH + #endif // XRESOURCES_RELOAD_PATCH | BACKGROUND_IMAGE_RELOAD_PATCH | DARKMAN_PATCH + #if DARKMAN_PATCH + memcpy(colornames[0], colorname, sizeof(colorname)); + #endif // DARKMAN_PATCH #if XRESOURCES_PATCH if (!(xw.dpy = XOpenDisplay(NULL))) die("Can't open display\n"); From 03c0eb9d1eec5b688db3be8f1445405780bb282a Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:07:50 +0100 Subject: [PATCH 25/38] change default colors --- config.def.h | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/config.def.h b/config.def.h index fcf0487..bdaac0a 100644 --- a/config.def.h +++ b/config.def.h @@ -182,34 +182,29 @@ char *xdndescchar = " !\"#$&'()*;<>?[\\]^`{|}~"; #endif // DRAG_AND_DROP_PATCH /* Terminal colors (16 first used in escape sequence) */ -static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", - - [255] = 0, - - /* more colors can be added after 255 to use with DefaultXX */ - "#add8e6", /* 256 -> cursor */ - "#555555", /* 257 -> rev cursor*/ - "#000000", /* 258 -> bg */ - "#e5e5e5", /* 259 -> fg */ +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", + [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 */ }; #if DARKMAN_PATCH From a3de76da581c51ed9bd66396f4729cba860eb2e4 Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:09:02 +0100 Subject: [PATCH 26/38] change keys to keyboard select and zoom --- config.def.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index bdaac0a..44813c9 100644 --- a/config.def.h +++ b/config.def.h @@ -452,8 +452,8 @@ static Shortcut shortcuts[] = { { ControlMask, XK_Print, toggleprinter, {.i = 0} }, { ShiftMask, XK_Print, printscreen, {.i = 0} }, { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, - { TERMMOD, XK_Prior, zoom, {.f = +1} }, - { TERMMOD, XK_Next, zoom, {.f = -1} }, + { MODKEY | ControlMask, XK_comma, zoom, {.f = +1} }, + { MODKEY | ControlMask, XK_semicolon, zoom, {.f = -1} }, { TERMMOD, XK_Home, zoomreset, {.f = 0} }, { TERMMOD, XK_C, clipcopy, {.i = 0} }, { TERMMOD, XK_V, clippaste, {.i = 0} }, @@ -497,7 +497,7 @@ static Shortcut shortcuts[] = { #endif // EXTERNALPIPEIN_PATCH #endif // EXTERNALPIPE_PATCH #if KEYBOARDSELECT_PATCH - { TERMMOD, XK_Escape, keyboard_select, { 0 } }, + { TERMMOD, XK_space, keyboard_select, { 0 } }, #endif // KEYBOARDSELECT_PATCH #if KEYBOARDSELECT_PATCH && REFLOW_PATCH { TERMMOD, XK_F, searchforward, { 0 } }, From cc4388ac0d2f38b57d42ed0520c57c529a604915 Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:11:37 +0100 Subject: [PATCH 27/38] enable patches I want --- config.mk | 12 ++++++------ patches.def.h | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/config.mk b/config.mk index a3b94cd..fc54978 100644 --- a/config.mk +++ b/config.mk @@ -21,14 +21,14 @@ PKG_CONFIG = pkg-config #XCURSOR = `$(PKG_CONFIG) --libs xcursor` # Uncomment the lines below for the ligatures patch / LIGATURES_PATCH -#LIGATURES_C = hb.c -#LIGATURES_H = hb.h -#LIGATURES_INC = `$(PKG_CONFIG) --cflags harfbuzz` -#LIGATURES_LIBS = `$(PKG_CONFIG) --libs harfbuzz` +LIGATURES_C = hb.c +LIGATURES_H = hb.h +LIGATURES_INC = `$(PKG_CONFIG) --cflags harfbuzz` +LIGATURES_LIBS = `$(PKG_CONFIG) --libs harfbuzz` # Uncomment this for the SIXEL patch / SIXEL_PATCH -#SIXEL_C = sixel.c sixel_hls.c -#SIXEL_LIBS = `$(PKG_CONFIG) --libs imlib2` +SIXEL_C = sixel.c sixel_hls.c +SIXEL_LIBS = `$(PKG_CONFIG) --libs imlib2` # Uncomment for the netwmicon patch / NETWMICON_PATCH #NETWMICON_LIBS = `$(PKG_CONFIG) --libs gdlib` diff --git a/patches.def.h b/patches.def.h index 20bff47..5fd71db 100644 --- a/patches.def.h +++ b/patches.def.h @@ -70,12 +70,12 @@ * This patch makes bold text rendered simply as bold, leaving the color unaffected. * https://st.suckless.org/patches/bold-is-not-bright/ */ -#define BOLD_IS_NOT_BRIGHT_PATCH 0 +#define BOLD_IS_NOT_BRIGHT_PATCH 1 /* This patch adds custom rendering of lines/blocks/braille characters for gapless alignment. * https://st.suckless.org/patches/boxdraw/ */ -#define BOXDRAW_PATCH 0 +#define BOXDRAW_PATCH 1 /* By default st only sets PRIMARY on selection. * This patch makes st set CLIPBOARD on selection. @@ -192,7 +192,7 @@ * that are available to GUI applications. * https://st.suckless.org/patches/fix_keyboard_input/ */ -#define FIXKEYBOARDINPUT_PATCH 0 +#define FIXKEYBOARDINPUT_PATCH 1 /* This patch allows you to add spare font besides the default. Some glyphs can be not present in * the default font. For this glyphs st uses font-config and try to find them in font cache first. @@ -200,7 +200,7 @@ * So they will be used first for glyphs that are absent in the default font. * https://st.suckless.org/patches/font2/ */ -#define FONT2_PATCH 0 +#define FONT2_PATCH 1 /* This patch adds the ability to toggle st into fullscreen mode. * Two key bindings are defined: F11 which is typical with other applications and Alt+Enter @@ -239,7 +239,7 @@ * * https://st.suckless.org/patches/keyboard_select/ */ -#define KEYBOARDSELECT_PATCH 0 +#define KEYBOARDSELECT_PATCH 1 /* This patch adds support for drawing ligatures using the Harfbuzz library to transform * original text of a single line to a list of glyphs with ligatures included. @@ -302,7 +302,7 @@ * same CWD (current working directory) as the original st instance. * https://st.suckless.org/patches/newterm/ */ -#define NEWTERM_PATCH 0 +#define NEWTERM_PATCH 1 /* This patch will set the _MOTIF_WM_HINTS property for the st window which, if the window manager * respects it, will show the st window without window decorations. @@ -327,7 +327,7 @@ * * https://www.reddit.com/r/suckless/comments/cc83om/st_open_url/ */ -#define OPENURLONCLICK_PATCH 0 +#define OPENURLONCLICK_PATCH 1 /* This patch allows st to fetch the current working directory through the OSC 7 escape * sequence emitted by shells. Must be used with newterm patch. @@ -349,7 +349,7 @@ * Text wraps when the terminal window is made smaller. * Comes with scrollback. */ -#define REFLOW_PATCH 0 +#define REFLOW_PATCH 1 /* This patch allows you to specify a border that is relative in size to the width of a cell * in the terminal. @@ -366,19 +366,19 @@ /* Scroll back through terminal output using Shift+{PageUp, PageDown}. * https://st.suckless.org/patches/scrollback/ */ -#define SCROLLBACK_PATCH 0 +#define SCROLLBACK_PATCH 1 /* Scroll back through terminal output using Shift+MouseWheel. * This variant depends on SCROLLBACK_PATCH being enabled. * https://st.suckless.org/patches/scrollback/ */ -#define SCROLLBACK_MOUSE_PATCH 0 +#define SCROLLBACK_MOUSE_PATCH 1 /* Scroll back through terminal output using mouse wheel (when not in MODE_ALTSCREEN). * This variant depends on SCROLLBACK_PATCH being enabled. * https://st.suckless.org/patches/scrollback/ */ -#define SCROLLBACK_MOUSE_ALTSCREEN_PATCH 0 +#define SCROLLBACK_MOUSE_ALTSCREEN_PATCH 1 /* This patch adds the two color-settings selectionfg and selectionbg to config.def.h. * Those define the fore- and background colors which are used when text on the screen is selected @@ -412,7 +412,7 @@ * * https://gist.github.com/saitoha/70e0fdf22e3e8f63ce937c7f7da71809 */ -#define SIXEL_PATCH 0 +#define SIXEL_PATCH 1 /* This patch allows clients to embed into the st window and is useful if you tend to * start X applications from the terminal. For example: @@ -472,7 +472,7 @@ * * https://st.suckless.org/patches/undercurl/ */ -#define UNDERCURL_PATCH 0 +#define UNDERCURL_PATCH 1 /* Allows mouse scroll without modifier keys for regardless of alt screen using the external * scroll program. From 405415b61df64b5393844a9445bdafb2ee015b2f Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 12 Jan 2025 16:15:49 +0100 Subject: [PATCH 28/38] Add a nix flake --- default.nix | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..0450b6c --- /dev/null +++ b/default.nix @@ -0,0 +1,56 @@ +{ lib +, stdenv +, pkg-config +, fontconfig +, freetype +, libX11 +, libXft +, harfbuzz +, gd +, glib +, ncurses +, writeText +, conf ? null +, patches ? [] +, extraLibs ? [] +, nixosTests +, imlib2 +}: + +stdenv.mkDerivation rec { + pname = "st"; + version = "0.8.5"; + + src = ./.; + inherit patches; + + configFile = + lib.optionalString (conf != null) (writeText "config.def.h" conf); + + postPatch = lib.optionalString (conf != null) "cp ${configFile} config.def.h" + + lib.optionalString stdenv.isDarwin '' + substituteInPlace config.mk --replace "-lrt" "" + ''; + + strictDeps = true; + + makeFlags = [ "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" ]; + + nativeBuildInputs = [ pkg-config ncurses fontconfig freetype ]; + buildInputs = [ libX11 libXft harfbuzz gd glib imlib2 ] ++ extraLibs; + + preInstall = '' + export TERMINFO=$out/share/terminfo + ''; + + installFlags = [ "PREFIX=$(out)" ]; + + passthru.tests.test = nixosTests.terminal-emulators.st; + + meta = with lib; { + description = "st terminal"; + license = licenses.mit; + maintainers = with maintainers; [ sioodmy ]; + platforms = platforms.unix; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..586a00c --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1736549401, + "narHash": "sha256-ibkQrMHxF/7TqAYcQE+tOnIsSEzXmMegzyBWza6uHKM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1dab772dd4a68a7bba5d9460685547ff8e17d899", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-24.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a30e80d --- /dev/null +++ b/flake.nix @@ -0,0 +1,41 @@ +{ + description = "st terminal"; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in rec { + packages = flake-utils.lib.flattenTree { + st = pkgs.callPackage ./default.nix { }; + }; + defaultPackage = packages.st; + apps.st = flake-utils.lib.mkApp { + drv = packages.st; + exePath = "/bin/st"; + }; + apps.default = apps.st; + defaultApp = apps.st; + devShell = pkgs.mkShell rec { + name = "st"; + packages = with pkgs; [ + pkg-config + xorg.libX11 + xorg.libXft + fontconfig + harfbuzz.dev + imlib2 + gd + glib + # ccls + # bear + # lldb + # gdb + # valgrind + ]; + }; + + }); +} From 89749e95150d815ab72bbc7503ad383c45dd06e9 Mon Sep 17 00:00:00 2001 From: ant Date: Wed, 21 May 2025 20:49:42 +0200 Subject: [PATCH 29/38] enable boxdraw --- config.def.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index 44813c9..bf02b2d 100644 --- a/config.def.h +++ b/config.def.h @@ -127,11 +127,11 @@ int hidecursor = 1; * Bold affects lines thickness if boxdraw_bold is not 0. Italic is ignored. * 0: disable (render all U25XX glyphs normally from the font). */ -const int boxdraw = 0; -const int boxdraw_bold = 0; +const int boxdraw = 1; +const int boxdraw_bold = 1; /* braille (U28XX): 1: render as adjacent "pixels", 0: use font */ -const int boxdraw_braille = 0; +const int boxdraw_braille = 1; #endif // BOXDRAW_PATCH /* From 4a5abeb82a20b611a88ea9ca1ec8debb78c5edad Mon Sep 17 00:00:00 2001 From: ant Date: Wed, 21 May 2025 20:41:36 +0200 Subject: [PATCH 30/38] Enable alpha patch --- patches.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches.def.h b/patches.def.h index 5fd71db..d927446 100644 --- a/patches.def.h +++ b/patches.def.h @@ -14,7 +14,7 @@ * when including this patch. * https://st.suckless.org/patches/alpha/ */ -#define ALPHA_PATCH 0 +#define ALPHA_PATCH 1 /* The alpha focus highlight patch allows the user to specify two distinct opacity values or * background colors in order to easily differentiate between focused and unfocused terminal From a2c1ab57061c1855f048a4bec6b78033b5c5c52c Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Mon, 2 Jun 2025 09:17:07 +0200 Subject: [PATCH 31/38] decrease default font size --- config.def.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index bf02b2d..89b6319 100644 --- a/config.def.h +++ b/config.def.h @@ -5,10 +5,10 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "Cascadia Code NF:regular:pixelsize=16:fontfeatures=calt,ss01:antialias=true:autohint=true"; +static char *font = "Cascadia Code NF:regular:pixelsize=13.5:fontfeatures=calt,ss01:antialias=true:autohint=true"; #if FONT2_PATCH /* Spare fonts */ -static char *font2[] = { "CaskaydiaCove Nerd Font:pixelsize=16:antialias=true:autohint=true" }; +static char *font2[] = { "CaskaydiaCove Nerd Font:pixelsize=13.5:antialias=true:autohint=true" }; #endif // FONT2_PATCH #if BACKGROUND_IMAGE_PATCH From 5efe76d0f6d06f043fdbfcd9dcfecf2a18fe0606 Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Fri, 18 Jul 2025 00:22:52 +0200 Subject: [PATCH 32/38] add keybinnds to scroll --- config.def.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.def.h b/config.def.h index 89b6319..6b3b9c9 100644 --- a/config.def.h +++ b/config.def.h @@ -472,6 +472,10 @@ static Shortcut shortcuts[] = { #if SCROLLBACK_PATCH || REFLOW_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 #if CLIPBOARD_PATCH { TERMMOD, XK_Y, clippaste, {.i = 0} }, From f627e69374c80da5e19ff162e50bf23601e450a6 Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Fri, 3 Oct 2025 13:21:56 +0200 Subject: [PATCH 33/38] change colors for light theme --- config.def.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/config.def.h b/config.def.h index 6b3b9c9..c91e5bd 100644 --- a/config.def.h +++ b/config.def.h @@ -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 From f2fdc033cbb55a505a344d78deb4c87ff435ccbb Mon Sep 17 00:00:00 2001 From: ant Date: Sun, 30 Nov 2025 15:17:14 +0100 Subject: [PATCH 34/38] Revert "change colors for light theme" This reverts commit 042af42400e57abd9d1ad50f6094ea09b2679b2d. --- config.def.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/config.def.h b/config.def.h index c91e5bd..6b3b9c9 100644 --- a/config.def.h +++ b/config.def.h @@ -162,7 +162,7 @@ unsigned int tabspaces = 8; #if ALPHA_PATCH /* bg opacity */ -float alpha = 0.9; +float alpha = 0.8; #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[] = { - "#000000", - "#ff3333", - "#86b200", - "#f19618", - "#41a6d9", - "#f07078", - "#4cbe99", - "#ffffff", - "#323232", - "#ff6565", - "#b8e532", - "#ffc849", - "#73d7ff", - "#ffa3aa", - "#7ff0cb", - "#ffffff", + "#011627", /* hard contrast: #1d2021 / soft contrast: #32302f */ + "#d3423e", + "#2aa298", + "#daaa01", + "#4876d6", + "#403f53", + "#08916a", + "#7a8181", + "#7a8181", + "#f76e6e", + "#49d0c5", + "#dac26b", + "#5ca7e4", + "#697098", + "#00c990", + "#989fb1", [255] = 0, /* more colors can be added after 255 to use with DefaultXX */ "#403f53", /* 256 -> cursor */ - "#f0ede4", /* 257 -> rev cursor*/ - "#fafafa", /* 258 -> bg */ - "#5b6673", /* 259 -> fg */ + "#f2f2f2", /* 257 -> rev cursor*/ + "#ffffff", /* 258 -> bg */ + "#403f53", /* 259 -> fg */ }; #if DARKMAN_PATCH From 9e96ffc61ea8f182f59358d233296f4b4a52b2a4 Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Thu, 5 Feb 2026 11:02:35 +0100 Subject: [PATCH 35/38] fix: alt key with two bytes keys --- x.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x.c b/x.c index c80e772..c61ccbd 100644 --- a/x.c +++ b/x.c @@ -3740,6 +3740,13 @@ kpress(XEvent *ev) len = 2; } } + if (len > 1 && len != 64 && e->state & Mod1Mask) { + // TODO: does this work with MODE_8BIT ? + for (int i = len; i != 0; i -= 1) + buf[i] = buf[i-1]; + buf[0] = '\033'; + len += 1; + } ttywrite(buf, len, 1); } From 3d9c53068d429da6dc30771ecd5f4a7300b8ce13 Mon Sep 17 00:00:00 2001 From: Antoine Vaure Date: Tue, 10 Mar 2026 10:44:26 +0100 Subject: [PATCH 36/38] fix: missing else in previous commit --- x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x.c b/x.c index c61ccbd..da24e88 100644 --- a/x.c +++ b/x.c @@ -3740,7 +3740,7 @@ kpress(XEvent *ev) len = 2; } } - if (len > 1 && len != 64 && e->state & Mod1Mask) { + else if (len > 1 && len != 64 && e->state & Mod1Mask) { // TODO: does this work with MODE_8BIT ? for (int i = len; i != 0; i -= 1) buf[i] = buf[i-1]; From 0814fc7a5dc10f338c425d0b63d17d92b1191a97 Mon Sep 17 00:00:00 2001 From: ant Date: Thu, 12 Mar 2026 19:29:46 +0100 Subject: [PATCH 37/38] symplify nix flake --- default.nix | 56 ------------------------------------------------- flake.lock | 8 +++---- flake.nix | 60 ++++++++++++++++++++++++++++++++++++----------------- 3 files changed, 45 insertions(+), 79 deletions(-) delete mode 100644 default.nix diff --git a/default.nix b/default.nix deleted file mode 100644 index 0450b6c..0000000 --- a/default.nix +++ /dev/null @@ -1,56 +0,0 @@ -{ lib -, stdenv -, pkg-config -, fontconfig -, freetype -, libX11 -, libXft -, harfbuzz -, gd -, glib -, ncurses -, writeText -, conf ? null -, patches ? [] -, extraLibs ? [] -, nixosTests -, imlib2 -}: - -stdenv.mkDerivation rec { - pname = "st"; - version = "0.8.5"; - - src = ./.; - inherit patches; - - configFile = - lib.optionalString (conf != null) (writeText "config.def.h" conf); - - postPatch = lib.optionalString (conf != null) "cp ${configFile} config.def.h" - + lib.optionalString stdenv.isDarwin '' - substituteInPlace config.mk --replace "-lrt" "" - ''; - - strictDeps = true; - - makeFlags = [ "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" ]; - - nativeBuildInputs = [ pkg-config ncurses fontconfig freetype ]; - buildInputs = [ libX11 libXft harfbuzz gd glib imlib2 ] ++ extraLibs; - - preInstall = '' - export TERMINFO=$out/share/terminfo - ''; - - installFlags = [ "PREFIX=$(out)" ]; - - passthru.tests.test = nixosTests.terminal-emulators.st; - - meta = with lib; { - description = "st terminal"; - license = licenses.mit; - maintainers = with maintainers; [ sioodmy ]; - platforms = platforms.unix; - }; -} diff --git a/flake.lock b/flake.lock index 586a00c..71aa6c8 100644 --- a/flake.lock +++ b/flake.lock @@ -20,16 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1736549401, - "narHash": "sha256-ibkQrMHxF/7TqAYcQE+tOnIsSEzXmMegzyBWza6uHKM=", + "lastModified": 1773122722, + "narHash": "sha256-FIqHByVqxCprNjor1NqF80F2QQoiiyqanNNefdlvOg4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1dab772dd4a68a7bba5d9460685547ff8e17d899", + "rev": "62dc67aa6a52b4364dd75994ec00b51fbf474e50", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-24.11", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index a30e80d..03a79a6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,39 +1,61 @@ { description = "st terminal"; - inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in rec { - packages = flake-utils.lib.flattenTree { - st = pkgs.callPackage ./default.nix { }; + packages.st = pkgs.stdenv.mkDerivation { + pname = "st"; + version = "ant"; + + src = ./.; + + postPatch = pkgs.lib.optionalString pkgs.stdenv.isDarwin '' + substituteInPlace config.mk --replace "-lrt" "" + ''; + + strictDeps = true; + + makeFlags = [ "PKG_CONFIG=${pkgs.stdenv.cc.targetPrefix}pkg-config" ]; + + nativeBuildInputs = with pkgs; [ pkg-config ncurses fontconfig freetype ]; + buildInputs = with pkgs; [ libx11 libxft harfbuzz gd glib imlib2 ]; + + preInstall = '' + export TERMINFO=$out/share/terminfo + ''; + + installFlags = [ "PREFIX=$(out)" ]; + + passthru.tests.test = pkgs.nixosTests.terminal-emulators.st; + + meta = with pkgs.lib; { + description = "st terminal"; + license = licenses.mit; + maintainers = [ "ant" ]; + platforms = platforms.unix; + }; }; - defaultPackage = packages.st; + apps.st = flake-utils.lib.mkApp { drv = packages.st; exePath = "/bin/st"; }; apps.default = apps.st; + packages.default = packages.st; defaultApp = apps.st; - devShell = pkgs.mkShell rec { - name = "st"; + + devShell = pkgs.mkShell { + inputsFrom = [ packages.st ]; + hardeningDisable = [ "fortify" ]; packages = with pkgs; [ - pkg-config - xorg.libX11 - xorg.libXft - fontconfig - harfbuzz.dev - imlib2 - gd - glib - # ccls - # bear - # lldb - # gdb - # valgrind + bear + clang-tools + gdb ]; }; From 4c439e7b8ef070be1bbb12d0324a43b5ec889842 Mon Sep 17 00:00:00 2001 From: ant Date: Thu, 12 Mar 2026 21:13:02 +0100 Subject: [PATCH 38/38] use "emoji" as fallback font to prevent crash when emoji is not found --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 6b3b9c9..79e279f 100644 --- a/config.def.h +++ b/config.def.h @@ -8,7 +8,7 @@ static char *font = "Cascadia Code NF:regular:pixelsize=13.5:fontfeatures=calt,ss01:antialias=true:autohint=true"; #if FONT2_PATCH /* Spare fonts */ -static char *font2[] = { "CaskaydiaCove Nerd Font:pixelsize=13.5:antialias=true:autohint=true" }; +static char *font2[] = { "emoji:pixelsize=13.5:antialias=true:autohint=true" }; #endif // FONT2_PATCH #if BACKGROUND_IMAGE_PATCH