Skip Menu |

This queue is for tickets about the ACME-KeyboardMarathon CPAN distribution.

Report information
The Basics
Id: 117203
Status: open
Priority: 0/
Queue: ACME-KeyboardMarathon

People
Owner: Nobody in particular
Requestors: 'spro^^*%*^6ut# [...] &$%*c
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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;
Here is a patch for marathon.pl. (Did I say I had already spent too much time on this? )
Subject: open_HjpUkL3z.txt
diff -rup Acme-KeyboardMarathon-1.25-WD9CxM-orig/marathon.pl Acme-KeyboardMarathon-1.25-WD9CxM/marathon.pl --- Acme-KeyboardMarathon-1.25-WD9CxM-orig/marathon.pl 2016-08-23 22:51:25.000000000 -0700 +++ Acme-KeyboardMarathon-1.25-WD9CxM/marathon.pl 2016-08-24 20:08:56.000000000 -0700 @@ -7,6 +7,9 @@ the command line as arguments and it ret $> ./marathon.pl foo.txt bar.txt baz.txt +The first argument may be --qwerty or --dvorak, to specify the keyboard +layout. It defaults to QWERTY. + =cut use Acme::KeyboardMarathon; @@ -14,7 +17,8 @@ use Math::BigInt lib => 'GMP'; use strict; use warnings; -my $akm = new Acme::KeyboardMarathon; +my $akm = new Acme::KeyboardMarathon + layout => $ARGV[0] =~ /^--\w/ ? substr shift(@ARGV), 2 : 'qwerty'; our @ARGV; my $total = Math::BigInt->bzero();