From a96c33e81ef8918743b47511a0488be0d585460a Mon Sep 17 00:00:00 2001 From: Joseph Benden <joe@benden.us> Date: Fri, 17 May 2019 11:49:55 -0700 Subject: [PATCH 1/6] Add interval timer to XIM updates Signed-off-by: Joseph Benden <joe@benden.us> --- config.h | 8 ++++++++ st.c | 11 ++++++++++- st.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/config.h b/config.h index e68878c..c0c2ff9 100644 --- a/config.h +++ b/config.h @@ -51,6 +51,13 @@ static unsigned int actionfps = 30; */ static unsigned int blinktimeout = 800; +/* + * interval (in milliseconds) between each successive call to ximspot. This + * improves terminal performance while not reducing functionality to those + * whom need XIM support. + */ +int ximspot_update_interval = 1000; + /* * thickness of underline and bar cursors */ @@ -184,6 +191,7 @@ ResourcePref resources[] = { { "cwscale", FLOAT, &cwscale }, { "chscale", FLOAT, &chscale }, { "alpha", FLOAT, &alpha }, + { "ximspot_update_interval", INTEGER, &ximspot_update_interval }, }; /* diff --git a/st.c b/st.c index 21c6739..e4df60c 100644 --- a/st.c +++ b/st.c @@ -14,6 +14,7 @@ #include <sys/types.h> #include <sys/wait.h> #include <termios.h> +#include <time.h> #include <unistd.h> #include <wchar.h> @@ -142,6 +143,7 @@ typedef struct { int charset; /* current charset */ int icharset; /* selected charset for sequence */ int *tabs; + struct timespec last_ximspot_update; } Term; /* CSI Escape sequence structs */ @@ -1056,6 +1058,7 @@ void tnew(int col, int row) { term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } }; + clock_gettime(CLOCK_MONOTONIC, &term.last_ximspot_update); tresize(col, row); treset(); } @@ -2744,7 +2747,13 @@ draw(void) term.ocx, term.ocy, term.line[term.ocy][term.ocx]); term.ocx = cx, term.ocy = term.c.y; xfinishdraw(); - xximspot(term.ocx, term.ocy); + + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + if (ximspot_update_interval && TIMEDIFF(now, term.last_ximspot_update) > ximspot_update_interval) { + xximspot(term.ocx, term.ocy); + term.last_ximspot_update = now; + } } void diff --git a/st.h b/st.h index 94ce5c3..4504a30 100644 --- a/st.h +++ b/st.h @@ -133,3 +133,4 @@ extern unsigned int defaultfg; extern unsigned int defaultbg; extern float alpha; extern MouseKey mkeys[]; +extern int ximspot_update_interval; From cd28e535f8da2b22f4f6d4da32b406d05062ae16 Mon Sep 17 00:00:00 2001 From: Luke Smith <luke@lukesmith.xyz> Date: Fri, 7 Feb 2020 18:46:12 -0500 Subject: [PATCH 2/6] link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6117f8b..47515c8 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Note that when you run `wal`, it will negate the transparency of existing window ## Crashing error -If st crashes when viewing emojis, install `[libxft-bgra](https://aur.archlinux.org/packages/libxft-bgra/)` from the AUR. +If st crashes when viewing emojis, install [libxft-bgra](https://aur.archlinux.org/packages/libxft-bgra/) from the AUR. ## Contact From f0b7aeeb53aab8e15f46dacfcbd03994e3be881c Mon Sep 17 00:00:00 2001 From: Luke Smith <luke@lukesmith.xyz> Date: Fri, 7 Feb 2020 18:46:24 -0500 Subject: [PATCH 3/6] minor regex improvement --- config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 22e9d21..c86c8c1 100644 --- a/config.h +++ b/config.h @@ -213,11 +213,11 @@ MouseKey mkeys[] = { }; static char *openurlcmd[] = { "/bin/sh", "-c", - "sed 's/.*│//g' | tr -d '\n' | grep -aEo '(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./&%?#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)'| uniq | sed 's/^www./http:\\/\\/www\\./g' | dmenu -i -p 'Follow which url?' -l 10 | xargs -r xdg-open", + "sed 's/.*│//g' | tr -d '\n' | grep -aEo '(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./&%?$#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)'| uniq | sed 's/^www./http:\\/\\/www\\./g' | dmenu -i -p 'Follow which url?' -l 10 | xargs -r xdg-open", "externalpipe", NULL }; static char *copyurlcmd[] = { "/bin/sh", "-c", - "sed 's/.*│//g' | tr -d '\n' | grep -aEo '(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./&%?#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)' | uniq | sed 's/^www./http:\\/\\/www\\./g' | dmenu -i -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard", + "sed 's/.*│//g' | tr -d '\n' | grep -aEo '(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./&%?$#=_-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)' | uniq | sed 's/^www./http:\\/\\/www\\./g' | dmenu -i -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard", "externalpipe", NULL }; static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NULL }; From 4c05d1cef30cee4e05698d067f5c9f5e44a1eba2 Mon Sep 17 00:00:00 2001 From: Luke Smith <luke@lukesmith.xyz> Date: Fri, 7 Feb 2020 22:44:19 -0500 Subject: [PATCH 4/6] font display fixes --- README.md | 6 ++++-- config.h | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 47515c8..466c366 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The [suckless terminal (st)](https://st.suckless.org/) with some additional feat + Compatibility with `Xresources` and `pywal` for dynamic colors. The `Xdefaults` file shows a usage example. + Default [gruvbox](https://github.com/morhetz/gruvbox) colors otherwise. + Transparency/alpha, which is also adjustable from your `Xresources`. -+ Default font is system "mono" at 16pt, meaning the font will match your system font. ++ Default font is system "mono" at 14pt, meaning the font will match your system font. ## Other st patches @@ -70,10 +70,12 @@ To be clear about the color settings: Note that when you run `wal`, it will negate the transparency of existing windows, but new windows will continue with the previously defined transparency. -## Crashing error +## Notes on Emojis and Special Characters If st crashes when viewing emojis, install [libxft-bgra](https://aur.archlinux.org/packages/libxft-bgra/) from the AUR. +Note that some special characters may appear truncated if too wide. You might want to manually set your prefered emoji/special character font to a lower size in the `config.h` file to avoid this. By default, JoyPixels is used at a smaller size than the usual text. + ## Contact - Luke Smith <luke@lukesmith.xyz> diff --git a/config.h b/config.h index c86c8c1..d5b48b9 100644 --- a/config.h +++ b/config.h @@ -5,8 +5,8 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "mono:pixelsize=16:antialias=true:autohint=true"; -static char *font2[] = { "Inconsolata for Powerline:pixelsize=16:antialias=true:autohint=true" }; +static char *font = "mono:pixelsize=14:antialias=true:autohint=true"; +static char *font2[] = { "JoyPixels:pixelsize=10:antialias=true:autohint=true" }; static int borderpx = 2; /* From 66780d00e41d9b69dd42c9fb1a18f516fadce1fb Mon Sep 17 00:00:00 2001 From: Luke Smith <luke@lukesmith.xyz> Date: Sun, 9 Feb 2020 15:46:13 -0500 Subject: [PATCH 5/6] middle click pastes selection again --- config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/config.h b/config.h index d5b48b9..3fc8c64 100644 --- a/config.h +++ b/config.h @@ -235,6 +235,7 @@ static Shortcut shortcuts[] = { { MODKEY, XK_c, clipcopy, {.i = 0} }, { MODKEY, XK_v, clippaste, {.i = 0} }, { MODKEY, XK_p, selpaste, {.i = 0} }, + { XK_ANY_MOD, Button2, selpaste, {.i = 0} }, { MODKEY, XK_Num_Lock, numlock, {.i = 0} }, { MODKEY, XK_Control_L, iso14755, {.i = 0} }, { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} }, From e2a59d5521775042eda2fa64bfc847fc388df6c2 Mon Sep 17 00:00:00 2001 From: Luke Smith <luke@lukesmith.xyz> Date: Sun, 9 Feb 2020 15:48:07 -0500 Subject: [PATCH 6/6] backend color number changes --- config.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/config.h b/config.h index 3fc8c64..6ee8ea9 100644 --- a/config.h +++ b/config.h @@ -106,9 +106,10 @@ static const char *colorname[] = { "#ebdbb2", [255] = 0, /* more colors can be added after 255 to use with DefaultXX */ - "#282828", /* 256 -> bg */ - "#ebdbb2", /* 257 -> fg */ - "#add8e6", /* 258 -> cursor */ + "#add8e6", /* 256 -> cursor */ + "#555555", /* 257 -> rev cursor*/ + "#282828", /* 258 -> bg */ + "#ebdbb2", /* 259 -> fg */ }; @@ -116,10 +117,10 @@ static const char *colorname[] = { * Default colors (colorname index) * foreground, background, cursor, reverse cursor */ -unsigned int defaultfg = 257; -unsigned int defaultbg = 256; -static unsigned int defaultcs = 258; -static unsigned int defaultrcs = 0; +unsigned int defaultfg = 259; +unsigned int defaultbg = 258; +static unsigned int defaultcs = 256; +static unsigned int defaultrcs = 257; /* * Default shape of cursor @@ -172,9 +173,9 @@ ResourcePref resources[] = { { "color13", STRING, &colorname[13] }, { "color14", STRING, &colorname[14] }, { "color15", STRING, &colorname[15] }, - { "background", STRING, &colorname[256] }, - { "foreground", STRING, &colorname[257] }, - { "cursorColor", STRING, &colorname[258] }, + { "background", STRING, &colorname[258] }, + { "foreground", STRING, &colorname[259] }, + { "cursorColor", STRING, &colorname[256] }, { "termname", STRING, &termname }, { "shell", STRING, &shell }, { "xfps", INTEGER, &xfps },