PyObject * Evas_Textblock_Cursor_PyObject__copy(Evas_Textblock_Cursor_PyObject *self, PyObject * args) { Evas_Textblock_Cursor *new_cursor; BENCH_START new_cursor = evas_object_textblock_cursor_new(self->textblock->object); evas_textblock_cursor_copy(self->cursor, new_cursor); BENCH_END return (PyObject *)wrap_evas_textblock_cursor(new_cursor, self->textblock); }
static void _undo_do(Edi_Editor *editor, Elm_Entry_Change_Info *inf) { if (inf->insert) { const Evas_Object *tb = elm_entry_textblock_get(editor->entry); Evas_Textblock_Cursor *mcur, *end; mcur = (Evas_Textblock_Cursor *) evas_object_textblock_cursor_get(tb); end = evas_object_textblock_cursor_new(tb); if (inf->insert) { elm_entry_cursor_pos_set(editor->entry, inf->change.insert.pos); evas_textblock_cursor_pos_set(end, inf->change.insert.pos + inf->change.insert.plain_length); } else { elm_entry_cursor_pos_set(editor->entry, inf->change.del.start); evas_textblock_cursor_pos_set(end, inf->change.del.end); } evas_textblock_cursor_range_delete(mcur, end); evas_textblock_cursor_free(end); elm_entry_calc_force(editor->entry); } else { if (inf->insert) { elm_entry_cursor_pos_set(editor->entry, inf->change.insert.pos); elm_entry_entry_insert(editor->entry, inf->change.insert.content); } else { size_t start; start = (inf->change.del.start < inf->change.del.end) ? inf->change.del.start : inf->change.del.end; elm_entry_cursor_pos_set(editor->entry, start); elm_entry_entry_insert(editor->entry, inf->change.insert.content); elm_entry_cursor_pos_set(editor->entry, inf->change.del.end); } } }
PyObject * Evas_Textblock_Cursor_PyObject__new(PyTypeObject *type, PyObject * args, PyObject * kwargs) { Evas_Textblock_Cursor_PyObject *self; Evas_Object_PyObject *textblock = NULL; if (args != NULL && !PyArg_ParseTuple(args, "O!", &Evas_Object_PyObject_Type, &textblock)) return NULL; self = (Evas_Textblock_Cursor_PyObject *)type->tp_alloc(type, 0); if (textblock) { BENCH_START self->cursor = evas_object_textblock_cursor_new(textblock->object); BENCH_END self->textblock = textblock; Py_INCREF(textblock); } printf("Textblock Cursor alloc: %p\n", self->cursor); return (PyObject *)self; }
static Eina_Bool _find_in_entry(Evas_Object *entry, const char *text, Eina_Bool jump_next) { Eina_Bool try_next = EINA_FALSE; const char *found; char *utf8; const Evas_Object *tb = elm_entry_textblock_get(entry); Evas_Textblock_Cursor *end, *start, *mcur; size_t initial_pos; if (!text || !*text) return EINA_FALSE; mcur = (Evas_Textblock_Cursor *) evas_object_textblock_cursor_get(tb); if (!cur_find) { cur_find = evas_object_textblock_cursor_new(tb); } else if (!evas_textblock_cursor_compare(cur_find, mcur)) { try_next = EINA_TRUE; } if (forward) { evas_textblock_cursor_paragraph_last(cur_find); start = mcur; end = cur_find; } else { /* Not correct, more adjustments needed. */ evas_textblock_cursor_paragraph_first(cur_find); start = cur_find; end = mcur; } initial_pos = evas_textblock_cursor_pos_get(start); utf8 = evas_textblock_cursor_range_text_get(start, end, EVAS_TEXTBLOCK_TEXT_PLAIN); if (!utf8) return EINA_FALSE; if (try_next && jump_next) { found = strstr(utf8 + 1, text); if (!found) { found = utf8; } } else { found = strstr(utf8, text); } if (found) { size_t pos = 0; int idx = 0; while ((utf8 + idx) < found) { pos++; eina_unicode_utf8_get_next(utf8, &idx); } elm_entry_select_none(entry); evas_textblock_cursor_pos_set(mcur, pos + initial_pos + strlen(text)); elm_entry_cursor_selection_begin(entry); elm_entry_cursor_pos_set(entry, pos + initial_pos); elm_entry_cursor_selection_end(entry); evas_textblock_cursor_copy(mcur, cur_find); } free(utf8); return !!found; }