keyboard/altgr: scalar references indicate aliases
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 14 Mar 2024 23:15:05 +0000 (00:15 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 8 Apr 2024 15:39:26 +0000 (17:39 +0200)
Common support in Shiar_Sheet::FormatChar::kbchars() replaces some manual
definition manipulation; adding a couple in eurkey previously not worth the
effort.

Shiar_Sheet/KeyboardChars.pm
keyboard/altgr/drix.eng.inc.pl
keyboard/altgr/eurkey.eng.inc.pl
keyboard/altgr/olpc.eng.inc.pl

index d0e84c8e082799c31b45428b979b20cf36abe895..5301185e42601cc8d981a73d218e4c008d3d4579 100644 (file)
@@ -9,7 +9,7 @@ use Unicode::Normalize qw( NFKD );
 use Text::Unidecode ();
 use Shiar_Sheet::FormatChar;
 
-our $VERSION = '1.04';
+our $VERSION = '1.05';
 our @EXPORT = qw( kbchars kbmodes );
 
 my $uc = Shiar_Sheet::FormatChar->new;
@@ -48,11 +48,17 @@ sub kbmodes ($modes) {
                        $info{def}->{$lead}{$lead} = 'g1 mode'; # back
                }
                while (my ($k, $v) = each %{ $modes->{$lead} }) {
+                       my @class;
+                       if (ref $v eq 'SCALAR') {
+                               my ($reflead, $ref) = split /(.)$/, ${$v};
+                               $v = $modes->{$reflead}->{$ref};
+                               @class = 'ext';
+                       }
                        my ($glyph, $title) = $uc->glyph_html($v);
                        $info{key}{$lead.$k} = join "\n", $glyph, $title;
                        my $c = $k =~ s/\A[+^](?=.)//r;  # trim modifier indicator
 
-                       my $class = (
+                       unshift @class, (
                                  !defined $v || $c eq $v ? 'no' # identical
                                : $v =~ /\A\p{Mn}+\z/ ? 'g9' # combining accent
                                : NFKD($v) =~ /\A\Q$c\E\p{Mn}*\z/ ? 'g2' # decomposed equivalent
@@ -62,8 +68,8 @@ sub kbmodes ($modes) {
                                : $v =~ /^\p{Latin}/ ? 'g5' # latin script
                                : 'g6'
                        );
-                       $g{$class} = 1 unless $class eq 'no';
-                       $info{def}{$lead}{$k} //= $class;
+                       $g{$_} = 1 for grep { $_ ne 'no' } @class;
+                       $info{def}{$lead}{$k} //= join ' ', @class;
                }
        }
        $info{flag} = {%{{
@@ -75,6 +81,7 @@ sub kbmodes ($modes) {
                g7 => ['punctuation', "(punctuation) mark"],
                g8 => ['mark', "modifier letter or mark (spacing diacritic)"],
                g9 => ['combining', "diacritical mark to be combined with a following character"],
+               ext => ['alias', 'alternative with identical results as something else'],
        }}{keys %g}};
        return \%info;
 }
index c36f53bf1c9e6e42315cf5ce1f7937f3b081ea21..a63a5a0d2a33c982a4451daebe9199e68f088f0f 100644 (file)
@@ -31,7 +31,7 @@ my %rows = (
        ']' => "}",
        '^' => "\N{COMBINING MACRON}",
        '_' => "\xB1",
-       '`' => "\xA3",
+       '`' => \'l',
        'A' => "\x{2190}",
        'a' => "\xE6",
        'B' => "\x{20bf}",
@@ -41,7 +41,7 @@ my %rows = (
        'd' => "\x{394}",
        'D' => "\x{2192}",
        'e' => "\x{20AC}",
-       'E' => "\x{20AC}",
+       'E' => \'e',
        'f' => "\x{192}",
        'F' => "\x{191}",
        #'g' => "g",
@@ -81,7 +81,7 @@ my %rows = (
        'x' => "\xD7",
        'X' => "\xF7",
        'y' => "\xA5",
-       'Y' => "\xA5",
+       'Y' => \'y',
        'z' => "\xA7",
        'Z' => "\xB6",
        '{' => "\xAB",
@@ -103,11 +103,8 @@ my %rows = (
        ';' => "\xA1",     # unshifted ! at m
 );
 
-my $groups = kbchars(\%rows);
-$groups->{def}{''}{$_} .= ' ext' for qw( ` E Y );
-
 +{
-       %{$groups},
+       %{ kbchars(\%rows) },
        version => '1.0',
        title => 'Drix',
        category => 'latin/xorg',
index d628ac1e8e3089abaa13c754b4865f68685239f0..ac7902795de48922be003eac420985a783d431b1 100644 (file)
@@ -109,7 +109,7 @@ my %rows = (
        # greek
        'm' => {
                'a' => 'α',
-               'b' => 'β', # v
+               'b' => 'β',
                'g' => 'γ',
                'd' => 'δ',
                'e' => 'ε',
@@ -131,7 +131,11 @@ my %rows = (
                'f' => 'φ',
                'c' => 'χ',
                'w' => 'ψ',
-               'q' => 'ω', # u
+               'q' => 'ω',
+
+               # aliases
+               'v' => \'mb',
+               'u' => \'mq',
 
                # suþscript
                '1' => '¹',
index 3d72e36306565aa8355b3fd7b52c6a3637a1891e..e67d8e75963b5ba055606b23245abf14d7185c3a 100644 (file)
@@ -64,11 +64,10 @@ my %shift = (
        qw( { [  } ]  " '  | \  < ,  > .  ? /  ` 3  ~ = ),
        (map {uc, lc} qw[ r t y u i o p  h j  m  ]),
 );
-$rows{$_} = $rows{ $shift{$_} } for keys %shift; # alias shifted
+$rows{$_} = \$shift{$_} for keys %shift; # alias shifted
 
 my $groups = kbchars(\%rows);
 $groups->{flag}{ext} = ['alias', 'identical results from unshifted key'];
-$groups->{def}{''}{$_} .= ' ext' for keys %shift; # mark aliases
 
 +{
        %{ $groups },