Allows a non-interactive keyboard custom-tailored to show only wanted key
modes and cases. Useful to print out specific rows.
Letters indicate Vim modes (e.g. g, ^w, v, i, nothing for normal), following
digits specify keyboard modes/cases (where 1 is lower case, 2 shifted, and
3 with control pressed). After this, a dash with more digits can be added
to supply alternative key cases shown only at the top (numeric) row.
For example: ?static=i3+z1+g1-2+321-21 would result in:
1. insert mode keys with control pressed;
2. z + unshifted keys;
3. g + shifted keys for the first row, so !-) instead of 1-0,
+ normal keys (a-z, not A-Z as would be g2) elsewhere;
4. standard rows (control, shift, normal) for normal mode,
but leaving out ctrl for the first row (only ^^ there).
Clicking mode keys will not work correctly (should probably just be
disabled).
our $map = defined $keyrows{$get{map}} ? $get{map} : 'qwerty';
my $keyrows = $keyrows{$map};
our $map = defined $keyrows{$get{map}} ? $get{map} : 'qwerty';
my $keyrows = $keyrows{$map};
+my @moderows = $get{static} ? split(/\s+/, $get{static}) : sort keys %keys;
for (my $row = 0; $row <= $#$keyrows; $row++) {
my $keyrow = $keyrows->[$row];
for (my $row = 0; $row <= $#$keyrows; $row++) {
my $keyrow = $keyrows->[$row];
+ my @caserows = 0 .. $#$keyrow;
+
print qq{<li class="row row$row"><ul>\n};
print qq{<li class="row row$row"><ul>\n};
- while (my ($mode, $modekeys) = each %keys) {
- for (my $case = 0; $case <= $#$keyrow; $case++) {
- my $keycase = $keyrow->[$case];
+ for my $modefull (@moderows) {
+ my $mode = $modefull;
+ my @showcase = $mode =~ s/(\d+)(?:-(\d+))?$//
+ ? (map {3 - $_} split //, $row == 0 && $2 || $1) : @caserows;
+ my $modekeys = $keys{$mode};
+
+ for my $case (@showcase) {
+ my $keycase = $keyrow->[$case] or next;
@$keycase or next;
printf "\t<li%s>", $mode ne '' && sprintf(
@$keycase or next;
printf "\t<li%s>", $mode ne '' && sprintf(
- ' class="%s"', 'mode mode' . escapeclass($mode)
+ ' class="%s"', ($get{static} ? '' : 'mode ') . 'mode' . escapeclass($mode)
);
printf("<h3>%s<small>: %s</small></h3>\n", # XXX insert here to fix msie<=6
$modekeys->{desc} || "mode $mode",
);
printf("<h3>%s<small>: %s</small></h3>\n", # XXX insert here to fix msie<=6
$modekeys->{desc} || "mode $mode",