dotfiles

[void/arch] linux dotfiles
git clone git://git.mdnr.space/dotfiles
Log | Files | Refs

commit 36b04c872fc36b6aaa002f6acb190dced876e552
parent 4801819ea83205fd5695ae147e3d2baef3c28ee4
Author: mehdi-norouzi <mehdeenoroozi@gmail.com>
Date:   Mon, 12 Jun 2023 12:48:21 +0330

st: add blinking cursor patch

Diffstat:
Msuckless/.local/src/st/config.h | 23++++++++++++++---------
Msuckless/.local/src/st/x.c | 24+++++++++++++++++++++---
2 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/suckless/.local/src/st/config.h b/suckless/.local/src/st/config.h @@ -5,8 +5,8 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "mono:pixelsize=10:antialias=true:autohint=true"; -static char *font2[] = { "NotoColorEmoji:pixelsize=10:antialias=true:autohint=true" }; +static char *font = "JetBrainsMonoNerdFont-Medium:pixelsize=11:antialias=true:autohint=true"; +static char *font2[] = { "JetBrainsMonoNerdFont-Regular:pixelsize=10:antialias=true:autohint=true" }; static int borderpx = 2; /* @@ -149,13 +149,18 @@ unsigned int defaultrcs = 257; unsigned int background = 258; /* - * Default shape of cursor - * 2: Block ("█") - * 4: Underline ("_") - * 6: Bar ("|") - * 7: Snowman ("☃") + * Default style of cursor + * 0: blinking block + * 1: blinking block (default) + * 2: steady block ("█") + * 3: blinking underline + * 4: steady underline ("_") + * 5: blinking bar + * 6: steady bar ("|") + * 7: Snowman ("☃")/ */ -static unsigned int cursorshape = 2; + +static unsigned int cursorstyle = 1; /* * Default columns and rows numbers @@ -240,7 +245,7 @@ static MouseShortcut mshortcuts[] = { /* Internal keyboard shortcuts. */ #define MODKEY Mod1Mask -#define TERMMOD (Mod1Mask|ShiftMask) +#define TERMMOD (ControlMask|ShiftMask) static char *openurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -o", "externalpipe", NULL }; static char *copyurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -c", "externalpipe", NULL }; diff --git a/suckless/.local/src/st/x.c b/suckless/.local/src/st/x.c @@ -1733,13 +1733,20 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le switch (win.cursor) { case 7: /* st extension */ g.u = 0x2603; /* snowman (U+2603) */ - /* FALLTHROUGH */ + xdrawglyph(g, cx, cy); + break; case 0: /* Blinking Block */ case 1: /* Blinking Block (Default) */ + if (IS_SET(MODE_BLINK)) + break; + /* FALLTHROUGH */ case 2: /* Steady Block */ xdrawglyph(g, cx, cy); break; case 3: /* Blinking Underline */ + if (IS_SET(MODE_BLINK)) + break; + /* FALLTHROUGH */ case 4: /* Steady Underline */ XftDrawRect(xw.draw, &drawcol, borderpx + cx * win.cw, @@ -1748,6 +1755,9 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og, Line line, int le win.cw, cursorthickness); break; case 5: /* Blinking bar */ + if (IS_SET(MODE_BLINK)) + break; + /* FALLTHROUGH */ case 6: /* Steady bar */ XftDrawRect(xw.draw, &drawcol, borderpx + cx * win.cw, @@ -2123,6 +2133,7 @@ run(void) int xfd = XConnectionNumber(xw.dpy), ttyfd, xev, drawing; struct timespec seltv, *tv, now, lastblink, trigger; double timeout; + int blinkcursor; /* Waiting for window mapping */ do { @@ -2189,6 +2200,10 @@ run(void) if (FD_ISSET(ttyfd, &rfd) || xev) { if (!drawing) { trigger = now; + if (IS_SET(MODE_BLINK)) { + win.mode ^= MODE_BLINK; + } + lastblink = now; drawing = 1; } timeout = (maxlatency - TIMEDIFF(now, trigger)) \ @@ -2199,7 +2214,9 @@ run(void) /* idle detected or maxlatency exhausted -> draw */ timeout = -1; - if (blinktimeout && tattrset(ATTR_BLINK)) { + blinkcursor = win.cursor == 0 || win.cursor == 1 || + win.cursor == 3 || win.cursor == 5; + if (blinktimeout && (blinkcursor || tattrset(ATTR_BLINK))) { timeout = blinktimeout - TIMEDIFF(now, lastblink); if (timeout <= 0) { if (-timeout > blinktimeout) /* start visible */ @@ -2288,7 +2305,8 @@ main(int argc, char *argv[]) { xw.l = xw.t = 0; xw.isfixed = False; - xsetcursor(cursorshape); + // xsetcursor(cursorshape); + win.cursor = cursorstyle; ARGBEGIN { case 'a':