ucd/line_break.mbt1///|2/// Line_Break values and lookup3/// Generated from LineBreak.txt45///|6/// Unicode Line_Break values7/// See UAX #14: https://www.unicode.org/reports/tr14/#Table18#derive(Debug, Eq)9pub(all) enum LineBreak {10 AI // Ambiguous (Alphabetic or Ideographic)11 AK // Aksara12 AL // Alphabetic13 AP // Aksara Pre-Base14 AS // Aksara Start15 B2 // Break Opportunity Before and After16 BA // Break After17 BB // Break Before18 BK // Mandatory Break19 CB // Contingent Break Opportunity20 CJ // Conditional Japanese Starter21 CL // Close Punctuation22 CM // Combining Mark23 CP // Close Parenthesis24 CR // Carriage Return25 EB // Emoji Base26 EM // Emoji Modifier27 EX // Exclamation/Interrogation28 GL // Non-breaking ("Glue")29 H2 // Hangul LV Syllable30 H3 // Hangul LVT Syllable31 HH // Unambiguous Hyphen32 HL // Hebrew Letter33 HY // Hyphen34 ID // Ideographic35 IN // Inseparable36 IS // Infix Numeric Separator37 JL // Hangul L Jamo38 JT // Hangul T Jamo39 JV // Hangul V Jamo40 LF // Line Feed41 NL // Next Line42 NS // Nonstarter43 NU // Numeric44 OP // Open Punctuation45 PO // Postfix Numeric46 PR // Prefix Numeric47 QU // Quotation48 RI // Regional Indicator49 SA // Complex Context Dependent (South East Asian)50 SG // Surrogate51 SP // Space52 SY // Symbols Allowing Break After53 VF // Virama Final54 VI // Virama55 WJ // Word Joiner56 XX // Unknown57 ZW // Zero Width Space58 ZWJ // Zero Width Joiner59}6061///|62#deprecated("Use `Debug::to_repr` instead", skip_current_package=true)63#doc(hidden)64pub extend LineBreak with Debug::{to_repr}6566///|67pub extend LineBreak with Eq::{not_equal, equal}6869///|70pub extend LineBreak with Show::{to_string, output}7172///|73pub impl Show for LineBreak with fn output(self, logger) {74 logger.write_string(75 match self {76 AI => "AI"77 AK => "AK"78 AL => "AL"79 AP => "AP"80 AS => "AS"81 B2 => "B2"82 BA => "BA"83 BB => "BB"84 BK => "BK"85 CB => "CB"86 CJ => "CJ"87 CL => "CL"88 CM => "CM"89 CP => "CP"90 CR => "CR"91 EB => "EB"92 EM => "EM"93 EX => "EX"94 GL => "GL"95 H2 => "H2"96 H3 => "H3"97 HH => "HH"98 HL => "HL"99 HY => "HY"100 ID => "ID"101 IN => "IN"102 IS => "IS"103 JL => "JL"104 JT => "JT"105 JV => "JV"106 LF => "LF"107 NL => "NL"108 NS => "NS"109 NU => "NU"110 OP => "OP"111 PO => "PO"112 PR => "PR"113 QU => "QU"114 RI => "RI"115 SA => "SA"116 SG => "SG"117 SP => "SP"118 SY => "SY"119 VF => "VF"120 VI => "VI"121 WJ => "WJ"122 XX => "XX"123 ZW => "ZW"124 ZWJ => "ZWJ"125 },126 )127}128129///|130/// Convert a LineBreak ordinal, below 49, to the enum value.131///132/// A constructor without arguments is its ordinal on every backend. A133/// `match` or a table would cost a jump table or a load on wasm, wasm-gc134/// and JS, slower there than the trie lookup itself.135fn ordinal_to_line_break(ordinal : Int32) -> LineBreak = "%identity"136137///|138/// Get the Line_Break for a character.139///140/// Line_Break is the property the line breaking rules of UAX #14 are141/// written in terms of. It is a property of a single character, and the142/// value is the one the Unicode Character Database assigns: rule LB1 of143/// the algorithm, which resolves AI, CJ, SA, SG, and XX to other classes,144/// is not applied. Unassigned code points are XX, except in ranges145/// reserved for characters of a known class, such as ID in the CJK146/// ideograph blocks and in planes 2 and 3.147pub fn line_break(c : Char) -> LineBreak {148 ordinal_to_line_break(@line_break.lookup_line_break(c))149}150
///|
/// Line_Break values and lookup
/// Generated from LineBreak.txt
///|
/// Unicode Line_Break values
/// See UAX #14: https://www.unicode.org/reports/tr14/#Table1
#derive(Debug, Eq)
pub(all) enum LineBreak {
AI // Ambiguous (Alphabetic or Ideographic)
AK // Aksara
AL // Alphabetic
AP // Aksara Pre-Base
AS // Aksara Start
B2 // Break Opportunity Before and After
BA // Break After
BB // Break Before
BK // Mandatory Break
CB // Contingent Break Opportunity
CJ // Conditional Japanese Starter
CL // Close Punctuation
CM // Combining Mark
CP // Close Parenthesis
CR // Carriage Return
EB // Emoji Base
EM // Emoji Modifier
EX // Exclamation/Interrogation
GL // Non-breaking ("Glue")
H2 // Hangul LV Syllable
H3 // Hangul LVT Syllable
HH // Unambiguous Hyphen
HL // Hebrew Letter
HY // Hyphen
ID // Ideographic
IN // Inseparable
IS // Infix Numeric Separator
JL // Hangul L Jamo
JT // Hangul T Jamo
JV // Hangul V Jamo
LF // Line Feed
NL // Next Line
NS // Nonstarter
NU // Numeric
OP // Open Punctuation
PO // Postfix Numeric
PR // Prefix Numeric
QU // Quotation
RI // Regional Indicator
SA // Complex Context Dependent (South East Asian)
SG // Surrogate
SP // Space
SY // Symbols Allowing Break After
VF // Virama Final
VI // Virama
WJ // Word Joiner
XX // Unknown
ZW // Zero Width Space
ZWJ // Zero Width Joiner
}
///|
#deprecated("Use `Debug::to_repr` instead", skip_current_package=true)
#doc(hidden)
pub extend LineBreak with Debug::{to_repr}
///|
pub extend LineBreak with Eq::{not_equal, equal}
///|
pub extend LineBreak with Show::{to_string, output}
///|
pub impl Show for LineBreak with fn output(self, logger) {
logger.write_string(
match self {
AI => "AI"
AK => "AK"
AL => "AL"
AP => "AP"
AS => "AS"
B2 => "B2"
BA => "BA"
BB => "BB"
BK => "BK"
CB => "CB"
CJ => "CJ"
CL => "CL"
CM => "CM"
CP => "CP"
CR => "CR"
EB => "EB"
EM => "EM"
EX => "EX"
GL => "GL"
H2 => "H2"
H3 => "H3"
HH => "HH"
HL => "HL"
HY => "HY"
ID => "ID"
IN => "IN"
IS => "IS"
JL => "JL"
JT => "JT"
JV => "JV"
LF => "LF"
NL => "NL"
NS => "NS"
NU => "NU"
OP => "OP"
PO => "PO"
PR => "PR"
QU => "QU"
RI => "RI"
SA => "SA"
SG => "SG"
SP => "SP"
SY => "SY"
VF => "VF"
VI => "VI"
WJ => "WJ"
XX => "XX"
ZW => "ZW"
ZWJ => "ZWJ"
},
)
}
///|
/// Convert a LineBreak ordinal, below 49, to the enum value.
///
/// A constructor without arguments is its ordinal on every backend. A
/// `match` or a table would cost a jump table or a load on wasm, wasm-gc
/// and JS, slower there than the trie lookup itself.
fn ordinal_to_line_break(ordinal : Int32) -> LineBreak = "%identity"
///|
/// Get the Line_Break for a character.
///
/// Line_Break is the property the line breaking rules of UAX #14 are
/// written in terms of. It is a property of a single character, and the
/// value is the one the Unicode Character Database assigns: rule LB1 of
/// the algorithm, which resolves AI, CJ, SA, SG, and XX to other classes,
/// is not applied. Unassigned code points are XX, except in ranges
/// reserved for characters of a known class, such as ID in the CJK
/// ideograph blocks and in planes 2 and 3.
pub fn line_break(c : Char) -> LineBreak {
ordinal_to_line_break(@line_break.lookup_line_break(c))
}