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
This commit is contained in:
Matthias Melcher
2010-11-06 00:29:58 +00:00
parent 5027ca90d3
commit 0fb4feb11a
4 changed files with 157 additions and 126 deletions
+2
View File
@@ -713,6 +713,7 @@ public:
\param ix index to the current char
*/
int prev_char(int ix) const;
int prev_char_clipped(int ix) const;
/**
Returns a pointer to the previous character.
@@ -726,6 +727,7 @@ public:
\param ix index to the current char
*/
int next_char(int ix) const;
int next_char_clipped(int ix) const;
/**
Returns a pointer to the next character.
+27 -2
View File
@@ -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$".
//
+127 -123
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -785,7 +785,7 @@ Fl_Window* new_view() {
Fl_Menu_Bar* m = new Fl_Menu_Bar(0, 0, 660, 30);
m->copy(menuitems, w);
w->editor = new Fl_Text_Editor(0, 30, 660, 370);
w->editor->wrap_mode(1, 32);
//w->editor->wrap_mode(1, 32);
w->editor->textfont(FL_COURIER);
w->editor->textsize(TS);
w->editor->buffer(textbuf);