]> git.armaanb.net Git - st.git/commitdiff
use iswspace()/iswpunct() to find word delimiters
authorLauri Tirkkonen <lotheac@iki.fi>
Wed, 13 Mar 2019 15:15:04 +0000 (17:15 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 15 Mar 2019 11:25:13 +0000 (12:25 +0100)
this inverts the configuration logic: you no longer provide a list of
delimiters -- all space and punctuation characters are considered
delimiters, unless listed in extrawordchars.

config.def.h
st.c
st.h

index 482901ea41675bdb77bafa15dc34e67a70a9094d..9ce45a7c84ade44f6069439adde11b614264d465 100644 (file)
@@ -28,11 +28,12 @@ static float cwscale = 1.0;
 static float chscale = 1.0;
 
 /*
- * word delimiter string
+ * all space and punctuation characters are considered word delimiters, unless
+ * listed here.
  *
- * More advanced example: L" `'\"()[]{}"
+ * More advanced example: L"#$%&+,-./:=?_~"
  */
-wchar_t *worddelimiters = L" ";
+wchar_t *extrawordchars = L"./:";
 
 /* selection timeouts (in milliseconds) */
 static unsigned int doubleclicktimeout = 300;
diff --git a/st.c b/st.c
index 812f30c42d3302ea3cab66cc6c0923f645b66f4f..c383b43052a3815ecc99600b29098117ccc12d3e 100644 (file)
--- a/st.c
+++ b/st.c
@@ -16,6 +16,7 @@
 #include <termios.h>
 #include <unistd.h>
 #include <wchar.h>
+#include <wctype.h>
 
 #include "st.h"
 #include "win.h"
@@ -41,7 +42,7 @@
 #define ISCONTROLC0(c)         (BETWEEN(c, 0, 0x1f) || (c) == '\177')
 #define ISCONTROLC1(c)         (BETWEEN(c, 0x80, 0x9f))
 #define ISCONTROL(c)           (ISCONTROLC0(c) || ISCONTROLC1(c))
-#define ISDELIM(u)             (u != 0 && wcschr(worddelimiters, u) != NULL)
+#define ISDELIM(u)             ((iswspace(u) || iswpunct(u)) && wcschr(extrawordchars, u) == NULL)
 
 enum term_mode {
        MODE_WRAP        = 1 << 0,
diff --git a/st.h b/st.h
index 4da30515901a2ff726ceefcf5015bcc6cf338de9..a3b19dea2f58072518fcbc7052d370e9f4829448 100644 (file)
--- a/st.h
+++ b/st.h
@@ -114,7 +114,7 @@ char *xstrdup(char *);
 extern char *utmp;
 extern char *stty_args;
 extern char *vtiden;
-extern wchar_t *worddelimiters;
+extern wchar_t *extrawordchars;
 extern int allowaltscreen;
 extern char *termname;
 extern unsigned int tabspaces;