Ejemplo n.º 1
0
 /// <summary>
 /// Uncomments selected lines or current line if range has zero length.
 /// Only removes single comment. ### -> ## -> # and so on. Matches C# behavior.
 /// </summary>
 public static void UncommentBlock(IEditorView editorView, IEditorBuffer editorBuffer, ITextRange range, IEditorSupport es)
 {
     DoActionOnLines(editorView, editorBuffer, range, es, UncommentLine, Resources.UncommentSelection);
 }
Ejemplo n.º 2
0
        public static void DoActionOnLines(IEditorView editorView, IEditorBuffer editorBuffer, ITextRange range, IEditorSupport es, Func <IEditorLine, bool> action, string actionName)
        {
            // When user clicks editor margin to select a line, selection actually
            // ends in the beginning of the next line. In order to prevent commenting
            // of the next line that user did not select, we need to shrink span to
            // format and exclude the trailing line break.

            var snapshot = editorBuffer.CurrentSnapshot;
            var line     = snapshot.GetLineFromPosition(range.End);

            int start = range.Start;
            int end   = range.End;

            if (line.Start == range.End && range.Length > 0)
            {
                if (line.LineNumber > 0)
                {
                    line  = snapshot.GetLineFromLineNumber(line.LineNumber - 1);
                    end   = line.End;
                    start = Math.Min(start, end);
                }
            }

            int startLineNumber = editorBuffer.CurrentSnapshot.GetLineNumberFromPosition(start);
            int endLineNumber   = editorBuffer.CurrentSnapshot.GetLineNumberFromPosition(end);

            using (var undoAction = es.CreateUndoAction(editorView)) {
                undoAction.Open(actionName);
                bool changed = false;
                for (int i = startLineNumber; i <= endLineNumber; i++)
                {
                    line     = editorBuffer.CurrentSnapshot.GetLineFromLineNumber(i);
                    changed |= action(line);
                }
                if (changed)
                {
                    undoAction.Commit();
                }
            }
        }
Ejemplo n.º 3
0
 public SourceCodeEditor() : base()
 {
     syntaxController           = this.CreateSyntaxHighlighter();
     this.FCTB.CurrentLineColor = System.Drawing.Color.Khaki;
 }