From 68cd1d43c36cc71c6204fa66d1a80218a2f94795 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Fri, 29 Mar 2002 13:15:13 +0000 Subject: * Les flags sont dans un unsigned short (16 flags). * Correction du calcul de la longueur de ligne pour tenir correctment compte du \n de fin. Il s'affichait sous forme d'un petit carr�. --- generic/Text.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'generic/Text.c') diff --git a/generic/Text.c b/generic/Text.c index e9bae13..3f8cba3 100644 --- a/generic/Text.c +++ b/generic/Text.c @@ -89,7 +89,7 @@ typedef struct _TextItemStruct { ZnJustify alignment; ZnDim width; ZnDim spacing; - unsigned char flags; + unsigned short flags; /* Private data */ ZnPoint pos_dev; @@ -409,16 +409,18 @@ ComputeCoordinates(Item item, } info.num_chars = Tk_MeasureChars(text->font, scan, num, wrap, TK_WHOLE_WORDS|TK_AT_LEAST_ONE, &info.width); + + info.start = scan; + text->max_width = MAX(info.width, text->max_width); + + scan += info.num_chars; /* * Adjust for the newline at the end of line. */ if (ptr) { - info.num_chars++; + scan++; } - info.start = scan; - text->max_width = MAX(info.width, text->max_width); - - scan += info.num_chars; + /* Build a line info even for an empty line * at the end of text or for an empty text. * It is needed to enable selection and cursor @@ -790,7 +792,7 @@ Render(Item item) WidgetInfo *wi = item->wi; TextItem text = (TextItem) item; TextLineInfo lines, lines_ptr; - int i, num_lines, num_chars; + int i, num_lines; XColor *color; int alpha; @@ -815,15 +817,11 @@ Render(Item item) num_lines = ZnListSize(text->text_info); for (i = 0, lines_ptr = lines; i < num_lines; i++, lines_ptr++) { - num_chars = lines_ptr->num_chars; - while (lines_ptr->start[num_chars-1] == '\n') { - num_chars--; - } glPushMatrix(); glTranslatef(text->pos_dev.x + lines_ptr->text_origin.x, text->pos_dev.y + lines_ptr->text_origin.y, 0.0); - txfRenderString(text->txf, lines_ptr->start, num_chars); + txfRenderString(text->txf, lines_ptr->start, lines_ptr->num_chars); glPopMatrix(); } glDisable(GL_TEXTURE_2D); -- cgit v1.1