[hackers] [dmenu] Add config option for word delimiters || Quentin Rameau
commit 120e8401074254d39be916ad83bafda9ef25e6a9
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Sat Dec 19 09:32:55 2015 +0100
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Sat Dec 19 20:32:14 2015 +0100
Add config option for word delimiters
Let the user configure word boundaries other than ' ', only works with
the portable character set.
diff --git a/config.def.h b/config.def.h
index a9122f7..8db1dda 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -15,3 +15,9 @@ static const char *outbgcolor = "#00ffff";
static const char *outfgcolor = "#000000";
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
static unsigned int lines = 0;
+
+/*
+ * Characters not considered part of a word while deleting words
+ * for example: " /?\"&[]"
+ */
+static const char worddelimiters[] = " ";
diff --git a/dmenu.c b/dmenu.c
index a07f8e3..e0c2f80 100644
--- a/dmenu.c
+++ b/dmenu.c
_AT_@ -314,9 +314,11 @@ keypress(XKeyEvent *ev)
insert(NULL, 0 - cursor);
break;
case XK_w: /* delete word */
- while (cursor > 0 && text[nextrune(-1)] == ' ')
+ while (cursor > 0 && strchr(worddelimiters,
+ text[nextrune(-1)]))
insert(NULL, nextrune(-1) - cursor);
- while (cursor > 0 && text[nextrune(-1)] != ' ')
+ while (cursor > 0 && !strchr(worddelimiters,
+ text[nextrune(-1)]))
insert(NULL, nextrune(-1) - cursor);
break;
case XK_y: /* paste selection */
Received on Sat Dec 19 2015 - 20:34:02 CET
This archive was generated by hypermail 2.3.0
: Sat Dec 19 2015 - 20:36:21 CET