struct
TermBuf::Unicode::WidthPolicy
- TermBuf::Unicode::WidthPolicy
- Struct
- Value
- Object
Overview
How a particular terminal measures a grapheme cluster.
UAX #29 says where a cluster ends and UAX #11 says how wide a character is. Neither says what a terminal does with four emoji joined by zero width joiners, and terminals disagree: some advance two columns, some eleven. A buffer measuring a cluster differently from the terminal drawing it has every later cell on that row in the wrong place, so the measurement has to come from the terminal rather than from the standard.
WidthProbe fills one of these in by asking. The defaults are what a
current terminal does, and what a terminal that answers nothing is assumed
to do.
Defined in:
termbuf/unicode/policy.crConstant Summary
-
DEFAULT =
new -
What a current terminal does.
-
NAMES =
["ambiguous_wide", "emoji_presentation", "joined_emoji", "regional_indicators", "spacing_marks"] of ::String -
Every rule by name, for diagnostics and for
TERMBUF_WIDTHSto check against.
Constructors
Instance Method Summary
-
#ambiguous : Int32
Cells an East Asian Ambiguous character takes.
- #copy_with(ambiguous : Int32 = @ambiguous, emoji_presentation : Bool = @emoji_presentation, joined_emoji : Bool = @joined_emoji, regional_indicators : Bool = @regional_indicators, spacing_marks : Bool = @spacing_marks) : WidthPolicy
-
#emoji_presentation? : Bool
Whether U+FE0F widens a pictograph that would otherwise be text.
-
#enabled?(name : String) : Bool
Whether the rule name is on.
-
#joined_emoji? : Bool
Whether an emoji sequence joined by U+200D collapses to the width of one emoji.
-
#regional_indicators? : Bool
Whether a pair of regional indicators collapses to one flag.
-
#spacing_marks? : Bool
Whether a spacing mark takes a cell beside its base rather than none.
-
#to_s(io : IO) : Nil
Same as
#inspect(io). -
#with(name : String, enabled : Bool) : WidthPolicy
The flags by the names
TERMBUF_WIDTHSuses.
Constructor Detail
Instance Method Detail
Cells an East Asian Ambiguous character takes. One on most terminals, two on a terminal configured for CJK text, and the standard leaves it to the environment.
Whether U+FE0F widens a pictograph that would otherwise be text. Without
it ☺️ is as narrow as ☺.
Whether the rule name is on. ambiguous_wide reads as a flag here even
though it is stored as a count.
Whether an emoji sequence joined by U+200D collapses to the width of one emoji. Without it the cluster is as wide as its pieces laid end to end.