Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers')
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/DocumentLineWrapper.cs122
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/FoldSegmentWrapper.cs66
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/ITextDocumentWrapper.cs371
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/IndentationTrackerWrapper.cs77
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/ReadonlyDocumentSnapshot.cs179
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/RopeTextSource.cs126
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/SelectionSurroundingProviderWrapper.cs58
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/SemanticHighlightingSyntaxMode.cs187
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextChangeEventArgsWrapper.cs37
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextPasteHandlerWrapper.cs68
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextSourceVersionWrapper.cs71
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TooltipProviderWrapper.cs117
12 files changed, 1479 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/DocumentLineWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/DocumentLineWrapper.cs
new file mode 100644
index 0000000000..ea5db27406
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/DocumentLineWrapper.cs
@@ -0,0 +1,122 @@
+//
+// DocumentLineWrapper.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class DocumentLineWrapper : MonoDevelop.Ide.Editor.IDocumentLine
+ {
+ public Mono.TextEditor.DocumentLine Line {
+ get;
+ private set;
+ }
+
+ public DocumentLineWrapper (Mono.TextEditor.DocumentLine line)
+ {
+ if (line == null)
+ throw new ArgumentNullException ("line");
+ this.Line = line;
+ }
+
+ #region IDocumentLine implementation
+ int MonoDevelop.Ide.Editor.IDocumentLine.LengthIncludingDelimiter {
+ get {
+ return Line.LengthIncludingDelimiter;
+ }
+ }
+
+ int MonoDevelop.Ide.Editor.IDocumentLine.EndOffsetIncludingDelimiter {
+ get {
+ return Line.EndOffsetIncludingDelimiter;
+ }
+ }
+
+ MonoDevelop.Core.Text.ISegment MonoDevelop.Ide.Editor.IDocumentLine.SegmentIncludingDelimiter {
+ get {
+ return MonoDevelop.Core.Text.TextSegment.FromBounds (Line.Offset, Line.EndOffsetIncludingDelimiter);
+ }
+ }
+
+ MonoDevelop.Core.Text.UnicodeNewline MonoDevelop.Ide.Editor.IDocumentLine.UnicodeNewline {
+ get {
+ return (MonoDevelop.Core.Text.UnicodeNewline)Line.UnicodeNewline;
+ }
+ }
+
+ int MonoDevelop.Ide.Editor.IDocumentLine.DelimiterLength {
+ get {
+ return Line.DelimiterLength;
+ }
+ }
+
+ int MonoDevelop.Ide.Editor.IDocumentLine.LineNumber {
+ get {
+ return Line.LineNumber;
+ }
+ }
+
+ MonoDevelop.Ide.Editor.IDocumentLine MonoDevelop.Ide.Editor.IDocumentLine.PreviousLine {
+ get {
+ var prev = Line.PreviousLine;
+ return prev != null ? new DocumentLineWrapper (prev) : null;
+ }
+ }
+
+ MonoDevelop.Ide.Editor.IDocumentLine MonoDevelop.Ide.Editor.IDocumentLine.NextLine {
+ get {
+ var next = Line.NextLine;
+ return next != null ? new DocumentLineWrapper (next) : null;
+ }
+ }
+
+ bool MonoDevelop.Ide.Editor.IDocumentLine.IsDeleted {
+ get {
+ return false;
+ }
+ }
+ #endregion
+
+ #region ISegment implementation
+ int MonoDevelop.Core.Text.ISegment.Offset {
+ get {
+ return Line.Offset;
+ }
+ }
+
+ int MonoDevelop.Core.Text.ISegment.Length {
+ get {
+ return Line.Length;
+ }
+ }
+
+ int MonoDevelop.Core.Text.ISegment.EndOffset {
+ get {
+ return Line.EndOffset;
+ }
+ }
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/FoldSegmentWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/FoldSegmentWrapper.cs
new file mode 100644
index 0000000000..8d1ba6cf48
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/FoldSegmentWrapper.cs
@@ -0,0 +1,66 @@
+//
+// FoldSegmentWrapper.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Mono.TextEditor;
+using MonoDevelop.Ide.Editor;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class FoldSegmentWrapper : Mono.TextEditor.FoldSegment, IFoldSegment
+ {
+ bool IFoldSegment.IsCollapsed {
+ get {
+ return IsFolded;
+ }
+ set {
+ IsFolded = value;
+ }
+ }
+
+ string IFoldSegment.CollapsedText {
+ get {
+ return Description;
+ }
+ set {
+ Description = value;
+ }
+ }
+
+ MonoDevelop.Ide.Editor.FoldingType IFoldSegment.FoldingType {
+ get {
+ return (MonoDevelop.Ide.Editor.FoldingType)base.FoldingType;
+ }
+ set {
+ base.FoldingType = (Mono.TextEditor.FoldingType)value;
+ }
+ }
+
+ public FoldSegmentWrapper (TextDocument doc, string description, int offset, int length, Mono.TextEditor.FoldingType foldingType) : base (doc, description, offset, length, foldingType)
+ {
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/ITextDocumentWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/ITextDocumentWrapper.cs
new file mode 100644
index 0000000000..21f09028b6
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/ITextDocumentWrapper.cs
@@ -0,0 +1,371 @@
+//
+// ITextDocumentWrapper.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using MonoDevelop.Ide.Editor;
+using Mono.TextEditor;
+using System.IO;
+using MonoDevelop.Core;
+using MonoDevelop.Core.Text;
+using Atk;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class TextDocumentWrapper : ITextDocument
+ {
+ readonly TextDocument document;
+
+ public TextDocument Document {
+ get {
+ return document;
+ }
+ }
+
+ public TextDocumentWrapper (TextDocument document)
+ {
+ this.document = document;
+ this.document.TextReplaced += HandleTextReplaced;
+ this.document.TextReplacing += HandleTextReplacing;
+ this.document.LineChanged += delegate(object sender, Mono.TextEditor.LineEventArgs e) {
+ var handler = LineChanged;
+ if (handler != null)
+ handler (this, new MonoDevelop.Ide.Editor.LineEventArgs (new DocumentLineWrapper (e.Line)));
+ };
+
+ this.document.LineInserted += delegate(object sender, Mono.TextEditor.LineEventArgs e) {
+ var handler = LineInserted;
+ if (handler != null)
+ handler (this, new MonoDevelop.Ide.Editor.LineEventArgs (new DocumentLineWrapper (e.Line)));
+ };
+
+ this.document.LineRemoved += delegate(object sender, Mono.TextEditor.LineEventArgs e) {
+ var handler = LineRemoved;
+ if (handler != null)
+ handler (this, new MonoDevelop.Ide.Editor.LineEventArgs (new DocumentLineWrapper (e.Line)));
+ };
+ }
+
+ void HandleTextReplacing (object sender, DocumentChangeEventArgs e)
+ {
+ var handler = textChanging;
+ if (handler != null)
+ handler (this, new MonoDevelop.Core.Text.TextChangeEventArgs (e.Offset, e.RemovedText.Text, e.InsertedText.Text));
+ }
+
+ void HandleTextReplaced (object sender, DocumentChangeEventArgs e)
+ {
+ var handler = textChanged;
+ if (handler != null)
+ handler (this, new MonoDevelop.Core.Text.TextChangeEventArgs (e.Offset, e.RemovedText.Text, e.InsertedText.Text));
+ }
+
+ #region ITextDocument implementation
+ event EventHandler<MonoDevelop.Core.Text.TextChangeEventArgs> textChanging;
+ event EventHandler<MonoDevelop.Core.Text.TextChangeEventArgs> ITextDocument.TextChanging {
+ add {
+ textChanging += value;
+ }
+ remove {
+ textChanging -= value;
+ }
+ }
+
+ event EventHandler<MonoDevelop.Core.Text.TextChangeEventArgs> textChanged;
+ event EventHandler<MonoDevelop.Core.Text.TextChangeEventArgs> ITextDocument.TextChanged {
+ add {
+ textChanged += value;
+ }
+ remove {
+ textChanged -= value;
+ }
+ }
+
+ void ITextDocument.InsertText (int offset, string text)
+ {
+ document.Insert (offset, text);
+ }
+
+ void ITextDocument.InsertText (int offset, MonoDevelop.Core.Text.ITextSource text)
+ {
+ document.Insert (offset, text.Text);
+ }
+
+ void ITextDocument.RemoveText (int offset, int length)
+ {
+ document.Remove (offset, length);
+ }
+
+ void ITextDocument.ReplaceText (int offset, int length, string value)
+ {
+ document.Replace (offset, length, value);
+ }
+
+ void ITextDocument.ReplaceText (int offset, int length, MonoDevelop.Core.Text.ITextSource value)
+ {
+ document.Replace (offset, length, value.Text);
+ }
+
+ IDisposable ITextDocument.OpenUndoGroup ()
+ {
+ return document.OpenUndoGroup ();
+ }
+
+ IReadonlyTextDocument ITextDocument.CreateDocumentSnapshot ()
+ {
+ return new ReadonlyDocumentSnapshot (document);
+ }
+
+ string ITextDocument.Text {
+ get {
+ return document.Text;
+ }
+ set {
+ document.Text = value;
+ }
+ }
+
+ bool ITextDocument.IsReadOnly {
+ get {
+ return document.ReadOnly;
+ }
+ set {
+ document.ReadOnly = value;
+ }
+ }
+
+ FilePath ITextDocument.FileName {
+ get {
+ return document.FileName;
+ }
+ set {
+ document.FileName = value;
+ }
+ }
+
+ event EventHandler ITextDocument.FileNameChanged {
+ add {
+ document.FileNameChanged += value;
+ }
+ remove {
+ document.FileNameChanged -= value;
+ }
+ }
+
+ string ITextDocument.MimeType {
+ get {
+ return document.MimeType;
+ }
+ set {
+ document.MimeType = value;
+ }
+ }
+
+ event EventHandler ITextDocument.MimeTypeChanged {
+ add {
+ document.MimeTypeChanged += value;
+ }
+ remove {
+ document.MimeTypeChanged -= value;
+ }
+ }
+
+
+
+ bool ITextDocument.UseBOM {
+ get {
+ return document.UseBom;
+ }
+ set {
+ document.UseBom = value;
+ }
+ }
+
+ System.Text.Encoding ITextDocument.Encoding {
+ get {
+ return document.Encoding;
+ }
+ set {
+ document.Encoding = value;
+ }
+ }
+
+ bool ITextDocument.IsInAtomicUndo {
+ get {
+ return document.IsInAtomicUndo;
+ }
+ }
+
+ char ITextDocument.this [int offset] {
+ get {
+ return document.GetCharAt (offset);
+ }
+ set {
+ document.Replace (offset, 1, value.ToString ());
+ }
+ }
+
+ char MonoDevelop.Core.Text.ITextSource.this [int offset] {
+ get {
+ return document.GetCharAt (offset);
+ }
+ }
+
+ public event EventHandler<MonoDevelop.Ide.Editor.LineEventArgs> LineChanged;
+ public event EventHandler<MonoDevelop.Ide.Editor.LineEventArgs> LineInserted;
+ public event EventHandler<MonoDevelop.Ide.Editor.LineEventArgs> LineRemoved;
+
+ #endregion
+
+ #region IReadonlyTextDocument implementation
+
+ int IReadonlyTextDocument.LocationToOffset (int line, int column)
+ {
+ return document.LocationToOffset (line, column);
+ }
+
+ MonoDevelop.Ide.Editor.DocumentLocation IReadonlyTextDocument.OffsetToLocation (int offset)
+ {
+ var loc = document.OffsetToLocation (offset);
+ return new MonoDevelop.Ide.Editor.DocumentLocation (loc.Line, loc.Column);
+ }
+
+ IDocumentLine IReadonlyTextDocument.GetLine (int lineNumber)
+ {
+ var line = document.GetLine (lineNumber);
+ return line != null ? new DocumentLineWrapper (line) : null;
+ }
+
+ IDocumentLine IReadonlyTextDocument.GetLineByOffset (int offset)
+ {
+ var line = document.GetLineByOffset (offset);
+ return line != null ? new DocumentLineWrapper (line) : null;
+ }
+
+ bool IReadonlyTextDocument.IsReadOnly {
+ get {
+ return document.ReadOnly;
+ }
+ }
+
+ FilePath IReadonlyTextDocument.FileName {
+ get {
+ return document.FileName;
+ }
+ }
+
+ string IReadonlyTextDocument.MimeType {
+ get {
+ return document.MimeType;
+ }
+ }
+
+ int IReadonlyTextDocument.LineCount {
+ get {
+ return document.LineCount;
+ }
+ }
+
+ #endregion
+
+ #region ITextSource implementation
+
+ string MonoDevelop.Core.Text.ITextSource.GetTextAt (int offset, int length)
+ {
+ return document.GetTextAt (offset, length);
+ }
+
+ MonoDevelop.Core.Text.ITextSourceVersion MonoDevelop.Core.Text.ITextSource.Version {
+ get {
+ return new TextSourceVersionWrapper (document.Version);
+ }
+ }
+
+ bool MonoDevelop.Core.Text.ITextSource.UseBOM {
+ get {
+ return document.UseBom;
+ }
+ }
+
+ System.Text.Encoding MonoDevelop.Core.Text.ITextSource.Encoding {
+ get {
+ return document.Encoding;
+ }
+ }
+
+ int MonoDevelop.Core.Text.ITextSource.Length {
+ get {
+ return document.TextLength;
+ }
+ }
+
+ string MonoDevelop.Core.Text.ITextSource.Text {
+ get {
+ return document.Text;
+ }
+ }
+
+ char MonoDevelop.Core.Text.ITextSource.GetCharAt (int offset)
+ {
+ return document.GetCharAt (offset);
+ }
+
+
+ TextReader MonoDevelop.Core.Text.ITextSource.CreateReader ()
+ {
+ return document.CreateReader ();
+ }
+
+ TextReader MonoDevelop.Core.Text.ITextSource.CreateReader (int offset, int length)
+ {
+ return document.CreateReader (offset, length);
+ }
+
+ void MonoDevelop.Core.Text.ITextSource.WriteTextTo (TextWriter writer)
+ {
+ if (writer == null)
+ throw new ArgumentNullException ("writer");
+ writer.Write (document.Text);
+ }
+
+ void MonoDevelop.Core.Text.ITextSource.WriteTextTo (TextWriter writer, int offset, int length)
+ {
+ if (writer == null)
+ throw new ArgumentNullException ("writer");
+ writer.Write (document.GetTextAt (offset, length));
+ }
+
+ ITextSource ITextSource.CreateSnapshot ()
+ {
+ return new RopeTextSource (document.CloneRope (), document.Encoding, document.UseBom, new TextSourceVersionWrapper (document.Version));
+ }
+
+ ITextSource ITextSource.CreateSnapshot (int offset, int length)
+ {
+ return new RopeTextSource (document.CloneRope (offset, length), document.Encoding, document.UseBom);
+ }
+ #endregion
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/IndentationTrackerWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/IndentationTrackerWrapper.cs
new file mode 100644
index 0000000000..1331ffc936
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/IndentationTrackerWrapper.cs
@@ -0,0 +1,77 @@
+// IndentationTrackerWrapper.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using MonoDevelop.Ide.Editor;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class IndentationTrackerWrapper : Mono.TextEditor.IIndentationTracker
+ {
+ readonly IReadonlyTextDocument document;
+ readonly MonoDevelop.Ide.Editor.Extension.IndentationTracker indentationTracker;
+
+ readonly Mono.TextEditor.TextEditorData textEditorData;
+
+ public IndentationTrackerWrapper (Mono.TextEditor.TextEditorData textEditorData, IReadonlyTextDocument document, MonoDevelop.Ide.Editor.Extension.IndentationTracker indentationTracker)
+ {
+ if (textEditorData == null)
+ throw new System.ArgumentNullException ("textEditorData");
+ if (document == null)
+ throw new System.ArgumentNullException ("document");
+ if (indentationTracker == null)
+ throw new System.ArgumentNullException ("indentationTracker");
+ this.textEditorData = textEditorData;
+ this.document = document;
+ this.indentationTracker = indentationTracker;
+ }
+
+ #region IIndentationTracker implementation
+ string Mono.TextEditor.IIndentationTracker.GetIndentationString (int offset)
+ {
+ return indentationTracker.GetIndentationString (document.OffsetToLineNumber (offset));
+ }
+
+ string Mono.TextEditor.IIndentationTracker.GetIndentationString (int lineNumber, int column)
+ {
+ return indentationTracker.GetIndentationString (lineNumber);
+ }
+
+ static int CountIndent (string str)
+ {
+ // '\t' == 1 - virtual indent is here the character indent not the visual one.
+ return str.Length;
+ }
+
+ int Mono.TextEditor.IIndentationTracker.GetVirtualIndentationColumn (int offset)
+ {
+ return 1 + CountIndent(((Mono.TextEditor.IIndentationTracker)this).GetIndentationString (offset));
+ }
+
+ int Mono.TextEditor.IIndentationTracker.GetVirtualIndentationColumn (int lineNumber, int column)
+ {
+ return 1 + CountIndent(((Mono.TextEditor.IIndentationTracker)this).GetIndentationString (lineNumber, column));
+ }
+ #endregion
+ }
+}
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/ReadonlyDocumentSnapshot.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/ReadonlyDocumentSnapshot.cs
new file mode 100644
index 0000000000..45584f18ad
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/ReadonlyDocumentSnapshot.cs
@@ -0,0 +1,179 @@
+//
+// ReadonlyDocumentSnapshot.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using MonoDevelop.Ide.Editor;
+using Mono.TextEditor.Utils;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class ReadonlyDocumentSnapshot : IReadonlyTextDocument
+ {
+ readonly Mono.TextEditor.TextDocument snapshot;
+ readonly MonoDevelop.Core.Text.ITextSourceVersion version;
+
+ public ReadonlyDocumentSnapshot (Mono.TextEditor.TextDocument textDocument)
+ {
+ snapshot = textDocument.CreateDocumentSnapshot ();
+ version = new TextSourceVersionWrapper (textDocument.Version);
+ }
+
+ #region IReadonlyTextDocument implementation
+
+ int IReadonlyTextDocument.LocationToOffset (int line, int column)
+ {
+ return snapshot.LocationToOffset (line, column);
+ }
+
+ DocumentLocation IReadonlyTextDocument.OffsetToLocation (int offset)
+ {
+ var loc = snapshot.OffsetToLocation (offset);
+ return new MonoDevelop.Ide.Editor.DocumentLocation (loc.Line, loc.Column);
+ }
+
+ IDocumentLine IReadonlyTextDocument.GetLine (int lineNumber)
+ {
+ var line = snapshot.GetLine (lineNumber);
+ return line != null ? new DocumentLineWrapper (line) : null;
+ }
+
+ IDocumentLine IReadonlyTextDocument.GetLineByOffset (int offset)
+ {
+ var line = snapshot.GetLineByOffset (offset);
+ return line != null ? new DocumentLineWrapper (line) : null;
+ }
+
+ bool IReadonlyTextDocument.IsReadOnly {
+ get {
+ return true;
+ }
+ }
+
+ MonoDevelop.Core.FilePath IReadonlyTextDocument.FileName {
+ get {
+ return snapshot.FileName;
+ }
+ }
+
+ string IReadonlyTextDocument.MimeType {
+ get {
+ return snapshot.MimeType;
+ }
+ }
+
+ int IReadonlyTextDocument.LineCount {
+ get {
+ return snapshot.LineCount;
+ }
+ }
+
+ #endregion
+
+ #region ITextSource implementation
+
+ char MonoDevelop.Core.Text.ITextSource.GetCharAt (int offset)
+ {
+ return snapshot.GetCharAt (offset);
+ }
+
+ char MonoDevelop.Core.Text.ITextSource.this [int offset] {
+ get {
+ return snapshot.GetCharAt (offset);
+ }
+ }
+
+ string MonoDevelop.Core.Text.ITextSource.GetTextAt (int offset, int length)
+ {
+ return snapshot.GetTextAt (offset, length);
+ }
+
+ System.IO.TextReader MonoDevelop.Core.Text.ITextSource.CreateReader ()
+ {
+ return snapshot.CreateReader ();
+ }
+
+ System.IO.TextReader MonoDevelop.Core.Text.ITextSource.CreateReader (int offset, int length)
+ {
+ return snapshot.CreateReader (offset, length);
+ }
+
+ void MonoDevelop.Core.Text.ITextSource.WriteTextTo (System.IO.TextWriter writer)
+ {
+ if (writer == null)
+ throw new ArgumentNullException ("writer");
+ writer.Write (snapshot.Text);
+ }
+
+ void MonoDevelop.Core.Text.ITextSource.WriteTextTo (System.IO.TextWriter writer, int offset, int length)
+ {
+ if (writer == null)
+ throw new ArgumentNullException ("writer");
+ writer.Write (snapshot.GetTextAt (offset, length));
+ }
+
+ MonoDevelop.Core.Text.ITextSource MonoDevelop.Core.Text.ITextSource.CreateSnapshot ()
+ {
+ return this;
+ }
+
+ MonoDevelop.Core.Text.ITextSource MonoDevelop.Core.Text.ITextSource.CreateSnapshot (int offset, int length)
+ {
+ return new RopeTextSource (snapshot.CloneRope (offset, length), snapshot.Encoding, snapshot.UseBom);
+ }
+
+ MonoDevelop.Core.Text.ITextSourceVersion MonoDevelop.Core.Text.ITextSource.Version {
+ get {
+ return version;
+ }
+ }
+
+ bool MonoDevelop.Core.Text.ITextSource.UseBOM {
+ get {
+ return snapshot.UseBom;
+ }
+ }
+
+ System.Text.Encoding MonoDevelop.Core.Text.ITextSource.Encoding {
+ get {
+ return snapshot.Encoding;
+ }
+ }
+
+ int MonoDevelop.Core.Text.ITextSource.Length {
+ get {
+ return snapshot.TextLength;
+ }
+ }
+
+ string MonoDevelop.Core.Text.ITextSource.Text {
+ get {
+ return snapshot.Text;
+ }
+ }
+
+ #endregion
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/RopeTextSource.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/RopeTextSource.cs
new file mode 100644
index 0000000000..808ada5224
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/RopeTextSource.cs
@@ -0,0 +1,126 @@
+//
+// RopeTextSource.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using MonoDevelop.Core.Text;
+using Mono.TextEditor.Utils;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class RopeTextSource : ITextSource
+ {
+ readonly Rope<char> rope;
+ readonly ITextSourceVersion version;
+
+ public RopeTextSource (Mono.TextEditor.Utils.Rope<char> rope, System.Text.Encoding encoding, bool useBom, ITextSourceVersion version = null)
+ {
+ if (rope == null)
+ throw new ArgumentNullException ("rope");
+ this.rope = rope;
+ this.encoding = encoding;
+ UseBOM = useBom;
+ this.version = version;
+ }
+
+ #region ITextSource implementation
+ char ITextSource.GetCharAt (int offset)
+ {
+ return rope [offset];
+ }
+
+ char ITextSource.this [int offset] {
+ get {
+ return rope [offset];
+ }
+ }
+
+ string ITextSource.GetTextAt (int offset, int length)
+ {
+ return rope.ToString (offset, length);
+ }
+
+ System.IO.TextReader ITextSource.CreateReader ()
+ {
+ return new RopeTextReader (rope);
+ }
+
+ System.IO.TextReader ITextSource.CreateReader (int offset, int length)
+ {
+ return new RopeTextReader (rope.GetRange (offset, length));
+ }
+
+ void ITextSource.WriteTextTo (System.IO.TextWriter writer)
+ {
+ rope.WriteTo (writer, 0, rope.Length);
+ }
+
+ void ITextSource.WriteTextTo (System.IO.TextWriter writer, int offset, int length)
+ {
+ rope.WriteTo (writer, offset, length);
+ }
+
+ ITextSource ITextSource.CreateSnapshot ()
+ {
+ return this;
+ }
+
+ ITextSource ITextSource.CreateSnapshot (int offset, int length)
+ {
+ return new RopeTextSource (rope.GetRange (offset, length), Encoding, UseBOM);
+ }
+
+ ITextSourceVersion ITextSource.Version {
+ get {
+ return version;
+ }
+ }
+
+ public bool UseBOM {
+ get;
+ private set;
+ }
+
+ System.Text.Encoding encoding;
+ public System.Text.Encoding Encoding {
+ get {
+ return encoding ?? System.Text.Encoding.UTF8;
+ }
+ }
+
+ int ITextSource.Length {
+ get {
+ return rope.Length;
+ }
+ }
+
+ string ITextSource.Text {
+ get {
+ return rope.ToString ();
+ }
+ }
+ #endregion
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/SelectionSurroundingProviderWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/SelectionSurroundingProviderWrapper.cs
new file mode 100644
index 0000000000..516a662f6b
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/SelectionSurroundingProviderWrapper.cs
@@ -0,0 +1,58 @@
+//
+// SelectionSurroundingProviderWrapper.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Mono.TextEditor;
+using MonoDevelop.SourceEditor.Wrappers;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class SelectionSurroundingProviderWrapper : ISelectionSurroundingProvider
+ {
+ readonly MonoDevelop.Ide.Editor.Extension.SelectionSurroundingProvider surroundingProvider;
+
+ public SelectionSurroundingProviderWrapper (MonoDevelop.Ide.Editor.Extension.SelectionSurroundingProvider surroundingProvider)
+ {
+ if (surroundingProvider == null)
+ throw new ArgumentNullException ("surroundingProvider");
+ this.surroundingProvider = surroundingProvider;
+ }
+
+ #region ISelectionSurroundingProvider implementation
+
+ bool ISelectionSurroundingProvider.GetSelectionSurroundings (TextEditorData textEditorData, uint unicodeKey, out string start, out string end)
+ {
+ return surroundingProvider.GetSelectionSurroundings (unicodeKey, out start, out end);
+ }
+
+ void ISelectionSurroundingProvider.HandleSpecialSelectionKey (TextEditorData textEditorData, uint unicodeKey)
+ {
+ surroundingProvider.HandleSpecialSelectionKey (unicodeKey);
+ }
+
+ #endregion
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/SemanticHighlightingSyntaxMode.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/SemanticHighlightingSyntaxMode.cs
new file mode 100644
index 0000000000..230fea5ab5
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/SemanticHighlightingSyntaxMode.cs
@@ -0,0 +1,187 @@
+//
+// SemanticHighlightingSyntaxMode.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Mono.TextEditor.Highlighting;
+using MonoDevelop.Ide.Editor.Highlighting;
+using Mono.TextEditor;
+using System.Collections.Generic;
+using MonoDevelop.Ide.Editor;
+using System.Linq;
+using Gtk;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ sealed class SemanticHighlightingSyntaxMode : SyntaxMode
+ {
+ readonly ExtensibleTextEditor editor;
+ readonly SyntaxMode syntaxMode;
+ readonly SemanticHighlighting semanticHighlighting;
+
+ public override TextDocument Document {
+ get {
+ return syntaxMode.Document;
+ }
+ set {
+ syntaxMode.Document = value;
+ }
+ }
+
+ internal class StyledTreeSegment : Mono.TextEditor.TreeSegment
+ {
+ public string Style {
+ get;
+ private set;
+ }
+
+ public StyledTreeSegment (int offset, int length, string style) : base (offset, length)
+ {
+ Style = style;
+ }
+ }
+
+ class HighlightingSegmentTree : Mono.TextEditor.SegmentTree<StyledTreeSegment>
+ {
+ public bool GetStyle (Chunk chunk, ref int endOffset, out string style)
+ {
+ var segment = GetSegmentsAt (chunk.Offset).FirstOrDefault ();
+ if (segment == null) {
+ style = null;
+ return false;
+ }
+ endOffset = segment.EndOffset;
+ style = segment.Style;
+ return true;
+ }
+
+ public void AddStyle (MonoDevelop.Core.Text.ISegment segment, string style)
+ {
+ if (IsDirty)
+ return;
+ Add (new StyledTreeSegment (segment.Offset, segment.Length, style));
+ }
+ }
+
+ Dictionary<DocumentLine, HighlightingSegmentTree> lineSegments = new Dictionary<DocumentLine, HighlightingSegmentTree> ();
+
+ public SemanticHighlightingSyntaxMode (ExtensibleTextEditor editor, ISyntaxMode syntaxMode, SemanticHighlighting semanticHighlighting)
+ {
+ if (editor == null)
+ throw new ArgumentNullException ("editor");
+ if (syntaxMode == null)
+ throw new ArgumentNullException ("syntaxMode");
+ if (semanticHighlighting == null)
+ throw new ArgumentNullException ("semanticHighlighting");
+ this.editor = editor;
+ this.semanticHighlighting = semanticHighlighting;
+ this.syntaxMode = syntaxMode as SyntaxMode;
+ semanticHighlighting.SemanticHighlightingUpdated += delegate {
+ Application.Invoke (delegate {
+ foreach (var kv in lineSegments) {
+ try {
+ kv.Value.RemoveListener ();
+ } catch (Exception) {
+ }
+ }
+ lineSegments.Clear ();
+
+ var margin = editor.TextViewMargin;
+ margin.PurgeLayoutCache ();
+ editor.QueueDraw ();
+ });
+ };
+ }
+
+ public override SpanParser CreateSpanParser (Mono.TextEditor.DocumentLine line, CloneableStack<Span> spanStack)
+ {
+ return syntaxMode.CreateSpanParser (line, spanStack);
+ }
+
+ public override ChunkParser CreateChunkParser (SpanParser spanParser, Mono.TextEditor.Highlighting.ColorScheme style, DocumentLine line)
+ {
+ return new CSharpChunkParser (this, spanParser, style, line);
+ }
+
+ class CSharpChunkParser : ChunkParser
+ {
+ SemanticHighlightingSyntaxMode semanticMode;
+
+ int lineNumber;
+ public CSharpChunkParser (SemanticHighlightingSyntaxMode semanticMode, SpanParser spanParser, Mono.TextEditor.Highlighting.ColorScheme style, DocumentLine line) : base (semanticMode, spanParser, style, line)
+ {
+ lineNumber = line.LineNumber;
+ this.semanticMode = semanticMode;
+ }
+
+ protected override void AddRealChunk (Chunk chunk)
+ {
+ if (!DefaultSourceEditorOptions.Instance.EnableSemanticHighlighting) {
+ base.AddRealChunk (chunk);
+ return;
+ }
+ int endLoc = -1;
+ string semanticStyle = null;
+
+ try {
+ HighlightingSegmentTree tree;
+ if (!semanticMode.lineSegments.TryGetValue (line, out tree)) {
+ tree = new HighlightingSegmentTree ();
+ tree.InstallListener (semanticMode.Document);
+ foreach (var seg in semanticMode.semanticHighlighting.GetColoredSegments (new MonoDevelop.Core.Text.TextSegment (line.Offset, line.Length))) {
+ tree.AddStyle (seg, seg.ColorStyleKey);
+ }
+ semanticMode.lineSegments[line] = tree;
+ }
+ string style;
+ if (tree.GetStyle (chunk, ref endLoc, out style)) {
+ semanticStyle = style;
+ }
+ } catch (Exception e) {
+ Console.WriteLine ("Error in semantic highlighting: " + e);
+ }
+
+ if (semanticStyle != null) {
+ if (endLoc < chunk.EndOffset) {
+ base.AddRealChunk (new Chunk (chunk.Offset, endLoc - chunk.Offset, semanticStyle));
+ base.AddRealChunk (new Chunk (endLoc, chunk.EndOffset - endLoc, chunk.Style));
+ return;
+ }
+ chunk.Style = semanticStyle;
+ }
+
+ base.AddRealChunk (chunk);
+ }
+
+ protected override string GetStyle (Chunk chunk)
+ {
+ /*if (spanParser.CurRule.Name == "Comment") {
+ if (tags.Contains (doc.GetTextAt (chunk)))
+ return "Comment Tag";
+ }*/
+ return base.GetStyle (chunk);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextChangeEventArgsWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextChangeEventArgsWrapper.cs
new file mode 100644
index 0000000000..754bb26cad
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextChangeEventArgsWrapper.cs
@@ -0,0 +1,37 @@
+//
+// TextSourceVersionWrapper.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using MonoDevelop.Core.Text;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class TextChangeEventArgsWrapper : TextChangeEventArgs
+ {
+ public TextChangeEventArgsWrapper (ICSharpCode.NRefactory.Editor.TextChangeEventArgs change) : base (change.Offset, change.RemovedText.Text, change.InsertedText.Text)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextPasteHandlerWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextPasteHandlerWrapper.cs
new file mode 100644
index 0000000000..765e39f7a2
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextPasteHandlerWrapper.cs
@@ -0,0 +1,68 @@
+// SourceEditorView.cs
+//
+// Author:
+// Mike Krüger <mkrueger@novell.com>
+//
+// Copyright (c) 2008 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class TextPasteHandlerWrapper : ICSharpCode.NRefactory.Editor.ITextPasteHandler, IDisposable
+ {
+ readonly MonoDevelop.Ide.Editor.Extension.TextPasteHandler textPasteHandler;
+ readonly Mono.TextEditor.TextEditorData data;
+
+ public TextPasteHandlerWrapper (Mono.TextEditor.TextEditorData data, MonoDevelop.Ide.Editor.Extension.TextPasteHandler textPasteHandler)
+ {
+ this.data = data;
+ this.textPasteHandler = textPasteHandler;
+ data.Paste += HandlePaste;
+ }
+
+ void HandlePaste (int insertionOffset, string text, int insertedChars)
+ {
+ textPasteHandler.PostFomatPastedText (insertionOffset, insertedChars);
+ }
+
+ #region IDisposable implementation
+
+ public void Dispose ()
+ {
+ data.Paste -= HandlePaste;
+ }
+
+ #endregion
+
+ #region ITextPasteHandler implementation
+
+ string ICSharpCode.NRefactory.Editor.ITextPasteHandler.FormatPlainText (int offset, string text, byte[] copyData)
+ {
+ return textPasteHandler.FormatPlainText (offset, text, copyData);
+ }
+
+ byte[] ICSharpCode.NRefactory.Editor.ITextPasteHandler.GetCopyData (ICSharpCode.NRefactory.Editor.ISegment segment)
+ {
+ return textPasteHandler.GetCopyData (segment.Offset, segment.Length);
+ }
+ #endregion
+ }
+} \ No newline at end of file
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextSourceVersionWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextSourceVersionWrapper.cs
new file mode 100644
index 0000000000..f185268b4d
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TextSourceVersionWrapper.cs
@@ -0,0 +1,71 @@
+//
+// TextSourceVersionWrapper.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using MonoDevelop.Core.Text;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class TextSourceVersionWrapper : ITextSourceVersion
+ {
+ readonly ICSharpCode.NRefactory.Editor.ITextSourceVersion version;
+
+ public TextSourceVersionWrapper (ICSharpCode.NRefactory.Editor.ITextSourceVersion version)
+ {
+ if (version == null)
+ throw new ArgumentNullException ("version");
+ this.version = version;
+ }
+
+ #region ITextSourceVersion implementation
+
+ bool ITextSourceVersion.BelongsToSameDocumentAs (ITextSourceVersion other)
+ {
+ var otherWrapper = other as TextSourceVersionWrapper;
+ return otherWrapper != null && version.BelongsToSameDocumentAs (otherWrapper.version);
+ }
+
+ int ITextSourceVersion.CompareAge (ITextSourceVersion other)
+ {
+ var otherWrapper = (TextSourceVersionWrapper)other;
+ return version.CompareAge (otherWrapper.version);
+ }
+
+ System.Collections.Generic.IEnumerable<TextChangeEventArgs> ITextSourceVersion.GetChangesTo (ITextSourceVersion other)
+ {
+ var otherWrapper = (TextSourceVersionWrapper)other;
+ foreach (var change in version.GetChangesTo (otherWrapper.version))
+ yield return new TextChangeEventArgsWrapper (change);
+ }
+
+ int ITextSourceVersion.MoveOffsetTo (ITextSourceVersion other, int oldOffset)
+ {
+ var otherWrapper = (TextSourceVersionWrapper)other;
+ return version.MoveOffsetTo (otherWrapper.version, oldOffset);
+ }
+ #endregion
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TooltipProviderWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TooltipProviderWrapper.cs
new file mode 100644
index 0000000000..bae8352c41
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.Wrappers/TooltipProviderWrapper.cs
@@ -0,0 +1,117 @@
+//
+// TooltipProviderWrapper.cs
+//
+// Author:
+// Mike Krüger <mkrueger@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin Inc. (http://xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Mono.TextEditor;
+using MonoDevelop.Ide;
+
+namespace MonoDevelop.SourceEditor.Wrappers
+{
+ class TooltipProviderWrapper : TooltipProvider
+ {
+ readonly MonoDevelop.Ide.Editor.TooltipProvider provider;
+ TooltipItem lastWrappedItem;
+ Ide.Editor.TooltipItem lastUnwrappedItem;
+
+ public MonoDevelop.Ide.Editor.TooltipProvider OriginalProvider {
+ get {
+ return provider;
+ }
+ }
+
+ public TooltipProviderWrapper (MonoDevelop.Ide.Editor.TooltipProvider provider)
+ {
+ if (provider == null)
+ throw new ArgumentNullException ("provider");
+ this.provider = provider;
+ }
+
+ #region implemented abstract members of TooltipProvider
+
+ static MonoDevelop.Ide.Editor.TextEditor WrapEditor (MonoTextEditor editor)
+ {
+ foreach (var doc in IdeApp.Workbench.Documents) {
+ if (doc.FileName == editor.FileName)
+ return doc.Editor;
+ }
+ return null;
+ }
+
+ public override TooltipItem GetItem (MonoTextEditor editor, int offset)
+ {
+ var item = provider.GetItem (WrapEditor (editor), IdeApp.Workbench.ActiveDocument, offset);
+ if (item == null)
+ return null;
+ if (lastUnwrappedItem != null) {
+ if (lastUnwrappedItem.Offset == item.Offset && lastUnwrappedItem.Length == item.Length) {
+ return lastWrappedItem;
+ }
+ }
+ lastUnwrappedItem = item;
+ return lastWrappedItem = new TooltipItem (item.Item, item.Offset, item.Length);
+ }
+
+ public override bool IsInteractive (MonoTextEditor editor, Gtk.Window tipWindow)
+ {
+ var wrappedEditor = WrapEditor (editor);
+ if (wrappedEditor == null)
+ return false;
+ return provider.IsInteractive (wrappedEditor, tipWindow);
+ }
+
+ public override Gtk.Window CreateTooltipWindow (MonoTextEditor editor, int offset, Gdk.ModifierType modifierState, TooltipItem item)
+ {
+ var wrappedEditor = WrapEditor (editor);
+ if (wrappedEditor == null)
+ return null;
+ var control = provider.CreateTooltipWindow (wrappedEditor, IdeApp.Workbench.ActiveDocument, new MonoDevelop.Ide.Editor.TooltipItem (item.Item, item.ItemSegment.Offset, item.ItemSegment.Length), offset, modifierState);
+ if (control == null)
+ return null;
+ return (Gtk.Window)control;
+ }
+
+ protected override void GetRequiredPosition (MonoTextEditor editor, Gtk.Window tipWindow, out int requiredWidth, out double xalign)
+ {
+ var wrappedEditor = WrapEditor (editor);
+ if (wrappedEditor == null) {
+ requiredWidth = 0;
+ xalign = 0;
+ return;
+ }
+ provider.GetRequiredPosition (wrappedEditor, tipWindow, out requiredWidth, out xalign);
+ }
+
+ public override Gtk.Window ShowTooltipWindow (MonoTextEditor editor, Gtk.Window tipWindow, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
+ {
+ var wrappedEditor = WrapEditor (editor);
+ if (wrappedEditor == null) {
+ return tipWindow;
+ }
+ provider.ShowTooltipWindow (wrappedEditor, tipWindow, new MonoDevelop.Ide.Editor.TooltipItem (item.Item, item.ItemSegment.Offset, item.ItemSegment.Length), modifierState, mouseX, mouseY);
+ return tipWindow;
+ }
+ #endregion
+ }
+} \ No newline at end of file