--- Fl_Text_Display.cxx.old	2012-05-07 15:47:12.308490700 +1000
+++ Fl_Text_Display.cxx.new	2012-05-07 09:47:15.292969576 +1000
@@ -80,8 +80,22 @@
  \param X, Y, W, H position and size of widget
  \param l label text, defaults to none
  */
+
+
 Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H, const char* l)
 : Fl_Group(X, Y, W, H, l) {
+#if FLTK_ABI_VERSION >= 10302
+  init(FL_BACKGROUND2_COLOR, FL_SELECTION_COLOR);
+}
+
+Fl_Text_Display::Fl_Text_Display(int X, int Y, int W, int H,
+		Fl_Color background, Fl_Color selection, const char* l)
+: Fl_Group(X, Y, W, H, l) {
+  init(background,selection);
+}
+
+void Fl_Text_Display::init(Fl_Color background, Fl_Color selection) {
+#endif
   int i;
 
   mMaxsize = 0;
@@ -92,7 +106,11 @@
   display_insert_position_hint = 0;
   shortcut_ = 0;
 
+#if FLTK_ABI_VERSION >= 10302
+  color(background,selection);
+#else 
   color(FL_BACKGROUND2_COLOR, FL_SELECTION_COLOR);
+#endif
   box(FL_DOWN_FRAME);
   textsize(FL_NORMAL_SIZE);
   textcolor(FL_FOREGROUND_COLOR);
@@ -152,6 +170,9 @@
   mContinuousWrap = 0;
   mWrapMarginPix = 0;
   mSuppressResync = mNLinesDeleted = mModifyingTabDistance = 0;
+#if FLTK_ABI_VERSION >= 10302
+  mIsHighlightBG = false;
+#endif
 }
 
 
@@ -250,11 +271,23 @@
   mUnfinishedHighlightCB = unfinishedHighlightCB;
   mHighlightCBArg = cbArg;
   mColumnScale = 0;
+  mIsHighlightBG = false;
 
   mStyleBuffer->canUndo(0);
   damage(FL_DAMAGE_EXPOSE);
 }
 
+#if FLTK_ABI_VERSION >= 10302
+void Fl_Text_Display::highlight_data_BG(Fl_Text_Buffer *styleBuffer,
+                                     const Style_Table_Entry *styleTable,
+                                     int nStyles, char unfinishedStyle,
+                                     Unfinished_Style_Cb unfinishedHighlightCB,
+                                     void *cbArg ) {
+  highlight_data(styleBuffer,styleTable,nStyles,
+  				unfinishedStyle,unfinishedHighlightCB,cbArg);
+  mIsHighlightBG = true;
+}  
+#endif
 
 
 /**
@@ -1911,6 +1944,51 @@
  \param string text if this is a drawing operation
  \param nChars number of characters to draw
  */
