public FoldingManagerAdapter(ITextEditor textEditor) { AvalonEditTextEditorAdapter adaptor = textEditor as AvalonEditTextEditorAdapter; if (adaptor != null) { this.foldingManager = FoldingManager.Install(adaptor.TextEditor.TextArea); } }
public void InterfaceEndSub() { string code = "Public Interface Foo\r\n" + "\tPublic Sub Bar\r\n" + "\r\n" + // This extra new line is required. This is the new line just entered by the user. "End Interface"; string bar = "Sub Bar\r\n"; int cursorOffset = code.IndexOf(bar) + bar.Length; string expectedCode = "Public Interface Foo\r\n" + "\tPublic Sub Bar\r\n" + "\t\r\n" + "End Interface"; int expectedOffset = ("Public Interface Foo\r\n" + "\tPublic Sub Bar\r\n" + "\t").Length; AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor()); editor.Document.Text = code; editor.Caret.Offset = cursorOffset; VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy(); formattingStrategy.FormatLine(editor, '\n'); Assert.AreEqual(expectedCode, editor.Document.Text); Assert.AreEqual(expectedOffset, editor.Caret.Offset); }
static ITextEditorOptions GetTextEditorOptions() { ICSharpCode.AvalonEdit.TextEditor editor = new ICSharpCode.AvalonEdit.TextEditor(); AvalonEditTextEditorAdapter adapter = new AvalonEditTextEditorAdapter(editor); return(adapter.Options); }
void RemoveExistingFoldingManager(AvalonEditTextEditorAdapter textEditorAdapter) { var existingFoldingManager = textEditorAdapter.TextEditor.TextArea.GetService(typeof(FoldingManager)) as FoldingManager; if (existingFoldingManager != null) { FoldingManager.Uninstall(existingFoldingManager); } }
public void GetWordBeforeCaretExtendedTest1() { ITextEditor editor = new AvalonEditTextEditorAdapter(new AvalonEdit.TextEditor()); editor.Document.Text = "<Test />"; editor.Caret.Offset = 6; string text = editor.GetWordBeforeCaretExtended(); Assert.AreEqual(string.Empty, text); }
void RunTest(string code, int cursorOffset, string expectedCode, int expectedOffset, char keyPressed) { AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor()); editor.Document.Text = code; editor.Caret.Offset = cursorOffset; VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy(); formattingStrategy.FormatLine(editor, keyPressed); Assert.AreEqual(expectedCode, editor.Document.Text); Assert.AreEqual(expectedOffset, editor.Caret.Offset); }
public void GetWordBeforeCaretExtendedTest3() { ITextEditor editor = new AvalonEditTextEditorAdapter(new AvalonEdit.TextEditor()); editor.Document.Text = "<Test value=\"\" />"; editor.Caret.Offset = 14; string text = editor.GetWordBeforeCaretExtended(); Assert.AreEqual(string.Empty, text); }
void CreatePythonFormattingStrategy() { MockTextEditorOptions textEditorOptions = new MockTextEditorOptions(); textEditorOptions.IndentationSize = 4; textEditor = new TextEditor(); textEditor.Options = textEditorOptions; textEditorAdapter = new AvalonEditTextEditorAdapter(textEditor); formattingStrategy = new PythonFormattingStrategy(); }
void RunFormatTest(string code, string expectedCode) { AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor()); editor.Document.Text = code; VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy(); formattingStrategy.IndentLines(editor, 1, editor.Document.TotalNumberOfLines); Console.WriteLine(editor.Document.Text); Assert.AreEqual(expectedCode, editor.Document.Text); }
void CreateTextEditor() { if (textEditorHost != null) { return; } textEditor = AvalonEditTextEditorAdapter.CreateAvalonEditInstance(); textEditor.IsReadOnly = true; textEditor.MouseDoubleClick += TextEditorDoubleClick; textEditorHost = new ElementHost(); textEditorHost.Dock = DockStyle.Fill; textEditorHost.Child = textEditor; }
/// <summary> /// Checks that when the user presses the return key after the Operator line that the /// expected code is generated. /// </summary> void RunFormatLineTest(string code, string expectedCode, int expectedOffset) { string foo = "As Foo\r\n"; int cursorOffset = code.IndexOf(foo) + foo.Length; AvalonEditTextEditorAdapter editor = new AvalonEditTextEditorAdapter(new TextEditor()); editor.Document.Text = code; editor.Caret.Offset = cursorOffset; VBNetFormattingStrategy formattingStrategy = new VBNetFormattingStrategy(); formattingStrategy.FormatLine(editor, '\n'); Assert.AreEqual(expectedCode, editor.Document.Text); Assert.AreEqual(expectedOffset, editor.Caret.Offset); }
void CreateTextEditor() { if (textEditorHost != null) { return; } textEditor = AvalonEditTextEditorAdapter.CreateAvalonEditInstance(); textEditor.IsReadOnly = true; textEditor.MouseDoubleClick += TextEditorDoubleClick; var adapter = new AvalonEditTextEditorAdapter(textEditor); var textMarkerService = new TextMarkerService(adapter.TextEditor.Document); adapter.TextEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService); adapter.TextEditor.TextArea.TextView.LineTransformers.Add(textMarkerService); adapter.TextEditor.TextArea.TextView.Services.AddService(typeof(ITextMarkerService), textMarkerService); textEditorHost = new ElementHost(); textEditorHost.Dock = DockStyle.Fill; textEditorHost.Child = textEditor; }
static ITextEditorOptions GetTextEditorOptions() { ICSharpCode.AvalonEdit.TextEditor editor = new ICSharpCode.AvalonEdit.TextEditor(); AvalonEditTextEditorAdapter adapter = new AvalonEditTextEditorAdapter(editor); return adapter.Options; }
public void GetWordBeforeCaretExtendedTest7() { ITextEditor editor = new AvalonEditTextEditorAdapter(new AvalonEdit.TextEditor()); editor.Document.Text = "<Test member.value=\"\" />"; editor.Caret.Offset = 14; string text = editor.GetWordBeforeCaretExtended(); Assert.AreEqual("member.v", text); }