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_PHONETIC_EDITOR_H_
22
#define __PY_PHONETIC_EDITOR_H_
24
#include "LookupTable.h"
26
#include "PinyinParser.h"
27
#include "PhraseEditor.h"
28
#include "SpecialPhraseTable.h"
32
class SpecialPhraseTable;
34
class PhoneticEditor : public Editor {
36
PhoneticEditor (PinyinProperties & props, Config & config);
39
/* virtual functions */
40
virtual void pageUp (void);
41
virtual void pageDown (void);
42
virtual void cursorUp (void);
43
virtual void cursorDown (void);
44
virtual void update (void);
45
virtual void reset (void);
46
virtual void candidateClicked (guint index, guint button, guint state);
47
virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
48
virtual gboolean processSpace (guint keyval, guint keycode, guint modifiers);
49
virtual gboolean processFunctionKey (guint keyval, guint keycode, guint modifiers);
50
virtual void updateLookupTable ();
51
virtual void updateLookupTableFast ();
52
virtual gboolean fillLookupTableByPage ();
56
gboolean updateSpecialPhrases ();
57
gboolean selectCandidate (guint i);
58
gboolean selectCandidateInPage (guint i);
59
gboolean resetCandidate (guint i);
60
gboolean resetCandidateInPage (guint i);
62
void commit (const gchar *str);
64
/* inline functions */
65
void updatePhraseEditor ()
67
m_phrase_editor.update (m_pinyin);
70
const gchar * textAfterPinyin () const
72
return (const gchar *)m_text + m_pinyin_len;
75
const gchar * textAfterPinyin (guint i) const
77
g_assert (i <= m_pinyin.size ());
78
if ( G_UNLIKELY (i == 0))
81
return (const gchar *)m_text + m_pinyin[i].begin + m_pinyin[i].len;
84
const gchar * textAfterCursor () const
86
return (const gchar *)m_text + m_cursor;
89
/* pure virtual functions */
90
virtual gboolean insert (gint ch) = 0;
91
virtual gboolean removeCharBefore (void) = 0;
92
virtual gboolean removeCharAfter (void) = 0;
93
virtual gboolean removeWordBefore (void) = 0;
94
virtual gboolean removeWordAfter (void) = 0;
95
virtual gboolean moveCursorLeft (void) = 0;
96
virtual gboolean moveCursorRight (void) = 0;
97
virtual gboolean moveCursorLeftByWord (void) = 0;
98
virtual gboolean moveCursorRightByWord (void) = 0;
99
virtual gboolean moveCursorToBegin (void) = 0;
100
virtual gboolean moveCursorToEnd (void) = 0;
101
virtual void commit (void) = 0;
102
virtual void updateAuxiliaryText (void) = 0;
103
virtual void updatePreeditText (void) = 0;
106
PinyinArray m_pinyin;
109
LookupTable m_lookup_table;
110
PhraseEditor m_phrase_editor;
111
std::vector<std::string> m_special_phrases;
112
std::string m_selected_special_phrase;