Compare commits
14 commits
df11aae8c3
...
b5498bad11
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5498bad11 | ||
|
|
33209c6746 | ||
|
|
f8b47f894b | ||
|
|
ae3a9baf0d | ||
|
|
1cc56c4856 | ||
|
|
a9d0d20213 | ||
|
|
7415d93cf2 | ||
|
|
d0b32e19c6 | ||
|
|
1ea9ec607b | ||
|
|
84a920d545 | ||
|
|
48defe07d2 | ||
|
|
d44ab2a9a2 | ||
|
|
b8131450b0 | ||
|
|
ec1b8b0ac0 |
7 changed files with 21 additions and 145 deletions
|
|
@ -15,8 +15,6 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
|
|||
|
||||
### Changelog:
|
||||
|
||||
2026-01-08 - Added the xresources-xdefaults patch
|
||||
|
||||
2025-10-28 - Added the selectionbg-alpha patch
|
||||
|
||||
2025-02-20 - Added the drag-n-drop and open-selected-text patches
|
||||
|
|
@ -342,6 +340,3 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
|
|||
- [xresources](https://st.suckless.org/patches/xresources/)
|
||||
- adds the ability to configure st via Xresources
|
||||
- during startup, st will read and apply the resources named in the resources[] array in config.h
|
||||
|
||||
- xresources-xdefaults
|
||||
- allows .Xdefaults to be read as well in addition to the RESOURCE_MANAGER property on the root window
|
||||
|
|
@ -22,8 +22,7 @@ resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
|
|||
|
||||
switch (rtype) {
|
||||
case STRING:
|
||||
/* Note: this leaks memory */
|
||||
*sdst = strdup(ret.addr);
|
||||
*sdst = ret.addr;
|
||||
break;
|
||||
case INTEGER:
|
||||
*idst = strtoul(ret.addr, NULL, 10);
|
||||
|
|
@ -35,102 +34,6 @@ resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if XRESOURCES_XDEFAULTS_PATCH
|
||||
/* Returns an XrmDatabase that needs to be freed by the caller. */
|
||||
static XrmDatabase
|
||||
get_resources(Display *dpy)
|
||||
{
|
||||
/*******************************************************************/
|
||||
/* Adapted from rxvt-unicode-9.31 rxvttoolkit.C get_resources() */
|
||||
/*******************************************************************/
|
||||
char *homedir = getenv("HOME");
|
||||
char fname[1024];
|
||||
|
||||
char *displayResource, *xe;
|
||||
XrmDatabase rdb1;
|
||||
XrmDatabase database = XrmGetStringDatabase("");
|
||||
|
||||
/* For ordering, see for example http://www.faqs.org/faqs/Xt-FAQ/ Subject: 20 */
|
||||
|
||||
/* 6. System wide per application default file. */
|
||||
|
||||
/* Add in $XAPPLRESDIR/St only; not bothering with XUSERFILESEARCHPATH */
|
||||
if ((xe = getenv("XAPPLRESDIR")) || (xe = "/etc/X11/app-defaults"))
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/%s", xe, "St");
|
||||
|
||||
if ((rdb1 = XrmGetFileDatabase(fname)))
|
||||
XrmMergeDatabases(rdb1, &database);
|
||||
}
|
||||
|
||||
/* 5. User's per application default file. None. */
|
||||
|
||||
/* 4. User's defaults file. */
|
||||
if (homedir)
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/.Xdefaults", homedir);
|
||||
|
||||
if ((rdb1 = XrmGetFileDatabase(fname)))
|
||||
XrmMergeDatabases(rdb1, &database);
|
||||
}
|
||||
|
||||
/* Get any Xserver Resources (xrdb). */
|
||||
displayResource = XResourceManagerString(dpy);
|
||||
|
||||
if (displayResource)
|
||||
{
|
||||
if ((rdb1 = XrmGetStringDatabase(displayResource)))
|
||||
XrmMergeDatabases(rdb1, &database);
|
||||
}
|
||||
|
||||
/* Get screen specific resources. */
|
||||
displayResource = XScreenResourceString(ScreenOfDisplay(dpy, DefaultScreen(dpy)));
|
||||
|
||||
if (displayResource)
|
||||
{
|
||||
if ((rdb1 = XrmGetStringDatabase(displayResource)))
|
||||
XrmMergeDatabases(rdb1, &database);
|
||||
|
||||
XFree(displayResource);
|
||||
}
|
||||
|
||||
/* 3. User's per host defaults file. */
|
||||
/* Add in XENVIRONMENT file */
|
||||
if ((xe = getenv("XENVIRONMENT")) && (rdb1 = XrmGetFileDatabase(xe)))
|
||||
XrmMergeDatabases(rdb1, &database);
|
||||
else if (homedir)
|
||||
{
|
||||
struct utsname un;
|
||||
|
||||
if (!uname(&un))
|
||||
{
|
||||
snprintf(fname, sizeof(fname), "%s/.Xdefaults-%s", homedir, un.nodename);
|
||||
|
||||
if ((rdb1 = XrmGetFileDatabase(fname)))
|
||||
XrmMergeDatabases(rdb1, &database);
|
||||
}
|
||||
}
|
||||
|
||||
return database;
|
||||
}
|
||||
|
||||
void
|
||||
config_init(Display *dpy)
|
||||
{
|
||||
XrmDatabase db;
|
||||
ResourcePref *p;
|
||||
|
||||
XrmInitialize();
|
||||
db = get_resources(dpy);
|
||||
|
||||
for (p = resources; p < resources + LEN(resources); p++)
|
||||
resource_load(db, p->name, p->type, p->dst);
|
||||
|
||||
XrmDestroyDatabase(db);
|
||||
}
|
||||
|
||||
#else // !XRESOURCES_XDEFAULTS_PATCH
|
||||
|
||||
void
|
||||
config_init(Display *dpy)
|
||||
{
|
||||
|
|
@ -139,21 +42,14 @@ config_init(Display *dpy)
|
|||
ResourcePref *p;
|
||||
|
||||
XrmInitialize();
|
||||
|
||||
resm = XResourceManagerString(dpy);
|
||||
if (!resm)
|
||||
return;
|
||||
|
||||
db = XrmGetStringDatabase(resm);
|
||||
if (!db)
|
||||
return;
|
||||
|
||||
for (p = resources; p < resources + LEN(resources); p++)
|
||||
resource_load(db, p->name, p->type, p->dst);
|
||||
|
||||
XrmDestroyDatabase(db);
|
||||
}
|
||||
#endif // XRESOURCES_XDEFAULTS_PATCH
|
||||
|
||||
#if XRESOURCES_RELOAD_PATCH
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
#include <X11/Xresource.h>
|
||||
#if XRESOURCES_XDEFAULTS_PATCH
|
||||
#include <sys/utsname.h>
|
||||
#endif // XRESOURCES_XDEFAULTS_PATCH
|
||||
|
||||
/* Xresources preferences */
|
||||
enum resource_type {
|
||||
|
|
|
|||
|
|
@ -542,10 +542,3 @@
|
|||
* Depends on the XRESOURCES_PATCH.
|
||||
*/
|
||||
#define XRESOURCES_RELOAD_PATCH 0
|
||||
|
||||
/* This patch adds the ability to configure st via Xdefaults, in addition to Xresources,
|
||||
* like the rxvt-unicode terminal. At startup, st will read and apply the system and user's
|
||||
* local Xdefault files, the XServer's Xresources, and the screen and per-host Xdefaults.
|
||||
* This patch depends on XRESOURCES_PATCH and is compatible with XRESOURCES_RELOAD_PATCH.
|
||||
*/
|
||||
#define XRESOURCES_XDEFAULTS_PATCH 0
|
||||
|
|
|
|||
7
sixel.c
7
sixel.c
|
|
@ -100,13 +100,9 @@ set_default_color(sixel_image_t *image)
|
|||
image->palette[n++] = SIXEL_RGB(i * 11, i * 11, i * 11);
|
||||
}
|
||||
|
||||
/* sixels rarely use more than 256 colors and if they do, they use a custom
|
||||
* palette, so we don't need to initialize these colors */
|
||||
/*
|
||||
for (; n < DECSIXEL_PALETTE_MAX; n++) {
|
||||
image->palette[n] = SIXEL_RGB(255, 255, 255);
|
||||
}
|
||||
*/
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -614,12 +610,11 @@ sixel_parser_parse(sixel_state_t *st, const unsigned char *p, size_t len)
|
|||
st->param = 0;
|
||||
|
||||
if (st->nparams > 0) {
|
||||
st->color_index = st->params[0];
|
||||
st->color_index = 1 + st->params[0]; /* offset 1(background color) added */
|
||||
if (st->color_index < 0)
|
||||
st->color_index = 0;
|
||||
else if (st->color_index >= DECSIXEL_PALETTE_MAX)
|
||||
st->color_index = DECSIXEL_PALETTE_MAX - 1;
|
||||
st->color_index++; /* offset by 1 (background) */
|
||||
}
|
||||
|
||||
if (st->nparams > 4) {
|
||||
|
|
|
|||
2
sixel.h
2
sixel.h
|
|
@ -14,7 +14,7 @@ typedef struct sixel_image_buffer {
|
|||
sixel_color_no_t *data;
|
||||
int width;
|
||||
int height;
|
||||
sixel_color_t palette[DECSIXEL_PALETTE_MAX + 1];
|
||||
sixel_color_t palette[DECSIXEL_PALETTE_MAX];
|
||||
sixel_color_no_t ncolors;
|
||||
int palette_modified;
|
||||
int use_private_register;
|
||||
|
|
|
|||
36
sixel_hls.c
36
sixel_hls.c
|
|
@ -30,18 +30,20 @@
|
|||
// sale, use or other dealings in this Software without prior written
|
||||
// authorization.
|
||||
|
||||
#define SIXEL_RGB(r, g, b) ((255 << 24) + ((r) << 16) + ((g) << 8) + (b))
|
||||
#define SIXEL_RGB(r, g, b) ((r) + ((g) << 8) + ((b) << 16) + (255 << 24))
|
||||
|
||||
int
|
||||
hls_to_rgb(int hue, int lum, int sat)
|
||||
{
|
||||
double hs = (hue + 240) % 360;
|
||||
double hv = hs / 360.0;
|
||||
double lv = lum / 100.0;
|
||||
double sv = sat / 100.0;
|
||||
double c, x, m, c2;
|
||||
double r1, g1, b1;
|
||||
int r, g, b, hs;
|
||||
int r, g, b;
|
||||
int hpi;
|
||||
|
||||
hue = (hue + 240) % 360;
|
||||
if (sat == 0) {
|
||||
r = g = b = lum * 255 / 100;
|
||||
return SIXEL_RGB(r, g, b);
|
||||
|
|
@ -50,14 +52,12 @@ hls_to_rgb(int hue, int lum, int sat)
|
|||
if ((c2 = ((2.0 * lv) - 1.0)) < 0.0) {
|
||||
c2 = -c2;
|
||||
}
|
||||
if ((hs = (hue % 120) - 60) < 0) {
|
||||
hs = -hs;
|
||||
}
|
||||
c = (1.0 - c2) * sv;
|
||||
x = ((60 - hs) / 60.0) * c;
|
||||
hpi = (int) (hv * 6.0);
|
||||
x = (hpi & 1) ? c : 0.0;
|
||||
m = lv - 0.5 * c;
|
||||
|
||||
switch (hue / 60) {
|
||||
switch (hpi) {
|
||||
case 0:
|
||||
r1 = c;
|
||||
g1 = x;
|
||||
|
|
@ -92,24 +92,24 @@ hls_to_rgb(int hue, int lum, int sat)
|
|||
return SIXEL_RGB(255, 255, 255);
|
||||
}
|
||||
|
||||
r = (int) ((r1 + m) * 255.0 + 0.5);
|
||||
g = (int) ((g1 + m) * 255.0 + 0.5);
|
||||
b = (int) ((b1 + m) * 255.0 + 0.5);
|
||||
r = (int) ((r1 + m) * 100.0 + 0.5);
|
||||
g = (int) ((g1 + m) * 100.0 + 0.5);
|
||||
b = (int) ((b1 + m) * 100.0 + 0.5);
|
||||
|
||||
if (r < 0) {
|
||||
r = 0;
|
||||
} else if (r > 255) {
|
||||
r = 255;
|
||||
} else if (r > 100) {
|
||||
r = 100;
|
||||
}
|
||||
if (g < 0) {
|
||||
g = 0;
|
||||
} else if (g > 255) {
|
||||
g = 255;
|
||||
} else if (g > 100) {
|
||||
g = 100;
|
||||
}
|
||||
if (b < 0) {
|
||||
b = 0;
|
||||
} else if (b > 255) {
|
||||
b = 255;
|
||||
} else if (b > 100) {
|
||||
b = 100;
|
||||
}
|
||||
return SIXEL_RGB(r, g, b);
|
||||
return SIXEL_RGB(r * 255 / 100, g * 255 / 100, b * 255 / 100);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue