[hackers] [dmenu] add key bindings Mod1+b and Mod1+f for moving to the prev or next word

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Tue, 13 Mar 2018 17:18:48 +0100

---
 dmenu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff --git a/dmenu.c b/dmenu.c
index a246111..90feea5 100644
--- a/dmenu.c
+++ b/dmenu.c
_AT_@ -345,6 +345,20 @@ keypress(XKeyEvent *ev)
 		}
 	else if (ev->state & Mod1Mask)
 		switch(ksym) {
+		case XK_b: /* move cursor to left delimiter */
+			while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
+				cursor = nextrune(-1);
+			while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
+				cursor = nextrune(-1);
+			ksym = NoSymbol;
+			break;
+		case XK_f: /* move cursor to right delimiter */
+			while (text[cursor] && !strchr(worddelimiters, text[cursor]))
+				cursor = nextrune(+1);
+			while (text[cursor] && strchr(worddelimiters, text[cursor]))
+				cursor = nextrune(+1);
+			ksym = NoSymbol;
+			break;
 		case XK_g: ksym = XK_Home;  break;
 		case XK_G: ksym = XK_End;   break;
 		case XK_h: ksym = XK_Up;    break;
_AT_@ -359,6 +373,8 @@ keypress(XKeyEvent *ev)
 		if (!iscntrl(*buf))
 			insert(buf, len);
 		break;
+	case NoSymbol:
+		break;
 	case XK_Delete:
 		if (text[cursor] == '\0')
 			return;
-- 
2.16.2
Received on Tue Mar 13 2018 - 17:18:48 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 13 2018 - 17:24:27 CET