当前位置: 首页>>代码示例>>C++>>正文


C++ WideString::compare方法代码示例

本文整理汇总了C++中WideString::compare方法的典型用法代码示例。如果您正苦于以下问题:C++ WideString::compare方法的具体用法?C++ WideString::compare怎么用?C++ WideString::compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WideString的用法示例。


在下文中一共展示了WideString::compare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void
ArrayInstance::space_key_press()
{
    // space is the page down key when keying symbols and phrases
    if (m_lookup_table.number_of_candidates() > m_lookup_table.get_page_size())
    {
        lookup_table_page_down();
        return;
    }

    WideString inkey = m_preedit_string;
    
    // If the user is already press the space before, 
    // commit the first candidate in the lookup table
    if (commit_press_count == 1)
    {
        WideString str = m_lookup_table.get_candidate_in_current_page (0);
        if (str.compare(utf8_mbstowcs(SCIM_ARRAY_EMPTY_CHAR)) == 0) {
            hide_lookup_table();
            return;
        }
        if (str.length()) {
            send_commit_string(inkey, str);
            return;
        }
    }

    create_lookup_table(_ScimArray::Array_Table);
    update_lookup_table(m_lookup_table);
    if (m_lookup_table.number_of_candidates() > 1)
    {
        show_lookup_table();
        commit_press_count++;
        return;
    }
    hide_lookup_table();
    WideString str = m_lookup_table.get_candidate_in_current_page (0);
    if (str.length() && str.compare(utf8_mbstowcs(SCIM_ARRAY_EMPTY_CHAR))) {
        send_commit_string(inkey, str);
        return;
    }
}
开发者ID:tzhuan,项目名称:scim-array,代码行数:42,代码来源:scim_array_imengine.cpp

示例2: reset

bool
ArrayInstance::process_key_event (const KeyEvent& rawkey)
{
    KeyEvent key = rawkey.map_to_layout(SCIM_KEYBOARD_Default);

    if (key.is_key_release ()) return false;

    // English/Chinese change mode key
    if ( match_key_event(m_factory->m_ench_key, key))
    {
        trigger_property(SCIM_PROP_STATUS);
        return true;
    }

    // Full/Half width chang mode key
    if ( match_key_event(m_factory->m_full_half_key, key))
    {
        trigger_property(SCIM_PROP_LETTER);
        return true;
    }

    // if in forward mode
    if (m_forward)
    {
        if ( key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
        {
            if (m_full_width_letter)
            {
                char widthc = key.get_ascii_code();
                WideString outws;
                outws.push_back(scim_wchar_to_full_width(widthc));
                commit_string(outws);
                return true;
            }
            else
                return false;
        }
        else 
            return false;
    }

    //reset key
    if (key.code == SCIM_KEY_Escape && key.mask == 0) {
        // Do not catch ESC while no key input for VI users
        if (m_preedit_string.size() == 0)
            return false;
        reset ();
        return true;
    }

    //delete key
    if (key.code == SCIM_KEY_BackSpace && key.mask == 0 &&
        m_preedit_string.size () != 0) 
    {
        m_preedit_string.erase (m_preedit_string.length () - 1, 1);
        pre_update_preedit_string (m_preedit_string);
        process_preedit_string ();
        commit_press_count = 0;     // reset to 0 to avoid output error
        return true;
    }

    // valid keys
    if (((key.code >= SCIM_KEY_a && key.code <= SCIM_KEY_z) ||
         (key.code == SCIM_KEY_comma) || (key.code == SCIM_KEY_period) ||
         (key.code == SCIM_KEY_semicolon) || (key.code == SCIM_KEY_slash))
            &&
        (key.mask == 0))
    {
        if (m_preedit_string.length () >=  m_max_preedit_len)
            return true;
 
        if (commit_press_count == 1)
        {
            WideString str = m_lookup_table.get_candidate_in_current_page (0);
            if (str.length() && str.compare(utf8_mbstowcs(SCIM_ARRAY_EMPTY_CHAR)) != 0 ) {
                send_commit_string(m_preedit_string,
                        m_lookup_table.get_candidate_in_current_page(0));
            }
            else
                reset();
        }

        if (m_preedit_string.length () == 0)
        {
            hide_aux_string ();
            show_preedit_string ();
        }

        ucs4_t ascii = (ucs4_t) tolower (key.get_ascii_code ());
        m_preedit_string.push_back (ascii);
        pre_update_preedit_string (m_preedit_string);
        process_preedit_string ();

        return true;
    }

    // apostrophe key for end of phrases
    if (m_use_phrases && key.code == SCIM_KEY_apostrophe 
            && m_preedit_string.length())
    {
//.........这里部分代码省略.........
开发者ID:tzhuan,项目名称:scim-array,代码行数:101,代码来源:scim_array_imengine.cpp


注:本文中的WideString::compare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。