support (shift+)meta (alt) key combinations
[sheet.git] / Shiar_Sheet / Keyboard.pm
index d8d827440b474d88a68d680028ad95a682dd815f..6ba2a4ad12674ad04674e9cb3133d3624a309adb 100644 (file)
@@ -5,11 +5,13 @@ use warnings;
 no  warnings 'uninitialized';  # save some useless checks for more legible code
 use Carp;
 
-our $VERSION = '1.01';
+our $VERSION = '1.02';
 
-my @casedesc = qw(ctrl shift);
+my @casedesc = (undef, qw/shift ctrl meta/, 'shift meta');
 my @rowdesc = qw(numeric top home bottom);
 my %keyrows = do 'keys.inc.pl';
+# add first two cases of each row again with each char prepended by + (alt)
+push @$_, map { [map {"+$_"} @$_] } @$_[0,1] for map {@$_} values %keyrows;
 
 my %keytrans = qw(
        ^@ NUL ^a SOH ^b STX ^c ETX  ^d EOT ^e ENQ ^f ACK ^g BEL
@@ -45,6 +47,7 @@ sub map {
 sub escapeclass {
        local $_ = shift;
        s/\^/_c/g;
+       s/\+/_m/g;
        s/\[/_sbo/g;
        s/\]/_sbc/g;
        s/^$/_/;
@@ -63,7 +66,7 @@ sub keyunalias {
        my $self = shift;
        my ($key, $ancestry) = @_;
 
-       $key =~ s/(\S*?)(\^?\S)($|\s.*)/$2/;
+       $key =~ s/(\S*?)(\+?\^?\S)($|\s.*)/$2/;
        my $mode = $1;
        my $keyinfo = $self->{keys}->{$mode}->{$key};