static void fallback_preedit_changed (GtkIMContext *context, gpointer data) { scim_bridge_pdebugln (4, "fallback_preedit_changed ()"); if (focused_imcontext != NULL && !focused_imcontext->enabled && context != NULL) { gchar* preedit_string = NULL; gint preedit_cursor_position = 0; PangoAttrList *preedit_attributes = NULL; gtk_im_context_get_preedit_string (context, &preedit_string, &preedit_attributes, &preedit_cursor_position); if (preedit_string != NULL) { free (focused_imcontext->preedit_string); focused_imcontext->preedit_string = preedit_string; focused_imcontext->preedit_string_capacity = strlen (preedit_string); focused_imcontext->preedit_shown = TRUE; } else { focused_imcontext->preedit_string[0] = '\0'; focused_imcontext->preedit_shown = FALSE; } focused_imcontext->preedit_cursor_position = preedit_cursor_position; if (focused_imcontext->preedit_attributes != NULL) pango_attr_list_unref (focused_imcontext->preedit_attributes); focused_imcontext->preedit_attributes = preedit_attributes; g_signal_emit_by_name (focused_imcontext, "preedit-changed"); } }
static gint check_preedit(GtkWidget *view) { gint cursor_pos; gtk_im_context_get_preedit_string( GTK_TEXT_VIEW(view)->im_context, NULL, NULL, &cursor_pos); return cursor_pos; }
static VALUE rg_preedit_string(VALUE self) { gchar* str; PangoAttrList* attrs; gint cursor_pos; gtk_im_context_get_preedit_string(_SELF(self), &str, &attrs, &cursor_pos); return rb_ary_new3(3, CSTR2RVAL(str), BOXED2RVAL(attrs, PANGO_TYPE_ATTR_LIST), INT2NUM(cursor_pos)); }
void TextInputGTK::PreEditChangedCallback( GtkIMContext *context, gpointer userData ) { gchar *str = NULL; gtk_im_context_get_preedit_string( context, &str, NULL, NULL ); if (str) { REALstring key = REALBuildString( str, strlen(str), kREALTextEncodingUTF8 ); FireSetIncompleteText( reinterpret_cast<REALcontrolInstance>(userData), key, NULL, NULL ); REALUnlockString( key ); g_free( str ); } }
static void imContextPreeditChanged(GtkIMContext* context, EditorClient* client) { Frame* frame = core(static_cast<WebKitWebView*>(client->webView()))->focusController()->focusedOrMainFrame(); if (!frame || !frame->editor()->canEdit()) return; // We ignore the provided PangoAttrList for now. GOwnPtr<gchar> newPreedit(0); gtk_im_context_get_preedit_string(context, &newPreedit.outPtr(), 0, 0); String preeditString = String::fromUTF8(newPreedit.get()); Vector<CompositionUnderline> underlines; underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false)); frame->editor()->setComposition(preeditString, underlines, 0, 0); }
static void gimp_text_tool_im_preedit_changed (GtkIMContext *context, GimpTextTool *text_tool) { if (text_tool->preedit_string) g_free (text_tool->preedit_string); gtk_im_context_get_preedit_string (context, &text_tool->preedit_string, NULL, &text_tool->preedit_cursor); if (text_tool->preedit_label) gtk_label_set_text (GTK_LABEL (text_tool->preedit_label), text_tool->preedit_string); }
void scim_bridge_client_imcontext_get_preedit_string (GtkIMContext *context, gchar **str, PangoAttrList **pango_attrs, gint *cursor_pos) { scim_bridge_pdebugln (4, "scim_bridge_client_imcontext_get_preedit_string ()"); ScimBridgeClientIMContext *imcontext = SCIM_BRIDGE_CLIENT_IMCONTEXT (context); if (imcontext->slave_preedit) { gtk_im_context_get_preedit_string (imcontext->slave, str, pango_attrs, cursor_pos); return; } if (scim_bridge_client_is_messenger_opened () && imcontext != NULL && imcontext->preedit_shown) { const size_t preedit_string_length = strlen (imcontext->preedit_string); const size_t preedit_wstring_length = g_utf8_strlen (imcontext->preedit_string, -1); if (str) { if (preedit_string_length > 0) { *str = g_strdup (imcontext->preedit_string); } else { *str = g_strdup (""); } } if (cursor_pos) { if (imcontext->preedit_cursor_position > preedit_wstring_length) { *cursor_pos = preedit_wstring_length; } else { *cursor_pos = imcontext->preedit_cursor_position; } } if (pango_attrs) { *pango_attrs = imcontext->preedit_attributes; pango_attr_list_ref (imcontext->preedit_attributes); } } else { if (str) *str = g_strdup (""); if (cursor_pos) *cursor_pos = 0; if (pango_attrs) *pango_attrs = pango_attr_list_new (); } }
void EditorClient::handleInputMethodMousePress() { Frame* targetFrame = core(m_webView)->focusController()->focusedOrMainFrame(); if (!targetFrame || !targetFrame->editor()->canEdit()) return; WebKitWebViewPrivate* priv = m_webView->priv; // When a mouse press fires, the commit signal happens during a composition. // In this case, if the focused node is changed, the commit signal happens in a diffrent node. // Therefore, we need to confirm the current compositon and ignore the next commit signal. GOwnPtr<gchar> newPreedit(0); gtk_im_context_get_preedit_string(priv->imContext.get(), &newPreedit.outPtr(), 0, 0); if (g_utf8_strlen(newPreedit.get(), -1)) { targetFrame->editor()->confirmComposition(); m_preventNextCompositionCommit = true; gtk_im_context_reset(priv->imContext.get()); } }
static void imContextPreeditChanged(GtkIMContext* context, EditorClient* client) { Frame* frame = core(client->m_webView)->focusController()->focusedOrMainFrame(); Editor* editor = frame->editor(); gchar* preedit = NULL; gint cursorPos = 0; // We ignore the provided PangoAttrList for now. gtk_im_context_get_preedit_string(context, &preedit, NULL, &cursorPos); String preeditString = String::fromUTF8(preedit); g_free(preedit); // setComposition() will replace the user selection if passed an empty // preedit. We don't want this to happen. if (preeditString.isEmpty() && !editor->hasComposition()) return; Vector<CompositionUnderline> underlines; underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false)); editor->setComposition(preeditString, underlines, cursorPos, 0); }
static void st_im_text_preedit_changed_cb (GtkIMContext *context, StIMText *imtext) { ClutterText *clutter_text = CLUTTER_TEXT (imtext); gchar *preedit_str = NULL; PangoAttrList *preedit_attrs = NULL; gint cursor_pos = 0; gtk_im_context_get_preedit_string (context, &preedit_str, &preedit_attrs, &cursor_pos); clutter_text_set_preedit_string (clutter_text, preedit_str, preedit_attrs, cursor_pos); g_free (preedit_str); pango_attr_list_unref (preedit_attrs); }
static gint im_context_preedit_callback (GtkIMContext *imcontext, gpointer user_data) { gchar *preedit_string; PangoAttrList *attrs; gint cursor_pos; gtk_im_context_get_preedit_string (imcontext, &preedit_string, &attrs, &cursor_pos); if (gc_board_get_current_board_plugin()!=NULL && gc_board_get_current_board_plugin()->key_press) { int result = gc_board_get_current_board_plugin()->key_press (0, NULL, preedit_string); g_free(preedit_string); pango_attr_list_unref (attrs); return(result); } return FALSE; }
static void fcitx_im_context_get_preedit_string(GtkIMContext *context, gchar **str, PangoAttrList **attrs, gint *cursor_pos) { FcitxLog(LOG_LEVEL, "fcitx_im_context_get_preedit_string"); FcitxIMContext *fcitxcontext = FCITX_IM_CONTEXT(context); if (fcitx_client_is_valid(fcitxcontext->client)) { if (str) { if (fcitxcontext->preedit_string) *str = strdup(fcitxcontext->preedit_string); else *str = strdup(""); } if (attrs) { if (fcitxcontext->attrlist == NULL) { *attrs = pango_attr_list_new(); if (str) { PangoAttribute *pango_attr; pango_attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE); pango_attr->start_index = 0; pango_attr->end_index = strlen(*str); pango_attr_list_insert(*attrs, pango_attr); } } else { *attrs = pango_attr_list_ref (fcitxcontext->attrlist); } } if (cursor_pos) *cursor_pos = fcitxcontext->cursor_pos; } else gtk_im_context_get_preedit_string(fcitxcontext->slave, str, attrs, cursor_pos); return ; }
void GtkInputMethodFilter::handlePreeditChanged() { if (!m_enabled) return; GUniqueOutPtr<gchar> newPreedit; gtk_im_context_get_preedit_string(m_context.get(), &newPreedit.outPtr(), 0, &m_cursorOffset); if (m_preventNextCommit) { if (strlen(newPreedit.get()) > 0) m_preventNextCommit = false; else return; } m_preedit = String::fromUTF8(newPreedit.get()); m_cursorOffset = std::min(std::max(m_cursorOffset, 0), static_cast<int>(m_preedit.length())); m_composingTextCurrently = !m_preedit.isEmpty(); m_preeditChanged = true; if (!m_filteringKeyEvent) sendCompositionAndPreeditWithFakeKeyEvents(Preedit); }
static gint key_press(guint keyval, gchar *commit_str, gchar *preedit_str) { gchar *letter; gint i; LettersItem *item; gchar *str; gunichar unichar_letter; gint retval = TRUE; if(!gcomprisBoard) return FALSE; if (keyval){ g_warning("keyval %d", keyval); return TRUE; } if (preedit_str){ g_warning("preedit_str %s", preedit_str); /* show the preedit string on bottom of the window */ GcomprisProperties *properties = gc_prop_get (); gchar *text; PangoAttrList *attrs; gint cursor_pos; gtk_im_context_get_preedit_string (properties->context, &text, &attrs, &cursor_pos); if (!preedit_text) preedit_text = \ goo_canvas_text_new (goo_canvas_get_root_item(gcomprisBoard->canvas), "", BOARDWIDTH/2, BOARDHEIGHT - 100, -1, GTK_ANCHOR_N, "font", gc_skin_font_board_huge_bold, //"fill_color_rgba", 0xba00ffff, NULL); g_object_set (preedit_text, "text", text, "attributes", attrs, NULL); return TRUE; } /* commit str */ g_warning("commit_str %s", commit_str); str = commit_str; #if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_lock (&items_lock); #else g_static_mutex_lock (&items_lock); #endif for (i=0; i < g_utf8_strlen(commit_str,-1); i++){ unichar_letter = g_utf8_get_char(str); str = g_utf8_next_char(str); if(!g_unichar_isalnum (unichar_letter)){ player_loose(); retval = FALSE; break; } letter = g_new0(gchar,6); g_unichar_to_utf8 (unichar_letter, letter); /* Force entered letter to the casing we expect * Children is to small to manage the caps lock key for now */ if (uppercase_only) { gchar *old = letter; letter = g_utf8_strup(old, -1); g_free(old); } else { gchar *old = letter; letter = g_utf8_strdown(old, -1); g_free(old); } if(item_on_focus==NULL) { for (i=0;i<items->len;i++) { item=g_ptr_array_index(items,i); g_assert (item!=NULL); if (strcmp(item->letter,letter)==0) { item_on_focus=item; break; } } } if(item_on_focus!=NULL) { if(strcmp(item_on_focus->letter, letter)==0) { gchar *tmpstr; item_on_focus->count++; g_free(item_on_focus->overword); tmpstr = g_utf8_strndup(item_on_focus->word, item_on_focus->count); /* Add the ZERO WIDTH JOINER to force joined char in Arabic and Hangul * http://en.wikipedia.org/wiki/Zero-width_joiner */ item_on_focus->overword = g_strdup_printf("%s%lc", tmpstr, 0x200D); g_free(tmpstr); g_object_set (item_on_focus->overwriteItem, "text", item_on_focus->overword, NULL); if (item_on_focus->count<g_utf8_strlen(item_on_focus->word,-1)) { g_free(item_on_focus->letter); item_on_focus->letter=g_utf8_strndup(item_on_focus->pos,1); item_on_focus->pos=g_utf8_find_next_char(item_on_focus->pos,NULL); } else { player_win(item_on_focus); item_on_focus=NULL; } } else { /* It is a loose : unselect the word and defocus */ g_free(item_on_focus->overword); item_on_focus->overword=g_strdup(" "); item_on_focus->count=0; g_free(item_on_focus->letter); item_on_focus->letter=g_utf8_strndup(item_on_focus->word,1); item_on_focus->pos=g_utf8_find_next_char(item_on_focus->word,NULL); g_object_set (item_on_focus->overwriteItem, "text", item_on_focus->overword, NULL); item_on_focus=NULL; g_free(letter); player_loose(); break; } } else { /* Anyway kid you clicked on the wrong key */ player_loose(); g_free(letter); break; } g_free(letter); } #if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_unlock (&items_lock); #else g_static_mutex_unlock (&items_lock); #endif return retval; }