Add Ctrl+space customization.
[platform/upstream/ibus.git] / src / ibuskeysyms-update.pl
1 #!/usr/bin/env perl
2
3 # Updates http://svn.gnome.org/viewcvs/gtk%2B/trunk/gdk/gdkkeysyms.h?view=log from upstream (X.org 7.x),
4 # from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
5 #
6 # Author  : Simos Xenitellis <simos at gnome dot org>.
7 # Version : 1.2
8 #
9 # Input   : http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h
10 # Output  : http://svn.gnome.org/svn/gtk+/trunk/gdk/gdkkeysyms.h
11 #
12 # Notes   : It downloads keysymdef.h from the Internet, if not found locally,
13 # Notes   : and creates an updated gdkkeysyms.h
14 # Notes   : This version updates the source of gdkkeysyms.h from CVS to the GIT server.
15
16 use strict;
17
18 # Used for reading the keysymdef symbols.
19 my @keysymelements;
20
21 if ( ! -f "keysymdef.h" )
22 {
23         print "Trying to download keysymdef.h from\n";
24         print "http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\n";
25         die "Unable to download keysymdef.h from http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\n"
26                 unless system("wget -c -O keysymdef.h \"http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob_plain;f=keysymdef.h\"") == 0;
27         print " done.\n\n";
28 }
29 else
30 {
31         print "We are using existing keysymdef.h found in this directory.\n";
32         print "It is assumed that you took care and it is a recent version\n";
33         print "as found at http://gitweb.freedesktop.org/?p=xorg/proto/x11proto.git;a=blob;f=keysymdef.h\n\n";
34 }
35
36
37 if ( -f "ibuskeysyms.h" )
38 {
39         print "There is already a ibuskeysyms.h file in this directory. We are not overwriting it.\n";
40         print "Please move it somewhere else in order to run this script.\n";
41         die "Exiting...\n\n";
42 }
43
44 # Source: http://cvs.freedesktop.org/xorg/xc/include/keysymdef.h
45 die "Could not open file keysymdef.h: $!\n" unless open(IN_KEYSYMDEF, "<:utf8", "keysymdef.h");
46
47 # Output: gtk+/gdk/gdkkeysyms.h
48 die "Could not open file ibuskeysyms.h: $!\n" unless open(OUT_IBUSKEYSYMS, ">:utf8", "ibuskeysyms.h");
49
50 print OUT_IBUSKEYSYMS<<EOF;
51 /* ibus - The Input Bus
52  * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang\@gmail.com>
53  * Copyright (C) 2008-2010 Red Hat, Inc.
54  *
55  * This library is free software; you can redistribute it and/or
56  * modify it under the terms of the GNU Lesser General Public
57  * License as published by the Free Software Foundation; either
58  * version 2 of the License, or (at your option) any later version.
59  *
60  * This library is distributed in the hope that it will be useful,
61  * but WITHOUT ANY WARRANTY; without even the implied warranty of
62  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
63  * Lesser General Public License for more details.
64  *
65  * You should have received a copy of the GNU Lesser General Public
66  * License along with this library; if not, write to the
67  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
68  * Boston, MA 02111-1307, USA.
69  */
70
71 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
72 #error "Only <ibus.h> can be included directly"
73 #endif
74
75 #ifndef __IBUS_KEYSYMS_H__
76 #define __IBUS_KEYSYMS_H__
77
78 EOF
79
80
81 while (<IN_KEYSYMDEF>)
82 {
83         next if ( ! /^#define / );
84
85         @keysymelements = split(/\s+/);
86         die "Internal error, no \@keysymelements: $_\n" unless @keysymelements;
87
88         $_ = $keysymelements[1];
89         die "Internal error, was expecting \"XC_*\", found: $_\n" if ( ! /^XK_/ );
90
91         $_ = $keysymelements[2];
92         die "Internal error, was expecting \"0x*\", found: $_\n" if ( ! /^0x/ );
93
94         $keysymelements[1] =~ s/^XK_/IBUS_KEY_/g;
95
96         printf OUT_IBUSKEYSYMS "#define %s 0x%03x\n", $keysymelements[1], hex($keysymelements[2]);
97 }
98
99 #$ibussyms{"0"} = "0000";
100
101 close IN_KEYSYMDEF;
102
103
104 print OUT_IBUSKEYSYMS<<EOF;
105
106 #endif /* __IBUS_KEYSYMS_H__ */
107 EOF
108
109 printf "We just finished converting keysymdef.h to ibuskeysyms.h\nThank you\n";