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:
authorMike Krüger <mkrueger@xamarin.com>2014-06-23 12:18:36 +0400
committerMike Krüger <mkrueger@xamarin.com>2014-06-23 12:18:36 +0400
commitf191aaa9e2900c5eaee69bb8d03cba1f072c1f12 (patch)
tree9c624d380ace30c79b4f95175d73267d6b4b7bcc
parentcbf55da7a430b61bfdeaf62b517acb29e3bdc234 (diff)
[SourceEditor] Implemented editor options API.
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj6
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs1
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs27
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs14
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/TextEditorToMonoDevelopOptionsWrapper.cs364
5 files changed, 387 insertions, 25 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj
index 9f4a3bbf96..b092f80fba 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor.csproj
@@ -103,23 +103,18 @@
<Reference Include="Mono.Posix" />
<Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<SpecificVersion>False</SpecificVersion>
- <Package>glib-sharp-2.0</Package>
</Reference>
<Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<SpecificVersion>False</SpecificVersion>
- <Package>gtk-sharp-2.0</Package>
</Reference>
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<SpecificVersion>False</SpecificVersion>
- <Package>gtk-sharp-2.0</Package>
</Reference>
<Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<SpecificVersion>False</SpecificVersion>
- <Package>gtk-sharp-2.0</Package>
</Reference>
<Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<SpecificVersion>False</SpecificVersion>
- <Package>gtk-sharp-2.0</Package>
</Reference>
<Reference Include="System.Core" />
<Reference Include="Mono.Cairo" />
@@ -195,6 +190,7 @@
<Compile Include="MonoDevelop.SourceEditor\TextPasteHandlerWrapper.cs" />
<Compile Include="MonoDevelop.SourceEditor.Wrappers\TextSourceVersionWrapper.cs" />
<Compile Include="MonoDevelop.SourceEditor.Wrappers\TextChangeEventArgsWrapper.cs" />
+ <Compile Include="MonoDevelop.SourceEditor\TextEditorToMonoDevelopOptionsWrapper.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="gtk-gui\gui.stetic">
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs
index dc9f423163..ca6889f2b1 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/ExtensibleTextEditor.cs
@@ -63,6 +63,7 @@ namespace MonoDevelop.SourceEditor
public new ISourceEditorOptions Options {
get { return (ISourceEditorOptions)base.Options; }
+ set { base.Options = value; }
}
public ExtensibleTextEditor (SourceEditorView view, ISourceEditorOptions options, Mono.TextEditor.TextDocument doc) : base(doc, options)
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
index 42b730da6c..0a8a9eca76 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
@@ -65,7 +65,7 @@ namespace MonoDevelop.SourceEditor
ICompletionWidget, ISplittable, IFoldable, IToolboxDynamicProvider, IEncodedTextContent,
ICustomFilteringToolboxConsumer, IZoomable, ITextEditorResolver, Mono.TextEditor.ITextEditorDataProvider,
ICodeTemplateHandler, ICodeTemplateContextProvider, ISupportsProjectReload, IPrintable,
- ITextEditorImpl, IEditorActionHost, IMarkerHost
+ ITextEditorImpl, IEditorActionHost, IMarkerHost
{
readonly SourceEditorWidget widget;
bool isDisposed = false;
@@ -2041,17 +2041,17 @@ namespace MonoDevelop.SourceEditor
bool toggle = true;
foreach (var segment in Document.FoldSegments) {
- if (segment.FoldingType == FoldingType.TypeMember || segment.FoldingType == FoldingType.Comment)
+ if (segment.FoldingType == Mono.TextEditor.FoldingType.TypeMember || segment.FoldingType == Mono.TextEditor.FoldingType.Comment)
if (segment.IsFolded)
toggle = false;
}
foreach (var segment in Document.FoldSegments) {
- if (segment.FoldingType == FoldingType.TypeDefinition) {
+ if (segment.FoldingType == Mono.TextEditor.FoldingType.TypeDefinition) {
segment.IsFolded = false;
}
- if (segment.FoldingType == FoldingType.TypeMember || segment.FoldingType == FoldingType.Comment)
+ if (segment.FoldingType == Mono.TextEditor.FoldingType.TypeMember || segment.FoldingType == Mono.TextEditor.FoldingType.Comment)
segment.IsFolded = toggle;
}
@@ -2616,6 +2616,8 @@ namespace MonoDevelop.SourceEditor
TextDocumentWrapper wrapper;
IReadonlyTextDocument ITextEditorImpl.Document {
get {
+ if (wrapper == null)
+ wrapper = new TextDocumentWrapper (widget.TextEditor.Document);
return wrapper;
}
set {
@@ -2744,27 +2746,29 @@ namespace MonoDevelop.SourceEditor
IEnumerable<ITextSegmentMarker> ITextEditorImpl.GetTextSegmentMarkersAt (MonoDevelop.Core.Text.ISegment segment)
{
- throw new NotImplementedException ();
+ return TextEditor.Document.GetTextSegmentMarkersAt (new Mono.TextEditor.TextSegment (segment.Offset, segment.Length)).OfType<ITextSegmentMarker> ();
}
IEnumerable<ITextSegmentMarker> ITextEditorImpl.GetTextSegmentMarkersAt (int offset)
{
- throw new NotImplementedException ();
+ return TextEditor.Document.GetTextSegmentMarkersAt (offset).OfType<ITextSegmentMarker> ();
}
void ITextEditorImpl.AddMarker (ITextSegmentMarker marker)
{
- throw new NotImplementedException ();
+ TextEditor.Document.AddMarker ((TextSegmentMarker)marker);
}
bool ITextEditorImpl.RemoveMarker (ITextSegmentMarker marker)
{
- throw new NotImplementedException ();
+ return TextEditor.Document.RemoveMarker ((TextSegmentMarker)marker);
}
void ITextEditorImpl.SetFoldings (IEnumerable<IFoldSegment> foldings)
{
- throw new NotImplementedException ();
+ TextEditor.Document.UpdateFoldSegments (
+ foldings.Select (f => new Mono.TextEditor.FoldSegment (TextEditor.Document, f.CollapsedText, f.Offset, f.Length, (Mono.TextEditor.FoldingType)f.FoldingType) { IsFolded = f.IsFolded }).ToList()
+ );
}
IEnumerable<IFoldSegment> ITextEditorImpl.GetFoldingsFromOffset (int offset)
@@ -2794,10 +2798,7 @@ namespace MonoDevelop.SourceEditor
MonoDevelop.Ide.Editor.ITextEditorOptions ITextEditorImpl.Options {
get {
- throw new NotImplementedException ();
- }
- set {
- throw new NotImplementedException ();
+ return new TextEditorToMonoDevelopOptionsWrapper (TextEditor.Options);
}
}
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
index f74fe10540..f6c369c77b 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
@@ -427,7 +427,7 @@ namespace MonoDevelop.SourceEditor
RemoveErrorUndelinesResetTimerId ();
}
- Mono.TextEditor.FoldSegment AddMarker (List<Mono.TextEditor.FoldSegment> foldSegments, string text, DomRegion region, FoldingType type)
+ Mono.TextEditor.FoldSegment AddMarker (List<Mono.TextEditor.FoldSegment> foldSegments, string text, DomRegion region, Mono.TextEditor.FoldingType type)
{
Document document = textEditorData.Document;
if (document == null || region.BeginLine <= 0 || region.EndLine <= 0 || region.BeginLine > document.LineCount || region.EndLine > document.LineCount)
@@ -479,30 +479,30 @@ namespace MonoDevelop.SourceEditor
foreach (FoldingRegion region in parsedDocument.Foldings) {
if (token.IsCancellationRequested)
return;
- FoldingType type = FoldingType.None;
+ var type = Mono.TextEditor.FoldingType.None;
bool setFolded = false;
bool folded = false;
//decide whether the regions should be folded by default
switch (region.Type) {
case FoldType.Member:
- type = FoldingType.TypeMember;
+ type = Mono.TextEditor.FoldingType.TypeMember;
break;
case FoldType.Type:
- type = FoldingType.TypeDefinition;
+ type = Mono.TextEditor.FoldingType.TypeDefinition;
break;
case FoldType.UserRegion:
- type = FoldingType.Region;
+ type = Mono.TextEditor.FoldingType.Region;
setFolded = options.DefaultRegionsFolding;
folded = true;
break;
case FoldType.Comment:
- type = FoldingType.Comment;
+ type = Mono.TextEditor.FoldingType.Comment;
setFolded = options.DefaultCommentFolding;
folded = true;
break;
case FoldType.CommentInsideMember:
- type = FoldingType.Comment;
+ type = Mono.TextEditor.FoldingType.Comment;
setFolded = options.DefaultCommentFolding;
folded = false;
break;
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/TextEditorToMonoDevelopOptionsWrapper.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/TextEditorToMonoDevelopOptionsWrapper.cs
new file mode 100644
index 0000000000..54da5ea396
--- /dev/null
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/TextEditorToMonoDevelopOptionsWrapper.cs
@@ -0,0 +1,364 @@
+//
+// TextEditorToMonoDevelopOptionsWrapper.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;
+
+namespace MonoDevelop.SourceEditor
+{
+ class TextEditorToMonoDevelopOptionsWrapper : ITextEditorOptions
+ {
+ readonly ISourceEditorOptions options;
+
+ public TextEditorToMonoDevelopOptionsWrapper (ISourceEditorOptions options)
+ {
+ if (options == null)
+ throw new ArgumentNullException ("options");
+ this.options = options;
+ }
+
+ #region ITextEditorOptions implementation
+ event EventHandler ITextEditorOptions.Changed {
+ add {
+ options.Changed += value;
+ }
+ remove {
+ options.Changed -= value;
+ }
+ }
+
+ void ITextEditorOptions.ZoomIn ()
+ {
+ options.ZoomIn ();
+ }
+
+ void ITextEditorOptions.ZoomOut ()
+ {
+ options.ZoomOut ();
+ }
+
+ void ITextEditorOptions.ZoomReset ()
+ {
+ options.ZoomReset ();
+ }
+
+ ColorScheme ITextEditorOptions.GetColorStyle ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ double ITextEditorOptions.Zoom {
+ get {
+ return options.Zoom;
+ }
+ set {
+ options.Zoom = value;
+ }
+ }
+
+ bool ITextEditorOptions.CanZoomIn {
+ get {
+ return options.CanZoomIn;
+ }
+ }
+
+ bool ITextEditorOptions.CanZoomOut {
+ get {
+ return options.CanZoomOut;
+ }
+ }
+
+ bool ITextEditorOptions.CanResetZoom {
+ get {
+ return options.CanResetZoom;
+ }
+ }
+
+ string ITextEditorOptions.IndentationString {
+ get {
+ return options.IndentationString;
+ }
+ }
+
+ IWordFindStrategy ITextEditorOptions.WordFindStrategy {
+ get {
+ return null;
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ bool ITextEditorOptions.AllowTabsAfterNonTabs {
+ get {
+ return options.AllowTabsAfterNonTabs;
+ }
+ set {
+ options.AllowTabsAfterNonTabs = value;
+ }
+ }
+
+ bool ITextEditorOptions.HighlightMatchingBracket {
+ get {
+ return options.HighlightMatchingBracket;
+ }
+ set {
+ options.HighlightMatchingBracket = value;
+ }
+ }
+
+ bool ITextEditorOptions.TabsToSpaces {
+ get {
+ return options.TabsToSpaces;
+ }
+ set {
+ options.TabsToSpaces = value;
+ }
+ }
+
+ int ITextEditorOptions.IndentationSize {
+ get {
+ return options.IndentationSize;
+ }
+ set {
+ options.IndentationSize = value;
+ }
+ }
+
+ int ITextEditorOptions.TabSize {
+ get {
+ return options.TabSize;
+ }
+ set {
+ options.TabSize = value;
+ }
+ }
+
+ bool ITextEditorOptions.ShowIconMargin {
+ get {
+ return options.ShowIconMargin;
+ }
+ set {
+ options.ShowIconMargin = value;
+ }
+ }
+
+ bool ITextEditorOptions.ShowLineNumberMargin {
+ get {
+ return options.ShowLineNumberMargin;
+ }
+ set {
+ options.ShowLineNumberMargin = value;
+ }
+ }
+
+ bool ITextEditorOptions.ShowFoldMargin {
+ get {
+ return options.ShowFoldMargin;
+ }
+ set {
+ options.ShowFoldMargin = value;
+ }
+ }
+
+ bool ITextEditorOptions.HighlightCaretLine {
+ get {
+ return options.HighlightCaretLine;
+ }
+ set {
+ options.HighlightCaretLine = value;
+ }
+ }
+
+ int ITextEditorOptions.RulerColumn {
+ get {
+ return options.RulerColumn;
+ }
+ set {
+ options.RulerColumn = value;
+ }
+ }
+
+ bool ITextEditorOptions.ShowRuler {
+ get {
+ return options.ShowRuler;
+ }
+ set {
+ options.ShowRuler = value;
+ }
+ }
+
+ IndentStyle ITextEditorOptions.IndentStyle {
+ get {
+ return (IndentStyle)options.IndentStyle;
+ }
+ set {
+ options.IndentStyle = (Mono.TextEditor.IndentStyle)value;
+ }
+ }
+
+ bool ITextEditorOptions.OverrideDocumentEolMarker {
+ get {
+ return options.OverrideDocumentEolMarker;
+ }
+ set {
+ options.OverrideDocumentEolMarker = value;
+ }
+ }
+
+ bool ITextEditorOptions.EnableSyntaxHighlighting {
+ get {
+ return options.EnableSyntaxHighlighting;
+ }
+ set {
+ options.EnableSyntaxHighlighting = value;
+ }
+ }
+
+ bool ITextEditorOptions.EnableAnimations {
+ get {
+ return options.EnableAnimations;
+ }
+ }
+
+ bool ITextEditorOptions.EnableSelectionWrappingKeys {
+ get {
+ return options.EnableSelectionWrappingKeys;
+ }
+ }
+
+ bool ITextEditorOptions.EnableQuickDiff {
+ get {
+ return options.EnableQuickDiff;
+ }
+ set {
+ options.EnableQuickDiff = value;
+ }
+ }
+
+ bool ITextEditorOptions.DrawIndentationMarkers {
+ get {
+ return options.DrawIndentationMarkers;
+ }
+ set {
+ options.DrawIndentationMarkers = value;
+ }
+ }
+
+ bool ITextEditorOptions.WrapLines {
+ get {
+ return options.WrapLines;
+ }
+ set {
+ options.WrapLines = value;
+ }
+ }
+
+ string ITextEditorOptions.FontName {
+ get {
+ return options.FontName;
+ }
+ set {
+ options.FontName = value;
+ }
+ }
+
+ Pango.FontDescription ITextEditorOptions.Font {
+ get {
+ return options.Font;
+ }
+ }
+
+ string ITextEditorOptions.GutterFontName {
+ get {
+ return options.GutterFontName;
+ }
+ set {
+ options.GutterFontName = value;
+ }
+ }
+
+ Pango.FontDescription ITextEditorOptions.GutterFont {
+ get {
+ return options.GutterFont;
+ }
+ }
+
+ string ITextEditorOptions.ColorScheme {
+ get {
+ return options.ColorScheme;
+ }
+ set {
+ options.ColorScheme = value;
+ }
+ }
+
+ string ITextEditorOptions.DefaultEolMarker {
+ get {
+ return options.DefaultEolMarker;
+ }
+ set {
+ options.DefaultEolMarker = value;
+ }
+ }
+
+ ShowWhitespaces ITextEditorOptions.ShowWhitespaces {
+ get {
+ return (ShowWhitespaces)options.ShowWhitespaces;
+ }
+ set {
+ options.ShowWhitespaces = (Mono.TextEditor.ShowWhitespaces)value;
+ }
+ }
+
+ IncludeWhitespaces ITextEditorOptions.IncludeWhitespaces {
+ get {
+ return (IncludeWhitespaces)options.IncludeWhitespaces;
+ }
+ set {
+ options.IncludeWhitespaces = (Mono.TextEditor.IncludeWhitespaces)value;
+ }
+ }
+
+ bool ITextEditorOptions.GenerateFormattingUndoStep {
+ get {
+ return options.GenerateFormattingUndoStep;
+ }
+ set {
+ options.GenerateFormattingUndoStep = value;
+ }
+ }
+ #endregion
+
+ #region IDisposable implementation
+ void IDisposable.Dispose ()
+ {
+ options.Dispose ();
+ }
+ #endregion
+ }
+
+}