protected String GetTTText(String strLine, int iChar) { //==================================================================== // Look for controlled lines first RegexTag retLine = GetLineTag(strLine); if (retLine != null) { if (retLine.ToolTip) { return(retLine.Comment); } return(String.Empty); } // Now look through the rest foreach (RegexTag ret in Tags) { if (ret.ToolTip && !ret.ControlsWholeLine) { foreach (Match m in ret.MatchesIn(strLine)) { if (m.Index <= iChar && m.Index + m.Length >= iChar) { return(ret.Comment); } } } } return(String.Empty); }
private void SetLineToTag(int iLine, RegexTag ret) { //==================================================================== SelectBackBufferLine(iLine); rtfBackBuffer.SelectionFont = ret.Font; rtfBackBuffer.SelectionColor = ret.ForeColor; rtfBackBuffer.SelectionBackColor = ret.BackColor; return; }
private void SetMatchToTag(int iLine, Match m, RegexTag ret) { //==================================================================== rtfBackBuffer.SelectionStart = GetFirstCharIndexFromLine(iLine) + m.Index; rtfBackBuffer.SelectionLength = m.Length; rtfBackBuffer.SelectionFont = ret.Font; rtfBackBuffer.SelectionColor = ret.ForeColor; rtfBackBuffer.SelectionBackColor = ret.BackColor; return; }
public void RescanTags() { //==================================================================== if (_bInRescan) { return; // Preventing an infinite loop when we're called by OnChange and then change the text } // Reset the text, re-run the regexes, and re-apply the regex settings int iSelStart = SelectionStart; int iSelLen = SelectionLength; rtfBackBuffer.Rtf = Rtf; for (int i = 0; i < Lines.Length; i += 1) { RegexTag retLine = GetLineTag(Lines[i]); if (null != retLine) { SetLineToTag(i, retLine); } else { SelectBackBufferLine(i); rtfBackBuffer.SelectionFont = Font; rtfBackBuffer.SelectionBackColor = BackColor; rtfBackBuffer.SelectionColor = ForeColor; // So, do any of the non-line tags match any parts? foreach (RegexTag ret in Tags) { if (!ret.ControlsWholeLine && ret.Enabled) { foreach (Match m in ret.MatchesIn(Lines[i])) { SetMatchToTag(i, m, ret); } // Loop over matches } // Not a whole-line tag } // Loop over tags } // Not a line controlled by a tag } // Loop over lines // Prevent exceptions from leaving this flag stranded _bInRescan = true; try { Rtf = rtfBackBuffer.Rtf; SelectionStart = iSelStart; SelectionLength = iSelLen; } finally { _bInRescan = false; } return; }