From f560b71b0ab48a2a46ead14d9466a541cf43f2d1 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 27 Nov 2010 21:15:52 +0000 Subject: Fixed Fl_Text_Display Tabulator calculations (STR #2450) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7897 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Text_Display.cxx | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index cd3ff4e67..e22f89710 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -25,10 +25,6 @@ // http://www.fltk.org/str.php // -// TODO: fix all fixme's and todo's -// TODO: blinking selection when moving mouse outside of widget area -// TODO: line wrapping - scroll bars -// TODO: rendering of the Tab character // TODO: rendering of the "optional hyphen" // TODO: make line numbering work again @@ -1744,6 +1740,7 @@ int Fl_Text_Display::handle_vline( for (i=0; inext_char(b); colNum = 0; width = 0; - // TODO: we should have a much more efficient function already available! int iMax = buf->next_char(p); for (i=buf->next_char(b); inext_char(i)) { - width += measure_proportional_character(buf->address(i), colNum, + width += measure_proportional_character(buf->address(i), width, i+styleBufOffset); colNum++; } @@ -3165,7 +3141,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos, newLineStart = max(p, buf->next_char(lineStart)); const char *s = buf->address(b); colNum++; - width = measure_proportional_character(s, colNum, p+styleBufOffset); + width = measure_proportional_character(s, 0, p+styleBufOffset); } if (p >= maxPos) { *retPos = maxPos; @@ -3214,13 +3190,18 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos, should now be solid because they are now used for online help display. \param s text string - \param colNum unused + \param xPix x pixel position needed for calculating tab widths \param pos offset within string \return width of character in pixels */ -double Fl_Text_Display::measure_proportional_character(const char *s, int colNum, int pos) const { +double Fl_Text_Display::measure_proportional_character(const char *s, int xPix, int pos) const { IS_UTF8_ALIGNED(s) + if (*s=='\t') { + int tab = col_to_x(8); + return (((xPix/tab)+1)*tab) - xPix; + } + int charLen = fl_utf8len(*s), style = 0; if (mStyleBuffer) { style = mStyleBuffer->byte_at(pos); -- cgit v1.2.3