Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
/**
 * Selects the word at the provided character index
 */
EAPI void
e_editable_select_word(Evas_Object *editable, int index)
{
   E_Editable_Smart_Data *sd;
   int spos = 0, epos = -1, i = 0, pos = 0;

   if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERRNR();
   if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
     return;
   if ((index < 0) || (index >= sd->unicode_length)) return;

   while (i < sd->char_length)
     {
	if (sd->text[i] == ' ')
	  {
	     if (pos < index) spos = pos + 1;
	     else if (pos > index)
	       {
		  epos = pos;
		  break;
	       }
	  }
	i = evas_string_char_next_get(sd->text, i, NULL);
	pos++;
     }
   if (epos == -1) epos = pos;
   e_editable_selection_pos_set(editable, spos);
   e_editable_cursor_pos_set(editable, epos);
}
Ejemplo n.º 3
0
/**
 * Moves the selection bound to the start of the editable object
 *
 * @param editable an editable object
 */
EAPI void
e_editable_selection_move_to_start(Evas_Object *editable)
{
   if (!editable)
     return;
   e_editable_selection_pos_set(editable, 0);
}
Ejemplo n.º 4
0
/**
 * Moves the selection bound to the start of the editable object
 *
 * @param editable an editable object
 */
EAPI void
e_editable_selection_move_to_start(Evas_Object *editable)
{
   if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERRNR();
   if (!editable)
     return;
   e_editable_selection_pos_set(editable, 0);
}
Ejemplo n.º 5
0
/**
 * Unselects all the text of the editable object. The selection bound will be
 * moved to the cursor position
 *
 * @param editable an editable object
 */
EAPI void
e_editable_unselect_all(Evas_Object *editable)
{
   E_Editable_Smart_Data *sd;

   if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
     return;
   e_editable_selection_pos_set(editable, sd->cursor_pos);
}
Ejemplo n.º 6
0
/**
 * Moves the selection bound forward by one character offset
 *
 * @param editable an editable object
 */
EAPI void
e_editable_selection_move_right(Evas_Object *editable)
{
   E_Editable_Smart_Data *sd;

   if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
     return;
   e_editable_selection_pos_set(editable, sd->selection_pos + 1);
}
Ejemplo n.º 7
0
/**
 * Moves the selection bound to the end of the editable object
 *
 * @param editable an editable object
 */
EAPI void
e_editable_selection_move_to_end(Evas_Object *editable)
{
   E_Editable_Smart_Data *sd;

   if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
     return;
   e_editable_selection_pos_set(editable, sd->unicode_length);
}
Ejemplo n.º 8
0
/**
 * Moves the selection bound backward by one character offset
 *
 * @param editable an editable object
 */
EAPI void
e_editable_selection_move_left(Evas_Object *editable)
{
   E_Editable_Smart_Data *sd;

   if (evas_object_smart_smart_get(editable) != _e_editable_smart) SMARTERRNR();
   if ((!editable) || (!(sd = evas_object_smart_data_get(editable))))
     return;
   e_editable_selection_pos_set(editable, sd->selection_pos - 1);
}
Ejemplo n.º 9
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;
}