private void UpdateResultsDisplay() { //update the display with new colors txtResults.ModifyBase(txtResults.State, btnResultsBackColor.Color); txtResults.ModifyText(txtResults.State, btnResultsForeColor.Color); // remove the tag if exists TextTag temp = txtResults.Buffer.TagTable.Lookup("highlight"); if (temp != null) { txtResults.Buffer.TagTable.Remove(temp); } // create new tag and add TextTag tag = new TextTag("highlight"); tag.BackgroundGdk = btnMatchBackColor.Color; tag.ForegroundGdk = btnMatchForeColor.Color; txtResults.Buffer.TagTable.Add(tag); // highlight match int pos = txtResults.Buffer.Text.IndexOf("match"); TextIter start = txtResults.Buffer.GetIterAtLineOffset(1, pos); TextIter end = txtResults.Buffer.GetIterAtLineOffset(1, pos + "match".Length); txtResults.Buffer.ApplyTag("highlight", start, end); }