diff options
Diffstat (limited to 'main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs')
-rw-r--r-- | main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs b/main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs index 698686bd2a..2886fd80c8 100644 --- a/main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs +++ b/main/tests/UnitTests/MonoDevelop.CSharpBinding/TestViewContent.cs @@ -29,16 +29,17 @@ using System;
using System.Linq;
using System.Collections.Generic;
-using Mono.TextEditor;
using MonoDevelop.Core;
using MonoDevelop.Ide.Gui;
using MonoDevelop.Ide.Gui.Content;
+using MonoDevelop.Ide.Editor;
+using MonoDevelop.Core.Text;
namespace MonoDevelop.CSharpBinding.Tests { - public class TestViewContent : AbstractViewContent, IEditableTextBuffer, Mono.TextEditor.ITextEditorDataProvider
+ public class TestViewContent : AbstractViewContent
{
- TextEditorData data;
+ TextEditor data;
public override Gtk.Widget Control { get {
@@ -46,85 +47,84 @@ namespace MonoDevelop.CSharpBinding.Tests } }
- public TextEditorData Data {
+ public TextEditor Data {
get {
return this.data;
}
}
public TestViewContent ()
{
- document = new Mono.TextEditor.TextDocument ();
- data = new TextEditorData (document);
+ data = TextEditorFactory.CreateNewEditor ();
+ Contents.Add (data);; Name = "";
}
- public TestViewContent (TextEditorData data)
+ public TestViewContent (IReadonlyTextDocument doc)
{
- this.document = data.Document;
- this.data = data;
+ data = TextEditorFactory.CreateNewEditor (doc);
+ Contents.Add (data);
Name = "";
}
- public override void Load(string fileName)
+ public override void Load(FileOpenInformation fileOpenInformation)
{
}
FilePath name;
public FilePath Name {
get { return name; }
- set { name = document.FileName = value; }
+ set { name = data.FileName = value; }
}
public int LineCount {
get {
- return document.LineCount;
+ return data.LineCount;
}
}
- - Mono.TextEditor.TextDocument document; + public string Text {
get {
- return document.Text;
+ return data.Text;
}
set {
- document.Text = value;
+ data.Text = value;
}
}
public int InsertText (int position, string text)
{
- document.Insert (position, text);
+ data.InsertText (position, text);
return text.Length;
}
public void DeleteText (int position, int length)
{
- document.Replace (position, length, "");
+ data.ReplaceText (position, length, "");
} public int Length {
get {
- return document.TextLength;
+ return data.Length;
}
} public string GetText (int startPosition, int endPosition)
{
- return document.GetTextBetween (startPosition, endPosition);
+ return data.GetTextBetween (startPosition, endPosition);
} public char GetCharAt (int position)
{
- return document.GetCharAt (position);
+ return data.GetCharAt (position);
} public int GetPositionFromLineColumn (int line, int column)
{
- return document.LocationToOffset (line, column);
+ return data.LocationToOffset (line, column);
}
public void GetLineColumnFromPosition (int position, out int line, out int column)
{
- DocumentLocation loc = document.OffsetToLocation (position);
+ var loc = data.OffsetToLocation (position);
line = loc.Line;
column = loc.Column;
}
@@ -133,17 +133,17 @@ namespace MonoDevelop.CSharpBinding.Tests public int CursorPosition {
get {
- return data.Caret.Offset;
+ return data.CaretOffset;
}
set {
- data.Caret.Offset = value;
+ data.CaretOffset = value;
}
} public int SelectionStartPosition {
get {
if (!data.IsSomethingSelected)
- return data.Caret.Offset;
+ return data.CaretOffset;
return data.SelectionRange.Offset;
}
}
@@ -151,14 +151,14 @@ namespace MonoDevelop.CSharpBinding.Tests public int SelectionEndPosition {
get {
if (!data.IsSomethingSelected)
- return data.Caret.Offset;
+ return data.CaretOffset;
return data.SelectionRange.EndOffset;
}
} public void Select (int startPosition, int endPosition) { - data.SelectionRange = new TextSegment (startPosition, endPosition - startPosition);
+ data.SelectionRange = TextSegment.FromBounds (startPosition, endPosition);
}
public void ShowPosition (int position)
@@ -204,15 +204,20 @@ namespace MonoDevelop.CSharpBinding.Tests public override object GetContent (Type type)
{
- return Contents.FirstOrDefault (o => type.IsInstanceOfType (type)) ?? base.GetContent (type);
+ return Contents.FirstOrDefault (type.IsInstanceOfType) ?? base.GetContent (type);
}
-
+
+ public override IEnumerable<T> GetContents<T> ()
+ {
+ return Contents.OfType<T> ();
+ }
+
public IDisposable OpenUndoGroup ()
{
return new DisposeStub ();
}
- public TextEditorData GetTextEditorData () + public TextEditor GetTextEditorData () { return data;
}
@@ -230,6 +235,5 @@ namespace MonoDevelop.CSharpBinding.Tests }
#endregion
public event EventHandler CaretPositionSet; - public event EventHandler<TextChangedEventArgs> TextChanged; }
} |