Acme::Tpyo
Acme::Tpyo - Perl extension for misspelling words!
use Acme::Tpyo;
my $tpyist = Acme::Tpyo->new();
print $tpyist->misspell("one of these days alice, bang zoom, straight to the moon");
...
my $keysetup = {
MY_BOARD => {
# Key tables
unmodified =>
[
"`1234567890-=\\",
"qwertyuiop[]",
"asdfghjkl;'",
"zxcvbnm,./",
],
shift =>
[
"~!@#$%^&*()_+|",
"QWERTYUIOP{}",
"ASDFGHJKL:\"",
"ZXCVBNM<>?",
],
# Relative positions of the first key of each row.
_offsets =>
[
0, 0.5, 1, 2
],
# Which key tables can we jump between? [ from, to ]
_allow_table_jump =>
[
[ qw( unmodified shift ) ],
[ qw( shift unmodified ) ],
],
},
};
Tired of having to misspell your words by accident?
Want to do it more often and worse than normal?
Acme::Tpyo is for you!
With Acme::Tpyo you can use your normally perfectly typed strings and make them look like a 2nd grader! Great to give your project that professional edge your boss is always asking for!
$tpyist->misspell($string);
Use it to misspell stuff.
$string
The string to misspell.
$keyset
Optional defaults to US_QWERTY otherwise.
Pass a) a hashref (see below) or b) a string naming one of the default keyboard layouts
$typist
Optional.
Pass a hashref describing the typist. Defaults will be used if not provided.
Returns
Tpyo object
Creating a new keyboard layout is easy.
If you don't read the rest, note these.
First, describe what the key setup looks like without any modifiers. To do this, start a new hashref in $keysetup with whatever name you wish:
my $keysetup = {
# ...
NEW_LAYOUT => {
}
}
Then, add a key called "unmodified". In fact, you can name your key tables whatever you wish, but Tpyo expects there to be one called "unmodified".
Hash keys starting with an underscore are ignored, because these are meta-keys used by the engine as settings for the key tables.
This key points to an array ref. The array ref contains as many strings as you have rows on your keyboard.
Fill in your strings by pressing the first key on the row and then dragging it jazz-pianist style to the end of the row. Repeat for each row.
my $keysetup = {
# ...
NEW_LAYOUT => {
unmodified => [
q[`1234567890-=],
q[qwertyuiop[]],
# ... etc
]
}
}
Next, repeat this process for each accelerator or modifier key that you care about. For instance, shift:
my $keysetup = {
# ...
NEW_LAYOUT => {
unmodified => [
# ...
],
shift => [
q[ ¬!"£$%^*()_+ ],
# ...
]
}
}
This constructs a table for each modifier key.
You may also wish to specify the offsets of each row, relative to the leftmost row, which is at 0. This doesn't have to be precise; it just helps for the engine to know which keys are next to which other keys.
my $keysetup = {
# ...
NEW_LAYOUT => {
unmodified => [
# ...
],
shift => [
# ...
],
_offsets => [
0, 1.5, 1.75, 1.25
]
}
}
Table jumping is what happens when you accidentally press a modifier key while typing. This usually happens when you don't let go of it fast enough, or press it too early.
As part of the keyboard settings you can specify which modifiers you're likely, as a typist, to press at the wrong time.
my $keysetup = {
# ...
NEW_LAYOUT => {
# ...
_allow_table_jump => [
[ qw( unmodified shift ) ],
[ qw( shift unmodified ) ],
[ qw( altgr unmodified ) ],
[ qw( altgrshift shift ) ],
[ qw( altgrshift altgr ) ],
]
}
}
The above means that a character found in the 'unmodified' table may be replaced by the equivalent character from the 'shift' key table; a character on the 'shift' key table may be replaced by a character in the 'unmodified' key table; and a character in the 'altgr' keytable may be replaced by a character from the 'unmodified' key table. But, a character from the 'unmodified' and 'shift' key tables may not be replaced by a character from the 'altgr' key table, because one is not likely to accidentally press altgr - but one is likely to accidentally fail to press it.
Ryan Voots, simcop@cpan.org Alastair Douglas, alastair.douglas+cpan@gmail.com
Copyright (C) 2004,2008 by Ryan Voots, portions by Alastair Douglas
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available.