Enlightenment CVS committal
Author : rephorm
Project : e17
Module : libs/etox
Dir : e17/libs/etox/src
Modified Files:
Etox.h etox.c etox_line.c etox_line.h etox_selection.c
Log Message:
added:
etox_select_str()
create a selection from a string.
warning: this func may cause errors due to some bugs in etox_get_text()
etox_line_get_geometry()
etox_selection_get_geometry()
get the geometry of the selection in the form of an array of rectangles
that define the selection. (one per line)
Etox_Rect
a rect struct for use in the previous func
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/Etox.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- Etox.h 20 Aug 2003 17:37:10 -0000 1.40
+++ Etox.h 4 Sep 2003 03:05:23 -0000 1.41
@@ -71,6 +71,13 @@
} marker;
};
+typedef struct _etox_rect Etox_Rect;
+struct _etox_rect
+{
+ double x, y;
+ double w, h;
+};
+
typedef struct _etox_obstacle Etox_Obstacle;
typedef struct _etox_selection Etox_Selection;
@@ -171,7 +178,7 @@
Etox_Selection *etox_select_coords(Evas_Object * et, double sx, double sy,
double ex, double ey);
Etox_Selection *etox_select_index(Evas_Object * et, int si, int ei);
-Etox_Selection *etox_select_str(Evas_Object * et, char *match, char **last);
+Etox_Selection *etox_select_str(Evas_Object * et, char *match, int *index);
/*
* Release a selection that is no longer needed.
@@ -209,5 +216,6 @@
Evas_Callback_Type callback);
void etox_selection_apply_context(Etox_Selection *selected,
Etox_Context *context);
+Etox_Rect *etox_selection_get_geometry(Etox_Selection *selected, int *num);
#endif
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -3 -r1.62 -r1.63
--- etox.c 25 Aug 2003 21:18:53 -0000 1.62
+++ etox.c 4 Sep 2003 03:05:23 -0000 1.63
@@ -493,7 +493,6 @@
*/
if (!et->lines)
return NULL;
-
ret = (char *) calloc((et->length + 1), sizeof(char));
temp = ret;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- etox_line.c 21 Aug 2003 02:03:08 -0000 1.27
+++ etox_line.c 4 Sep 2003 03:05:23 -0000 1.28
@@ -372,7 +372,10 @@
for (l = line->bits; l; l = l->next) {
es = l->data;
temp = estyle_get_text(es);
+ printf("*** temp:\n%s\n", temp);
strcat(buf, temp);
+ printf("*** buf:\n%s\n", buf);
+ free(temp);
}
strcat(buf, "\n");
@@ -697,3 +700,21 @@
}
}
+void
+etox_line_get_geometry(Etox_Line *line, double *x, double *y,
+ double *w, double *h)
+{
+ if (!line)
+ {
+ if (x) *x = 0;
+ if (y) *y = 0;
+ if (w) *w = 0;
+ if (h) *h = 0;
+ return;
+ }
+
+ if (x) *x = line->x;
+ if (y) *y = line->y;
+ if (w) *w = line->w;
+ if (h) *h = line->h;
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- etox_line.h 22 Aug 2003 16:13:10 -0000 1.12
+++ etox_line.h 4 Sep 2003 03:05:23 -0000 1.13
@@ -17,6 +17,8 @@
int etox_line_wrap(Etox *et, Etox_Line *line);
void etox_line_split(Etox_Line *line, Evas_Object *bit, int index);
void etox_line_unwrap(Etox *et, Etox_Line *line);
+void etox_line_get_geometry(Etox_Line *line, double *x, double *y,
+ double *w, double *h);
Evas_Object *etox_line_coord_to_bit(Etox_Line *line, int x);
Evas_Object *etox_line_index_to_bit(Etox_Line *line, int *i);
void etox_line_index_to_geometry(Etox_Line *line, int index, double *x,
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_selection.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- etox_selection.c 27 Aug 2003 18:58:09 -0000 1.12
+++ etox_selection.c 4 Sep 2003 03:05:23 -0000 1.13
@@ -241,15 +241,43 @@
/**
*/
Etox_Selection *
-etox_select_str(Evas_Object * obj, char *match, char **last)
+etox_select_str(Evas_Object * obj, char *match, int *index)
{
- Etox *et;
+ char *text = NULL, *pos = NULL;
+ int i = 0, si = 0, ei = 0;
CHECK_PARAM_POINTER_RETURN("obj", obj, NULL);
- et = evas_object_smart_data_get(obj);
+ /*
+ * FIXME possibly search bit by bit to cut down on
+ * memory for really large strings
+ */
- return NULL;
+ text = etox_get_text(obj);
+
+ if (index)
+ i = *index;
+
+ pos = strstr(text + i, match);
+
+ if (pos == NULL)
+ {
+ if (index) *index = -1;
+ free(text);
+ return NULL;
+ }
+
+ si = pos - text;
+ ei = si + strlen(match);
+
+ printf("si: %d, ei: %d\n", si, ei);
+
+ if (index)
+ *index = ei;
+
+ free(text);
+
+ return etox_select_index(obj, si, ei);
}
/**
@@ -285,6 +313,9 @@
Evas_List *l;
Etox_Line *line;
+ CHECK_PARAM_POINTER("selected", selected);
+ CHECK_PARAM_POINTER("context", context);
+
if (selected->start.line == selected->end.line)
{
etox_line_apply_context(selected->start.line, context,
@@ -336,4 +367,76 @@
selected->end.line = line;
}
}
+}
+
+Etox_Rect *
+etox_selection_get_geometry(Etox_Selection *selected, int *num)
+{
+ Etox_Rect *rects = NULL, *cur = NULL;
+ Evas_List *l = NULL, *midlines = NULL;
+ double x, y, w, h;
+ int count = 1;
+
+ if (selected->start.line == selected->end.line)
+ {
+ return NULL;
+ }
+
+ l = evas_list_find_list(selected->etox->lines, selected->start.line);
+
+ for (l = l->next; l; l = l->next)
+ {
+ Etox_Line *line = l->data;
+
+ count++; /* count the last line also */
+
+ if (line == selected->end.line) break;
+
+ midlines = evas_list_append(midlines, line);
+ }
+
+ printf("count: %d\n", count);
+
+ rects = calloc(count, sizeof(Etox_Rect)); /* start and end line also */
+
+ /* first line */
+ //etox_line_index_to_geometry(selected->start.line, selected->start.index,
+ // &x, &y, &w, &h);
+ evas_object_geometry_get(selected->start.bit, &x, &y, &w, &h);
+ rects->x = x;
+ rects->y = y;
+ etox_line_get_geometry(selected->start.line, &x, &y, &w, &h);
+ rects->w = x + w - rects->x;
+ rects->h = y + h - rects->y;
+
+ printf("(%f, %f) %f x %f\n", rects->x, rects->y, rects->w, rects->h);
+ cur = rects;
+ printf("cur1: %d\n", cur);
+ for (l = midlines; l; l = l->next)
+ {
+ Etox_Line *line = l->data;
+
+ cur++;
+ printf("cur2: %d\n", cur);
+ etox_line_get_geometry(line, &x, &y, &w, &h);
+
+ cur->x = x;
+ cur->y = y;
+ cur->w = w;
+ cur->h = h;
+ }
+
+ cur ++;
+ etox_line_get_geometry(selected->end.line, &x, &y, &w, &h);
+ cur->x = x;
+ cur->y = y;
+ //etox_line_index_to_geometry(selected->end.line, selected->end.index,
+ // &x, &y, &w, &h);
+ evas_object_geometry_get(selected->end.bit, &x, &y, &w, &h);
+ cur->w = x + w - cur->x;
+ cur->h = y + h - cur->y;
+
+
+ if (num) *num = count;
+ return rects;
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs