Some command line options are not GNU/POSIX compliant (4)
[geeqie.git] / keymap / keymap.awk
1 # Convert the original keymap_template.svg file to C program file
2 # Reformat to use data in the style of the gtk accelerator map routines
3 # awk -f keymap.awk keymap_template.svg > ../src/keymap_template.c
4
5 BEGIN {
6         print "/*"
7         print " * Copyright (C) 2004 John Ellis"
8         print " * Copyright (C) 2008 - 2016 The Geeqie Team"
9         print " *"
10         print " * Author: John Ellis"
11         print " *"
12         print " * This program is free software; you can redistribute it and/or modify"
13         print " * it under the terms of the GNU General Public License as published by"
14         print " * the Free Software Foundation; either version 2 of the License, or"
15         print " * (at your option) any later version."
16         print " *"
17         print " * This program is distributed in the hope that it will be useful,"
18         print " * but WITHOUT ANY WARRANTY; without even the implied warranty of"
19         print " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
20         print " * GNU General Public License for more details."
21         print " *"
22         print " * You should have received a copy of the GNU General Public License along"
23         print " * with this program; if not, write to the Free Software Foundation, Inc.,"
24         print " * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."
25         print " */"
26         print ""
27         print "static char *keymap_template [] = {"
28 }
29
30 {
31         gsub(/\"/,"\\\"")
32         gsub(/<control>/,"\\<Primary\\>")
33         gsub(/<meta>/,"\\<Alt\\>")
34         gsub(/<shift>/,"\\<Shift\\>")
35         gsub(/<super>/,"\\<Super\\>")
36         gsub(/<Shift><Primary>/,"\\<Primary\\>\\<Shift\\>")
37         gsub(/<Alt><Shift>/,"\\<Shift\\>\\<Alt\\>")
38         gsub(/<Alt><Primary>/,"\\<Primary\\>\\<Alt\\>")
39
40         gsub(/>\\</,">\\\\<")
41
42         gsub(/^/,"\"")
43         gsub(/$/,"\",")
44
45         keycodes[0,0]="0"
46         keycodes[0,1]="parenright"
47         keycodes[1,0]="1"
48         keycodes[1,1]="exclam"
49         keycodes[2,0]="2"
50         keycodes[2,1]="quotedbl"
51         keycodes[3,0]="3"
52         keycodes[3,1]="sterling"
53         keycodes[4,0]="4"
54         keycodes[4,1]="dollar"
55         keycodes[5,0]="5"
56         keycodes[5,1]="percent"
57         keycodes[6,0]="6"
58         keycodes[6,1]="asciicircum"
59         keycodes[7,0]="7"
60         keycodes[7,1]="ampersand"
61         keycodes[8,0]="8"
62         keycodes[8,1]="asterisk"
63         keycodes[9,0]="9"
64         keycodes[9,1]="parenleft"
65         keycodes[10,0]="minus"
66         keycodes[10,1]="underscore"
67         keycodes[11,0]="equal"
68         keycodes[11,1]="plus"
69         keycodes[12,0]="bracketleft"
70         keycodes[12,1]="braceleft"
71         keycodes[13,0]="bracketright"
72         keycodes[13,1]="braceright"
73         keycodes[14,0]="minus"
74         keycodes[14,1]="underscore"
75         keycodes[15,0]="semicolon"
76         keycodes[15,1]="colon"
77         keycodes[16,0]="apostrophe"
78         keycodes[16,1]="at"
79         keycodes[17,0]="numbersign"
80         keycodes[17,1]="asciitilde"
81         keycodes[18,0]="comma"
82         keycodes[18,1]="less"
83         keycodes[19,0]="period"
84         keycodes[19,1]="greater"
85         keycodes[20,0]="slash"
86         keycodes[20,1]="question"
87         keycodes[21,0]="grave"
88         keycodes[21,1]="notsign"
89         keycodes[22,0]="backslash"
90         keycodes[22,1]="bar"
91
92         for (i=0; i<23; i++)
93                 {
94                 gsub("Shift&gt;"keycodes[i,0],"Shift\\&gt;"keycodes[i,1])
95                 gsub("Primary&gt;&lt;Shift&gt;"keycodes[i,0],"Primary\\&gt;\\&lt;Shift\\&gt;"keycodes[i,1])
96                 gsub("Shift&gt;&lt;Alt&gt;"keycodes[i,0],"Shift\\&gt;\\&lt;Alt\\&gt;"keycodes[i,1])
97                 }
98
99         print
100 }
101
102 END {
103         print "NULL,"
104         print "};"
105
106 }