File: gen_keysyms

package info (click to toggle)
gnome-subtitles 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 103,144 kB
  • sloc: xml: 406,395; cs: 364,495; ansic: 3,104; perl: 1,477; sh: 769; python: 545; javascript: 500; makefile: 49
file content (28 lines) | stat: -rwxr-xr-x 529 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl -w
# Generates a C# Key enum from the Gdk headers (gdkkeysyms.h)
# Usage: ./gen_keysyms < gdkkeysyms.h > Key.cs
# Alp Toker <alp@atoker.com>

print "// Generated File.  Do not modify.\n\n";
print "namespace Gdk\n";
print "{\n";
print "\tpublic enum Key {\n";

while(<>) {
	chomp;

	if (m/^\W*#define\W+GDK_(\w+)\W+(\w+)\W*$/) {
		$key = $1;
		$value = $2;
		
		# keys can't start with a digit
		if ($key =~ m/^\d.*$/) {
			$key = "Key_$key";
		}

		print "\t\t$key = $value,\n";
	}
}

print "\t}\n";
print "}\n";