Example #1
0
 bool pop()
 {
     if (level_==0) {
         return true;
     }
     prefix_ = prefix_.substr(0,prefix_.length()-1);
     level_--;
     update_candidates();
     return false;
 }
Example #2
0
 bool push_button(int key) {
     crtrace trace("selector::push(): ");
     lString8 old_prefix = prefix_;
     prefix_.append(1,static_cast<char>(key));
     if(update_candidates()) {
         level_++;
         return true;
     }
     prefix_ = old_prefix;
     return false;
 }
Example #3
0
    selector(LVDocView& docview, const TEncoding& encoding) :
        words_(docview, encoding),
        current_(0),
        level_(0),
        candidates_(),
        prefix_(),
        repeat_(0)
    {
//            init_keytable(keytable_);
        update_candidates();
    };
void
HangulInstance::select_candidate (unsigned int index)
{
    SCIM_DEBUG_IMENGINE(2) << "select_candidate.\n";

    if ((int)index >= m_lookup_table.get_current_page_size ())
	return;

    WideString candidate = m_lookup_table.get_candidate_in_current_page(index);

    WideString commit_str = candidate;
    WideString preedit = get_preedit_string();
    if (is_hanja_mode() || m_factory->m_commit_by_word) {
	// prefix method
	int len = m_surrounding_text.length();
	if (len > 0)
	    delete_surrounding_text(-len, len);
	if (candidate.length() <= m_surrounding_text.length()) {
	    len = m_surrounding_text.length() - candidate.length();
	    commit_str.append(m_surrounding_text, candidate.length(), len);
	    m_surrounding_text.erase(0, candidate.length());
	} else if (candidate.length() <= m_surrounding_text.length() + preedit.length()) {
	    len = candidate.length() - m_surrounding_text.length();
	    if (len > (int)m_preedit.length()) {
		m_preedit.clear();
		hangul_ic_reset(m_hic);
	    } else {
		m_preedit.erase(0, len);
	    }
	    m_surrounding_text.clear();
	} else {
	    m_preedit.clear();
	    hangul_ic_reset(m_hic);
	    m_surrounding_text.clear();
	}
    } else {
	// suffix method
	if (candidate.length() > preedit.length()) {
	    int len = candidate.length() - preedit.length();
	    delete_surrounding_text(-len, len);
	}
	hangul_ic_reset(m_hic);
	m_surrounding_text.clear();
    }

    commit_string(commit_str);
    hangul_update_preedit_string ();

    if (is_hanja_mode()) {
	update_candidates();
    } else {
	delete_candidates();
    }
}
Example #5
0
void
empathy_call_handler_bus_message (EmpathyCallHandler *handler,
  GstBus *bus, GstMessage *message)
{
  EmpathyCallHandlerPriv *priv = GET_PRIV (handler);
  const GstStructure *s = gst_message_get_structure (message);

  if (priv->tfchannel == NULL)
    return;

  if (s != NULL &&
      gst_structure_has_name (s, "farsight-send-codec-changed"))
    {
      const GValue *val;
      FsCodec *codec;
      FsSession *session;

      DEBUG ("farsight-send-codec-changed");

      val = gst_structure_get_value (s, "codec");
      codec = g_value_get_boxed (val);

      val = gst_structure_get_value (s, "session");
      session = g_value_get_object (val);

      update_sending_codec (handler, codec, session);
    }
  else if (s != NULL &&
      gst_structure_has_name (s, "farsight-recv-codecs-changed"))
    {
      const GValue *val;
      GList *codecs;
      FsStream *stream;

      DEBUG ("farsight-recv-codecs-changed");

      val = gst_structure_get_value (s, "codecs");
      codecs = g_value_get_boxed (val);

      val = gst_structure_get_value (s, "stream");
      stream = g_value_get_object (val);

      update_receiving_codec (handler, codecs, stream);
    }
  else if (s != NULL &&
      gst_structure_has_name (s, "farsight-new-active-candidate-pair"))
    {
      const GValue *val;
      FsCandidate *remote_candidate, *local_candidate;
      FsStream *stream;

      DEBUG ("farsight-new-active-candidate-pair");

      val = gst_structure_get_value (s, "remote-candidate");
      remote_candidate = g_value_get_boxed (val);

      val = gst_structure_get_value (s, "local-candidate");
      local_candidate = g_value_get_boxed (val);

      val = gst_structure_get_value (s, "stream");
      stream = g_value_get_object (val);

      update_candidates (handler, remote_candidate, local_candidate, stream);
    }

  tf_channel_bus_message (priv->tfchannel, message);
}
bool
HangulInstance::process_key_event (const KeyEvent& rawkey)
{
    SCIM_DEBUG_IMENGINE(1) << "process_key_event.\n";

    KeyEvent key = rawkey.map_to_layout(SCIM_KEYBOARD_Default);

    m_prev_key = key;

    if (use_ascii_mode() && !is_hangul_mode()) {
	if (is_hangul_key(key)) {
	    toggle_hangul_mode();
	    return true;
	}

	return false;
    }

    /* ignore key release. */
    if (key.is_key_release ())
        return false;

    /* mode change */
    if (use_ascii_mode() && is_hangul_key(key)) {
	toggle_hangul_mode();
	return true;
    }

    /* hanja mode */
    if (is_hanja_mode_key (key)) {
	toggle_hanja_mode();
    }

    /* toggle candidate table */
    if (is_hanja_key (key)) {
	if (is_hanja_mode()) {
	    update_candidates ();
	} else {
	    if (m_lookup_table.number_of_candidates ())
		delete_candidates ();
	    else
		update_candidates ();
	}

        return true;
    }

    /* ignore shift keys */
    if (key.code == SCIM_KEY_Shift_L || key.code == SCIM_KEY_Shift_R)
        return false;

    /* flush on modifier-on keys */
    if (key.is_control_down() || key.is_alt_down()) {
	flush ();
        return false;
    }

    /* candidate keys */
    if (m_lookup_table.number_of_candidates ()) {
        if (candidate_key_event(key))
	    return true;
    }

    /* change to ascii mode on ESCAPE key, for vi users.
     * We should process this key after processing candidate keys,
     * or input mode will be changed to non-hangul mode when the user presses
     * escape key to close candidate window. */
    if (use_ascii_mode() && !is_hanja_mode()) {
	if (key.code == SCIM_KEY_Escape) {
	    toggle_hangul_mode();
	}
    }

    /* backspace */
    if (is_backspace_key(key)) {
        bool ret = hangul_ic_backspace(m_hic);
        if (ret) {
	    hangul_update_preedit_string ();
	} else if (m_preedit.length() > 0) {
	    ret = true;
	    m_preedit.erase(m_preedit.length() - 1, 1);
	    hangul_update_preedit_string();
	} else {
	    if (m_surrounding_text.length() > 0) {
		m_surrounding_text.erase(m_surrounding_text.length() - 1, 1);
		if (m_surrounding_text.empty()) {
		    delete_candidates();
		    return ret;
		}
	    }
	}

	if (is_hanja_mode() && m_lookup_table.number_of_candidates()) {
	    update_candidates();
	}

        return ret;
    }

    if (key.code >= SCIM_KEY_exclam && key.code <= SCIM_KEY_asciitilde) {
	/* main hangul composing process */
	int ascii = key.get_ascii_code();
	if (key.is_caps_lock_down()) {
	    if (isupper(ascii))
		ascii = tolower(ascii);
	    else if (islower(ascii))
		ascii = toupper(ascii);
	}

	bool ret = hangul_ic_process(m_hic, ascii);

	WideString wstr;
	wstr = get_commit_string ();
	if (wstr.length ()) {
	    /* Before commit, we set preedit string to null to work arround
	     * some buggy IM implementation, ex) Qt, Evolution */
	    hide_preedit_string ();
	    if (is_hanja_mode() || m_factory->m_commit_by_word) {
		m_preedit += wstr;
	    } else {
		commit_string(wstr);
	    }
	}

	if (is_hanja_mode() || m_factory->m_commit_by_word) {
	    if (hangul_ic_is_empty(m_hic)) {
		flush();
	    }
	}

	hangul_update_preedit_string ();

	if (is_hanja_mode()) {
	    update_candidates();
	}

	return ret;
    }

    flush();
    return false;
}