Exemplo n.º 1
0
        private static void ScintillaNet_InsertCheck(object sender, InsertCheckEventArgs e)
        {
            DocumentView documentView = ((MainWindow)App.Current.MainWindow).ActiveDocument;

            if (documentView == null)
            {
                return;
            }

            ScintillaNET.WPF.ScintillaWPF scintilla = documentView.scintilla;
            var currentPos = scintilla.CurrentPosition;

            if (e.Text == "\u0013")
            {
                e.Text = string.Empty;
                return;
            }

            if ((e.Text.EndsWith("\r") || e.Text.EndsWith("\n")))
            {
                var curLine     = scintilla.LineFromPosition(e.Position);
                var curLineText = scintilla.Lines[curLine].Text.Replace("\r", "").Replace("\n", "");

                var indent = Regex.Match(curLineText, @"^\s*");
                e.Text += indent.Value;

                if (Regex.IsMatch(curLineText, @"{\s*$"))
                {
                    e.Text += '\t';
                }
            }
        }
Exemplo n.º 2
0
        private static void TextArea_MarginClick(object sender, MarginClickEventArgs e)
        {
            ScintillaNET.WPF.ScintillaWPF scintilla = ((MainWindow)App.Current.MainWindow).ActiveDocument.scintilla;

            if (e.Margin == ScintillaConstants.BREAKPOINT_MARGIN)
            {
                const uint mask = (1 << ScintillaConstants.BREAKPOINT_MARKER);
                Line       line = scintilla.Lines[scintilla.LineFromPosition(e.Position)];

                scintilla.IndicatorCurrent = ScintillaConstants.BREAKPOINT_INDICATOR;
                if ((line.MarkerGet() & mask) > 0)
                {
                    line.MarkerDelete(ScintillaConstants.BREAKPOINT_MARKER);
                    line.MarkerDelete(ScintillaConstants.BREAKPOINT_BG);
                    scintilla.IndicatorClearRange(line.Position, line.Length);
                }
                else
                {
                    int breakPointStartPosition, breakPointHighlightLength;
                    if (ScintillaBreakPointValidator.IsBreakPointAllowed(scintilla, line, out breakPointStartPosition, out breakPointHighlightLength))
                    {
                        line.MarkerAdd(ScintillaConstants.BREAKPOINT_MARKER);
                        scintilla.IndicatorFillRange(breakPointStartPosition, breakPointHighlightLength);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void TextArea_MarginClick(object sender, MarginClickEventArgs e)
        {
            ScintillaNET.WPF.ScintillaWPF TextArea = ActiveDocument.Scintilla;

            if (e.Margin == BOOKMARK_MARGIN)
            {
                // Do we have a marker for this line?
                const uint mask = (1 << BOOKMARK_MARKER);
                var        line = TextArea.Lines[TextArea.LineFromPosition(e.Position)];
                if ((line.MarkerGet() & mask) > 0)
                {
                    // Remove existing bookmark
                    line.MarkerDelete(BOOKMARK_MARKER);
                }
                else
                {
                    // Add bookmark
                    line.MarkerAdd(BOOKMARK_MARKER);
                }
            }
        }