sites

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

commit b697350f15956135914068eff6262ae1c1b202c8
parent 55c12687a05acbe17a60d2d5812e8c5532675d6c
Author: Michael Buch <michaelbuch12@gmail.com>
Date:   Sun,  9 Jan 2022 19:59:09 +0000

[wiki][st][patches] Ignore configurable delimiter on line snap selection

This patch adds following new variable into `config.def.h`:
* `snap_line_delimiters`: this is the array of (multi-byte) characters which
                          will terminate a line snap selection. By default it
                          contains the `tmux` window pane separator `│`.

The primary use-case would be snap selecting a line in a terminal
multiplexer like tmux. Such selection would typically select across
all panes, whereas the user most likely wanted to select only the line
within a pane.

Diffstat:
Ast.suckless.org/patches/line_snap_delimiter/index.md | 33+++++++++++++++++++++++++++++++++
Ast.suckless.org/patches/line_snap_delimiter/st-line_snap_delimiter-3bd7e43.diff | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+), 0 deletions(-)

diff --git a/st.suckless.org/patches/line_snap_delimiter/index.md b/st.suckless.org/patches/line_snap_delimiter/index.md @@ -0,0 +1,33 @@ +line\_snap\_delimiter +===================== + +Description +----------- +The primary use-case would be snap selecting a line in a terminal +multiplexer like tmux. Such selection would typically select across +all panes, whereas the user most likely wanted to select only the line +within a pane. + +This patch adds following new variable into `config.def.h`: +* `snap_line_delimiters`: this is the array of (multi-byte) characters which + will terminate a line snap selection. By default it + contains the `tmux` window pane separator `│`. + +Notes +----- +* When snap selecting a line and dragging it, the selection can span multiple + panes. It's probably possible to address this in follow-up patches. + +* The new delimiter variable does *not* affect word snap selection. If you want + to ignore certain characters when double tapping a word for seleciton, add that + character to `worddelimiters` in `config.def.h`. However, if a word snap selection + does select the line snap delimiter, a subsequent line snap selection will de-select + that character again anyway. + +Download +-------- +* [st-line\_snap\_delimiter-3bd7e43.diff](st-line_snap_delimiter-3bd7e43.diff) + +Authors +------- +* Michael Buch - <michaelbuch12@gmail.com> diff --git a/st.suckless.org/patches/line_snap_delimiter/st-line_snap_delimiter-3bd7e43.diff b/st.suckless.org/patches/line_snap_delimiter/st-line_snap_delimiter-3bd7e43.diff @@ -0,0 +1,86 @@ +From 3bd7e43c2666084814b09a4a4412029a0b53eb37 Mon Sep 17 00:00:00 2001 +From: Michael Buch <michaelbuch12@gmail.com> +Date: Sun, 9 Jan 2022 19:37:07 +0000 +Subject: [PATCH] [st][patches] Ignore configurable delimiter on line snap + selection + +Adds ability to ignore certain characters when snap selecting +an entire line (e.g., triple mouse button press). +--- + config.def.h | 1 + + st.c | 22 +++++++++++++++++++++- + st.h | 1 + + 3 files changed, 23 insertions(+), 1 deletion(-) + +diff --git a/config.def.h b/config.def.h +index 91ab8ca..272fdc5 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -35,6 +35,7 @@ static float chscale = 1.0; + * More advanced example: L" `'\"()[]{}" + */ + wchar_t *worddelimiters = L" "; ++wchar_t *snap_line_delimiters = L"│"; + + /* selection timeouts (in milliseconds) */ + static unsigned int doubleclicktimeout = 300; +diff --git a/st.c b/st.c +index 51049ba..0d57a7e 100644 +--- a/st.c ++++ b/st.c +@@ -42,6 +42,7 @@ + #define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) + #define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c)) + #define ISDELIM(u) (u && wcschr(worddelimiters, u)) ++#define IS_SNAP_LINE_DELIM(u) (u && wcschr(snap_line_delimiters, u)) + + enum term_mode { + MODE_WRAP = 1 << 0, +@@ -563,12 +564,31 @@ selsnap(int *x, int *y, int direction) + } + break; + case SNAP_LINE: ++ /* ++ * Don't snap past a line snap delimiter ++ * (see 'snap_line_delimiters' in config.h) ++ */ ++ for(;;) { ++ newx = *x + direction; ++ ++ if (!BETWEEN(newx, 0, term.col - 1)) { ++ break; ++ } ++ ++ gp = &term.line[*y][newx]; ++ ++ if(IS_SNAP_LINE_DELIM(gp->u)) { ++ break; ++ } ++ ++ *x = newx; ++ } ++ + /* + * Snap around if the the previous line or the current one + * has set ATTR_WRAP at its end. Then the whole next or + * previous line will be selected. + */ +- *x = (direction < 0) ? 0 : term.col - 1; + if (direction < 0) { + for (; *y > 0; *y += direction) { + if (!(term.line[*y-1][term.col-1].mode +diff --git a/st.h b/st.h +index 519b9bd..9a97472 100644 +--- a/st.h ++++ b/st.h +@@ -119,6 +119,7 @@ extern char *scroll; + extern char *stty_args; + extern char *vtiden; + extern wchar_t *worddelimiters; ++extern wchar_t *snap_line_delimiters; + extern int allowaltscreen; + extern int allowwindowops; + extern char *termname; +-- +2.32.0 +