+/*
+#if FLTK_ABI_VERSION >= 10302
+// 
+//  a private function used by draw_string to save space  
+//  but as I can see saving time is more important so dont use it
+// 
+bool Fl_Text_Display::changedBackground(	Fl_Color& pBackground,
+				Fl_Color pSelection,int pStyle) const
+{
+bool lBackgroundChanged = true; 				
+bool lFocusUs = (Fl::focus() == (Fl_Widget*)this) ? true : false; 				
+  if (pStyle & PRIMARY_MASK)
+  {
+    if (lFocusUs)
+    {
+      pBackground = pSelection;
+    }	
+    else 
+    {
+      pBackground = fl_color_average(pBackground,pSelection, 0.4f);
+    }	
+  } 
+  else
+  {				
+    if (pStyle & HIGHLIGHT_MASK)
+    {
+      if (lFocusUs)
+      {
+        pBackground = fl_color_average(pBackground,pSelection, 0.5f);
+      }	
+      else 
+      {
+        pBackground = fl_color_average(pBackground,pSelection, 0.6f);
+      }
+    }  
+    else
+    {
+      lBackgroundChanged = false; 				
+    }
+  }
+  return lBackgroundChanged; 
+}
+#endif
+*/
+
 void Fl_Text_Display::draw_string(int style,
                                   int X, int Y, int toX,
                                   const char *string, int nChars) const {
@@ -1932,6 +2010,52 @@
   Fl_Font font = textfont();
   int fsize = textsize();
   Fl_Color foreground;
+#if FLTK_ABI_VERSION >= 10302
+  bool lDoUnderScore,lDoStrikeThru; lDoUnderScore = lDoStrikeThru = false;
+  Fl_Color background = color(); // set background
+  Fl_Color selection  = selection_color();
+  if ( style & STYLE_LOOKUP_MASK ) {
+    int si = (style & STYLE_LOOKUP_MASK) - 'A';
+    if (si < 0) si = 0;
+    else if (si >= mNStyles) si = mNStyles - 1;
+
+    styleRec = mStyleTable + si;
+    font  = styleRec->font;
+    fsize = styleRec->size;
+    if (mIsHighlightBG) {				
+    	background = styleRec->color_BG; // now using color_BG;
+    	int lAttr = styleRec->attr;
+    	lDoUnderScore = lAttr & STYLE_TABLE_ATTR_UNDERSCORE;
+    	lDoStrikeThru = lAttr & STYLE_TABLE_ATTR_STRIKETHRU;
+    }	
+    // background already set
+    if (style & PRIMARY_MASK) {
+      if (Fl::focus() == (Fl_Widget*)this) {background = selection;}	
+      else {background = fl_color_average(background,selection, 0.4f);}	
+    } else {				
+      if (style & HIGHLIGHT_MASK) {
+        if (Fl::focus() == (Fl_Widget*)this)
+        		 {background = fl_color_average(background,selection, 0.5f);}	
+        else {background = fl_color_average(background,selection, 0.6f);}
+      }  
+    }
+    foreground = fl_contrast(styleRec->color, background);
+  } else {				
+    if (style & PRIMARY_MASK) {
+      if (Fl::focus() == (Fl_Widget*)this) {background = selection;}	
+      else {background = fl_color_average(background,selection, 0.4f);}	
+      foreground = fl_contrast(textcolor(), background);
+    } else {				
+      if (style & HIGHLIGHT_MASK) {
+        if (Fl::focus() == (Fl_Widget*)this)
+        		 {background = fl_color_average(background,selection, 0.5f);}	
+        else {background = fl_color_average(background,selection, 0.6f);}
+        foreground = fl_contrast(textcolor(), background);
+      }  
+      else {foreground = textcolor();} // background already set
+    }
+  }  
+#else 
   Fl_Color background;
 
   if ( style & STYLE_LOOKUP_MASK ) {
@@ -1963,6 +2087,7 @@
     foreground = textcolor();
     background = color();
   }
+#endif
 
   if (!(style & TEXT_ONLY_MASK)) {
     fl_color( background );
@@ -1976,6 +2101,20 @@
     fl_push_clip(X, Y, toX - X, mMaxsize);
 #endif
     fl_draw( string, nChars, X, Y + mMaxsize - fl_descent());
+#if FLTK_ABI_VERSION >= 10302
+    if (lDoUnderScore || lDoStrikeThru) {
+      int YY = Y + mMaxsize - fl_descent();
+    	int X2,Y2; position_to_xy(xy_to_position(X,Y,CHARACTER_POS) + nChars,&X2,&Y2); 
+			if (lDoUnderScore) {
+				fl_line(X,YY,X2-1,YY);
+			}
+			if (lDoStrikeThru) {
+		  // try to hit centre of text 2 below (trial and error) seemed best fit
+				YY -= (((unsigned int)(fsize) >> 1) - 2); 
+				fl_line(X,YY,X2-1,YY);
+			}
+    }
+#endif
 #if !(defined(__APPLE__) || defined(WIN32)) && USE_XFT
     fl_pop_clip();
 #endif
