st

Suckless' st with my personal patches
git clone https://git.instinctive.eu/st.git
Log | Files | Refs | README | LICENSE

commit 715db96836504afc597e3d9aeb9649f20c8010d2
parent bf3ba4f37384914a708637eff02641b13f6d931c
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Sat, 10 Aug 2024 16:41:50 +0200

[nat] personal touches to colorschemes

Diffstat:
Mconfig.def.h | 54+++++++++++++++++++++++-------------------------------
Mst.c | 22----------------------
Mst.h | 2--
Mx.c | 18+++---------------
4 files changed, 26 insertions(+), 70 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -111,74 +111,66 @@ char *termname = "st-256color"; */ unsigned int tabspaces = 8; -typedef struct { - const char* const colors[258]; /* terminal colors */ - unsigned int fg; /* foreground */ - unsigned int bg; /* background */ - unsigned int cs; /* cursor */ - unsigned int rcs; /* reverse cursor */ -} ColorScheme; /* * Terminal colors (16 first used in escape sequence, - * 2 last for custom cursor color), - * foreground, background, cursor, reverse cursor + * 4 last for customs colors: cursor, reverse cursor, foreground, background */ -static const ColorScheme schemes[] = { +static const char * schemes[][260] = { // st (dark) - {{"black", "red3", "green3", "yellow3", + { "black", "red3", "green3", "yellow3", "blue2", "magenta3", "cyan3", "gray90", "gray50", "red", "green", "yellow", "#5c5cff", "magenta", "cyan", "white", - [256]="#cccccc", "#555555"}, 7, 0, 256, 257}, + [256]="#cccccc", "#555555", "gray90", "black" }, // Alacritty (dark) - {{"#1d1f21", "#cc6666", "#b5bd68", "#f0c674", + { "#1d1f21", "#cc6666", "#b5bd68", "#f0c674", "#81a2be", "#b294bb", "#8abeb7", "#c5c8c6", "#666666", "#d54e53", "#b9ca4a", "#e7c547", "#7aa6da", "#c397d8", "#70c0b1", "#eaeaea", - [256]="#cccccc", "#555555"}, 7, 0, 256, 257}, + [256]="#cccccc", "#555555", "#c5c8c6", "#1d1f21" }, // One Half dark - {{"#282c34", "#e06c75", "#98c379", "#e5c07b", + { "#282c34", "#e06c75", "#98c379", "#e5c07b", "#61afef", "#c678dd", "#56b6c2", "#dcdfe4", "#282c34", "#e06c75", "#98c379", "#e5c07b", "#61afef", "#c678dd", "#56b6c2", "#dcdfe4", - [256]="#cccccc", "#555555"}, 7, 0, 256, 257}, + [256]="#cccccc", "#555555", "#dcdfe4", "#282c34" }, // One Half light - {{"#fafafa", "#e45649", "#50a14f", "#c18401", - "#0184bc", "#a626a4", "#0997b3", "#383a42", + { "#fafafa", "#e45649", "#50a14f", "#c18401", + "#0184bc", "#a626a4", "#0997b3", "#383a42", "#fafafa", "#e45649", "#50a14f", "#c18401", "#0184bc", "#a626a4", "#0997b3", "#383a42", - [256]="#cccccc", "#555555"}, 7, 0, 256, 257}, + [256]="#cccccc", "#555555", "#383a42", "#fafafa" }, // Solarized dark - {{"#073642", "#dc322f", "#859900", "#b58900", + { "#073642", "#dc322f", "#859900", "#b58900", "#268bd2", "#d33682", "#2aa198", "#eee8d5", "#002b36", "#cb4b16", "#586e75", "#657b83", "#839496", "#6c71c4", "#93a1a1", "#fdf6e3", - [256]="#93a1a1", "#fdf6e3"}, 12, 8, 256, 257}, + [256]="#93a1a1", "#fdf6e3", "#839496", "#002b36" }, // Solarized light - {{"#eee8d5", "#dc322f", "#859900", "#b58900", + { "#eee8d5", "#dc322f", "#859900", "#b58900", "#268bd2", "#d33682", "#2aa198", "#073642", "#fdf6e3", "#cb4b16", "#93a1a1", "#839496", "#657b83", "#6c71c4", "#586e75", "#002b36", - [256]="#586e75", "#002b36"}, 12, 8, 256, 257}, + [256]="#586e75", "#002b36", "#657b83", "#fdf6e3" }, // Gruvbox dark - {{"#282828", "#cc241d", "#98971a", "#d79921", + { "#282828", "#cc241d", "#98971a", "#d79921", "#458588", "#b16286", "#689d6a", "#a89984", "#928374", "#fb4934", "#b8bb26", "#fabd2f", "#83a598", "#d3869b", "#8ec07c", "#ebdbb2", - [256]="#ebdbb2", "#555555"}, 15, 0, 256, 257}, + [256]="#ebdbb2", "#555555", "#ebdbb2", "#282828" }, // Gruvbox light - {{"#fbf1c7", "#cc241d", "#98971a", "#d79921", + { "#fbf1c7", "#cc241d", "#98971a", "#d79921", "#458588", "#b16286", "#689d6a", "#7c6f64", "#928374", "#9d0006", "#79740e", "#b57614", "#076678", "#8f3f71", "#427b58", "#3c3836", - [256]="#3c3836", "#555555"}, 15, 0, 256, 257}, + [256]="#3c3836", "#555555", "#3c3836", "#fbf1c7" }, }; static const char * const * colorname; @@ -188,10 +180,10 @@ int colorscheme = 0; * Default colors (colorname index) * foreground, background, cursor, reverse cursor */ -unsigned int defaultfg; -unsigned int defaultbg; -unsigned int defaultcs; -static unsigned int defaultrcs; +unsigned int defaultfg = 258; +unsigned int defaultbg = 259; +unsigned int defaultcs = 256; +static unsigned int defaultrcs = 257; /* * Default shape of cursor diff --git a/st.c b/st.c @@ -2201,28 +2201,6 @@ tstrsequence(uchar c) } void -tupdatebgcolor(int oldbg, int newbg) -{ - for (int y = 0; y < term.row; y++) { - for (int x = 0; x < term.col; x++) { - if (term.line[y][x].bg == oldbg) - term.line[y][x].bg = newbg; - } - } -} - -void -tupdatefgcolor(int oldfg, int newfg) -{ - for (int y = 0; y < term.row; y++) { - for (int x = 0; x < term.col; x++) { - if (term.line[y][x].fg == oldfg) - term.line[y][x].fg = newfg; - } - } -} - -void tcontrolcode(uchar ascii) { switch (ascii) { diff --git a/st.h b/st.h @@ -92,8 +92,6 @@ int tattrset(int); void tnew(int, int); void tresize(int, int); void tsetdirtattr(int); -void tupdatebgcolor(int, int); -void tupdatefgcolor(int, int); void ttyhangup(void); int ttynew(const char *, char *, const char *, char **); size_t ttyread(void); diff --git a/x.c b/x.c @@ -829,7 +829,7 @@ xloadcols(void) for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); } else { - dc.collen = 258; + dc.collen = 260; dc.col = xmalloc(dc.collen * sizeof(Color)); } @@ -2196,16 +2196,8 @@ updatescheme(void) oldbg = defaultbg; oldfg = defaultfg; - colorname = schemes[colorscheme].colors; - defaultbg = schemes[colorscheme].bg; - defaultfg = schemes[colorscheme].fg; - defaultcs = schemes[colorscheme].cs; - defaultrcs = schemes[colorscheme].rcs; + colorname = schemes[colorscheme]; xloadcols(); - if (defaultbg != oldbg) - tupdatebgcolor(oldbg, defaultbg); - if (defaultfg != oldfg) - tupdatefgcolor(oldfg, defaultfg); cresize(win.w, win.h); redraw(); } @@ -2262,11 +2254,7 @@ main(int argc, char *argv[]) } ARGEND; run: - colorname = schemes[colorscheme].colors; - defaultbg = schemes[colorscheme].bg; - defaultfg = schemes[colorscheme].fg; - defaultcs = schemes[colorscheme].cs; - defaultrcs = schemes[colorscheme].rcs; + colorname = schemes[colorscheme]; if (argc > 0) /* eat all remaining arguments */ opt_cmd = argv;