commit 9778b6b675462220fa133aa7a13fe8e5d45be6d1
Author: Tom Schwindl <[email protected]>
AuthorDate: Mon Feb 6 15:42:58 2023 +0100
Commit: Jan Klemkow <[email protected]>
CommitDate: Wed Feb 15 09:30:17 2023 +0100
slackline: ctrl+w: stop deleting when certain characters occur
diff --git a/slackline.c b/slackline.c
index 8668534..889165a 100644
--- a/slackline.c
+++ b/slackline.c
@@ -26,6 +26,9 @@
#include "slackline.h"
#include "util.h"
+/* CTRL+W: stop erasing if certain characters are reached. */
+#define IS_WORD_BREAK "\f\n\r\t\v (){}[]\\/#,.=-+|%$!@^&*"
+
struct slackline *
sl_init(void)
{
@@ -165,9 +168,9 @@ sl_default(struct slackline *sl, int key)
sl_reset(sl);
break;
case CTRL_W: /* erase previous word */
- while (sl->rcur != 0 && isspace((unsigned char) *(sl->ptr-1)))
+ while (sl->rcur != 0 && strchr(IS_WORD_BREAK, *(sl->ptr-1)) !=
NULL)
sl_backspace(sl);
- while (sl->rcur != 0 && !isspace((unsigned char) *(sl->ptr-1)))
+ while (sl->rcur != 0 && strchr(IS_WORD_BREAK, *(sl->ptr-1)) ==
NULL)
sl_backspace(sl);
break;
case BACKSPACE: