Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src
Modified Files:
ewl_entry.c ewl_entry.h
Log Message:
Removed selection code as it will be entirely different supporting multi-line
selections.
More reliable positioning of cursors entries, need to fix delete still.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -3 -r1.111 -r1.112
--- ewl_entry.c 6 Oct 2004 04:54:08 -0000 1.111
+++ ewl_entry.c 12 Oct 2004 17:49:29 -0000 1.112
@@ -7,13 +7,13 @@
*/
static void ewl_entry_ops_apply(Ewl_Entry *e);
static void ewl_entry_op_prune_list(Ewl_Entry *e, int rstart, int rend,
- int bstart, int bend);
+ int bstart, int bend);
static void ewl_entry_op_free(void *data);
static Ewl_Entry_Op *ewl_entry_op_relevant_find(Ewl_Entry *e,
- Ewl_Entry_Op_Type type);
+ Ewl_Entry_Op_Type type);
static Ewl_Entry_Op *ewl_entry_op_color_new(Ewl_Entry *e, int r, int g, int b,
- int a);
+ int a);
static void ewl_entry_op_color_apply(Ewl_Entry *e, Ewl_Entry_Op *op);
static Ewl_Entry_Op *ewl_entry_op_font_new(Ewl_Entry *e, char *font, int size);
@@ -31,9 +31,10 @@
static Ewl_Entry_Op *ewl_entry_op_text_append_new(Ewl_Entry *e, char *text);
static Ewl_Entry_Op *ewl_entry_op_text_prepend_new(Ewl_Entry *e, char *text);
static Ewl_Entry_Op *ewl_entry_op_text_insert_new(Ewl_Entry *e, char *text,
- int index);
+ int index);
static Ewl_Entry_Op *ewl_entry_op_text_delete_new(Ewl_Entry *e,
- unsigned int start, unsigned int len);
+ unsigned int start,
+ unsigned int len);
static void ewl_entry_op_text_apply(Ewl_Entry *e, Ewl_Entry_Op *op);
static void ewl_entry_op_text_free(void *op);
@@ -132,13 +133,13 @@
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), 0);
ewl_widget_show(e->cursor);
- e->selection = NULL;
+ e->selections = NULL;
/*
* Attach necessary callback mechanisms
*/
- ewl_callback_append(w, EWL_CALLBACK_CONFIGURE,
- ewl_entry_configure_cb, NULL);
+ ewl_callback_append(w, EWL_CALLBACK_CONFIGURE, ewl_entry_configure_cb,
+ NULL);
ewl_callback_append(w, EWL_CALLBACK_SELECT, ewl_entry_select_cb, NULL);
ewl_callback_append(w, EWL_CALLBACK_DESELECT, ewl_entry_deselect_cb,
@@ -155,9 +156,8 @@
ewl_entry_editable_set(e, TRUE);
ewl_callback_append(w, EWL_CALLBACK_MOUSE_DOWN,
- ewl_entry_mouse_down_cb, NULL);
- ewl_callback_del(w, EWL_CALLBACK_MOUSE_UP,
- ewl_entry_mouse_up_cb);
+ ewl_entry_mouse_down_cb, NULL);
+ ewl_callback_del(w, EWL_CALLBACK_MOUSE_UP, ewl_entry_mouse_up_cb);
/*
ewl_callback_append(w, EWL_CALLBACK_DOUBLE_CLICKED,
ewl_entry_mouse_double_click_cb, NULL);
@@ -231,11 +231,6 @@
if (e->cursor)
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), 0);
- if (e->selection) {
- ewl_widget_destroy(e->selection);
- e->selection = NULL;
- }
-
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -332,14 +327,18 @@
void ewl_entry_text_insert(Ewl_Entry * e, char *text, int index)
{
Ewl_Entry_Op *op;
+ int len = 0;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("e", e);
DCHECK_PARAM_PTR("text", text);
op = ewl_entry_op_text_insert_new(e, text, index);
+ len = strlen(text);
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor),
- index + strlen(text));
+ index + len);
+ e->length += len;
+
ecore_dlist_prepend(e->ops, op);
if (REALIZED(e))
ewl_entry_ops_apply(e);
@@ -612,7 +611,7 @@
* after the entry widget has been realized.
*/
void ewl_entry_index_geometry_map(Ewl_Entry *e, int index, int *x, int *y,
- int *w, int *h)
+ int *w, int *h)
{
Evas_Coord tx, ty, tw, th;
@@ -640,8 +639,8 @@
*/
void ewl_entry_configure_cb(Ewl_Widget * w, void *ev_data, void *user_data)
{
- Ewl_Entry *e;
- int xx, yy, ww, hh;
+ Ewl_Entry *e;
+ int xx, yy, ww, hh;
int c_pos = 0, pos, l;
int cx = 0, cy = 0;
unsigned int cw = 0, ch = 0;
@@ -673,7 +672,7 @@
l = ewl_entry_length_get(e);
c_pos = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor));
- if (c_pos > l)
+ if (c_pos >= l)
pos = l - 1;
else
pos = c_pos;
@@ -681,20 +680,13 @@
if (l) {
ewl_entry_index_geometry_map(e, pos, &cx, &cy, &cw, &ch);
if (pos != c_pos)
- ewl_entry_index_geometry_map(e, c_pos,
- &cx, &cy, NULL, NULL);
+ ewl_entry_index_geometry_map(e, c_pos, &cx, &cy,
+ NULL, NULL);
}
else
ewl_object_current_geometry_get(EWL_OBJECT(w), &cx, &cy, &cw,
&ch);
- /*
- * D'oh, get the hell out of here, the entry is way too small to do
- * anything useful.
- */
- if (cw > ww)
- DRETURN(DLEVEL_STABLE);
-
if (e->offset < 0)
e->offset = 0;
@@ -894,17 +886,7 @@
e->in_select_mode = TRUE;
index = ewl_entry_coord_index_map(e, ev->x, ev->y);
-
- if (!e->selection) {
- e->selection = ewl_entry_selection_new();
- ewl_widget_show(e->selection);
- }
-
- ewl_entry_selection_start_position_set(EWL_ENTRY_SELECTION(e->selection),
index);
- ewl_entry_selection_end_position_set(EWL_ENTRY_SELECTION(e->selection), index);
-
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), index);
-
ewl_widget_configure(w);
DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -955,16 +937,8 @@
!(e->in_select_mode))
DRETURN(DLEVEL_STABLE);
-/* if (ev->x < CURRENT_X(e->text))
- index = 0;
- else if (ev->x > CURRENT_X(e->text) + CURRENT_W(e->text)) {
- index = ewl_text_length_get(EWL_ENTRY(e->text));
- }
- else {
-*/
- index = ewl_entry_coord_index_map(e, ev->x, ev->y);
-/* }
-*/
+ index = ewl_entry_coord_index_map(e, ev->x, ev->y);
+
/*
* Should begin scrolling in either direction?
*/
@@ -975,8 +949,6 @@
*/
}
- ewl_entry_selection_select_to(EWL_ENTRY_SELECTION(e->selection), index);
-
ewl_widget_configure(w);
DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -1003,34 +975,21 @@
start = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor));
- if (e->selection) {
- ewl_widget_destroy(e->selection);
- e->selection = ewl_entry_selection_new();
- }
-
s = ewl_entry_text_get(e);
while ((s[start] != ' ') && (s[start] != '\t')
- && (s[start] != '\n') && (--start > 0))
- ;
+ && (s[start] != '\n') && (--start > 0));
if (start < 0) start++;
end = start;
while ((s[end + 1] != ' ') && (s[end + 1] != '\t')
- && (s[end + 1] != '\n') && (++end < len))
- ;
+ && (s[end + 1] != '\n') && (++end < len));
- if (end == len) end --;
- ewl_entry_selection_start_position_set(
- EWL_ENTRY_SELECTION(e->selection), start);
- ewl_entry_selection_end_position_set(
- EWL_ENTRY_SELECTION(e->selection), end);
- ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), end + 1);
+ ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), end);
- } else {
-
ewl_entry_selection_start_position_set(EWL_ENTRY_SELECTION(e->selection), 0);
- ewl_entry_selection_select_to(EWL_ENTRY_SELECTION(e->selection), len -
1);
+ }
+ else {
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), len);
}
@@ -1049,8 +1008,6 @@
e = EWL_ENTRY(w);
- ewl_widget_show(e->selection);
-
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -1063,8 +1020,6 @@
e = EWL_ENTRY(w);
- ewl_widget_hide(e->selection);
-
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -1079,10 +1034,6 @@
if (--pos < 0) pos = 0;
- if (e->in_select_mode)
- ewl_entry_selection_start_position_set(
- EWL_ENTRY_SELECTION(e->selection), pos);
-
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), pos);
ewl_widget_configure(EWL_WIDGET(e));
@@ -1106,8 +1057,6 @@
FREE(str);
if (++pos > len) pos = len;
- if (e->in_select_mode)
- ewl_entry_selection_select_to(EWL_ENTRY_SELECTION(e->selection), pos);
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), pos);
@@ -1156,9 +1105,6 @@
else
lpos = nend - 1;
- if (e->in_select_mode)
-
ewl_entry_selection_select_to(EWL_ENTRY_SELECTION(e->selection), lpos);
-
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor),
lpos);
@@ -1207,9 +1153,6 @@
else
lpos = pend - 1;
- if (e->in_select_mode)
-
ewl_entry_selection_select_to(EWL_ENTRY_SELECTION(e->selection), lpos);
-
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor),
lpos);
@@ -1225,9 +1168,6 @@
{
DENTER_FUNCTION(DLEVEL_STABLE);
- if (e->in_select_mode)
-
ewl_entry_selection_start_position_set(EWL_ENTRY_SELECTION(e->selection), 0);
-
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), 0);
ewl_widget_configure(EWL_WIDGET(e));
@@ -1252,9 +1192,6 @@
FREE(s);
}
- if (e->in_select_mode)
- ewl_entry_selection_select_to(EWL_ENTRY_SELECTION(e->selection), l);
-
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), l);
ewl_widget_configure(EWL_WIDGET(e));
@@ -1264,7 +1201,7 @@
void ewl_entry_left_delete(Ewl_Entry * e)
{
Ewl_Entry_Op *op;
- int sp = 0, end = 0;
+ int sp = 0, ep = 0;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("e", e);
@@ -1273,29 +1210,17 @@
DLEAVE_FUNCTION(DLEVEL_STABLE)
}
- if (e->selection) {
- sp =
ewl_entry_selection_start_position_get(EWL_ENTRY_SELECTION(e->selection));
- end =
ewl_entry_selection_end_position_get(EWL_ENTRY_SELECTION(e->selection));
+ sp = ep = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor));
+ sp--;
- if (end == sp) sp --;
- end -= sp;
- } else {
- sp = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor));
- sp --;
- }
if (sp < 0) return;
- if (end == 0) end = 1;
+ if (ep == 0) ep = 1;
- op = ewl_entry_op_text_delete_new(e, sp, end);
+ op = ewl_entry_op_text_delete_new(e, sp, ep);
ecore_dlist_append(e->ops, op);
if (REALIZED(e))
ewl_entry_ops_apply(e);
- if (e->selection) {
- ewl_widget_destroy(e->selection);
- e->selection = NULL;
- }
-
ewl_entry_cursor_position_set(EWL_ENTRY_CURSOR(e->cursor), sp);
ewl_widget_configure(EWL_WIDGET(e));
@@ -1305,7 +1230,7 @@
void ewl_entry_right_delete(Ewl_Entry * e)
{
Ewl_Entry_Op *op;
- int sp = 0, len = 0, end = 0;
+ int sp = 0, len = 0, ep = 0;
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("e", e);
@@ -1314,29 +1239,15 @@
DLEAVE_FUNCTION(DLEVEL_STABLE)
}
- if (e->selection) {
- sp =
ewl_entry_selection_start_position_get(EWL_ENTRY_SELECTION(e->selection));
- end =
ewl_entry_selection_end_position_get(EWL_ENTRY_SELECTION(e->selection));
- end -= sp;
- } else {
- sp = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor));
- }
-
/* no reason to delete past the end of the text */
len = ewl_entry_length_get(e);
- if (sp >= len) return;
- if (end == 0) end = 1;
+ sp = ep = ewl_entry_cursor_position_get(EWL_ENTRY_CURSOR(e->cursor));
- op = ewl_entry_op_text_delete_new(e, sp, end);
+ op = ewl_entry_op_text_delete_new(e, sp, ep);
ecore_dlist_append(e->ops, op);
if (REALIZED(e))
ewl_entry_ops_apply(e);
- if (e->selection) {
- ewl_widget_destroy(e->selection);
- e->selection = NULL;
- }
-
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
@@ -1399,7 +1310,7 @@
void
ewl_entry_child_resize_cb(Ewl_Container * entry, Ewl_Widget * w, int size,
- Ewl_Orientation o)
+ Ewl_Orientation o)
{
/* Ewl_Object *text;
*/
@@ -1552,7 +1463,7 @@
void
ewl_entry_selection_start_position_set(Ewl_Entry_Selection *s,
- unsigned int start)
+ unsigned int start)
{
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("s", s);
@@ -1573,7 +1484,7 @@
void
ewl_entry_selection_end_position_set(Ewl_Entry_Selection *s,
- unsigned int end)
+ unsigned int end)
{
DENTER_FUNCTION(DLEVEL_STABLE);
DCHECK_PARAM_PTR("s", s);
@@ -1920,7 +1831,7 @@
static Ewl_Entry_Op *
ewl_entry_op_text_delete_new(Ewl_Entry *e, unsigned int start,
- unsigned int len)
+ unsigned int len)
{
Ewl_Entry_Op *op;
Ewl_Entry_Op_Text *ops;
@@ -2021,6 +1932,5 @@
* size for the widget.
*/
ewl_object_preferred_inner_size_set(EWL_OBJECT(e), (int)(width),
- (int)(height));
+ (int)(height));
}
-
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -3 -r1.43 -r1.44
--- ewl_entry.h 6 Oct 2004 04:54:08 -0000 1.43
+++ ewl_entry.h 12 Oct 2004 17:49:30 -0000 1.44
@@ -31,24 +31,24 @@
*/
struct Ewl_Entry
{
- Ewl_Container container; /**< Inherit from Ewl_Container */
+ Ewl_Container container; /**< Inherit from Ewl_Container */
- char *text; /**< The initial text in the entry */
- int length; /**< Length of the text displayed */
- Evas_Object *etox; /**< Etox does the actual layout work */
- Etox_Context *context; /**< Contains various format settings */
- Ecore_DList *ops; /**< Series of operations to apply */
- Ecore_DList *applied; /**< Applied set of operations */
-
- Ewl_Widget *cursor; /**< Provide Ewl_Entry_Cursor for cursor display
*/
- Ewl_Widget *selection; /**< Provied Ewl_Entry_Selection for selection
display */
-
- int offset; /**< Starting position of cursor in text */
- int editable; /**< Flag to indicate if user can edit text */
- Ecore_Timer *timer; /**< Time until scrolling text on select */
- double start_time; /**< Time timer started */
- int in_select_mode; /**< Do keyboard cursor movements select? */
- int multiline; /**< Do we deal with multiple lines of text? */
+ char *text; /**< The initial text in the entry */
+ int length; /**< Length of the text displayed */
+ Evas_Object *etox; /**< Etox does the actual layout work */
+ Etox_Context *context; /**< Contains various format settings */
+ Ecore_DList *ops; /**< Series of operations to apply */
+ Ecore_DList *applied; /**< Applied set of operations */
+
+ Ewl_Widget *cursor; /**< Cursor widget */
+ Ecore_List *selections; /**< List of selections for display */
+
+ int offset; /**< Starting position of scrolling */
+ int editable; /**< Flag indicating user can edit text */
+ Ecore_Timer *timer; /**< Time until next text scrolling */
+ double start_time; /**< Time timer started */
+ int in_select_mode; /**< keyboard cursor movements select? */
+ int multiline; /**< Deal with multiple lines of text? */
};
Ewl_Widget *ewl_entry_new(char *text);
@@ -74,20 +74,22 @@
char *ewl_entry_style_get(Ewl_Entry *e);
void ewl_entry_color_set(Ewl_Entry *e, int r, int g, int b, int a);
-void ewl_entry_color_get(Ewl_Entry *e, int *r, int *g, int *b, int *a);
+void ewl_entry_color_get(Ewl_Entry *e, int *r, int *g, int *b,
+ int *a);
void ewl_entry_align_set(Ewl_Entry *e, unsigned int align);
unsigned int ewl_entry_align_get(Ewl_Entry *e);
void ewl_entry_index_select(Ewl_Entry *e, int si, int ei);
void ewl_entry_coord_select(Ewl_Entry *e, int sx, int sy, int ex,
- int ey);
+ int ey);
void ewl_entry_index_geometry_map(Ewl_Entry *e, int index, int *xx,
- int *yy, int *ww, int *hh);
+ int *yy, int *ww, int *hh);
int ewl_entry_coord_index_map(Ewl_Entry *e, int x, int y);
-int ewl_entry_coord_geometry_map(Ewl_Entry *e, int x, int y, int *xx,
- int *yy, int *ww, int *hh);
+int ewl_entry_coord_geometry_map(Ewl_Entry *e, int x, int y,
+ int *xx, int *yy,
+ int *ww, int *hh);
void ewl_entry_cursor_left_move(Ewl_Entry * e);
void ewl_entry_cursor_right_move(Ewl_Entry * e);
@@ -205,15 +207,18 @@
struct Ewl_Entry_Selection
{
Ewl_Widget widget;
- unsigned int start;
+ Etox_Selection *select;
+ unsigned int start;
unsigned int end;
};
Ewl_Widget *ewl_entry_selection_new(void);
void ewl_entry_selection_init(Ewl_Entry_Selection *s);
-void ewl_entry_selection_start_position_set(Ewl_Entry_Selection *s, unsigned int
start);
+void ewl_entry_selection_start_position_set(Ewl_Entry_Selection *s,
+ unsigned int start);
int ewl_entry_selection_start_position_get(Ewl_Entry_Selection *s);
-void ewl_entry_selection_end_position_set(Ewl_Entry_Selection *s, unsigned int end);
+void ewl_entry_selection_end_position_set(Ewl_Entry_Selection *s,
+ unsigned int end);
int ewl_entry_selection_end_position_get(Ewl_Entry_Selection *s);
void ewl_entry_selection_select_to(Ewl_Entry_Selection *s, unsigned int pos);
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs