From 0fb4feb11a8fc3cf843aeb5f6ba02cf8c0538dce Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 6 Nov 2010 00:29:58 +0000 Subject: Working on correct line wrapping in Fl_Text_Display: starting to replace all byte based charracter calculations with utf8 functions. Current version wraps, but scroll bars are wrong. Non-wrapping text display starts to work better. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7797 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Text_Buffer.cxx | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/Fl_Text_Buffer.cxx') diff --git a/src/Fl_Text_Buffer.cxx b/src/Fl_Text_Buffer.cxx index 622ccd1ee..565e6183b 100644 --- a/src/Fl_Text_Buffer.cxx +++ b/src/Fl_Text_Buffer.cxx @@ -1585,7 +1585,7 @@ int Fl_Text_Buffer::outputfile(const char *file, int start, int end, Return the previous character position. Uncode safe. */ -int Fl_Text_Buffer::prev_char(int pos) const +int Fl_Text_Buffer::prev_char_clipped(int pos) const { if (pos<=0) return 0; @@ -1601,9 +1601,21 @@ int Fl_Text_Buffer::prev_char(int pos) const return pos; } + +/* + Return the previous character poosition. + Returns -1 if the beginning of the buffer is reached. + */ +int Fl_Text_Buffer::prev_char(int pos) const +{ + if (pos==0) return -1; + return prev_char_clipped(pos); +} + + /* Return the next character position. - Uncode safe. + Returns length() if the end of the buffer is reached. */ int Fl_Text_Buffer::next_char(int pos) const { @@ -1614,6 +1626,19 @@ int Fl_Text_Buffer::next_char(int pos) const return pos; } + +/* + Return the next character poosition. + If the end of the buffer is reached, it returns the current position. + */ +int Fl_Text_Buffer::next_char_clipped(int pos) const +{ + int n = next_char(pos); + if (pos==mLength) return pos; + return n; +} + + // // End of "$Id$". // -- cgit v1.2.3