Esempio n. 1
0
/* Updates the position of the cursor
 * It also updates automatically the text position and the selection */
static void
_e_editable_cursor_update(Evas_Object *editable)
{
   E_Editable_Smart_Data *sd;
   const Evas_Object *text_obj;
   Evas_Coord tx, ty;
   Evas_Coord cx, cy, ch;

   if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
     return;
   if (!(text_obj = edje_object_part_object_get(sd->text_object, "e.text.text")))
     return;

   evas_object_geometry_get(text_obj, &tx, &ty, NULL, NULL);
   _e_editable_char_geometry_get_from_pos(editable, sd->cursor_pos,
                                          &cx, &cy, NULL, &ch);

   evas_object_move(sd->cursor_object, tx + cx, ty + cy);
   evas_object_resize(sd->cursor_object, sd->cursor_width, ch);

   if (sd->cursor_visible && evas_object_visible_get(editable))
     {
        evas_object_show(sd->cursor_object);
        edje_object_signal_emit(sd->cursor_object, "e,action,show,cursor", "e");
     }

   _e_editable_selection_update(editable);
   _e_editable_text_position_update(editable, -1);
}
Esempio n. 2
0
/**
 * Deletes the text of the editable object, between position "start" and
 * position "end"
 *
 * @param editable the editable object in which the text should be deleted
 * @param start the position of the first char to delete
 * @param end the position of the last char to delete
 * @return Returns 1 if the text has been modified, 0 otherwise
 */
EAPI int
e_editable_delete(Evas_Object *editable, int start, int end)
{
   E_Editable_Smart_Data *sd;
   int unicode_length;

   if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERR(0);
   if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
     return 0;

   unicode_length = _e_editable_text_delete(editable, start, end);
   if (unicode_length <= 0) return 0;

   if (sd->cursor_pos > end)
     e_editable_cursor_pos_set(editable, sd->cursor_pos - unicode_length);
   else if (sd->cursor_pos > start)
     e_editable_cursor_pos_set(editable, start);

   if (sd->selection_pos > end)
     e_editable_selection_pos_set(editable, sd->selection_pos - unicode_length);
   else if (sd->selection_pos > start)
     e_editable_selection_pos_set(editable, start);

   _e_editable_text_position_update(editable, -1);
   return 1;
}
Esempio n. 3
0
/* Resizes the editable object */
static void
_e_editable_smart_resize(Evas_Object *object, Evas_Coord w, Evas_Coord h)
{
   E_Editable_Smart_Data *sd;

   if ((!object) || (!(sd = evas_object_smart_data_get(object))))
     return;

   evas_object_resize(sd->clip_object, w, h);
   evas_object_resize(sd->event_object, w, h);
   _e_editable_text_position_update(object, w);
}
Esempio n. 4
0
/**
 * Inserts some text at the given position in the editable object
 *
 * @param editable the editable object in which the text should be inserted
 * @param pos the position where to insert the text
 * @param text the text to insert
 * @return Returns 1 if the text has been modified, 0 otherwise
 */
EAPI int
e_editable_insert(Evas_Object *editable, int pos, const char *text)
{
   E_Editable_Smart_Data *sd;
   int unicode_length;

   if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
     return 0;

   unicode_length = _e_editable_text_insert(editable, pos, text);
   if (unicode_length <= 0) return 0;

   if (sd->cursor_pos >= pos)
     e_editable_cursor_pos_set(editable, sd->cursor_pos + unicode_length);
   if (sd->selection_pos >= pos)
     e_editable_selection_pos_set(editable, sd->selection_pos + unicode_length);

   _e_editable_text_position_update(editable, -1);
   return 1;
}