byGroup function
Create a function that checks if a character belongs to the same group as the starting character.
This is used for word-wise cursor movement.
Implementation
bool Function(String) byGroup(EditorState state, int pos, String start) {
final categorize = state.charCategorizer(pos);
var cat = categorize(start);
return (String next) {
final nextCat = categorize(next);
// If started on whitespace, transition to the next category
if (cat == CharCategory.space) cat = nextCat;
return cat == nextCat;
};
}