1 /* vim:set et ts=4 sts=4:
3 * ibus-pinyin - The Chinese PinYin engine for IBus
5 * Copyright (c) 2011 Peng Wu <alexepico@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_LIB_PINYIN_BASE_EDITOR_H_
22 #define __PY_LIB_PINYIN_BASE_EDITOR_H_
25 #include "PYLookupTable.h"
31 class LibPinyinPhoneticEditor : public Editor {
33 LibPinyinPhoneticEditor (PinyinProperties & props, Config & config);
36 /* virtual functions */
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);
44 virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
45 virtual gboolean processSpace (guint keyval, guint keycode, guint modifiers);
46 virtual gboolean processFunctionKey (guint keyval, guint keycode, guint modifiers);
47 virtual void updateLookupTable ();
48 virtual void updateLookupTableFast ();
49 virtual gboolean fillLookupTableByPage ();
52 gboolean selectCandidate (guint i);
53 gboolean selectCandidateInPage (guint i);
55 void commit (const gchar *str);
56 guint getPinyinCursor (void);
57 guint getLookupCursor (void);
59 /* inline functions */
61 /* pure virtual functions */
62 virtual gboolean insert (gint ch) = 0;
63 virtual gboolean removeCharBefore (void);
64 virtual gboolean removeCharAfter (void);
65 virtual gboolean removeWordBefore (void);
66 virtual gboolean removeWordAfter (void);
67 virtual gboolean moveCursorLeft (void);
68 virtual gboolean moveCursorRight (void);
69 virtual gboolean moveCursorLeftByWord (void);
70 virtual gboolean moveCursorRightByWord (void);
71 virtual gboolean moveCursorToBegin (void);
72 virtual gboolean moveCursorToEnd (void);
73 virtual void commit (void) = 0;
74 virtual void updateAuxiliaryText (void) = 0;
75 virtual void updatePreeditText (void) = 0;
76 virtual void updatePinyin (void) = 0;
78 guint getCursorLeftByWord (void);
79 guint getCursorRightByWord (void);
84 PinyinArray m_pinyins;
87 LookupTable m_lookup_table;
90 /* use LibPinyinBackEnd here. */
91 pinyin_instance_t *m_instance;
92 TokenVector m_candidates;