Add Ctrl+space customization.
[platform/upstream/ibus.git] / src / ibuskeymap.h
1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
3 /* IBus - The Input Bus
4  * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
5  * Copyright (C) 2008-2010 Red Hat, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
25 #endif
26
27 /**
28  * SECTION: ibuskeymap
29  * @short_description: Keyboard mapping handling.
30  * @title: IBusKeymap
31  * @stability: Stable
32  *
33  * An IBusKeymap defines the mapping between keyboard scancodes and
34  * keyboard symbols such as numbers, alphabets, and punctuation marks.
35  *
36  * Some input methods assume certain keyboard layout
37  * (such as Chewing and Wubi requires an US-QWERTY layout),
38  * and expect key symbols to be arranged in that order.
39  * These input methods should new an IBusKeymap
40  * instance and define the keyboard layout.
41  * Then ibus_keymap_lookup_keysym() can
42  * convert scancodes back to the key symbols.
43  *
44  * @see_also: #IBusComponent, #IBusEngineDesc
45  *
46  */
47
48 #ifndef __IBUS_KEYMAP_H_
49 #define __IBUS_KEYMAP_H_
50
51 #include "ibusobject.h"
52
53 /*
54  * Type macros.
55  */
56 /* define IBusKeymap macros */
57 #define IBUS_TYPE_KEYMAP             \
58     (ibus_keymap_get_type ())
59 #define IBUS_KEYMAP(obj)             \
60     (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_KEYMAP, IBusKeymap))
61 #define IBUS_KEYMAP_CLASS(klass)     \
62     (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_KEYMAP, IBusKeymapClass))
63 #define IBUS_IS_KEYMAP(obj)          \
64     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_KEYMAP))
65 #define IBUS_IS_KEYMAP_CLASS(klass)  \
66     (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_KEYMAP))
67 #define IBUS_KEYMAP_GET_CLASS(obj)   \
68     (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_KEYMAP, IBusKeymapClass))
69
70 G_BEGIN_DECLS
71
72 typedef struct _IBusKeymap IBusKeymap;
73 typedef struct _IBusKeymapClass IBusKeymapClass;
74
75 /**
76  * KEYMAP:
77  *
78  * Data structure for storing keymap.
79  * keymap[.][i]
80  * i:
81  *  0 - without modifer
82  *  1 - shift
83  *  2 - caplock
84  *  3 - shift caplock
85  *  4 - altgr
86  *  5 - shift altgr
87  *  6 - numlock
88  */
89 /* typedef guint KEYMAP[256][7]; */
90
91 /**
92  * IBusKeymap:
93  * @name: The name of the keymap, such as 'us', 'jp'.
94  * @keymap: Keymap table. IME developers normally don have to touch this.
95  *
96  * A keymap object in IBus.
97  */
98 struct _IBusKeymap {
99     /*< private >*/
100     IBusObject parent;
101     /* members */
102     /*< public >*/
103     gchar *name;
104     guint keymap[256][7];
105 };
106
107 struct _IBusKeymapClass {
108     IBusObjectClass parent;
109 };
110
111 GType            ibus_keymap_get_type               (void);
112
113 /**
114  * ibus_keymap_new:
115  * @name: The keymap file to be loaded, such as 'us', 'jp'.
116  * @returns: An IBusKeymap associated with the giving name; or NULL if failed.
117  *
118  * Get an IBusKeymap associated with the giving name.
119  *
120  * This function loads the keymap file specified in @name
121  * in the IBUS_DATA_DIR/keymaps directory.
122  *
123  * Deprecated: This function has been deprecated and should
124  * not be used in newly written code. Please use ibus_keymap_get().
125  */
126 IBusKeymap        *ibus_keymap_new                  (const gchar        *name)
127     G_GNUC_DEPRECATED;
128
129 /**
130  * ibus_keymap_get:
131  * @name: The keymap file to be loaded, such as 'us', 'jp'.
132  * @returns: An IBusKeymap associated with the giving name; or NULL if failed.
133  *
134  * Get an IBusKeymap associated with the giving name.
135  *
136  * This function loads the keymap file specified in @name
137  * in the IBUS_DATA_DIR/keymaps directory.
138  */
139 IBusKeymap        *ibus_keymap_get                  (const gchar        *name);
140
141 /**
142  * ibus_keymap_lookup_keysym:
143  * @keymap: An IBusKeymap.
144  * @keycode: A scancode to be converted.
145  * @state: Modifier flags(such as Ctrl, Shift).
146  * @returns: Corresponding keysym.
147  *
148  * Convert the scancode to keysym, given the keymap.
149  */
150 guint              ibus_keymap_lookup_keysym        (IBusKeymap         *keymap,
151                                                      guint16             keycode,
152                                                      guint32             state);
153
154 G_END_DECLS
155 #endif
156