Commit 0576f609 authored by Hiroshi Sumita's avatar Hiroshi Sumita
Browse files

Implements InputContext::Observer::updateInputText and updateCursor

BUG=None
TEST=Manual

Review URL: https://codereview.appspot.com/6298043
parent ad58ca3f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ m4_define([pyzy_released], [1])

m4_define([pyzy_major_version], [0])
m4_define([pyzy_minor_version], [0])
m4_define([pyzy_micro_version], [6])
m4_define([pyzy_micro_version], [7])
m4_define([pyzy_interface_age], [0])
m4_define([pyzy_binary_age],
          [m4_eval(100 * pyzy_minor_version + pyzy_micro_version)])
+16 −2
Original line number Diff line number Diff line
@@ -62,6 +62,8 @@ BopomofoContext::insert (char ch)
        return true;

    m_text.insert (m_cursor++, ch);
    updateInputText ();
    updateCursor ();

    if (G_UNLIKELY (!(m_config.option & PINYIN_INCOMPLETE_PINYIN))) {
        updateSpecialPhrases ();
@@ -80,6 +82,7 @@ BopomofoContext::insert (char ch)
            updateAuxiliaryText ();
        }
    }

    return true;
}

@@ -91,7 +94,8 @@ BopomofoContext::removeCharBefore (void)

    m_cursor --;
    m_text.erase (m_cursor, 1);

    updateInputText ();
    updateCursor ();
    updateSpecialPhrases ();
    updatePinyin ();

@@ -105,6 +109,7 @@ BopomofoContext::removeCharAfter (void)
        return false;

    m_text.erase (m_cursor, 1);
    updateInputText ();
    updatePreeditText ();
    updateAuxiliaryText ();

@@ -131,6 +136,8 @@ BopomofoContext::removeWordBefore (void)

    m_text.erase (cursor, m_cursor - cursor);
    m_cursor = cursor;
    updateInputText ();
    updateCursor ();
    updateSpecialPhrases ();
    updatePhraseEditor ();
    update ();
@@ -144,6 +151,7 @@ BopomofoContext::removeWordAfter (void)
        return false;

    m_text.erase (m_cursor, -1);
    updateInputText ();
    updatePreeditText ();
    updateAuxiliaryText ();
    return true;
@@ -156,6 +164,7 @@ BopomofoContext::moveCursorLeft (void)
        return false;

    m_cursor --;
    updateCursor ();
    updateSpecialPhrases ();
    updatePinyin ();

@@ -169,7 +178,7 @@ BopomofoContext::moveCursorRight (void)
        return false;

    m_cursor ++;

    updateCursor ();
    updateSpecialPhrases ();
    updatePinyin ();

@@ -192,6 +201,7 @@ BopomofoContext::moveCursorLeftByWord (void)
    m_pinyin_len -= p.len;
    m_pinyin.pop_back ();

    updateCursor ();
    updateSpecialPhrases ();
    updatePhraseEditor ();
    update ();
@@ -215,6 +225,7 @@ BopomofoContext::moveCursorToBegin (void)
    m_pinyin.clear ();
    m_pinyin_len = 0;

    updateCursor ();
    updateSpecialPhrases ();
    updatePhraseEditor ();
    update ();
@@ -229,6 +240,7 @@ BopomofoContext::moveCursorToEnd (void)
        return false;

    m_cursor = m_text.length ();
    updateCursor ();
    updateSpecialPhrases ();
    updatePinyin ();

