From 02aff73f80ccbf7d050280af1114f0e663c6d4dd Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 5 May 2009 19:52:00 +0000 Subject: [PATCH] flexible keyboard ?rows override option --- Shiar_Sheet/Keyboard.pm | 35 +++++++++++++++++++++++------------ nethack.plp | 2 +- readline.plp | 2 +- vim.plp | 2 +- vimperator.plp | 2 +- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Shiar_Sheet/Keyboard.pm b/Shiar_Sheet/Keyboard.pm index e6982f7..4bc142c 100644 --- a/Shiar_Sheet/Keyboard.pm +++ b/Shiar_Sheet/Keyboard.pm @@ -5,7 +5,7 @@ use warnings; no warnings 'uninitialized'; # save some useless checks for more legible code use Carp; -our $VERSION = 'v1.03'; +our $VERSION = 'v1.04'; my @casedesc = (undef, qw/shift ctrl meta/, 'shift meta'); my @rowdesc = qw(numeric top home bottom); @@ -107,28 +107,37 @@ sub print_key { sub print_rows { my $self = shift; - my $static = shift; - my @moderows = $static ? split(/\s+/, $static) : sort keys %{ $self->{keys} }; + my %moderows = ( + -DEFAULT => !@_ ? '' : split(/(?:\s*([^=\s]*)=\s*)/, shift), + # plus specific mode overrides prefixed by '=' + ); + my $defrows = shift || [2, 1, 0]; + my @modes = sort keys %{ $self->{keys} }; for (my $row = 0; $row <= $#{ $keyrows{$self->{map}} }; $row++) { my $keyrow = $keyrows{$self->{map}}->[$row]; print qq{
  • \n}; } # case - } # mode + } # submode + + } # basemode print qq{\t\n}; } # row } diff --git a/nethack.plp b/nethack.plp index 5db14cd..9b8606b 100644 --- a/nethack.plp +++ b/nethack.plp @@ -53,7 +53,7 @@ $header{content_type} = "text/html; charset=$sign{charset}"; use Shiar_Sheet::Keyboard; my $keys = Shiar_Sheet::Keyboard->new({do 'nethack.inc.pl'}); $keys->map($get{map}) or undef $get{map}; -$keys->print_rows($get{static} || '4321-421'); +$keys->print_rows($get{rows} || '4321-421', [3,2,1,0]); :> diff --git a/readline.plp b/readline.plp index 0e6a3da..dd81cbe 100644 --- a/readline.plp +++ b/readline.plp @@ -52,7 +52,7 @@ $header{content_type} = "text/html; charset=$sign{charset}"; use Shiar_Sheet::Keyboard; my $keys = Shiar_Sheet::Keyboard->new({do 'readline.inc.pl'}); $keys->map($get{map}) or undef $get{map}; -$keys->print_rows($get{static} || '543'); +$keys->print_rows($get{rows}, [4,3,2]); :> diff --git a/vim.plp b/vim.plp index 92a1f5f..e357b73 100644 --- a/vim.plp +++ b/vim.plp @@ -53,7 +53,7 @@ $header{content_type} = "text/html; charset=$sign{charset}"; use Shiar_Sheet::Keyboard; my $keys = Shiar_Sheet::Keyboard->new({do 'vim.inc.pl'}); $keys->map($get{map}) or undef $get{map}; -$keys->print_rows($get{static}); +$keys->print_rows($get{rows}); :> diff --git a/vimperator.plp b/vimperator.plp index 731c0f2..55c635f 100644 --- a/vimperator.plp +++ b/vimperator.plp @@ -53,7 +53,7 @@ $header{content_type} = "text/html; charset=$sign{charset}"; use Shiar_Sheet::Keyboard; my $keys = Shiar_Sheet::Keyboard->new({do 'vimperator.inc.pl'}); $keys->map($get{map}) or undef $get{map}; -$keys->print_rows($get{static}); +$keys->print_rows($get{rows}); :> -- 2.30.0