diff options
Diffstat (limited to 'src/modal.zig')
| -rw-r--r-- | src/modal.zig | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/src/modal.zig b/src/modal.zig index 6f0bdc9c..f540b1a7 100644 --- a/src/modal.zig +++ b/src/modal.zig @@ -526,29 +526,6 @@ pub fn isUnicodeWhitespace(cp: u21) bool { }; } -/// A codepoint's word class: Unicode word characters, punctuation, or -/// whitespace (line ends included; wordClassAt tells them apart). -fn kindOfCodepoint(cp: u21) WordClass { - if (isUnicodeWhitespace(cp)) return .ws; - if (cp == '_') return .word; - return switch (uucode.get(.general_category, cp)) { - .letter_uppercase, - .letter_lowercase, - .letter_titlecase, - .letter_modifier, - .letter_other, - .mark_nonspacing, - .mark_spacing_combining, - .mark_enclosing, - .number_decimal_digit, - .number_letter, - .number_other, - .punctuation_connector, - => .word, - else => .punct, - }; -} - fn lineLenOf(lines: []const []const u8, row: usize) usize { if (row >= lines.len) return 0; return lines[row].len; @@ -1042,6 +1019,29 @@ pub const WordTarget = enum { // that distinction is load-bearing in reached_target. const WordClass = enum { word, punct, ws, eol }; +/// A codepoint's word class: Unicode word characters, punctuation, or +/// whitespace (line ends included; wordClassAt tells them apart). +fn kindOfCodepoint(cp: u21) WordClass { + if (isUnicodeWhitespace(cp)) return .ws; + if (cp == '_') return .word; + return switch (uucode.get(.general_category, cp)) { + .letter_uppercase, + .letter_lowercase, + .letter_titlecase, + .letter_modifier, + .letter_other, + .mark_nonspacing, + .mark_spacing_combining, + .mark_enclosing, + .number_decimal_digit, + .number_letter, + .number_other, + .punctuation_connector, + => .word, + else => .punct, + }; +} + fn wordClassAt(text: []const u8, off: usize) WordClass { if (off >= text.len) return .eol; const cp = codepointAt(text, off); |
