commit 9778b6b675462220fa133aa7a13fe8e5d45be6d1
parent e413932d58bda64d7e9e34ca1e455d13bad17a3e
Author: Tom Schwindl <schwindl@posteo.de>
Date: Mon, 6 Feb 2023 15:42:58 +0100
slackline: ctrl+w: stop deleting when certain characters occur
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git 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: