Author: matt
Date: 2010-04-30 15:13:40 -0700 (Fri, 30 Apr 2010)
New Revision: 7573
Log:
Removing the text expander which is utterly useless in UTF8 land.
Modified:
branches/branch-1.3-STR2158-matt/src/Fl_Text_Display.cxx
Modified: branches/branch-1.3-STR2158-matt/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3-STR2158-matt/src/Fl_Text_Display.cxx 2010-04-30
21:55:58 UTC (rev 7572)
+++ branches/branch-1.3-STR2158-matt/src/Fl_Text_Display.cxx 2010-04-30
22:13:40 UTC (rev 7573)
@@ -681,7 +681,6 @@
int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) const {
int charIndex, lineStartPos, fontHeight, lineLen;
int visLineNum, charLen, outIndex, xStep, charStyle;
- char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ];
const char *lineStr;
// printf("position_to_xy(pos=%d, X=%p, Y=%p)\n", pos, X, Y);
@@ -724,17 +723,16 @@
/* Step through character positions from the beginning of the line
to "pos" to calculate the X coordinate */
+ // FIXME: use the text expander in draw_vline to calculate this!
xStep = text_area.x - mHorizOffset;
outIndex = 0;
- for (charIndex = 0;
- charIndex < lineLen && charIndex < pos - lineStartPos;
- charIndex += fl_utf8len(lineStr[charIndex]) )
+ for (charIndex = 0; charIndex < lineLen && charIndex < pos - lineStartPos; )
{
- charLen = Fl_Text_Buffer::expand_character( lineStr+charIndex, outIndex,
expandedChar,
- mBuffer->tab_distance());
+ charLen = fl_utf8len(lineStr[charIndex]);
charStyle = position_style( lineStartPos, lineLen, charIndex);
- xStep += string_width( expandedChar, charLen, charStyle );
+ xStep += string_width( lineStr+charIndex, charLen, charStyle );
outIndex += charLen;
+ charIndex += charLen;
}
*X = xStep;
free((char *)lineStr);
@@ -1455,6 +1453,8 @@
// FIXME: simplified line drawing - quite OK so far, but no line wrapping or
tab expansion
+ // we should use this function for calculating the line width as well to
avoid code doubeling!
+ // it would also be needed to convert the character index to a horizontal
pixel position and back!
X = text_area.x - mHorizOffset;
startX = X;
startIndex = 0;
@@ -1463,11 +1463,15 @@
style = position_style(lineStartPos, lineLen, -1);
draw_string( style|BG_ONLY_MASK, text_area.x, Y, text_area.x+text_area.w,
lineStr, lineLen );
}
+ // draw the line
style = position_style(lineStartPos, lineLen, i);
for (i=0; i<lineLen; ) {
int len = fl_utf8len(lineStr[i]);
charStyle = position_style(lineStartPos, lineLen, i);
+ // FIXME: if the character is a tab, we need to do the correct indenting
+ // FIXME: if the character is an optional hyphen, we need to ignore it
unless we wrap the text
if (charStyle!=style) {
+ // draw a segment whenever the style changes
int w = string_width( lineStr+startIndex, i-startIndex, style );
draw_string( style, startX, Y, startX+w, lineStr+startIndex,
i-startIndex );
style = charStyle;
@@ -1478,15 +1482,20 @@
}
int w = string_width( lineStr+startIndex, i-startIndex, style );
draw_string( style, startX, Y, startX+w, lineStr+startIndex, i-startIndex );
-
// clear the rest of the line
startX += w;
style = position_style(lineStartPos, lineLen, i);
draw_string( style|BG_ONLY_MASK, startX, Y, text_area.x+text_area.w,
lineStr, lineLen );
+ // free the line
+ if ( lineStr != NULL )
+ free((void *)lineStr);
return;
+
+#if 0
+
/* Step through character positions from the beginning of the line (even if
that's off the left edge of the displayed area) to find the first
character position that's not clipped, and the X coordinate for drawing
@@ -1621,6 +1630,9 @@
*/
if ( lineStr != NULL )
free((void *)lineStr);
+
+#endif
+
}
/**
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit