Author: matt
Date: 2010-05-01 01:41:01 -0700 (Sat, 01 May 2010)
New Revision: 7578
Log:
Remove character_width function. This function was used to calculate columns
assuming that all character have a width that is a multiple of a fixed pixel
number (which is wrong).
Modified:
branches/branch-1.3-STR2158-matt/FL/Fl_Text_Buffer.H
branches/branch-1.3-STR2158-matt/src/Fl_Text_Buffer.cxx
branches/branch-1.3-STR2158-matt/src/Fl_Text_Display.cxx
Modified: branches/branch-1.3-STR2158-matt/FL/Fl_Text_Buffer.H
===================================================================
--- branches/branch-1.3-STR2158-matt/FL/Fl_Text_Buffer.H 2010-05-01
08:36:19 UTC (rev 7577)
+++ branches/branch-1.3-STR2158-matt/FL/Fl_Text_Buffer.H 2010-05-01
08:41:01 UTC (rev 7578)
@@ -537,16 +537,6 @@
int word_end(int pos) const;
/**
- Return the length in displayed characters of character \p c expanded
- for display (as discussed above in expand_character() ).
- \param src address of utf-8 text
- \param indent
- \param tabDist
- \return number of byte in substitution
- */
- static int character_width(const char *src, int indent, int tabDist);
-
- /**
Count the number of displayed characters between buffer position
\p lineStartPos and \p targetPos. (displayed characters are the characters
shown on the screen to represent characters in the buffer, where tabs and
Modified: branches/branch-1.3-STR2158-matt/src/Fl_Text_Buffer.cxx
===================================================================
--- branches/branch-1.3-STR2158-matt/src/Fl_Text_Buffer.cxx 2010-05-01
08:36:19 UTC (rev 7577)
+++ branches/branch-1.3-STR2158-matt/src/Fl_Text_Buffer.cxx 2010-05-01
08:41:01 UTC (rev 7578)
@@ -673,32 +673,6 @@
}
-// This function takes a character and optionally converts it into a little
-// string which will replace the character on screen. This function returns
-// the number of bytes in the replacement string, but *not* the number of
-// bytes in the original character!
-// - unicode ok
-int Fl_Text_Buffer::character_width(const char *src, int indent, int tabDist)
-{
- return 1;
- // FIXME: this is only useful if all characters have the same pixel width.
This function must be replaced.
- char c = *src;
- if ((c & 0x80) && (c & 0x40)) { // first byte of UTF-8 sequence
- int len = fl_utf8len(c);
- int ret = 0;
- unsigned int ucs = fl_utf8decode(src, src+len, &ret);
- int width = fl_wcwidth_(ucs); // FIXME
- // fprintf(stderr, "mk_wcwidth(%x) -> %d (%d, %d, %s)\n", ucs, width, len,
ret, src);
- return width;
- }
- if ((c & 0x80) && !(c & 0x40)) { // other byte of UTF-8 sequence
- return 0;
- }
- return 1; // FIXME: ouch!
- //return character_width(c, indent, tabDist);
-}
-
-
int Fl_Text_Buffer::count_displayed_characters(int lineStartPos,
int targetPos) const
{
@@ -726,7 +700,7 @@
char c = *src;
if (c == '\n')
return pos;
- charCount += character_width(src, charCount, mTabDist);
+ charCount++;
pos += fl_utf8len(c);
}
return pos;
Modified: branches/branch-1.3-STR2158-matt/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3-STR2158-matt/src/Fl_Text_Display.cxx 2010-05-01
08:36:19 UTC (rev 7577)
+++ branches/branch-1.3-STR2158-matt/src/Fl_Text_Display.cxx 2010-05-01
08:41:01 UTC (rev 7578)
@@ -631,7 +631,7 @@
startIndent = mBuffer->count_displayed_characters( lineStart, startPos );
indent = startIndent;
for ( c = text; *c != '\0'; c++ )
- indent += Fl_Text_Buffer::character_width( c, indent, buf->tab_distance()
);
+ indent++;
endIndent = indent;
/* find which characters to remove, and if necessary generate additional
@@ -644,8 +644,7 @@
ch = buf->at( p );
if ( ch == '\n' )
break;
- const char *s = buf->address(p);
- indent += Fl_Text_Buffer::character_width(s, indent, buf->tab_distance()
); // FIXME: not unicode
+ indent++;
if ( indent == endIndent ) {
p++;
break;
@@ -2545,7 +2544,7 @@
int lineStart, newLineStart = 0, b, p, colNum, wrapMargin;
int maxWidth, i, foundBreak, width;
bool countPixels;
- int nLines = 0, tabDist = buffer()->tab_distance();
+ int nLines = 0;
unsigned char c;
/* If the font is fixed, or there's a wrap margin set, it's more efficient
@@ -2603,7 +2602,7 @@
width = 0;
} else {
const char *s = buf->address(p);
- colNum += Fl_Text_Buffer::character_width(s, colNum, tabDist); //
FIXME: unicode
+ colNum++;
if (countPixels)
width += measure_proportional_character(s, colNum,
p+styleBufOffset);
}
@@ -2636,7 +2635,7 @@
if (!foundBreak) { /* no whitespace, just break at margin */
newLineStart = max(p, lineStart+1);
const char *s = buf->address(b);
- colNum = Fl_Text_Buffer::character_width(s, colNum, tabDist); //
FIXME: unicode
+ colNum++;
if (countPixels)
width = measure_proportional_character(s, colNum,
p+styleBufOffset);
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit