X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=genrefcard.pl;h=057142ecf28836b13951eaea34b3b7982056bc2a;hb=refs%2Fheads%2Fmaster;hp=d50e91b14a97297630f04222d9333d85ac597a06;hpb=bd339d88f038566f8f1a39e6b4d9260025fcfe91;p=grml-gen-zshrefcard.git diff --git a/genrefcard.pl b/genrefcard.pl index d50e91b..057142e 100755 --- a/genrefcard.pl +++ b/genrefcard.pl @@ -2,7 +2,16 @@ use strict; #{{{ readme ### Author: Frank Terbeck -### GPLv2 +### +### This file is free software: you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published +### by the Free Software Foundation, either version 3 of the License, +### or (at your option) any later version. +### +### This file is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. ### ### generate grml zsh refcard. ### #v#: variables @@ -263,8 +272,9 @@ sub __abbrev { #{{{ my ($sec, $desc) = @_; my ($abbrev, $value, $doc); + xprint(1, "$ln, $i\n"); while ($ln <= $i) { # the global $i - if ($input[$ln] =~ m!^\s*\#A[0-9]*\#!) { + if ($input[$ln] =~ m!^\s*#A[0-9]*#!) { xprint(1, "Ending abbreviation handling in line $ln.\n"); $ln++; return 1; @@ -275,12 +285,12 @@ sub __abbrev { #{{{ $doc = $1; } - if ($input[$ln] =~ m!\s*['"]([^"']*)['"]\s\$?['"]([^"']*)['"]!) { + if ($input[$ln] =~ m!^\s*['"]([^"']*)['"]\s+\$?['"]([^"']*)['"]!) { $abbrev = $1; $value = &escape_string($2); xprint(2, "ab: $abbrev -> $value ($doc);\n"); push(@{ $data{"abbrev-$secmap[$sec]"} }, "\\command\{$abbrev\}\{\\kbd\{$value" . ($doc ne '' ? "\}\\quad $doc" : "\}") . "\}"); } else { - return 0; + xprint(0, "Line didn't look like abbreviation in abbreviations section: " . $input[$ln] . "\n"); } $ln++; } @@ -354,6 +364,25 @@ sub __keybinding { #{{{ #xprint(0, "!-> DEBUG: kbd: $kbd - value: $value - desc: $desc\n"); push(@{ $data{"keybindings-$secmap[$sec]"} }, "\\command\{$kbd\}\{$desc\}"); + } elsif ($input[$ln] =~ m!^.*bind2maps\s+([^-])+--\s+(.*)!) { + my ($maps, $rest) = ($1, $2); + my (@a) = split /\s+/, $rest, 2; + if ($a[0] ne q{-s}) { + push(@{ $data{"keybindings-$secmap[$sec]"} }, + "\\command\{$a[0]\}\{$desc\}"); + return 1; + } + my $seq; + $rest = $a[1]; + if ($rest =~ m!^'([^']+)'\s+!) { + $seq = $1; + } elsif ($rest =~ m!^"([^"]+)"\s+!) { + $seq = $1; + } else { + $seq = $rest; + } + $seq = demystify_keys($seq); + push(@{ $data{"keybindings-$secmap[$sec]"} }, "\\command\{$seq\}\{$desc\}"); } else { return 0; }