From 35b28fafd1a9b4d9bf67d3b01cfc1da9fad59f8c Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Fri, 22 Jul 2005 20:18:56 +0000 Subject: [PATCH] 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 --- CHANGES | 2 ++ fluid/CodeEditor.cxx | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index fd4beb627..608ada8be 100644 --- a/CHANGES +++ b/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 diff --git a/fluid/CodeEditor.cxx b/fluid/CodeEditor.cxx index 7e9fa72c0..ed3ad3f8b 100644 --- a/fluid/CodeEditor.cxx +++ b/fluid/CodeEditor.cxx @@ -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();