Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/etox
Dir : e17/libs/etox/src Modified Files: etox.c etox_line.c etox_line.h Log Message: Filled out etox_insert_text and abstracted some common line operations. If you run into issues, please let me know. These functions could use more testing. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox.c,v retrieving revision 1.49 retrieving revision 1.50 diff -u -3 -r1.49 -r1.50 --- etox.c 31 Jul 2003 04:57:09 -0000 1.49 +++ etox.c 31 Jul 2003 21:39:30 -0000 1.50 @@ -338,8 +338,70 @@ */ void etox_insert_text(Etox * et, char *text, int index) { + Estyle *bit; + Evas_List *lines, *ll; + Etox_Line *start, *end, *temp; + CHECK_PARAM_POINTER("et", et); CHECK_PARAM_POINTER("text", text); + + if (!index) { + etox_prepend_text(et, text); + return; + } + else if (index >= et->length) { + etox_append_text(et, text); + return; + } + + /* + * Break the incoming text into lines, and merge the first line of the + * new text with the last line of the old text. + */ + lines = _etox_break_text(et, text); + if (!lines) + return; + + start = etox_index_to_line(et, &index); + bit = etox_line_index_to_bit(start, &index); + etox_line_split(start, bit, index); + + /* + * Setup the merger betweeen the beginning of the existing text and the + * beginning of the added text. + */ + temp = lines->data; + lines = evas_list_remove(lines, temp); + etox_line_merge_append(start, temp); + + /* + * Now merge the end of the added text with the remainder of the + * existing text. + */ + ll = evas_list_last(lines); + temp = ll->data; + lines = evas_list_remove(lines, temp); + ll = evas_list_find_list(et->lines, start); + end = ll->next->data; + etox_line_merge_prepend(temp, end); + + /* + * Now add the remaining lines to the end of the line list. + */ + while (lines) { + end = lines->data; + + if (end->w > et->tw) + et->tw = end->w; + + et->h += end->h; + et->length += end->length; + et->lines = evas_list_append_relative(et->lines, end, start); + lines = evas_list_remove(lines, end); + start = end; + } + + etox_layout(et); if (et->lines && et->visible) evas_object_show(et->clip); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- etox_line.c 31 Jul 2003 04:57:09 -0000 1.15 +++ etox_line.c 31 Jul 2003 21:39:30 -0000 1.16 @@ -374,8 +374,7 @@ etox_line_wrap(Etox *et, Etox_Line *line) { Evas_List *ll; - Etox_Line *newline; - Estyle *bit = NULL, *split = NULL, *marker; + Estyle *bit = NULL, *marker; int x, w, y, h; int index = -1; @@ -406,15 +405,10 @@ index++; FREE(tmp); - etox_line_remove(line, bit); - - /* split the edge bit */ - split = estyle_split(bit, index); - etox_line_append(line, bit); - } + etox_line_split(line, bit, index); + ll = evas_list_find_list(et->lines, line); + ll = ll->next; - /* if split successful, set up the new bit */ - if (split) { /* create a marker bit. */ marker = estyle_new(et->evas, et->context->marker.text, et->context->marker.style); @@ -422,13 +416,35 @@ et->context->marker.g, et->context->marker.b, et->context->marker.a); estyle_set_clip(marker, et->clip); - estyle_set_font(bit, et->context->font, et->context->font_size); + estyle_set_font(marker, et->context->font, + et->context->font_size); estyle_show(marker); + etox_line_prepend(ll->data, marker); + } + else + index = 0; + + return index; +} + +void +etox_line_split(Etox_Line *line, Estyle *bit, int index) +{ + Evas_List *ll; + Etox_Line *newline; + Estyle *split = NULL; + + etox_line_remove(line, bit); + + /* split the edge bit */ + split = estyle_split(bit, index); + etox_line_append(line, bit); + + /* if split successful, set up the new bit */ + if (split) { - /* create a new line, with the marker and the split bits */ newline = etox_line_new(line->flags | ETOX_LINE_WRAPPED); - newline->et = et; - etox_line_append(newline, marker); + newline->et = line->et; etox_line_append(newline, split); ll = evas_list_find_list(line->bits, bit); @@ -441,12 +457,9 @@ } /* add the newline after the current one */ - et->lines = evas_list_append_relative(et->lines, newline, line); + line->et->lines = evas_list_append_relative(line->et->lines, + newline, line); } - else - index = 0; - - return index; } void =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/etox/src/etox_line.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- etox_line.h 31 Jul 2003 04:57:09 -0000 1.7 +++ etox_line.h 31 Jul 2003 21:39:30 -0000 1.8 @@ -15,6 +15,7 @@ void etox_line_get_text(Etox_Line * line, char *buf); int etox_line_wrap(Etox *et, Etox_Line *line); +void etox_line_split(Etox_Line *line, Estyle *bit, int index); void etox_line_unwrap(Etox *et, Etox_Line *line); Estyle *etox_line_coord_to_bit(Etox_Line *line, int x); Estyle *etox_line_index_to_bit(Etox_Line *line, int *i); ------------------------------------------------------- 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