summaryrefslogtreecommitdiff
path: root/src/Fl_Text_Buffer.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-11-06 00:29:58 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-11-06 00:29:58 +0000
commit0fb4feb11a8fc3cf843aeb5f6ba02cf8c0538dce (patch)
treee7ec5bd0f3ba01e973e1d4d724fc26cc469f181d /src/Fl_Text_Buffer.cxx
parent5027ca90d3492c73af556feb0c5dcf67025b69ad (diff)
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
Diffstat (limited to 'src/Fl_Text_Buffer.cxx')
-rw-r--r--src/Fl_Text_Buffer.cxx29
1 files changed, 27 insertions, 2 deletions
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$".
//