Enlightenment CVS committal
Author : dj2
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
ewl_entry.c ewl_text.c ewl_text.h
Log Message:
- API breakage. ewl_text_selection_get is now ewl_text_selection_text_get
which returns the selected text. ewl_text_selection_get will return the
selection struct itself.
- patch selections into the entry widget. the highlighting seems to be off a
bit but it will replace the selection on typeing/backspace/del etc.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_entry.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- ewl_entry.c 10 Jul 2005 23:10:51 -0000 1.22
+++ ewl_entry.c 17 Aug 2005 16:52:57 -0000 1.23
@@ -2,6 +2,8 @@
#include "ewl_debug.h"
#include "ewl_macros.h"
+static int ewl_entry_selection_clear(Ewl_Entry *e);
+
/**
* @param text: The text to set into the entry
* @return Returns a new Ewl_Widget on success or NULL on failure
@@ -232,11 +234,15 @@
ewl_entry_cursor_move_down(e);
else if (!strcmp(event->keyname, "BackSpace"))
- ewl_entry_delete_left(e);
-
+ {
+ if (!ewl_entry_selection_clear(e))
+ ewl_entry_delete_left(e);
+ }
else if (!strcmp(event->keyname, "Delete"))
- ewl_entry_delete_right(e);
-
+ {
+ if (!ewl_entry_selection_clear(e))
+ ewl_entry_delete_right(e);
+ }
else if ((!strcmp(event->keyname, "Return"))
|| (!strcmp(event->keyname, "KP_Return"))
|| (!strcmp(event->keyname, "Enter"))
@@ -250,13 +256,19 @@
IF_FREE(evd);
}
else
+ {
+ ewl_entry_selection_clear(e);
+
ewl_text_text_insert(EWL_TEXT(e), "\n",
ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor)));
+ }
}
else if ((event->keyname) && (strlen(event->keyname) == 1))
{
char *tmp;
+ ewl_entry_selection_clear(e);
+
tmp = calloc(2, sizeof(char));
snprintf(tmp, 2, "%s", event->keyname);
ewl_text_text_insert(EWL_TEXT(e), tmp,
@@ -267,6 +279,32 @@
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
+static int
+ewl_entry_selection_clear(Ewl_Entry *e)
+{
+ Ewl_Text_Trigger *sel;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR_RET("e", e, FALSE);
+
+ sel = ewl_text_selection_get(EWL_TEXT(e));
+ if (sel)
+ {
+ int len, pos;
+
+ len = ewl_text_trigger_length_get(sel);
+ pos = ewl_text_trigger_start_pos_get(sel);
+ ewl_text_cursor_position_set(EWL_TEXT(e), pos);
+ ewl_text_text_delete(EWL_TEXT(e), len);
+
+ /* remove the selection */
+ ewl_text_trigger_length_set(sel, 0);
+
+ DRETURN_INT(TRUE, DLEVEL_STABLE);
+ }
+ DRETURN_INT(FALSE, DLEVEL_STABLE);
+}
+
void
ewl_entry_cb_mouse_down(Ewl_Widget *w, void *ev, void *data)
{
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_text.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_text.c 16 Aug 2005 15:57:45 -0000 1.16
+++ ewl_text.c 17 Aug 2005 16:52:57 -0000 1.17
@@ -517,7 +517,7 @@
* @brief Gets the current text of the selection
*/
char *
-ewl_text_selection_get(Ewl_Text *t)
+ewl_text_selection_text_get(Ewl_Text *t)
{
char *ret = NULL;
@@ -541,6 +541,23 @@
}
/**
+ * @param t: The Ewl_Text to get the selection from
+ * @return Returns the selection object of this text or NULL if no current
+ * selection
+ */
+Ewl_Text_Trigger *
+ewl_text_selection_get(Ewl_Text *t)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+
+ if (ewl_text_trigger_length_get(t->selection) > 0)
+ {
+ DRETURN_PTR(t->selection, DLEVEL_STABLE);
+ }
+ DRETURN_PTR(NULL, DLEVEL_STABLE);
+}
+
+/**
* @param t: The Ewl_Text widget to set the position into
* @param pos: The position to set
* @return Returns no value.
@@ -1952,6 +1969,21 @@
t->len = len;
+ /* if the length is set to 0 remove the areas */
+ if (len == 0)
+ {
+ if (t->areas)
+ {
+ Ewl_Text_Trigger_Area *area;
+
+ ecore_list_goto_first(t->areas);
+ while ((area = ecore_list_next(t->areas)))
+ ewl_widget_hide(EWL_WIDGET(area));
+
+ ecore_list_clear(t->areas);
+ }
+ }
+
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_text.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ewl_text.h 15 Aug 2005 21:55:08 -0000 1.9
+++ ewl_text.h 17 Aug 2005 16:52:57 -0000 1.10
@@ -77,7 +77,9 @@
unsigned int idx);
void ewl_text_text_delete(Ewl_Text *t, unsigned int length);
-char *ewl_text_selection_get(Ewl_Text *t);
+char *ewl_text_selection_text_get(Ewl_Text *t);
+
+Ewl_Text_Trigger *ewl_text_selection_get(Ewl_Text *t);
void ewl_text_cursor_position_set(Ewl_Text *t, unsigned int pos);
unsigned int ewl_text_cursor_position_get(Ewl_Text *t);
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs