X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/800cd11bec46c84a8187b9180f0a7684e7be7d1c..885337ac8f6df8b7971248d0c31eed25ab5b8123:/tools/mkdigraphs-xorg diff --git a/tools/mkdigraphs-xorg b/tools/mkdigraphs-xorg index 67c60a6..be53fff 100755 --- a/tools/mkdigraphs-xorg +++ b/tools/mkdigraphs-xorg @@ -10,6 +10,8 @@ use Shiar_Sheet::FormatChar; our $VERSION = '1.01'; +my $matchvim; # enable to prefer best compatibility + my $symname = eval { open my $keysymh, '<', 'data/keysymdef.json' or die $!; local $/; @@ -33,22 +35,42 @@ while ($_ = readline) { 1; } or warn($@), next; $mnem =~ m/\A [\x20-\x7F]{2} \z/ or next; # only interested in two ascii - my $alias = (state $seen = {})->{$chr}++; # assume first is preferred + + my $alias = \(state $seen = {})->{$chr}; # assume first is preferred my $cp = ord $chr; - my $uninfo = Shiar_Sheet::FormatChar->glyph_info($cp); + my ($class, $name, undef, undef, $string) = @{ + Shiar_Sheet::FormatChar->glyph_info($cp) + }; my $comparison = ( !$vidi->{key}->{$mnem} ? 'l3' : # free $vidi->{key}->{$mnem}->[0] != $cp ? 'l1' : # conflict $vidi->{key}->{$mnem}->[2] eq 'l5' ? 'l5' : # rfc 'l4' # any ); - $table{$mnem} = [ - $cp, - $uninfo->[1] // '', # name - $comparison, - $alias ? 'l0 ex' : $uninfo->[0] // '', # class - $uninfo->[4] // (), # string - ]; + + if (${$alias}) { + # aliases an earlier occurrence + if ($matchvim and ${$alias}->[2] lt $comparison) { + # replace lower compatibility level + ${$alias}->[3] = 'l0'; + ${$alias}->[2] .= ' u-' . ${$alias}->[2]; + ${$alias} = undef; + } + else { + $class = 'l0'; + my $menm = substr($mnem, 1, 1).substr($mnem, 0, 1); + if ($table{$menm} && $table{$menm}[0] == $cp) { + # unannotated if identical to reversed input + $cp = 0; + } + else { + $class .= ' ex'; + } + } + } + + $table{$mnem} = [ $cp, $name, $comparison, $class, $string // () ]; + ${$alias} //= $table{$mnem}; } print JSON->new->canonical->indent->encode({ @@ -63,10 +85,15 @@ print JSON->new->canonical->indent->encode({ keywords => [qw( xorg x11 x )], flag => { 'l5' => "matching RFC-1345", - 'l4' => "matching proposal", + 'l4' => "matching Vim extension", 'l3' => "unique to Xorg", 'l1' => "conflict", - 'l0 ex' => "duplicate", + ('l0' => "Xorg preference") x !!$matchvim, + 'l0 ex' => "alias", + }, + flagclass => { + l5 => 'u-l4', + l4 => 'u-l5', }, });