Fix some editor problems; still have a few bugs that need to be resolved

before 1.1.0...


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2304 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2002-06-10 21:04:20 +00:00
parent 10c613f88a
commit ddd6ab5d83
3 changed files with 20 additions and 18 deletions

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Text_Buffer.cxx,v 1.9.2.7 2002/06/09 13:35:49 easysw Exp $"
// "$Id: Fl_Text_Buffer.cxx,v 1.9.2.8 2002/06/10 21:04:19 easysw Exp $"
//
// Copyright 2001-2002 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@ -202,7 +202,7 @@ char * Fl_Text_Buffer::text_range( int start, int end ) {
** Return the character at buffer position "pos". Positions start at 0.
*/
char Fl_Text_Buffer::character( int pos ) {
if ( pos < 0 || pos > mLength )
if ( pos < 0 || pos >= mLength )
return '\0';
if ( pos < mGapStart )
return mBuf[ pos ];
@ -631,15 +631,15 @@ void Fl_Text_Buffer::add_modify_callback( Fl_Text_Modify_Cb bufModifiedCB,
newModifyProcs = new Fl_Text_Modify_Cb [ mNModifyProcs + 1 ];
newCBArgs = new void * [ mNModifyProcs + 1 ];
for ( i = 0; i < mNModifyProcs; i++ ) {
newModifyProcs[ i ] = mNodifyProcs[ i ];
newCBArgs[ i ] = mCbArgs[ i ];
newModifyProcs[ i + 1 ] = mNodifyProcs[ i ];
newCBArgs[ i + 1 ] = mCbArgs[ i ];
}
if ( mNModifyProcs != 0 ) {
delete [] mNodifyProcs;
delete [] mCbArgs;
}
newModifyProcs[ mNModifyProcs ] = bufModifiedCB;
newCBArgs[ mNModifyProcs ] = cbArg;
newModifyProcs[ 0 ] = bufModifiedCB;
newCBArgs[ 0 ] = cbArg;
mNModifyProcs++;
mNodifyProcs = newModifyProcs;
mCbArgs = newCBArgs;
@ -2284,5 +2284,5 @@ Fl_Text_Buffer::outputfile(const char *file, int start, int end, int buflen) {
//
// End of "$Id: Fl_Text_Buffer.cxx,v 1.9.2.7 2002/06/09 13:35:49 easysw Exp $".
// End of "$Id: Fl_Text_Buffer.cxx,v 1.9.2.8 2002/06/10 21:04:19 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: Fl_Text_Display.cxx,v 1.12.2.18 2002/06/09 18:28:49 easysw Exp $"
// "$Id: Fl_Text_Display.cxx,v 1.12.2.19 2002/06/10 21:04:19 easysw Exp $"
//
// Copyright 2001-2002 by Bill Spitzak and others.
// Original code Copyright Mark Edel. Permission to distribute under
@ -887,6 +887,10 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
char *outPtr;
const char *lineStr;
// printf("draw_vline(visLineNum=%d, leftClip=%d, rightClip=%d, leftCharIndex=%d, rightCharIndex=%d)\n",
// visLineNum, leftClip, rightClip, leftCharIndex, rightCharIndex);
// printf("nNVisibleLines=%d\n", mNVisibleLines);
/* If line is not displayed, skip it */
if ( visLineNum < 0 || visLineNum >= mNVisibleLines )
return;
@ -897,6 +901,7 @@ void Fl_Text_Display::draw_vline(int visLineNum, int leftClip, int rightClip,
/* Get the text, length, and buffer position of the line to display */
lineStartPos = mLineStarts[ visLineNum ];
// printf("lineStartPos=%d\n", lineStartPos);
if ( lineStartPos == -1 ) {
lineLen = 0;
lineStr = NULL;
@ -1518,7 +1523,7 @@ void Fl_Text_Display::calc_line_starts( int startLine, int endLine ) {
start of the next line in lineStarts */
for ( line = startLine; line <= endLine; line++ ) {
lineEnd = buffer()->line_end(startPos);
nextLineStart = min(buffer()->length(), lineEnd + 1);
nextLineStart = min(bufLen, lineEnd + 1);
startPos = nextLineStart;
if ( startPos >= bufLen ) {
/* If the buffer ends with a newline or line break, put
@ -1645,7 +1650,7 @@ int Fl_Text_Display::measure_vline( int visLineNum ) {
int charCount = 0, lineStartPos = mLineStarts[ visLineNum ];
char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ];
if (lineStartPos < 0) return 0;
if (lineStartPos < 0 || lineLen == 0) return 0;
if ( mStyleBuffer == NULL ) {
for ( i = 0; i < lineLen; i++ ) {
len = mBuffer->expand_character( lineStartPos + i,
@ -1959,5 +1964,5 @@ int Fl_Text_Display::handle(int event) {
//
// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.18 2002/06/09 18:28:49 easysw Exp $".
// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.19 2002/06/10 21:04:19 easysw Exp $".
//

View File

@ -1,5 +1,5 @@
//
// "$Id: editor.cxx,v 1.2.2.3.2.9 2002/06/09 18:28:49 easysw Exp $"
// "$Id: editor.cxx,v 1.2.2.3.2.10 2002/06/10 21:04:20 easysw Exp $"
//
// A simple text editor program for the Fast Light Tool Kit (FLTK).
//
@ -287,11 +287,10 @@ style_init(void) {
memset(style, 'A', textbuf->length());
style[textbuf->length()] = '\0';
if (stylebuf) delete stylebuf;
if (!stylebuf) stylebuf = new Fl_Text_Buffer(textbuf->length());
style_parse(text, style, textbuf->length());
stylebuf = new Fl_Text_Buffer(textbuf->length());
stylebuf->text(style);
delete[] style;
free(text);
@ -465,7 +464,6 @@ void load_file(char *newfile, int ipos) {
else
if (!insert) strcpy(filename, newfile);
loading = 0;
style_init();
textbuf->call_modify_callbacks();
}
@ -553,7 +551,6 @@ void new_cb(Fl_Widget*, void*) {
filename[0] = '\0';
textbuf->select(0, textbuf->length());
textbuf->remove_selection();
style_init();
changed = 0;
textbuf->call_modify_callbacks();
}
@ -740,8 +737,8 @@ Fl_Window* new_view() {
w->resizable(w->editor);
w->callback((Fl_Callback *)close_cb, w);
textbuf->add_modify_callback(changed_cb, w);
textbuf->add_modify_callback(style_update, w->editor);
textbuf->add_modify_callback(changed_cb, w);
textbuf->call_modify_callbacks();
num_windows++;
return w;
@ -761,5 +758,5 @@ int main(int argc, char **argv) {
}
//
// End of "$Id: editor.cxx,v 1.2.2.3.2.9 2002/06/09 18:28:49 easysw Exp $".
// End of "$Id: editor.cxx,v 1.2.2.3.2.10 2002/06/10 21:04:20 easysw Exp $".
//