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.
26 Editor::Editor (PinyinProperties & props, Config & config)
34 Editor::~Editor (void)
39 Editor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
41 modifiers &= (IBUS_CONTROL_MASK |
46 /* ignore key events with some masks */
50 if (keyval >= IBUS_exclam && keyval <= IBUS_asciitilde) {
52 m_text.insert (m_cursor++, keyval);
65 m_text.erase (--m_cursor, 1);
71 if (m_cursor < m_text.length ()) {
72 m_text.erase (m_cursor, 1);
87 if (m_cursor < m_text.length ()) {
96 StaticText text (m_text);
112 gboolean need_update = (m_cursor != 0 || !m_text.empty ());
120 Editor::pageUp (void)
125 Editor::pageDown (void)
130 Editor::cursorUp (void)
135 Editor::cursorDown (void)
140 Editor::candidateClicked (guint index, guint button, guint state)
145 Editor::update (void)
148 StaticText text (m_text);
149 text.appendAttribute (IBUS_ATTR_TYPE_UNDERLINE, IBUS_ATTR_UNDERLINE_SINGLE, 0, -1);
150 updatePreeditText (text, m_cursor, TRUE);