1 package Shiar_Sheet::KeyboardChars;
6 use experimental 'signatures';
8 use Unicode::Normalize qw( NFKD );
9 use Text::Unidecode ();
10 use Shiar_Sheet::FormatChar;
12 our $VERSION = '1.05';
13 our @EXPORT = qw( kbchars kbmodes );
15 my $uc = Shiar_Sheet::FormatChar->new;
18 ⍺ a ⍵ w ∊ E ⍷ E ⍴ r ⍳ i ⍸ i ○ O ⍥ O ⌿ / ⍟ (*) ⊕ (+)
19 Ʊ U ǝ e Ǝ E ʌ vA Ʌ VA ɥ h ʘ O ɰ mw ɯ mw Ɯ MW ə @ae Ə @AE
20 ɸ PF ʎ yl ɔ co Ɔ CO ɛ 3E ƣ q Ƣ Q ∀ A ∃ E ∪ u ∩ n ≠ !=
21 ≈ =~ ∅ /0 ∘ o ⋅ . ∫ s ≝ =d ″ " ≤ < ≥ > √ rV ∛ 3V ∜ 4V
22 Α A Β B Γ G Δ D Ε E Ζ Z Η H Θ CQ Ι I Κ K Λ L Μ M
23 Ν N Ξ X Ο O Π P Ρ R Σ S Τ T Υ YU Φ F Χ CX Ψ Y Ω W
24 α a β b γ g δ d ε e ζ z η h θ cq ι i κ k λ l μ m
25 ν n ξ x ο o π p ρ r σ s τ t υ yu φ f χ cx ψ y ω w
30 return $unaccent{$_[0]} // Text::Unidecode::unidecode($_[0]);
34 return kbmodes({'' => $rows});
37 sub kbmodes ($modes) {
38 my %g; # present group classes
40 tableclass => 'keys big',
43 for my $lead (keys %{$modes}) {
45 $info{def}->{''}->{$lead}[0] = "g1 mode$lead";
47 $info{mode}->{$lead} //= "mode $lead";
48 $info{def}->{$lead}{$lead} = ['g1 mode']; # back
50 while (my ($k, $v) = each %{ $modes->{$lead} }) {
52 if (ref $v eq 'SCALAR') {
53 my ($reflead, $ref) = split /(.)$/, ${$v};
54 $v = $modes->{$reflead}->{$ref};
57 my ($glyph, $title) = $uc->glyph_html($v);
58 my $c = $k =~ s/\A[+^](?=.)//r; # trim modifier indicator
61 !defined $v || $c eq $v ? 'no' # identical
62 : $v =~ /\A\p{Mn}+\z/ ? 'g9' # combining accent
63 : NFKD($v) =~ /\A\Q$c\E\p{Mn}*\z/ ? 'g2' # decomposed equivalent
64 : unidecode($v) =~ /\Q$c\E+/i ? 'g4' # transliterated
65 : $v =~ /\A[\p{Sk}\p{Lm}]+\z/ ? 'g8' # modifier symbol
66 : $v =~ /\A[\pM\pP]+\z/ ? 'g7' # mark
67 : $v =~ /^\p{Latin}/ ? 'g5' # latin script
70 $g{$_} = 1 for grep { $_ ne 'no' } @class;
71 $info{def}{$lead}{$k} //= [join ' ', @class];
72 $info{def}{$lead}{$k}[1] = join "\n", $glyph, $title;
76 g1 => ['mode' => "switch to an alternate set of keys"],
77 g2 => ['accented', "decomposes to the original letter with a combining accent"],
78 g4 => ['similar', "transliterates (mostly) into the unmodified letter"],
79 g5 => ['latin', "a different (accented) latin letter"],
80 g6 => ['symbol', "other character not directly deducible from key"],
81 g7 => ['punctuation', "(punctuation) mark"],
82 g8 => ['mark', "modifier letter or mark (spacing diacritic)"],
83 g9 => ['combining', "diacritical mark to be combined with a following character"],
84 ext => ['alias', 'alternative with identical results as something else'],