private void TextArea_CharAdded(object sender, ScintillaNET.CharAddedEventArgs e) { char cc = (char)TextArea.GetCharAt(TextArea.CurrentPosition - 1); switch (AutoCompleteVer) { case 1: if (cc != '\r' && cc != '\n' && cc != '\t') { TextArea.AutoCShow(0, AutoCompletev1); } break; case 2: if (cc != '\r' && cc != '\n' && cc != '\t') { TextArea.AutoCShow(0, AutoCompletev2); } break; case 3: if (cc != '\r' && cc != '\n' && cc != '\t') { TextArea.AutoCShow(0, AutoCompletevB); } break; } }
public override void Highlight(ScintillaNET.Scintilla sci, int start, int end, AppSettings s) { bool startsWithNL = sci.GetCharAt(start) == '\n' || (start + 1 < sci.TextLength && sci.GetCharAt(start) == '\r' && sci.GetCharAt(start + 1) == '\n'); bool endsWithNL = sci.GetCharAt(end) == '\n' || (end - 1 >= 0 && sci.GetCharAt(end - 1) == '\n'); // move back to start of line if (!startsWithNL) { for (int i = 0; i < MAX_BACKTRACE && start > 0; i++, start--) { if (start > 0 && sci.GetCharAt(start - 1) == '\n') { break; } } } // move forward to end of line if (!endsWithNL) { for (int i = 0; i < MAX_FORWARDTRACE && end < sci.TextLength; i++, end++) { if (end >= sci.TextLength || sci.GetCharAt(end) == '\n') { break; } } } var text = sci.GetTextRange(start, end - start); if (s.LinkMode != LinkHighlightMode.Disabled) { LinkHighlight(sci, start, text); } else { sci.StartStyling(start); sci.SetStyling(end - start, STYLE_DEFAULT); } }
public override void Highlight(ScintillaNET.Scintilla sci, int istart, int iend, AppSettings s) { // http://spec.commonmark.org/0.28/ int visualStart = istart; for (; visualStart > 0; visualStart--) { if (visualStart > 0 && sci.GetCharAt(visualStart - 1) == '\n') { break; } } int visualEnd = iend; var fulltext = sci.Text; var maxLen = fulltext.Length; var start = 0; var active = false; var smode = ParserSuperMode.None; for (;;) { var lineEnd = Math.Min(start + 1, maxLen); while (lineEnd < maxLen && sci.GetCharAt(lineEnd) != '\n') { lineEnd++; } if (lineEnd < maxLen) { lineEnd++; } var text = fulltext.Substring(start, lineEnd - start); var isTildeFence = text.Trim().StartsWith("~~~"); var isTickFence = text.Trim().StartsWith("```"); bool resetFenceBlock = false; if (smode == ParserSuperMode.None && isTildeFence) { smode = ParserSuperMode.FencedTildeBlock; } else if (smode == ParserSuperMode.FencedTildeBlock && isTildeFence) { resetFenceBlock = true; } else if (smode == ParserSuperMode.None && isTickFence) { smode = ParserSuperMode.FencedBacktickBlock; } else if (smode == ParserSuperMode.FencedBacktickBlock && isTickFence) { resetFenceBlock = true; } if (!active && visualStart < lineEnd) { sci.StartStyling(start); active = true; } if (active) { if (smode == ParserSuperMode.FencedBacktickBlock || smode == ParserSuperMode.FencedTildeBlock) { HighlightFencedLine(sci, text); } else if (smode == ParserSuperMode.None) { HighlightLine(sci, text, s); } } if (resetFenceBlock) { smode = ParserSuperMode.None; } if (lineEnd >= visualEnd) { return; } start = lineEnd; } }