All pastes #84013 Raw Edit

layout_with_preedit

public c v1 · immutable
·published 2006-07-10 12:09 UTC
rendered paste body
static PangoLayout *layout_with_preedit (ECellTextView *text_view, int row, const char *text, gint width){	CellEdit *edit = text_view->edit;	PangoAttrList *attrs ;	PangoLayout *layout;	GString *tmp_string = g_string_new (NULL);	PangoAttrList *preedit_attrs = NULL;	gchar *preedit_string = NULL;	gint preedit_length = 0;	gint text_length = strlen (text);	gint cpos = 0;		layout = edit->layout;	g_string_prepend_len (tmp_string, text, text_length);		gtk_im_context_get_preedit_string (edit->im_context, &preedit_string,&preedit_attrs, NULL);			if(preedit_string && g_utf8_validate(preedit_string, -1, NULL))		edit->preedit_length = preedit_length = strlen (preedit_string);	else		edit->preedit_length = preedit_length = 0;		cpos = g_utf8_offset_to_pointer(text, edit->selection_start) - text;		if(preedit_length)		g_string_insert(tmp_string, cpos, preedit_string);	pango_layout_set_text (layout, tmp_string->str, tmp_string->len);	attrs = (PangoAttrList *) build_attr_list (text_view, row, text_length);		if (preedit_length)		pango_attr_list_splice (attrs, preedit_attrs, cpos, preedit_length);	pango_layout_set_attributes (layout, attrs);		if(tmp_string)		g_string_free (tmp_string, TRUE);	if (preedit_string)		g_free (preedit_string);	if (preedit_attrs)		pango_attr_list_unref (preedit_attrs);	pango_attr_list_unref (attrs);		update_im_cursor_location (text_view);		return layout;}