~ubuntu-branches/debian/sid/geany-plugins/sid

« back to all changes in this revision

Viewing changes to geanylua/util/mk-keytab.lua

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-07-10 22:56:41 UTC
  • Revision ID: james.westby@ubuntu.com-20090710225641-xc1126t7pq0jmpos
Tags: upstream-0.17.1
ImportĀ upstreamĀ versionĀ 0.17.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env lua
 
2
 
 
3
--[[
 
4
    Script to create the "glspi_keycmd.h" file.
 
5
 
 
6
    Requires: 
 
7
      ../geany/src/keybindings.h relative to the current directory.
 
8
      "lua" and "cpp" somewhere in your $PATH
 
9
 
 
10
    Note that you should invoke this script from the top-level /geanylua/
 
11
    directory, not from /geanylua/util/
 
12
 
 
13
    The only time you need this is if the keybinding group-IDs or key-IDs
 
14
    in /geany/src/keybindings.h have changed. But it is certainly possible
 
15
    for that file to have been altered so radically that this script will
 
16
    fail anyway!
 
17
 
 
18
--]]
 
19
 
 
20
 
 
21
 
 
22
 
 
23
local names={}
 
24
 
 
25
local cpp=io.popen(
 
26
  "cpp -P `pkg-config --cflags gtk+-2.0` -I../geany/src util/keydummy.h"
 
27
)
 
28
 
 
29
for line in cpp:lines()
 
30
do
 
31
  if line:find("^[ \t]*GEANY_KEYS_") and not line:find("^[ \t]*GEANY_KEYS_GROUP")
 
32
  then
 
33
    name=line:gsub("^[ \t]*GEANY_KEYS_([^ \t,]+).*$", "%1")
 
34
    table.insert(names, name)
 
35
  end
 
36
end
 
37
 
 
38
 
 
39
print(
 
40
[[
 
41
 
 
42
/*
 
43
 *******************  !!! IMPORTANT !!!  ***************************
 
44
 *
 
45
 * This is a machine generated file, do not edit by hand!
 
46
 * If you need to modify this file, see "geanylua/util/mk-keytab.lua"
 
47
 *
 
48
 *******************************************************************
 
49
 *
 
50
 */
 
51
 
 
52
]]
 
53
)
 
54
 
 
55
 
 
56
print("typedef struct _KeyCmdHashEntry {")
 
57
print("\tgchar *name;")
 
58
print("\tguint group;")
 
59
print("\tguint key_id;")
 
60
print("} KeyCmdHashEntry;")
 
61
print("\n")
 
62
 
 
63
print("static KeyCmdHashEntry key_cmd_hash_entries[] = {")
 
64
 
 
65
for num,name in pairs(names)
 
66
do
 
67
  print(
 
68
   string.format("\t{\"%s\", GEANY_KEY_GROUP_%s, GEANY_KEYS_%s},",
 
69
      name, name:gsub("_.*", ""), name)
 
70
   )
 
71
end
 
72
 
 
73
print("\t{NULL, 0, 0}")
 
74
print("};")
 
75
 
 
76
 
 
77
 
 
78
 
 
79