Beispiel #1
0
static void
ibus_m17n_engine_reset (IBusEngine *engine)
{
    IBusM17NEngine *m17n = (IBusM17NEngine *) engine;

    parent_class->reset (engine);

    minput_reset_ic (m17n->context);
}
Beispiel #2
0
void
nimf_m17n_reset (NimfEngine    *engine,
                 NimfServiceIC *target)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  NimfM17n *m17n = NIMF_M17N (engine);

  g_return_if_fail (m17n->im != NULL);

  nimf_candidatable_hide (m17n->candidatable);
  minput_filter (m17n->ic, Mnil, NULL);
  nimf_m17n_update_preedit (engine, target, g_strdup (""));
  minput_reset_ic (m17n->ic);
}
Beispiel #3
0
static void
on_changed_method (GSettings *settings,
                   gchar     *key,
                   NimfM17n  *m17n)
{
  g_debug (G_STRLOC ": %s", G_STRFUNC);

  g_free (m17n->method);
  m17n->method = g_settings_get_string (settings, key);

  if (m17n->ic)
    minput_reset_ic (m17n->ic);

  nimf_m17n_close_im (m17n);
  nimf_m17n_open_im  (m17n);
}
Beispiel #4
0
static gchar *
transliterator_m17n_real_transliterate (TranslitTransliterator *self,
                                        const gchar            *input,
                                        guint                  *endpos,
                                        GError                **error)
{
  TransliteratorM17n *m17n = TRANSLITERATOR_M17N (self);
  const gchar *p;
  GString *string;
  gchar *output;
  gint n_filtered = 0;

  string = g_string_sized_new (strlen (input));
  minput_reset_ic (m17n->ic);
  for (p = input; ; p = g_utf8_next_char (p))
    {
      gunichar uc = g_utf8_get_char (p);
      MSymbol symbol;
      gint retval;

      if (*p == '\0')
	symbol = Mnil;
      else
	{
	  gint length;
	  gchar *utf8;

	  length = g_unichar_to_utf8 (uc, NULL);
	  utf8 = g_slice_alloc0 (length + 1);
	  g_unichar_to_utf8 (uc, utf8);
	  symbol = msymbol (utf8);
	  g_slice_free1 (length, utf8);
	}

      retval = minput_filter (m17n->ic, symbol, NULL);
      if (retval == 0)
	{
	  MText *mt = mtext ();

	  retval = minput_lookup (m17n->ic, symbol, NULL, mt);

	  if (mtext_len (mt) > 0) {
	    output = mtext_to_utf8 (mt);
	    g_string_append (string, output);
	    g_free (output);
	  }

	  if (retval)
	    g_string_append_unichar (string, uc);

	  m17n_object_unref (mt);
	  n_filtered = 0;
	}
      else
	n_filtered++;

      if (symbol == Mnil)
	break;
    }

  if (endpos)
    *endpos = g_utf8_strlen (input, -1) - n_filtered;

  return g_string_free (string, FALSE);
}