From 497b99dabe402a5a00d640db547e28c87bf602bc Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 3 Dec 2023 15:10:04 +0100 Subject: [PATCH] keyboard: distinct altgr subpage for macos Code cleanup to map non-alphabetic characters in %rows instead of @rows. --- altgr-macos.eng.inc.pl | 14 ++++++++++++++ altgr.eng.inc.pl | 19 +++++++------------ keyboard.eng.inc.pl | 24 ++++++++++-------------- 3 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 altgr-macos.eng.inc.pl diff --git a/altgr-macos.eng.inc.pl b/altgr-macos.eng.inc.pl new file mode 100644 index 0000000..68a39ad --- /dev/null +++ b/altgr-macos.eng.inc.pl @@ -0,0 +1,14 @@ +use utf8; +my @az = ('A'..'Z', 'a'..'z'); +my @letters = qw( + Å ı Ç ð ´ ̉ ˝ ̣ ˆ ½  Þ ¾ ˜ Ø ∏ Œ ‰ / ˇ ¨ ◊ „ ˛ ¼ ¸ + å ∫ ç ∂ ́ ƒ © ˙ ̂ ∆ ° ¬ µ ̃ ø π œ ® ß † ̈ √ ∑ ≈ ¥ Ω +); +our %rows = map { + $az[$_] => $letters[$_] +} 0 .. $#az; + ++{ + %{ do 'keyboard.eng.inc.pl' }, + version => '1.2', +} diff --git a/altgr.eng.inc.pl b/altgr.eng.inc.pl index 7c06938..9388771 100644 --- a/altgr.eng.inc.pl +++ b/altgr.eng.inc.pl @@ -1,17 +1,12 @@ use utf8; -my @usintrows = ( - [ 'a' .. 'z'], - [qw(Á B ¢ Ð É F G H Í J Œ Ø µ Ñ Ó Ö Ä ® § Þ Ú V Å X Ü Æ)], - [qw(á b © ð é f g h í j œ ø µ ñ ó ö ä ® ß þ ú v å x ü æ)], - [qw(Å ı Ç ð ´ ̉ ˝ ̣ ˆ ½  Þ ¾ ˜ Ø ∏ Œ ‰ / ˇ ¨ ◊ „ ˛ ¼ ¸)], - [qw(å ∫ ç ∂ ́ ƒ © ˙ ̂ ∆ ° ¬ µ ̃ ø π œ ® ß † ̈ √ ∑ ≈ ¥ Ω)], -); -our @rows = ( - map { - my $c = $_; - [ map { $usintrows[$_]->[$c] } 0 .. 2 ] - } 0 .. $#{ $usintrows[0] } +my @az = ('A'..'Z', 'a'..'z'); +my @letters = qw( + Á B ¢ Ð É F G H Í J Œ Ø µ Ñ Ó Ö Ä ® § Þ Ú V Å X Ü Æ + á b © ð é f g h í j œ ø µ ñ ó ö ä ® ß þ ú v å x ü æ ); +our %rows = map { + $az[$_] => $letters[$_] +} 0 .. $#az; +{ %{ do 'keyboard.eng.inc.pl' }, diff --git a/keyboard.eng.inc.pl b/keyboard.eng.inc.pl index 0e6a8cb..efbdad1 100644 --- a/keyboard.eng.inc.pl +++ b/keyboard.eng.inc.pl @@ -2,28 +2,24 @@ use Unicode::Normalize qw( NFKD ); use Text::Unidecode qw( unidecode ); { - rows => [0], + rows => [0, 1], def => { '' => { map { - my @row = @{$_}; + my $v = $rows{$_}; my $class = ( - !defined $row[2] || $row[0] eq $row[2] ? 1 # identical - : $row[2] =~ /\A\p{Mn}+\z/ ? 8 # combining accent - : NFKD($row[2]) =~ $row[0] ? 2 # decomposed equivalent - : $row[2] =~ /^\p{Latin}/ ? 4 # latin script - : unidecode($row[2]) =~ /^\W*\Q$row[0]/ ? 5 # transliterated + !defined $v || $_ eq $v ? 1 # identical + : $v =~ /\A\p{Mn}+\z/ ? 8 # combining accent + : NFKD($v) =~ $_ ? 2 # decomposed equivalent + : $v =~ /^\p{Latin}/ ? 4 # latin script + : unidecode($v) =~ /^\W*\Q$_/ ? 5 # transliterated : 7 ); - $row[0] => "g$class" - } @rows + $_ => "g$class" + } keys %rows }, }, - key => { - map { - $_->[0] => "$_->[1]
$_->[2]" - } @rows - }, + key => \%rows, flag => { g1 => ['unaltered', "same results as without modifier"], g2 => ['accented', "decomposes to the original letter with a combining accent"], -- 2.30.0