You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Kaleidoscope/tools/generate_keymaps.pl

50 lines
808 B

use warnings;
use strict;
my @data = <STDIN>;
use Data::Dumper;
my $name = 'Unnamed';
my @map;
for my $line (@data) {
chomp($line);
if ($line =~ /^#NAME: (.*)/i) {
$name = $1;
next
}
my @keys = split(/\s+/, $line);
push @map, join(', ', map{ 'Key_'.lookup($_).'' } @keys);
}
print "#define KEYMAP_$name { /* Generated keymap for $name */ ";
for my $line (@map) {
print "\t{". $line ."},\\\n";
}
print "},\n";
sub lookup {
my %table = (
'{' => 'LCurlyBracket',
'}' => 'RCurlyBracket',
'['=> 'LSquareBracket',
']'=> 'RSquareBracket',
'|'=> 'Pipe',
'\\' => 'Backslash',
';' => 'Semicolon',
',' => 'Comma',
'.' => 'Period',
'/' => 'Slash',
"'" => 'Quote',
'`' => 'Backtick',
'-' => 'Minus',
'=' => 'Equals');
my $x = shift;
return $x unless defined $table{$x};
return $table{$x};
}