Subject: | [PATCH] Dvorak |
Show quoted text
> * A QWERTY keyboard is assumed. DVORAK people are thus left out in the cold.
> As they should be. The freaks.
:-)
Well, here is a patch. Of course, this being an Acme module, I did not bother with tests. I have already wasted too much time on this. :-)
Here is an example of how much effort normal people waste on typing:
bash-3.2$ perl -Ilib -MAcme::KeyboardMarathon -le 'print Acme::KeyboardMarathon->new( layout => "dvorak")-> distance ("Included in this distribution is an example script (marathon.pl) that can")'
89
bash-3.2$ perl -Ilib -MAcme::KeyboardMarathon -le 'print Acme::KeyboardMarathon->new( layout => "qwerty")-> distance ("Included in this distribution is an example script (marathon.pl) that can")'
123
And you can probably guess which keyboard layout I used to write this. :-)
Subject: | open_7pbr0Sy0.txt |
diff -rup Acme-KeyboardMarathon-1.25-WD9CxM-orig/lib/Acme/KeyboardMarathon.pm Acme-KeyboardMarathon-1.25-WD9CxM/lib/Acme/KeyboardMarathon.pm
--- Acme-KeyboardMarathon-1.25-WD9CxM-orig/lib/Acme/KeyboardMarathon.pm 2016-08-23 22:51:25.000000000 -0700
+++ Acme-KeyboardMarathon-1.25-WD9CxM/lib/Acme/KeyboardMarathon.pm 2016-08-24 19:59:46.000000000 -0700
@@ -15,6 +15,14 @@ sub new {
my $self = {};
bless($self,$class);
+ croak("Odd number of arguments") if @args%2;
+ my %args = @args;
+ my $layout = delete $args{layout} || 'qwerty';
+ croak("Unsupported layout $layout")
+ unless $layout =~ /^(?:qwerty|dvorak)\z/;
+
+ croak "Unknown options: " . join ", ", keys(%args) if keys %args;
+
# all measures in 100ths of a cm
my $depress_distance = 25;
@@ -25,14 +33,26 @@ sub new {
$self->{k} = {};
no warnings 'qw';
- map { $self->{k}->{$_} = 550 } ( '\\', '|' );
- map { $self->{k}->{$_} = 500 } ( qw/6 ^ ` ~/ );
- map { $self->{k}->{$_} = 450 } ( qw/= +/ );
- map { $self->{k}->{$_} = 400 } ( qw/] 1 2 3 4 7 8 9 0 5 - _ ! @ # $ % & * ( ) }/ );
- map { $self->{k}->{$_} = 350 } ( qw/B b/ );
- map { $self->{k}->{$_} = 230 } ( qw/[ {/ );
- map { $self->{k}->{$_} = 200 } ( qw/Q q W w G g H h E e R r T t Y y U u I i O o P p Z z X x C c V v N n M m , < > . \/ ? ' "/ );
- map { $self->{k}->{$_} = 0 } ( qw/A a S s D d F f J j K k L l ; :/ );
+ if ($layout eq 'qwerty') {
+ map { $self->{k}->{$_} = 550 } ( '\\', '|' );
+ map { $self->{k}->{$_} = 500 } ( qw/6 ^ ` ~/ );
+ map { $self->{k}->{$_} = 450 } ( qw/= +/ );
+ map { $self->{k}->{$_} = 400 } ( qw/] 1 2 3 4 7 8 9 0 5 - _ ! @ # $ % & * ( ) }/ );
+ map { $self->{k}->{$_} = 350 } ( qw/B b/ );
+ map { $self->{k}->{$_} = 230 } ( qw/[ {/ );
+ map { $self->{k}->{$_} = 200 } ( qw/Q q W w G g H h E e R r T t Y y U u I i O o P p Z z X x C c V v N n M m , < > . \/ ? ' "/ );
+ map { $self->{k}->{$_} = 0 } ( qw/A a S s D d F f J j K k L l ; :/ );
+ }
+ else { # freaks
+ map { $self->{k}->{$_} = 550 } ( '\\', '|' );
+ map { $self->{k}->{$_} = 500 } ( qw/6 ^ ` ~/ );
+ map { $self->{k}->{$_} = 450 } ( qw/] }/ );
+ map { $self->{k}->{$_} = 400 } ( qw/+ = 1 2 3 4 7 8 9 0 5 [ { ! @ # $ % & * ( )/ );
+ map { $self->{k}->{$_} = 350 } ( qw/X x/ );
+ map { $self->{k}->{$_} = 230 } ( qw/? \// );
+ map { $self->{k}->{$_} = 200 } ( qw/" ' < , I i D d > . P p Y y F f G g C c R r L l : ; Q q J j K k B b M m W w V v Z z - _/ );
+ map { $self->{k}->{$_} = 0 } ( qw/A a O o E e U u H h T t N n S s/ );
+ }
$self->{k}->{"\n"} = 400;
$self->{k}->{"\t"} = 230;