Enlightenment CVS committal
Author : rbdpngn
Project : e17
Module : libs/etox
Dir : e17/libs/etox/src
Modified Files:
Etox.h etox.c etox_line.c etox_obstacle.c etox_obstacle.h
Log Message:
Fixed up the segv's in etox_test that I am experiencing, which was in
etox_append_text. Also simplified the test program by removing the buggy
slide-in code, it was too slow when testing over the network anyways. Let me
know if you experience segfaults.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/Etox.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- Etox.h 23 Jul 2003 16:37:39 -0000 1.33
+++ Etox.h 26 Jul 2003 06:35:21 -0000 1.34
@@ -38,18 +38,6 @@
};
/*
- * Etox obstacles keep track of the lines that they intersect and the bit that
- * represents it.
- */
-typedef struct _etox_obstacle Etox_Obstacle;
-struct _etox_obstacle
-{
- Estyle *bit;
- int start_line;
- int end_line;
-};
-
-/*
* The info structure keeps the important information about the style, but not
* the bits used to display the text.
*/
@@ -209,6 +197,19 @@
};
/*
+ * Etox obstacles keep track of the lines that they intersect and the bit that
+ * represents it.
+ */
+typedef struct _etox_obstacle Etox_Obstacle;
+struct _etox_obstacle
+{
+ Etox *et;
+ Estyle *bit;
+ int start_line;
+ int end_line;
+};
+
+/*
* Selection are used to manipulate previously composed etox, it is
* recommended to keep the number of active selections to a minimum, and if
* possible, compose using contexts and setup time.
@@ -340,10 +341,9 @@
* Obstacle manipulation functions
*/
Etox_Obstacle *etox_obstacle_add(Etox * et, int x, int y, int w, int h);
-void etox_obstacle_remove(Etox * et, Etox_Obstacle * obstacle);
-void etox_obstacle_move(Etox * et, Etox_Obstacle * obstacle, int x, int y);
-void etox_obstacle_resize(Etox * et, Etox_Obstacle * obstacle, int w,
- int h);
+void etox_obstacle_remove(Etox_Obstacle * obstacle);
+void etox_obstacle_move(Etox_Obstacle * obstacle, int x, int y);
+void etox_obstacle_resize(Etox_Obstacle * obstacle, int w, int h);
/*
* These functions select regions of the etox.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -3 -r1.43 -r1.44
--- etox.c 24 Jul 2003 05:34:44 -0000 1.43
+++ etox.c 26 Jul 2003 06:35:21 -0000 1.44
@@ -189,9 +189,8 @@
*/
void etox_append_text(Etox * et, char *text)
{
- Evas_List *lines, *l, *ll;
+ Evas_List *lines, *l;
Etox_Line *end = NULL, *start;
- int i;
CHECK_PARAM_POINTER("et", et);
CHECK_PARAM_POINTER("text", text);
@@ -201,37 +200,40 @@
* new text with the last line of the old text.
*/
lines = _etox_break_text(et, text);
+ if (!lines)
+ return;
+
for (l = et->lines; l; l = l->next)
end = l->data;
- et->lines = evas_list_remove(et->lines, end);
- for (i = 0, ll = lines; ll; ll = ll->next, i++) {
- if (i == 0) {
- start = ll->data;
+ start = lines->data;
+ lines = evas_list_remove(lines, start);
- /*
- * Need to adjust the height and length of the line to reflect
the
- * text that was added.
- */
- et->length -= start->length;
- et->h -= start->h;
- etox_line_merge(start, end);
- et->length += start->length;
- et->h += start->h;
- et->lines = evas_list_append(et->lines, start);
- } else {
- start = ll->data;
+ /*
+ * Need to adjust the length, height, and width of the line to reflect
+ * the text that was added.
+ */
+ et->length -= end->length;
+ et->h -= start->h;
+ etox_line_merge(end, start);
+ et->length += end->length;
+ et->h += start->h;
+ if (end->w > et->w)
+ et->w = end->w;
- /*
- * Now add the remaining lines to the end of the line list.
- */
- if (start->w > et->w)
- et->w = start->w;
+ while (lines) {
+ start = lines->data;
- et->h += start->h;
- et->length += start->length;
- et->lines = evas_list_append(et->lines, start);
- }
+ /*
+ * Now add the remaining lines to the end of the line list.
+ */
+ if (start->w > et->w)
+ et->w = start->w;
+
+ et->h += start->h;
+ et->length += start->length;
+ et->lines = evas_list_append(et->lines, start);
+ lines = evas_list_remove(lines, start);
}
/*
@@ -679,8 +681,9 @@
* @w: a pointer to an int to store the width of the etox
* @h: a pointer to an int to store the height of the etox
*
- * Returns no value. Stores the geometry of the letter at coordinates @xc, @yc
- * in @et into the integers pointed to by @x, @y, @w, and @h.
+ * Returns the index in the text of the found character. Stores the geometry
+ * of the letter at coordinates @xc, @yc in @et into the integers pointed to by
+ * @x, @y, @w, and @h.
*/
int etox_coord_to_geometry(Etox * et, int xc, int yc, int *x, int *y,
int *w, int *h)
@@ -797,8 +800,8 @@
* @w: the width of the obstacle
* @h: the height of the obstacle
*
- * Returns no value. Adds an obstacle to the etox @et that the text will wrap
- * around.
+ * Returns a pointer to the new obstacle object on success, NULL on failure.
+ * Adds an obstacle to the etox @et that the text will wrap around.
*/
Etox_Obstacle *etox_obstacle_add(Etox * et, int x, int y, int w, int h)
{
@@ -808,9 +811,10 @@
obst = etox_obstacle_new(et, x, y, w, h);
- evas_list_append(et->obstacles, obst);
-
- etox_obstacle_place(et, obst);
+ if (obst) {
+ evas_list_append(et->obstacles, obst);
+ etox_obstacle_place(obst);
+ }
return obst;
}
@@ -823,14 +827,14 @@
* Returns no value. Removes an obstacle from the etox and updates any lines
* surrounding it.
*/
-void etox_obstacle_remove(Etox * et, Etox_Obstacle * obstacle)
+void etox_obstacle_remove(Etox_Obstacle * obstacle)
{
- CHECK_PARAM_POINTER("et", et);
CHECK_PARAM_POINTER("obstacle", obstacle);
- et->obstacles = evas_list_remove(et->obstacles, obstacle);
+ obstacle->et->obstacles = evas_list_remove(obstacle->et->obstacles,
+ obstacle);
- etox_obstacle_free(et, obstacle);
+ etox_obstacle_free(obstacle->et, obstacle);
}
/**
@@ -843,14 +847,13 @@
* Returns no value. Changes the position information for @obst and updates the
* etox to work around the new position.
*/
-void etox_obstacle_move(Etox * et, Etox_Obstacle * obst, int x, int y)
+void etox_obstacle_move(Etox_Obstacle * obst, int x, int y)
{
- CHECK_PARAM_POINTER("et", et);
CHECK_PARAM_POINTER("obst", obst);
estyle_move(obst->bit, x, y);
- etox_obstacle_unplace(et, obst);
- etox_obstacle_place(et, obst);
+ etox_obstacle_unplace(obst);
+ etox_obstacle_place(obst);
}
/**
@@ -863,10 +866,13 @@
* Returns no value. Changes the size information for @obst and updates the
* etox to work around the new position.
*/
-void etox_obstacle_resize(Etox * et, Etox_Obstacle * obst, int x, int y)
+void etox_obstacle_resize(Etox_Obstacle * obst, int x, int y)
{
- CHECK_PARAM_POINTER("et", et);
CHECK_PARAM_POINTER("obst", obst);
+
+ /*
+ * FIXME: Need to fill in the meat of this function
+ */
}
/*
@@ -874,8 +880,8 @@
* @et: the etox that will contain the text
* @text: the text that will be broken up into bits
*
- * Returns no value. Separates the text into lines and bits if specific
- * characters are contained in the text.
+ * Returns a list of lines on success, NULL on failure. Separates the text into
+ * lines and bits if specific characters are contained in the text.
*/
static Evas_List *_etox_break_text(Etox * et, char *text)
{
@@ -1151,6 +1157,13 @@
Evas_List *l;
CHECK_PARAM_POINTER("et", et);
+
+ /*
+ * What the hell, do you expect us to "just know" what text to
+ * display, you've got to set some dumbass!
+ */
+ if (!et->lines)
+ return;
/*
* Begin by rewrapping the necessary lines.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- etox_line.c 24 Jul 2003 01:46:42 -0000 1.12
+++ etox_line.c 26 Jul 2003 06:35:21 -0000 1.13
@@ -264,7 +264,6 @@
void etox_line_merge(Etox_Line * line1, Etox_Line * line2)
{
Estyle *bit;
- Evas_List *l;
CHECK_PARAM_POINTER("line1", line1);
CHECK_PARAM_POINTER("line2", line2);
@@ -272,9 +271,10 @@
/*
* Move the bits from line2 to line1.
*/
- for (l = line2->bits; l; l = l->next) {
- bit = l->data;
+ while (line2->bits) {
+ bit = line2->bits->data;
line1->bits = evas_list_append(line1->bits, bit);
+ line2->bits = evas_list_remove(line2->bits, bit);
}
/*
* Adjust the height, width and length of the merged line.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_obstacle.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- etox_obstacle.c 23 Jul 2003 06:46:17 -0000 1.11
+++ etox_obstacle.c 26 Jul 2003 06:35:21 -0000 1.12
@@ -26,6 +26,7 @@
*/
obst = (Etox_Obstacle *) calloc(1, sizeof(Etox_Obstacle));
if (obst) {
+ obst->et = et;
obst->bit = estyle_new(et->evas, "", NULL);
estyle_fix_geometry(obst->bit, x, y, w, h);
}
@@ -40,7 +41,7 @@
{
CHECK_PARAM_POINTER("obstacle", obstacle);
- etox_obstacle_unplace(et, obstacle);
+ etox_obstacle_unplace(obstacle);
FREE(obstacle);
}
@@ -52,7 +53,7 @@
*
* Returns no value. Places the obstacle @obst within the lines of etox @et.
*/
-void etox_obstacle_place(Etox * et, Etox_Obstacle * obst)
+void etox_obstacle_place(Etox_Obstacle * obst)
{
int i = 0;
int j = 0;
@@ -60,7 +61,6 @@
Etox_Line *line;
Evas_List *l_nodes, *l;
- CHECK_PARAM_POINTER("et", et);
CHECK_PARAM_POINTER("obst", obst);
/*
@@ -68,23 +68,23 @@
* outside of the etox.
*/
estyle_geometry(obst->bit, &x, &y, &w, &h);
- if (x > et->x + et->w)
+ if (x > obst->et->x + obst->et->w)
return;
- if (x + w < et->x)
+ if (x + w < obst->et->x)
return;
- if (y > et->y + et->h)
+ if (y > obst->et->y + obst->et->h)
return;
- if (y + h < et->y)
+ if (y + h < obst->et->y)
return;
/*
* We know the obstacle intersects this etox, so now determine
* starting and ending lines, as well as split lines appropriately.
*/
- for (l_nodes = et->lines; l_nodes; l_nodes = l_nodes->next)
+ for (l_nodes = obst->et->lines; l_nodes; l_nodes = l_nodes->next)
j++;
obst->start_line = j;
obst->end_line = -1;
@@ -93,7 +93,7 @@
* Run through to determine the lines to determine which intersect the
* obstacle
*/
- for (l = et->lines; l; l = l->next) {
+ for (l = obst->et->lines; l; l = l->next) {
line = l->data;
if (line->y < y + h) {
if (line->y > y) {
@@ -119,14 +119,13 @@
/*
* etox_obstacle_unplace - set empty positioning on an obstacle in the etox
*/
-void etox_obstacle_unplace(Etox * et, Etox_Obstacle * obst)
+void etox_obstacle_unplace(Etox_Obstacle * obst)
{
int i, j;
Estyle *bit;
Etox_Line *line;
Evas_List *l, *ll;
- CHECK_PARAM_POINTER("et", et);
CHECK_PARAM_POINTER("obst", obst);
/*
@@ -138,7 +137,7 @@
* On each line within the obstacle bounds, remove the obstacle from
* the list of bits.
*/
- for (j = 1, l = et->lines; j <= obst->end_line && l;
+ for (j = 1, l = obst->et->lines; j <= obst->end_line && l;
l = l->next, j++) {
if (j < i);
else {
@@ -185,8 +184,8 @@
if (!bit)
return;
/*
- * FIXME: We need to do some bit-splitting here, just need to
get
- * around to it.
+ * FIXME: We need to do some bit-splitting here, just
+ * need to get around to it.
*/
l = evas_list_prepend_relative(l, obst->bit, l->next);
break;
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_obstacle.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- etox_obstacle.h 25 Apr 2002 16:32:01 -0000 1.2
+++ etox_obstacle.h 26 Jul 2003 06:35:21 -0000 1.3
@@ -3,8 +3,8 @@
Etox_Obstacle *etox_obstacle_new(Etox * line, int x, int y, int w, int h);
void etox_obstacle_free(Etox * et, Etox_Obstacle * obstacle);
-void etox_obstacle_place(Etox * et, Etox_Obstacle * obst);
-void etox_obstacle_unplace(Etox * et, Etox_Obstacle * obst);
+void etox_obstacle_place(Etox_Obstacle * obst);
+void etox_obstacle_unplace(Etox_Obstacle * obst);
inline int etox_rect_intersect(int x1, int y1, int w1, int h1,
int x2, int y2, int w2, int h2);
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs