NAME
Acme::Tpyo - Perl extension for misspelling words!
SYNOPSIS
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 ) ],
],
},
};
DESCRIPTION
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!
METHODS
misspell
$tpyist->misspell($string);
Use it to misspell stuff.
$string
The string to misspell.
new
$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.
- modifier_discipline
-
Between 0 and 1, how unlikely the typist is to use the wrong key table.
- spacebar_discipline
-
Between 0 and 1, how unlikely the typist is to put the space at the end of a word in the wrong place.
- finger_fatness
-
Between 0 and 1, how likely the typist is to press more than one key at once.
- disorder
-
Between 0 and 1, how likely the typist is to get the letters in the wrong order.
- miscoordination
-
Between 0 and 1, how likely the typist is to get the letters wrong in the first place.
- weakness
-
Between 0 and 1, how likely the typist is to succeed in pressing the key.
- complete_failure
-
Between 0 and 1, how likely the typist is to have a complete brain fart and press completely the wrong key, rather than just miss.
- caffeine
-
Between 0 and 1, how likely the typist is to repeat a letter due to the jitters.
- drunkenness
-
Between 0 and 1, makes the typist worse at everything in one go.
Returns
Tpyo object
KEYBOARD LAYOUTS
Creating a new keyboard layout is easy.
Things to note
If you don't read the rest, note these.
You can call your keyboard layout anything you want
You can call your modifier tables anything you want, except something starting with an underscore.
You must have a table called "unmodified" for it to work
You can't lose modifier discipline if your _allow_table_jump array is empty - map your modifier table names to each other here.
_allow_table_jump must always be a two-dimensional array ref
If modifier+key produces nothing, put a space, so that the other keys line up in the table.
Key tables
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.
Offsets
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
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.
TODO
- 1 Check docs are proper, always needs doing
- 2 Allow space in keyset
- 3 Fix maths in drunkify function
- 4 (Suggested by f00li5h) Allow for permanent modifiers in the keyset, to be pressed by accident, such as caps next to A.
AUTHOR
Ryan Voots, simcop@cpan.org Alastair Douglas, alastair.douglas+cpan@gmail.com
COPYRIGHT AND LICENSE
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.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 577:
Non-ASCII character seen before =encoding in '¬!"£$%^*()_+'. Assuming UTF-8