sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 170584dc50890c3d70aa30d28fbe191cec759de5
parent 6d25da28f4c7ee93a36a013bb4f02f9e6bd2d7f4
Author: Steve Ward <planet36@gmail.com>
Date:   Mon, 11 May 2020 23:30:43 -0400

Add blinking cursor patch

Diffstat:
Ast.suckless.org/patches/blinking_cursor/index.md | 29+++++++++++++++++++++++++++++
Ast.suckless.org/patches/blinking_cursor/st-blinking_cursor-20200511-914fb82.diff | 106+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 135 insertions(+), 0 deletions(-)

diff --git a/st.suckless.org/patches/blinking_cursor/index.md b/st.suckless.org/patches/blinking_cursor/index.md @@ -0,0 +1,29 @@ +blinking cursor +=============== + +Description +----------- +This patch allows the use of a blinking cursor. + +To demonstrate the available cursor styles, try these commands: + echo -e -n "\x1b[\x30 q" # blinking block + echo -e -n "\x1b[\x31 q" # blinking block (default) + echo -e -n "\x1b[\x32 q" # steady block + echo -e -n "\x1b[\x33 q" # blinking underline + echo -e -n "\x1b[\x34 q" # steady underline + echo -e -n "\x1b[\x35 q" # blinking bar + echo -e -n "\x1b[\x36 q" # steady bar + +Notes +----- +* Only cursor styles 0, 1, 3, and 5 blink. Set `cursorstyle` accordingly. +* Cursor styles are defined [here](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81). + +Download +-------- +* [st-blinking\_cursor-20200511-914fb82.diff](st-blinking_cursor-20200511-914fb82.diff) + +Authors +------- +* Genki Sky - <https://lists.suckless.org/hackers/1708/15376.html> +* Steve Ward - <planet36@gmail.com> (914fb82 change) diff --git a/st.suckless.org/patches/blinking_cursor/st-blinking_cursor-20200511-914fb82.diff b/st.suckless.org/patches/blinking_cursor/st-blinking_cursor-20200511-914fb82.diff @@ -0,0 +1,106 @@ +From f570c5ba723be9391cdf03878a6f8c5d71a97a56 Mon Sep 17 00:00:00 2001 +From: Steve Ward <planet36@gmail.com> +Date: Mon, 11 May 2020 22:44:25 -0400 +Subject: [PATCH] Enable blinking cursor + +Adapted from this patch +https://lists.suckless.org/hackers/1708/15376.html +--- + config.def.h | 15 ++++++++++----- + x.c | 18 +++++++++++++++--- + 2 files changed, 25 insertions(+), 8 deletions(-) + +diff --git a/config.def.h b/config.def.h +index fdbacfd..f404201 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -129,13 +129,18 @@ static unsigned int defaultcs = 256; + static unsigned int defaultrcs = 257; + + /* +- * Default shape of cursor +- * 2: Block ("█") +- * 4: Underline ("_") +- * 6: Bar ("|") ++ * https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Functions-using-CSI-_-ordered-by-the-final-character-lparen-s-rparen:CSI-Ps-SP-q.1D81 ++ * 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 +diff --git a/x.c b/x.c +index 1dc44d6..b6aa7b4 100644 +--- a/x.c ++++ b/x.c +@@ -1528,13 +1528,20 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) + switch (win.cursor) { + case 7: /* st extension: snowman (U+2603) */ + g.u = 0x2603; +- /* 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, +@@ -1543,6 +1550,9 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) + 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, +@@ -1871,6 +1881,8 @@ run(void) + int xfd = XConnectionNumber(xw.dpy), ttyfd, xev, drawing; + struct timespec seltv, *tv, now, lastblink, trigger; + double timeout; ++ int blinkcursor = win.cursor == 0 || win.cursor == 1 || ++ win.cursor == 3 || win.cursor == 5; + + /* Waiting for window mapping */ + do { +@@ -1947,7 +1959,7 @@ run(void) + + /* idle detected or maxlatency exhausted -> draw */ + timeout = -1; +- if (blinktimeout && tattrset(ATTR_BLINK)) { ++ if (blinktimeout && (blinkcursor || tattrset(ATTR_BLINK))) { + timeout = blinktimeout - TIMEDIFF(now, lastblink); + if (timeout <= 0) { + if (-timeout > blinktimeout) /* start visible */ +@@ -1983,7 +1995,7 @@ main(int argc, char *argv[]) + { + xw.l = xw.t = 0; + xw.isfixed = False; +- win.cursor = cursorshape; ++ win.cursor = cursorstyle; + + ARGBEGIN { + case 'a': +-- +2.20.1 +