aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meson.build1
-rw-r--r--misc.c24
-rw-r--r--misc.h6
-rw-r--r--selection.c22
4 files changed, 32 insertions, 21 deletions
diff --git a/meson.build b/meson.build
index 0603805b..5c662e9e 100644
--- a/meson.build
+++ b/meson.build
@@ -75,6 +75,7 @@ executable(
'input.c', 'input.h',
'log.c', 'log.h',
'main.c',
+ 'misc.c', 'misc.h',
'osc.c', 'osc.h',
'render.c', 'render.h',
'search.c', 'search.h',
diff --git a/misc.c b/misc.c
new file mode 100644
index 00000000..b8eb3296
--- /dev/null
+++ b/misc.c
@@ -0,0 +1,24 @@
+#include "misc.h"
+
+#include <wctype.h>
+
+bool
+isword(wchar_t wc, bool spaces_only)
+{
+ if (spaces_only)
+ return iswgraph(wc);
+
+ switch (wc) {
+ default: return iswgraph(wc);
+
+ case L'(': case L')':
+ case L'[': case L']':
+ case L'{': case L'}':
+ case L'<': case L'>':
+ case L'│': case L'|':
+ case L',':
+ case L'`': case L'"': case L'\'':
+ case L':':
+ return false;
+ }
+}
diff --git a/misc.h b/misc.h
new file mode 100644
index 00000000..06dd3303
--- /dev/null
+++ b/misc.h
@@ -0,0 +1,6 @@
+#pragma once
+
+#include <stdbool.h>
+#include <wchar.h>
+
+bool isword(wchar_t wc, bool spaces_only);
diff --git a/selection.c b/selection.c
index b77dc64a..bbe990d7 100644
--- a/selection.c
+++ b/selection.c
@@ -15,6 +15,7 @@
#include "async.h"
#include "grid.h"
+#include "misc.h"
#include "render.h"
#include "vt.h"
@@ -222,27 +223,6 @@ selection_cancel(struct terminal *term)
}
}
-static bool
-isword(wint_t c, bool spaces_only)
-{
- if (spaces_only)
- return !iswspace(c);
-
- switch (c) {
- default: return !iswspace(c);
-
- case L'{': case L'}':
- case L'[': case L']':
- case L'(': case L')':
- case L'`':
- case L'\'':
- case L'"':
- case L',': case L'.':
- case L':': case L';':
- return false;
- }
-}
-
void
selection_mark_word(struct terminal *term, int col, int row, bool spaces_only,
uint32_t serial)