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/StyledSourceEditorOptions.cs')
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs448
1 files changed, 200 insertions, 248 deletions
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs
index 01d4f54f65..7e46cb6ac9 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/StyledSourceEditorOptions.cs
@@ -25,350 +25,302 @@
// THE SOFTWARE.
using System;
-using System.Collections.Generic;
-using MonoDevelop.Projects;
-using MonoDevelop.Projects.Policies;
-using MonoDevelop.Ide.Gui.Content;
-using MonoDevelop.Ide;
using Mono.TextEditor;
+using MonoDevelop.Ide.Editor;
namespace MonoDevelop.SourceEditor
{
-
- internal class StyledSourceEditorOptions : ISourceEditorOptions
+ class StyledSourceEditorOptions : TextEditorOptions
{
- PolicyContainer policyContainer;
- EventHandler changed;
- IEnumerable<string> mimeTypes;
- TextStylePolicy currentPolicy;
- string lastMimeType;
+ MonoDevelop.Ide.Editor.ITextEditorOptions optionsCore;
- public StyledSourceEditorOptions (Project styleParent, string mimeType)
- {
- UpdateStyleParent (styleParent, mimeType);
+ public MonoDevelop.Ide.Editor.ITextEditorOptions OptionsCore {
+ get {
+ return optionsCore;
+ }
+ set {
+ optionsCore = value;
+ OnChanged (EventArgs.Empty);
+ }
}
-
- TextStylePolicy CurrentPolicy {
- get { return currentPolicy; }
+
+ public StyledSourceEditorOptions (MonoDevelop.Ide.Editor.ITextEditorOptions optionsCore)
+ {
+ if (optionsCore == null)
+ throw new ArgumentNullException ("optionsCore");
+ this.optionsCore = optionsCore;
+ DefaultSourceEditorOptions.Instance.Changed += HandleChanged;
}
-
- public void UpdateStyleParent (Project styleParent, string mimeType)
+ public override void Dispose ()
{
- if (styleParent != null && policyContainer == styleParent.Policies && mimeType == lastMimeType)
- return;
- lastMimeType = mimeType;
-
- if (policyContainer != null)
- policyContainer.PolicyChanged -= HandlePolicyChanged;
-
- if (string.IsNullOrEmpty (mimeType))
- mimeType = "text/plain";
- this.mimeTypes = DesktopService.GetMimeTypeInheritanceChain (mimeType);
-
- if (styleParent != null)
- policyContainer = styleParent.Policies;
- else
- policyContainer = MonoDevelop.Projects.Policies.PolicyService.DefaultPolicies;
- currentPolicy = policyContainer.Get<TextStylePolicy> (mimeTypes);
-
- policyContainer.PolicyChanged += HandlePolicyChanged;
- if (changed != null)
- this.changed (this, EventArgs.Empty);
+ DefaultSourceEditorOptions.Instance.Changed -= HandleChanged;
+
+ base.Dispose ();
}
- void HandlePolicyChanged (object sender, MonoDevelop.Projects.Policies.PolicyChangedEventArgs args)
+ void HandleChanged (object sender, EventArgs e)
{
- currentPolicy = policyContainer.Get<TextStylePolicy> (mimeTypes);
- if (changed != null)
- this.changed (this, EventArgs.Empty);
+ DisposeFont ();
+ OnChanged (EventArgs.Empty);
}
- public bool OverrideDocumentEolMarker {
- get { return DefaultSourceEditorOptions.Instance.OverrideDocumentEolMarker; }
+ #region ITextEditorOptions implementation
+ static IWordFindStrategy monoDevelopWordFindStrategy = new EmacsWordFindStrategy (false);
+ static IWordFindStrategy emacsWordFindStrategy = new EmacsWordFindStrategy (true);
+ static IWordFindStrategy sharpDevelopWordFindStrategy = new SharpDevelopWordFindStrategy ();
+ static IWordFindStrategy viWordFindStrategy = new Mono.TextEditor.Vi.ViWordFindStrategy ();
+
+ public override IWordFindStrategy WordFindStrategy {
+ get {
+ switch (DefaultSourceEditorOptions.Instance.WordFindStrategy) {
+ case MonoDevelop.Ide.Editor.WordFindStrategy.MonoDevelop:
+ return monoDevelopWordFindStrategy;
+ case MonoDevelop.Ide.Editor.WordFindStrategy.Emacs:
+ return emacsWordFindStrategy;
+ case MonoDevelop.Ide.Editor.WordFindStrategy.SharpDevelop:
+ return sharpDevelopWordFindStrategy;
+ case MonoDevelop.Ide.Editor.WordFindStrategy.Vim:
+ return viWordFindStrategy;
+ default:
+ throw new ArgumentOutOfRangeException ();
+ }
+ }
set {
- throw new NotSupportedException ();
+ throw new NotImplementedException ();
}
}
-
- public string DefaultEolMarker {
- get { return TextStylePolicy.GetEolMarker (CurrentPolicy.EolMarker); }
+
+ public override bool AllowTabsAfterNonTabs {
+ get {
+ return DefaultSourceEditorOptions.Instance.AllowTabsAfterNonTabs;
+ }
set {
throw new NotSupportedException ();
}
}
- public int RulerColumn {
- get { return CurrentPolicy.FileWidth; }
+ public override bool HighlightMatchingBracket {
+ get {
+ return DefaultSourceEditorOptions.Instance.HighlightMatchingBracket;
+ }
set {
throw new NotSupportedException ();
}
}
- public int TabSize {
- get { return CurrentPolicy.TabWidth; }
+ public override bool TabsToSpaces {
+ get {
+ return optionsCore.TabsToSpaces;
+ }
set {
throw new NotSupportedException ();
}
}
- public bool TabsToSpaces {
- get { return CurrentPolicy.TabsToSpaces; }
+ public override int IndentationSize {
+ get {
+ return optionsCore.IndentationSize;
+ }
set {
throw new NotSupportedException ();
}
}
- public bool RemoveTrailingWhitespaces {
- get { return CurrentPolicy.RemoveTrailingWhitespace; }
+ public override int TabSize {
+ get {
+ return optionsCore.TabSize;
+ }
set {
throw new NotSupportedException ();
}
}
- public bool AllowTabsAfterNonTabs {
- get { return !CurrentPolicy.NoTabsAfterNonTabs; }
+
+ public override bool ShowIconMargin {
+ get {
+ return optionsCore.ShowIconMargin;
+ }
set {
throw new NotSupportedException ();
}
}
- public int IndentationSize {
- get { return CurrentPolicy.IndentWidth; }
+ public override bool ShowLineNumberMargin {
+ get {
+ return optionsCore.ShowLineNumberMargin;
+ }
set {
throw new NotSupportedException ();
}
}
- public string IndentationString {
- get { return this.TabsToSpaces ? new string (' ', this.TabSize) : "\t"; }
- }
-
- #region ITextEditorOptions implementation
-
- public bool CanResetZoom {
- get { return DefaultSourceEditorOptions.Instance.CanResetZoom; }
- }
-
- public bool CanZoomIn {
- get { return DefaultSourceEditorOptions.Instance.CanZoomIn; }
- }
-
- public bool CanZoomOut {
- get { return DefaultSourceEditorOptions.Instance.CanZoomOut; }
- }
-
- public event EventHandler Changed {
- add {
- if (changed == null)
- DefaultSourceEditorOptions.Instance.Changed += HandleDefaultsChanged;
- changed += value;
+ public override bool ShowFoldMargin {
+ get {
+ return optionsCore.ShowFoldMargin;
}
- remove {
- changed -= value;
- if (changed == null)
- DefaultSourceEditorOptions.Instance.Changed -= HandleDefaultsChanged;
+ set {
+ throw new NotSupportedException ();
}
}
- void HandleDefaultsChanged (object sender, EventArgs e)
- {
- if (changed != null)
- changed (this, EventArgs.Empty);
- }
-
- public string ColorScheme {
- get { return DefaultSourceEditorOptions.Instance.ColorScheme; }
- set { throw new NotSupportedException (); }
- }
-
- public bool EnableSyntaxHighlighting {
- get { return DefaultSourceEditorOptions.Instance.EnableSyntaxHighlighting; }
- set { throw new NotSupportedException (); }
- }
-
- public Pango.FontDescription Font {
- get { return DefaultSourceEditorOptions.Instance.Font; }
- }
-
- public string FontName {
- get { return DefaultSourceEditorOptions.Instance.FontName; }
- set { throw new NotSupportedException (); }
- }
-
- public Pango.FontDescription GutterFont {
- get { return DefaultSourceEditorOptions.Instance.GutterFont; }
- }
-
- public string GutterFontName {
- get { return DefaultSourceEditorOptions.Instance.GutterFontName; }
- set { throw new NotSupportedException (); }
- }
-
- public Mono.TextEditor.Highlighting.ColorScheme GetColorStyle ()
- {
- return DefaultSourceEditorOptions.Instance.GetColorStyle ();
- }
-
- public bool HighlightCaretLine {
- get { return DefaultSourceEditorOptions.Instance.HighlightCaretLine; }
- set { throw new NotSupportedException (); }
- }
-
- public bool HighlightMatchingBracket {
- get { return DefaultSourceEditorOptions.Instance.HighlightMatchingBracket; }
- set { throw new NotSupportedException (); }
- }
-
- public bool ShowFoldMargin {
- get { return DefaultSourceEditorOptions.Instance.ShowFoldMargin; }
- set { throw new NotSupportedException (); }
- }
-
- public bool ShowIconMargin {
- get { return DefaultSourceEditorOptions.Instance.ShowIconMargin; }
- set { throw new NotSupportedException (); }
- }
-
- public bool ShowLineNumberMargin {
- get { return DefaultSourceEditorOptions.Instance.ShowLineNumberMargin; }
- set { throw new NotSupportedException (); }
- }
-
- public bool ShowRuler {
- get { return DefaultSourceEditorOptions.Instance.ShowRuler; }
- set { throw new NotSupportedException (); }
- }
-
- public bool EnableAnimations {
- get { return DefaultSourceEditorOptions.Instance.EnableAnimations; }
- set { throw new NotSupportedException (); }
- }
-
- public Mono.TextEditor.IWordFindStrategy WordFindStrategy {
- get { return DefaultSourceEditorOptions.Instance.WordFindStrategy; }
- set { throw new NotSupportedException (); }
- }
-
- public double Zoom {
- get { return DefaultSourceEditorOptions.Instance.Zoom; }
- set { DefaultSourceEditorOptions.Instance.Zoom = value; }
- }
-
- public bool DrawIndentationMarkers {
- get { return DefaultSourceEditorOptions.Instance.DrawIndentationMarkers; }
- set { DefaultSourceEditorOptions.Instance.DrawIndentationMarkers = value; }
- }
-
- public ShowWhitespaces ShowWhitespaces {
- get { return DefaultSourceEditorOptions.Instance.ShowWhitespaces; }
- set { DefaultSourceEditorOptions.Instance.ShowWhitespaces = value; }
- }
-
- public IncludeWhitespaces IncludeWhitespaces {
- get { return DefaultSourceEditorOptions.Instance.IncludeWhitespaces; }
- set { DefaultSourceEditorOptions.Instance.IncludeWhitespaces = value; }
- }
-
- public bool WrapLines {
- get { return DefaultSourceEditorOptions.Instance.WrapLines; }
- set { DefaultSourceEditorOptions.Instance.WrapLines = value; }
+ public override bool HighlightCaretLine {
+ get {
+ return optionsCore.HighlightCaretLine;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool EnableQuickDiff {
- get { return DefaultSourceEditorOptions.Instance.EnableQuickDiff; }
- set { DefaultSourceEditorOptions.Instance.EnableQuickDiff = value; }
+ public override int RulerColumn {
+ get {
+ return optionsCore.RulerColumn;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool GenerateFormattingUndoStep {
- get { return DefaultSourceEditorOptions.Instance.GenerateFormattingUndoStep; }
- set { DefaultSourceEditorOptions.Instance.GenerateFormattingUndoStep = value; }
+ public override bool ShowRuler {
+ get {
+ return optionsCore.ShowRuler;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public void ZoomIn ()
- {
- DefaultSourceEditorOptions.Instance.ZoomIn ();
+ public override Mono.TextEditor.IndentStyle IndentStyle {
+ get {
+ if (optionsCore.IndentStyle == MonoDevelop.Ide.Editor.IndentStyle.Smart && optionsCore.RemoveTrailingWhitespaces)
+ return Mono.TextEditor.IndentStyle.Virtual;
+ return (Mono.TextEditor.IndentStyle)optionsCore.IndentStyle;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public void ZoomOut ()
- {
- DefaultSourceEditorOptions.Instance.ZoomOut ();
+ public override bool OverrideDocumentEolMarker {
+ get {
+ return optionsCore.OverrideDocumentEolMarker;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public void ZoomReset ()
- {
- DefaultSourceEditorOptions.Instance.ZoomReset ();
+ public override bool EnableSyntaxHighlighting {
+ get {
+ return optionsCore.EnableSyntaxHighlighting;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- #endregion
-
-
- #region ISourceEditorOptions implementation
-
- public bool AutoInsertMatchingBracket {
- get { return DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket; }
+ public override bool EnableAnimations {
+ get {
+ return DefaultSourceEditorOptions.Instance.HighlightMatchingBracket;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool DefaultCommentFolding {
- get { return DefaultSourceEditorOptions.Instance.DefaultCommentFolding; }
+ public override bool EnableQuickDiff {
+ get {
+ return DefaultSourceEditorOptions.Instance.EnableQuickDiff;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool DefaultRegionsFolding {
- get { return DefaultSourceEditorOptions.Instance.DefaultRegionsFolding; }
+ public override bool DrawIndentationMarkers {
+ get {
+ return DefaultSourceEditorOptions.Instance.DrawIndentationMarkers;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public EditorFontType EditorFontType {
- get { return DefaultSourceEditorOptions.Instance.EditorFontType; }
+ public override bool WrapLines {
+ get {
+ return optionsCore.WrapLines;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool EnableAutoCodeCompletion {
- get { return DefaultSourceEditorOptions.Instance.EnableAutoCodeCompletion; }
+ public override string FontName {
+ get {
+ return optionsCore.FontName;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool EnableSemanticHighlighting {
- get { return DefaultSourceEditorOptions.Instance.EnableSemanticHighlighting; }
+ public override string GutterFontName {
+ get {
+ return optionsCore.GutterFontName;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public IndentStyle IndentStyle {
+ public override string ColorScheme {
get {
- if ((DefaultSourceEditorOptions.Instance.IndentStyle == Mono.TextEditor.IndentStyle.Smart ||
- DefaultSourceEditorOptions.Instance.IndentStyle == Mono.TextEditor.IndentStyle.Auto) && CurrentPolicy.RemoveTrailingWhitespace)
- return IndentStyle.Virtual;
- return DefaultSourceEditorOptions.Instance.IndentStyle;
+ return optionsCore.ColorScheme;
}
set {
- throw new NotSupportedException ("Use property 'IndentStyle' instead.");
+ throw new NotSupportedException ();
}
}
- public bool TabIsReindent {
- get { return DefaultSourceEditorOptions.Instance.TabIsReindent; }
+ public override string DefaultEolMarker {
+ get {
+ return optionsCore.DefaultEolMarker;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool UnderlineErrors {
- get { return DefaultSourceEditorOptions.Instance.UnderlineErrors; }
+ public override Mono.TextEditor.ShowWhitespaces ShowWhitespaces {
+ get {
+ return (Mono.TextEditor.ShowWhitespaces)optionsCore.ShowWhitespaces;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool UseViModes {
- get { return DefaultSourceEditorOptions.Instance.UseViModes; }
+ public override Mono.TextEditor.IncludeWhitespaces IncludeWhitespaces {
+ get {
+ return (Mono.TextEditor.IncludeWhitespaces)optionsCore.IncludeWhitespaces;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
- public bool EnableSelectionWrappingKeys {
- get { return DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket; }
+ public override bool GenerateFormattingUndoStep {
+ get {
+ return optionsCore.GenerateFormattingUndoStep;
+ }
+ set {
+ throw new NotSupportedException ();
+ }
}
-
#endregion
- public void Dispose ()
- {
- mimeTypes = null;
- if (policyContainer != null)
- policyContainer.PolicyChanged -= HandlePolicyChanged;
- if (changed != null) {
- DefaultSourceEditorOptions.Instance.Changed -= HandleDefaultsChanged;
- changed = null;
- }
- }
+
}
}