@@ -345,6 +357,8 @@ BopomofoContext::commit (CommitType type)
    }

    resetContext ();
    updateInputText ();
    updateCursor ();
    update ();
    PhoneticContext::commitText (m_buffer);
}
+21 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ DoublePinyinContext::insert (char ch)
            return false;
        }
        else {
            updateInputText ();
            updateCursor ();
            if (updateSpecialPhrases ()) {
                update ();
            }
@@ -92,6 +94,8 @@ DoublePinyinContext::insert (char ch)
        }
    }
    else {
        updateInputText ();
        updateCursor ();
        updateSpecialPhrases ();
        updatePhraseEditor ();
        update ();
@@ -107,6 +111,8 @@ DoublePinyinContext::removeCharBefore (void)

    m_cursor --;
    m_text.erase (m_cursor, 1);
    updateInputText ();
    updateCursor ();

    if (updatePinyin (false)) {
        updateSpecialPhrases ();
@@ -132,6 +138,8 @@ DoublePinyinContext::removeCharAfter (void)
        return false;

    m_text.erase (m_cursor, 1);
    updateInputText ();

    if (updateSpecialPhrases ()) {
        update ();
    }
@@ -151,6 +159,8 @@ DoublePinyinContext::removeWordBefore (void)
    if (G_UNLIKELY (m_cursor > m_pinyin_len)) {
        m_text.erase (m_pinyin_len, m_cursor - m_pinyin_len);
        m_cursor = m_pinyin_len;
        updateInputText ();
        updateCursor ();
        if (updateSpecialPhrases ()) {
            update ();
        }
@@ -164,6 +174,8 @@ DoublePinyinContext::removeWordBefore (void)
        m_pinyin.pop_back ();
        m_text.erase (m_pinyin_len, m_cursor - m_pinyin_len);
        m_cursor = m_pinyin_len;
        updateInputText ();
        updateCursor ();
        updateSpecialPhrases ();
        updatePhraseEditor ();
        update ();
@@ -179,6 +191,8 @@ DoublePinyinContext::removeWordAfter (void)
        return false;

    m_text.erase (m_cursor);
    updateInputText ();

    if (updateSpecialPhrases ()) {
        update ();
    }
@@ -196,6 +210,7 @@ DoublePinyinContext::moveCursorLeft (void)
        return false;

    m_cursor --;
    updateCursor ();

    if (m_cursor >= m_pinyin_len) {
        if (updateSpecialPhrases ()) {
@@ -233,6 +248,7 @@ DoublePinyinContext::moveCursorRight (void)
        return false;

    m_cursor ++;
    updateCursor ();
    if (updatePinyin (false)) {
        updateSpecialPhrases ();
        updatePhraseEditor ();
@@ -258,6 +274,7 @@ DoublePinyinContext::moveCursorLeftByWord (void)

    if (G_UNLIKELY (m_cursor > m_pinyin_len)) {
        m_cursor = m_pinyin_len;
        updateCursor ();
        if (updateSpecialPhrases ()) {
            update ();
        }
@@ -269,6 +286,7 @@ DoublePinyinContext::moveCursorLeftByWord (void)
    else {
        m_cursor = m_pinyin_len = m_pinyin.back ().begin;
        m_pinyin.pop_back ();
        updateCursor ();
        updateSpecialPhrases ();
        updatePhraseEditor ();
        update ();
@@ -292,6 +310,7 @@ DoublePinyinContext::moveCursorToBegin (void)
    m_cursor = 0;
    m_pinyin.clear ();
    m_pinyin_len = 0;
    updateCursor ();
    updateSpecialPhrases ();
    updatePhraseEditor ();
    update ();
@@ -306,6 +325,8 @@ DoublePinyinContext::moveCursorToEnd (void)
        return false;

    m_cursor = m_text.length ();
    updateCursor ();

    if (updatePinyin (false)) {
        updateSpecialPhrases ();
        updatePhraseEditor ();
+13 −1
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ FullPinyinContext::insert (char ch)
        return true;

    m_text.insert (m_cursor++, ch);
    updateInputText ();
    updateCursor ();

    if (G_UNLIKELY (!(m_config.option & PINYIN_INCOMPLETE_PINYIN))) {
        updateSpecialPhrases ();
@@ -78,7 +80,8 @@ FullPinyinContext::removeCharBefore (void)

    m_cursor --;
    m_text.erase (m_cursor, 1);

    updateInputText ();
    updateCursor ();
    updateSpecialPhrases ();
    updatePinyin ();

@@ -92,6 +95,7 @@ FullPinyinContext::removeCharAfter (void)
        return false;

    m_text.erase (m_cursor, 1);
    updateInputText ();
    updatePreeditText ();
    updateAuxiliaryText ();

@@ -118,6 +122,8 @@ FullPinyinContext::removeWordBefore (void)

    m_text.erase (cursor, m_cursor - cursor);
    m_cursor = cursor;
    updateInputText ();
    updateCursor ();
    updateSpecialPhrases ();
    updatePhraseEditor ();
    update ();
@@ -131,6 +137,7 @@ FullPinyinContext::removeWordAfter (void)
        return false;

    m_text.erase (m_cursor, -1);
    updateInputText ();
    updatePreeditText ();
    updateAuxiliaryText ();
    return true;
@@ -143,6 +150,7 @@ FullPinyinContext::moveCursorLeft (void)
        return false;

    m_cursor --;
    updateCursor ();
    updateSpecialPhrases ();
    updatePinyin ();

@@ -156,6 +164,7 @@ FullPinyinContext::moveCursorRight (void)
        return false;

    m_cursor ++;
    updateCursor ();
    updateSpecialPhrases ();
    updatePinyin ();

@@ -178,6 +187,7 @@ FullPinyinContext::moveCursorLeftByWord (void)
    m_pinyin_len -= p.len;
    m_pinyin.pop_back ();

    updateCursor ();
    updateSpecialPhrases ();
    updatePhraseEditor ();
    update ();
@@ -200,6 +210,7 @@ FullPinyinContext::moveCursorToBegin (void)
    m_pinyin.clear ();
    m_pinyin_len = 0;

    updateCursor ();
    updateSpecialPhrases ();
    updatePhraseEditor ();
    update ();
@@ -213,6 +224,7 @@ FullPinyinContext::moveCursorToEnd (void)
        return false;

    m_cursor = m_text.length ();
    updateCursor ();
    updateSpecialPhrases ();
    updatePinyin ();

+18 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public:
    public:
        virtual ~Observer () { }


        /**
         * \brief Notifies a commit text.
         * @param context InputContext instance which triggered this method.
@@ -100,6 +101,23 @@ public:
        virtual void commitText (const InputContext * context,
                                 const std::string &commit_text) = 0;

        /**
         * \brief Notifies input text is changed.
         * @param context InputContext instance which triggered this method.
         *
         * This method is triggered by InputContext when input text is
         * changed.
         */
        virtual void inputTextChanged (const InputContext * context) = 0;

        /**
         * \brief Notifies cursor is changed.
         * @param context InputContext instance which triggered this method.
         *
         * This method is triggered by InputContext when cursor is changed.
         */
        virtual void cursorChanged (const InputContext * context) = 0;

        /**
         * \brief Notifies preedit text is changed.
         * @param context InputContext instance which triggered this method.
Loading