[hackers] [lchat] slackline: ctrl+w: stop deleting when certain characters occur || Tom Schwindl
commit 9778b6b675462220fa133aa7a13fe8e5d45be6d1
Author: Tom Schwindl <schwindl_AT_posteo.de>
AuthorDate: Mon Feb 6 15:42:58 2023 +0100
Commit: Jan Klemkow <j.klemkow_AT_wemelug.de>
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
_AT_@ -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 (){}[]\\/#,.=-+|%$!_AT_^&*"
+
struct slackline *
sl_init(void)
{
_AT_@ -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:
Received on Wed Feb 15 2023 - 09:41:15 CET
This archive was generated by hypermail 2.3.0
: Wed Feb 15 2023 - 09:48:39 CET