Exemplo n.º 1
0
void
HotkeyMatcher::add_hotkeys (const KeyEventList &keys, int id)
{
    for (KeyEventList::const_iterator it = keys.begin (); it != keys.end (); ++it) {
        if (!it->empty ())
            m_impl->m_hotkeys [*it] = id;
    }
}
Exemplo n.º 2
0
size_t
HotkeyMatcher::find_hotkeys     (int id, KeyEventList &keys) const
{
    keys.clear ();

    for (HotkeyRepository::iterator it = m_impl->m_hotkeys.begin (); it != m_impl->m_hotkeys.end (); ++it) {
        if (it->second == id) keys.push_back (it->first);
    }

    return keys.size ();
}
Exemplo n.º 3
0
size_t
HotkeyMatcher::get_all_hotkeys (KeyEventList &keys, std::vector <int> &ids) const
{
    keys.clear ();
    ids.clear ();

    for (HotkeyRepository::iterator it = m_impl->m_hotkeys.begin (); it != m_impl->m_hotkeys.end (); ++it) {
        keys.push_back (it->first);
        ids.push_back (it->second);
    }

    return keys.size ();
}
Exemplo n.º 4
0
size_t
IMEngineHotkeyMatcher::get_all_hotkeys (KeyEventList &keys, std::vector <String> &uuids) const
{
    keys.clear ();
    uuids.clear ();
    std::vector <int> ids;

    if (m_impl->m_matcher.get_all_hotkeys (keys, ids) > 0) {
        for (size_t i = 0; i < ids.size (); ++i)
            uuids.push_back (m_impl->m_uuids [ids [i]]);
    }

    return keys.size ();
}
Exemplo n.º 5
0
size_t
FrontEndHotkeyMatcher::get_all_hotkeys (KeyEventList &keys, std::vector <FrontEndHotkeyAction> &actions) const
{
    keys.clear ();
    actions.clear ();

    std::vector <int> ids;

    m_impl->m_matcher.get_all_hotkeys (keys, ids);

    for (size_t i = 0; i < ids.size (); ++i)
        actions.push_back (static_cast<FrontEndHotkeyAction> (ids [i]));

    return keys.size ();
}
Exemplo n.º 6
0
void
FrontEndHotkeyMatcher::add_hotkeys (const KeyEventList &keys, FrontEndHotkeyAction action)
{
    if (!keys.size () || action < SCIM_FRONTEND_HOTKEY_TRIGGER || action > SCIM_FRONTEND_HOTKEY_SHOW_FACTORY_MENU) return;

    m_impl->m_matcher.add_hotkeys (keys, (int) action);
}
Exemplo n.º 7
0
bool
ArrayInstance::match_key_event (const KeyEventList &keys, const KeyEvent &key) const
{
    KeyEventList::const_iterator kit; 
    
    for (kit = keys.begin (); kit != keys.end (); ++kit) {
        if (!key.is_key_release()) {
            if (key.code == kit->code) {
                int mask = key.mask;        // we should ignore capslock and numlock
                mask &= ~SCIM_KEY_CapsLockMask;
                mask &= ~SCIM_KEY_NumLockMask;
                if (mask == kit->mask)
                    return true;
            }
        }
    }
    return false;
}
Exemplo n.º 8
0
bool
match_key_event (const KeyEventList &list, const KeyEvent &key,
                 uint16 ignore_mask)
{
    KeyEventList::const_iterator kit;

    for (kit = list.begin (); kit != list.end (); kit++) {
        uint16 mod1, mod2;

        mod1 = kit->mask;
        mod2 = key.mask;
        mod1 &= ~ignore_mask;
        mod2 &= ~ignore_mask;

        if (key.code == kit->code && mod1 == mod2)
             return true;
    }
    return false;
}
Exemplo n.º 9
0
size_t
IMEngineHotkeyMatcher::find_hotkeys (const String &uuid, KeyEventList &keys) const
{
    for (size_t i = 0; i < m_impl->m_uuids.size (); ++i) {
        if (m_impl->m_uuids [i] == uuid)
            return m_impl->m_matcher.find_hotkeys ((int) i, keys);
    }

    keys.clear ();
    return 0;
}
Exemplo n.º 10
0
void
IMEngineHotkeyMatcher::add_hotkeys (const KeyEventList &keys, const String &uuid)
{
    if (!keys.size () || !uuid.length ()) return;

    size_t i;

    for (i = 0; i < m_impl->m_uuids.size (); ++i) {
        if (m_impl->m_uuids [i] == uuid)
            break;
    }

    if (i == m_impl->m_uuids.size ())
        m_impl->m_uuids.push_back (uuid);

    m_impl->m_matcher.add_hotkeys (keys, i);
}
Exemplo n.º 11
0
void ScimConsoleImpl::slot_reload_config (const ConfigPointer &config)
{
    scim_frontend_hotkey_matcher.load_hotkeys (scim_config);
    scim_imengine_hotkey_matcher.load_hotkeys (scim_config);

    panel_hotkey_matcher.clear ();
    vector<String> strings;
    KeyEventList hotkeys;

    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/Menu", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_F2));
        hotkeys.push_back (KeyEvent (SCIM_KEY_Menu));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_MENU);

    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/Cancel", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_Escape));
        hotkeys.push_back (KeyEvent (SCIM_KEY_BackSpace));
        hotkeys.push_back (KeyEvent (SCIM_KEY_Delete));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_CANCEL);

    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/OK", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_Return));
        hotkeys.push_back (KeyEvent (SCIM_KEY_space));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_OK);

    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/Previous", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_Left));
        hotkeys.push_back (KeyEvent (SCIM_KEY_Up));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_PREVIOUS);
    
    hotkeys.clear ();
    if (config->read ("/FrontEnd/Console/Hotkeys/Next", &strings)) {
        for (vector<String>::iterator i = strings.begin (); i != strings.end (); ++i) {
            const String &string = *i;
            KeyEventList keys;
            if (scim_string_to_key_list (keys, string)) {
                for (KeyEventList::iterator j = keys.begin (); j != keys.end (); ++j) {
                    KeyEvent &key = *j;
                    hotkeys.push_back (key);
                }
            }
        }
    }
    if (hotkeys.empty ()) {
        hotkeys.push_back (KeyEvent (SCIM_KEY_Right));
        hotkeys.push_back (KeyEvent (SCIM_KEY_Down));
    }
    panel_hotkey_matcher.add_hotkeys (hotkeys, PANEL_HOTKEY_NEXT);

    // Get keyboard layout setting
    // Flush the global config first, in order to load the new configs from disk.
    scim_global_config_flush ();

    scim_keyboard_layout = scim_get_default_keyboard_layout ();
}