last character in CodeEditor (Fluid) would disappear under certain circumstances. The problem is two consecutive calls to Fl_Text_Buffer::insert() which first insert a newline, then indent the text by two spaces. The first 'insert' marks the text all the way to the end for redraw. The second 'insert' adds two characters, however the last character for redraw remains the previously last character, hence the very last two characters are not redrawn.
This fix changes the CodeEditor to do a single 'insert'. It would be better to change Fl_Text_Display to increment the redraw range if more characters are inserted before the actual draw is called. Since this goes too close to core code for my taste, I leave that as an exercise for 2.0. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4446 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
394ab6af40
commit
35b28fafd1
2
CHANGES
2
CHANGES
@ -2,6 +2,8 @@ CHANGES IN FLTK 1.1.7
|
||||
|
||||
- Documentation fixes (STR #648, STR #692, STR #730, STR
|
||||
#744, STR #745, STR #942)
|
||||
- Fluid Code Editor would occasionally not draw the last character
|
||||
in the buffer (STR #798)
|
||||
- Fluid Declaration private flag fixed (STR #799)
|
||||
- Fluid overlay now shows a seperate bounding box of selected
|
||||
items with correct handles and a dotted boundig box for all
|
||||
|
@ -345,8 +345,17 @@ int CodeEditor::auto_indent(int, CodeEditor* e) {
|
||||
|
||||
for (ptr = text; isspace(*ptr); ptr ++);
|
||||
*ptr = '\0';
|
||||
e->insert("\n");
|
||||
if (*text) e->insert(text);
|
||||
if (*text) {
|
||||
// use only a single 'insert' call to avoid redraw issues
|
||||
int n = strlen(text);
|
||||
char *b = (char*)malloc(n+2);
|
||||
*b = '\n';
|
||||
strcpy(b+1, text);
|
||||
e->insert(b);
|
||||
free(b);
|
||||
} else {
|
||||
e->insert("\n");
|
||||
}
|
||||
e->show_insert_position();
|
||||
e->set_changed();
|
||||
if (e->when()&FL_WHEN_CHANGED) e->do_callback();
|
||||
|
Loading…
Reference in New Issue
Block a user