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-2015 Peng Huang <shawn.p.huang@gmail.com>
5  * Copyright (C) 2015-2019 Takao Fujiwara <takao.fujiwara1@gmail.com>
6  * Copyright (C) 2008-2017 Red Hat, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
21  * USA
22  */
23 
24 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
25 #error "Only <ibus.h> can be included directly"
26 #endif
27 
28 #ifndef __IBUS_ENGINE_SIMPLE_H__
29 #define __IBUS_ENGINE_SIMPLE_H__
30 
31 /**
32  * SECTION: ibusenginesimple
33  * @short_description: Input method engine supporting table-based input method
34  * @title: IBusEngineSimple
35  * @stability: Stable
36  *
37  * An IBusEngineSimple provides table-based input method logic.
38  *
39  * see_also: #IBusEngine
40  */
41 
42 #include "ibusengine.h"
43 #include "ibuskeysyms.h"
44 
45 G_BEGIN_DECLS
46 
47 #define IBUS_MAX_COMPOSE_LEN 0xFF
48 
49 /*
50  * Type macros.
51  */
52 
53 /* define GOBJECT macros */
54 #define IBUS_TYPE_ENGINE_SIMPLE             \
55     (ibus_engine_simple_get_type ())
56 #define IBUS_ENGINE_SIMPLE(obj)             \
57     (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_ENGINE_SIMPLE, IBusEngineSimple))
58 #define IBUS_ENGINE_SIMPLE_CLASS(klass)     \
59     (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_ENGINE_SIMPLE, IBusEngineSimpleClass))
60 #define IBUS_IS_ENGINE_SIMPLE(obj)          \
61     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_ENGINE_SIMPLE))
62 #define IBUS_IS_ENGINE_SIMPLE_CLASS(klass)  \
63     (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_ENGINE_SIMPLE))
64 #define IBUS_ENGINE_SIMPLE_GET_CLASS(obj)   \
65     (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_ENGINE_SIMPLE, IBusEngineSimpleClass))
66 
67 typedef struct _IBusEngineSimple IBusEngineSimple;
68 typedef struct _IBusEngineSimpleClass IBusEngineSimpleClass;
69 typedef struct _IBusEngineSimplePrivate IBusEngineSimplePrivate;
70 
71 /**
72  * IBusEngineSimple:
73  *
74  * IBusEngineSimple properties.
75  */
76 struct _IBusEngineSimple {
77     /*< private >*/
78     IBusEngine parent;
79     IBusEngineSimplePrivate *priv;
80 
81     /* instance members */
82     /*< public >*/
83 };
84 
85 struct _IBusEngineSimpleClass {
86     /*< private >*/
87     IBusEngineClass parent;
88 
89     /* class members */
90     /*< public >*/
91     /* signals */
92 
93     /*< private >*/
94     /* padding */
95     gpointer pdummy[8];
96 };
97 
98 static const guint16 IBUS_COMPOSE_IGNORE_KEYLIST[] = {
99     IBUS_KEY_Shift_L,
100     IBUS_KEY_Shift_R,
101     IBUS_KEY_Control_L,
102     IBUS_KEY_Control_R,
103     IBUS_KEY_Caps_Lock,
104     IBUS_KEY_Shift_Lock,
105     IBUS_KEY_Meta_L,
106     IBUS_KEY_Meta_R,
107     IBUS_KEY_Alt_L,
108     IBUS_KEY_Alt_R,
109     IBUS_KEY_Super_L,
110     IBUS_KEY_Super_R,
111     IBUS_KEY_Hyper_L,
112     IBUS_KEY_Hyper_R,
113     IBUS_KEY_Mode_switch,
114     IBUS_KEY_ISO_Level3_Shift
115 };
116 
117 GType   ibus_engine_simple_get_type       (void);
118 
119 /**
120  * ibus_engine_simple_add_table:
121  * @simple: An IBusEngineSimple.
122  * @data: (element-type guint16) (array): The table which must be available
123  *      during the whole life of the simple engine.
124  * @max_seq_len: Maximum length of a swquence in the table (cannot be greater
125  *      than %IBUS_MAX_COMPOSE_LEN)
126  * @n_seqs: number of sequences in the table
127  *
128  * Adds an additional table to search to the engine. Each row of the table
129  * consists of max_seq_len key symbols followed by two guint16 interpreted as
130  * the high and low words of a gunicode value. Tables are searched starting from
131  * the last added.
132  *
133  * The table must be sorted in dictionary order on the numeric value of the key
134  * symbol fields. (Values beyond the length of the sequence should be zero.)
135  */
136 void             ibus_engine_simple_add_table   (IBusEngineSimple  *simple,
137                                                  const guint16     *data,
138                                                  gint               max_seq_len,
139                                                  gint               n_seqs);
140 
141 /**
142  * ibus_engine_simple_add_table_by_locale:
143  * @simple: An IBusEngineSimple.
144  * @locale: (allow-none): The locale name. If the locale is %NULL,
145  *                        the current locale is used.
146  *
147  * Call ibus_engine_simple_add_table() internally by locale.
148  *
149  * Returns: %TRUE if the @locale is matched to the table.
150  */
151 gboolean         ibus_engine_simple_add_table_by_locale
152                                                 (IBusEngineSimple  *simple,
153                                                  const gchar       *locale);
154 
155 /**
156  * ibus_engine_simple_add_compose_file:
157  * @simple: An IBusEngineSimple.
158  * @file: The compose file.
159  *
160  * Call ibus_engine_simple_add_table() internally by locale.
161  *
162  * Returns: %TRUE if the @file is loaded.
163  */
164 gboolean         ibus_engine_simple_add_compose_file
165                                                 (IBusEngineSimple  *simple,
166                                                  const gchar       *file);
167 G_END_DECLS
168 
169 #endif // __IBUS_ENGINE_SIMPLE_H__
170