diff options
Diffstat (limited to 'src/Fl_Text_Display.cxx')
-rw-r--r-- | src/Fl_Text_Display.cxx | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index 21a68a4..0d6c9da 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -1,7 +1,7 @@ // -// "$Id: Fl_Text_Display.cxx,v 1.12.2.46 2003/08/24 13:09:06 easysw Exp $" +// "$Id: Fl_Text_Display.cxx,v 1.12.2.51 2004/04/11 04:38:58 easysw Exp $" // -// Copyright 2001-2003 by Bill Spitzak and others. +// Copyright 2001-2004 by Bill Spitzak and others. // Original code Copyright Mark Edel. Permission to distribute under // the LGPL for the FLTK library granted by Mark Edel. // @@ -143,7 +143,10 @@ Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l) ** freed, nor are the style buffer or style table. */ Fl_Text_Display::~Fl_Text_Display() { - if (mBuffer) mBuffer->remove_modify_callback(buffer_modified_cb, this); + if (mBuffer) { + mBuffer->remove_modify_callback(buffer_modified_cb, this); + mBuffer->remove_predelete_callback(buffer_predelete_cb, this); + } if (mLineStarts) delete[] mLineStarts; } @@ -153,6 +156,7 @@ Fl_Text_Display::~Fl_Text_Display() { void Fl_Text_Display::buffer( Fl_Text_Buffer *buf ) { /* If the text display is already displaying a buffer, clear it off of the display and remove our callback from it */ + if ( buf == mBuffer) return; if ( mBuffer != 0 ) { buffer_modified_cb( 0, 0, mBuffer->length(), 0, 0, this ); mBuffer->remove_modify_callback( buffer_modified_cb, this ); @@ -162,11 +166,13 @@ void Fl_Text_Display::buffer( Fl_Text_Buffer *buf ) { /* Add the buffer to the display, and attach a callback to the buffer for receiving modification information when the buffer contents change */ mBuffer = buf; - mBuffer->add_modify_callback( buffer_modified_cb, this ); - mBuffer->add_predelete_callback( buffer_predelete_cb, this ); + if (mBuffer) { + mBuffer->add_modify_callback( buffer_modified_cb, this ); + mBuffer->add_predelete_callback( buffer_predelete_cb, this ); - /* Update the display */ - buffer_modified_cb( 0, buf->length(), 0, 0, 0, this ); + /* Update the display */ + buffer_modified_cb( 0, buf->length(), 0, 0, 0, this ); + } /* Resize the widget to update the screen... */ resize(x(), y(), w(), h()); @@ -1580,13 +1586,15 @@ void Fl_Text_Display::draw_string( int style, int X, int Y, int toX, font = styleRec->font; fsize = styleRec->size; - if ( style & (HIGHLIGHT_MASK | PRIMARY_MASK) && Fl::focus() == this) { - background = selection_color(); + if (style & (HIGHLIGHT_MASK | PRIMARY_MASK)) { + if (Fl::focus() == this) background = selection_color(); + else background = fl_color_average(color(), selection_color(), 0.5f); } else background = color(); foreground = fl_contrast(styleRec->color, background); - } else if ( style & (HIGHLIGHT_MASK | PRIMARY_MASK) && Fl::focus() == this ) { - background = selection_color(); + } else if (style & (HIGHLIGHT_MASK | PRIMARY_MASK)) { + if (Fl::focus() == this) background = selection_color(); + else background = fl_color_average(color(), selection_color(), 0.5f); foreground = fl_contrast(textcolor(), background); } else { foreground = textcolor(); @@ -1744,7 +1752,7 @@ int Fl_Text_Display::position_style( int lineStartPos, style = FILL_MASK; else if ( styleBuf != NULL ) { style = ( unsigned char ) styleBuf->character( pos ); - if (style == mUnfinishedStyle) { + if (style == mUnfinishedStyle && mUnfinishedHighlightCB) { /* encountered "unfinished" style, trigger parsing */ (mUnfinishedHighlightCB)( pos, mHighlightCBArg); style = (unsigned char) styleBuf->character( pos); @@ -2700,7 +2708,7 @@ int Fl_Text_Display::measure_proportional_character(char c, int colNum, int pos) style = 0; } else { style = (unsigned char)styleBuf->character(pos); - if (style == mUnfinishedStyle) { + if (style == mUnfinishedStyle && mUnfinishedHighlightCB) { /* encountered "unfinished" style, trigger parsing */ (mUnfinishedHighlightCB)(pos, mHighlightCBArg); style = (unsigned char)styleBuf->character(pos); @@ -2978,7 +2986,7 @@ int Fl_Text_Display::handle(int event) { case FL_LEAVE: case FL_HIDE: - if (active_r()) { + if (active_r() && window()) { window()->cursor(FL_CURSOR_DEFAULT); return 1; @@ -3058,5 +3066,5 @@ int Fl_Text_Display::handle(int event) { // -// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.46 2003/08/24 13:09:06 easysw Exp $". +// End of "$Id: Fl_Text_Display.cxx,v 1.12.2.51 2004/04/11 04:38:58 easysw Exp $". // |