1 /* vim:set et ts=4 sts=4:
3 * ibus-pinyin - The Chinese PinYin engine for IBus
5 * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program 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
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __PY_EXT_EDITOR_
22 #define __PY_EXT_EDITOR_
26 typedef struct _IBusEnginePlugin IBusEnginePlugin;
27 typedef struct _lua_command_candidate_t lua_command_candidate_t;
32 class ExtEditor : public Editor {
34 ExtEditor (PinyinProperties & props, Config & config);
36 virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
37 virtual void pageUp (void);
38 virtual void pageDown (void);
39 virtual void cursorUp (void);
40 virtual void cursorDown (void);
41 virtual void update (void);
42 virtual void reset (void);
43 virtual void candidateClicked (guint index, guint button, guint state);
45 int loadLuaScript (std::string filename);
46 void resetLuaState (void);
49 bool updateStateFromInput (void);
51 /* Fill lookup table, and update preedit string. */
52 bool fillCommandCandidates (void);
53 bool fillCommandCandidates (std::string prefix);
54 bool fillCommand (std::string command_name, const char * argument);
56 bool fillChineseNumber(gint64 num);
58 /* Auxiliary functions for lookup table */
59 void clearLookupTable (void);
60 void updateLookupTable (void);
61 gboolean selectCandidateInPage (guint index);
62 gboolean selectCandidate (guint index);
64 void updatePreeditText (void);
65 void updateAuxiliaryText (void);
67 gboolean processEditKey (guint keyval);
68 gboolean processPageKey (guint keyval);
69 gboolean processLabelKey (guint keyval);
71 gboolean processSpace (guint keyval);
72 gboolean processEnter (guint keyval);
74 gboolean removeCharBefore (void);
75 gboolean removeCharAfter (void);
88 Pointer<IBusEnginePlugin> m_lua_plugin;
90 std::string m_preedit_text;
91 std::string m_auxiliary_text;
93 LookupTable m_lookup_table;
95 //saved lua extension call results.
97 const lua_command_candidate_t * m_candidate;
98 GArray * m_candidates;
100 const static int m_aux_text_len = 50;