9e0468f9290a23b7f6f1aa3dd7aeb655c76ef143
[m17n/m17n-lib.git] / src / input.h
1 /* input.h -- header file for the input method module.
2    Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
3      National Institute of Advanced Industrial Science and Technology (AIST)
4      Registration Number H15PRO112
5
6    This file is part of the m17n library.
7
8    The m17n library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU Lesser General Public License
10    as published by the Free Software Foundation; either version 2.1 of
11    the License, or (at your option) any later version.
12
13    The m17n 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 the m17n library; if not, write to the Free
20    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21    02111-1307, USA.  */
22
23 #ifndef _M17N_INPUT_H_
24 #define _M17N_INPUT_H_
25
26 typedef struct _MInputMethodInfo MInputMethodInfo;
27
28 struct _MInputMethodInfo
29 {
30   MDatabase *mdb;
31   MSymbol language, name, extra;
32   MPlist *cmds, *configured_cmds, *bc_cmds;
33   MPlist *vars, *configured_vars, *bc_vars;
34   MText *description;
35   MText *title;
36   MPlist *maps;
37   MPlist *states;
38   MPlist *macros;
39   MPlist *externals;
40   unsigned long tick;
41 };
42
43 typedef struct MIMState MIMState;
44
45 typedef struct MIMMap MIMMap;
46
47 typedef struct
48 {
49   /** The current state.  */
50   MIMState *state;
51
52   /** The previous state.  */
53   MIMState *prev_state;
54
55   /** The current map.  */
56   MIMMap *map;
57
58   /** Table of typed keys.  */
59   int size, inc, used;
60   MSymbol *keys;
61
62   /** Index of the key handled firstly in the current state.  */
63   int state_key_head;
64
65   /** Index of the key not yet handled.  */
66   int key_head;
67
68   /** Index of the key at the time of committing.  */
69   int commit_key_head;
70
71   /** Saved M-text when entered in the current state.  */
72   MText *preedit_saved;
73
74   /** The insertion position when shifted to the current state.  */
75   int state_pos;
76
77   /** List of markers.  */
78   MPlist *markers;
79
80   /** List of variables. */
81   MPlist *vars;
82
83   MPlist *vars_saved;
84
85   MText *preceding_text, *following_text;
86
87   int key_unhandled;
88
89   /** Used by minput_win_driver (input-win.c).  */
90   void *win_info;
91
92   MPlist *state_hook;
93
94   unsigned long tick;
95 } MInputContextInfo;
96
97 #define MINPUT_KEY_SHIFT_MODIFIER       (1 << 0)
98 #define MINPUT_KEY_CONTROL_MODIFIER     (1 << 1)
99 #define MINPUT_KEY_META_MODIFIER        (1 << 2)
100 #define MINPUT_KEY_ALT_MODIFIER         (1 << 3)
101 #define MINPUT_KEY_SUPER_MODIFIER       (1 << 4)
102 #define MINPUT_KEY_HYPER_MODIFIER       (1 << 5)
103
104 extern MSymbol minput__char_to_key (int c);
105
106 #endif /* not _M17N_INPUT_H_ */