struct
TermBuf::Unicode::Breaker
- TermBuf::Unicode::Breaker
- Struct
- Value
- Object
Overview
Decides where extended grapheme cluster boundaries fall, following the UAX #29 rules GB1 through GB999.
One instance walks one string. For each character in order, ask
#boundary? whether a cluster boundary precedes it, then hand the same
character to #consume to advance the state.
Defined in:
termbuf/unicode/grapheme.crConstructors
-
.new
A fresh breaker, positioned before the first character of a string.
Instance Method Summary
-
#boundary?(char : Char) : Bool
Whether a cluster boundary falls immediately before char.
-
#consume(char : Char) : Nil
Advances the state as though char had been added to the current cluster.
-
#consume_ascii : Nil
Advances the state for a printable ASCII character.
-
#prepend_pending? : Bool
Whether the character just consumed was a
Prepend.
Constructor Detail
Instance Method Detail
Whether a cluster boundary falls immediately before char. ameba:disable Metrics/CyclomaticComplexity
Advances the state as though char had been added to the current
cluster. Call exactly once per character, after #boundary?.
Advances the state for a printable ASCII character. Every code point in
0x20..0x7E has break class Other, conjunct class None, and no
pictographic property, so none of the tables need consulting.
Whether the character just consumed was a Prepend. That is the only
way an ASCII character can join the cluster before it, so it is also the
only case where the ASCII fast path in Unicode.each_grapheme is unsafe.