summaryrefslogtreecommitdiff
path: root/src/unicode.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2017-06-26 15:28:41 +0100
committerMaxime Coste <mawww@kakoune.org>2017-06-26 15:28:41 +0100
commitf41d78083aa8d3883bcd4ed819e6784e09e69dba (patch)
treea67d2432ecf7f2ed499760eb245120dcae0221f5 /src/unicode.hh
parentdc378aed7290eb9fd90b752a2841fa2457bb91d0 (diff)
Use the extra_word_chars option in word based normal commands
the completion_extra_word_chars is now gone, superseeded by extra_word_chars that gets used both for completion and for normal mode. Fixes #1304
Diffstat (limited to 'src/unicode.hh')
-rw-r--r--src/unicode.hh12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/unicode.hh b/src/unicode.hh
index eade3510..ba340b3a 100644
--- a/src/unicode.hh
+++ b/src/unicode.hh
@@ -6,6 +6,8 @@
#include <locale>
#include "units.hh"
+#include "array_view.hh"
+#include "containers.hh"
namespace Kakoune
{
@@ -30,13 +32,13 @@ inline bool is_blank(Codepoint c) noexcept
enum WordType { Word, WORD };
template<WordType word_type = Word>
-inline bool is_word(Codepoint c) noexcept
+inline bool is_word(Codepoint c, ConstArrayView<Codepoint> extra_word_chars = {}) noexcept
{
- return c == '_' or iswalnum((wchar_t)c);
+ return c == '_' or iswalnum((wchar_t)c) or contains(extra_word_chars, c);
}
template<>
-inline bool is_word<WORD>(Codepoint c) noexcept
+inline bool is_word<WORD>(Codepoint c, ConstArrayView<Codepoint>) noexcept
{
return not is_blank(c);
}
@@ -65,13 +67,13 @@ enum class CharCategories
};
template<WordType word_type = Word>
-inline CharCategories categorize(Codepoint c) noexcept
+inline CharCategories categorize(Codepoint c, ConstArrayView<Codepoint> extra_word_chars) noexcept
{
if (is_eol(c))
return CharCategories::EndOfLine;
if (is_horizontal_blank(c))
return CharCategories::Blank;
- if (word_type == WORD or is_word(c))
+ if (word_type == WORD or is_word(c, extra_word_chars))
return CharCategories::Word;
return CharCategories::Punctuation;
}