2
// StyledSourceEditorOptions.cs
5
// Michael Hutchinson <mhutchinson@novell.com>
7
// Copyright (c) 2009 Novell, Inc. (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using MonoDevelop.Projects;
29
using MonoDevelop.Ide.Gui.Content;
31
namespace MonoDevelop.SourceEditor
34
internal class StyledSourceEditorOptions : ISourceEditorOptions
36
TextStylePolicy currentPolicy;
40
public StyledSourceEditorOptions (Project styleParent)
42
UpdateStyleParent (styleParent);
45
public void UpdateStyleParent (Project styleParent)
47
if (this.styleParent != null)
48
this.styleParent.Policies.PolicyChanged -= HandlePolicyChanged;
50
this.styleParent = styleParent;
52
if (styleParent != null) {
53
currentPolicy = styleParent.Policies.Get<TextStylePolicy> ();
54
styleParent.Policies.PolicyChanged += HandlePolicyChanged;
60
void HandlePolicyChanged (object sender, MonoDevelop.Projects.Policies.PolicyChangedEventArgs args)
62
TextStylePolicy newPolicy = args.Policy as TextStylePolicy;
63
if (newPolicy != null) {
64
currentPolicy = newPolicy;
65
this.changed (this, EventArgs.Empty);
69
public int RulerColumn {
71
return currentPolicy != null
72
? currentPolicy.FileWidth
73
: DefaultSourceEditorOptions.Instance.RulerColumn;
79
return currentPolicy != null
80
? currentPolicy.TabWidth
81
: DefaultSourceEditorOptions.Instance.TabSize;
85
public bool TabsToSpaces {
87
return currentPolicy != null
88
? currentPolicy.TabsToSpaces
89
: DefaultSourceEditorOptions.Instance.TabsToSpaces;
93
public bool RemoveTrailingWhitespaces {
95
return currentPolicy != null
96
? currentPolicy.RemoveTrailingWhitespace
97
: DefaultSourceEditorOptions.Instance.RemoveTrailingWhitespaces;
101
public bool AllowTabsAfterNonTabs {
103
return currentPolicy != null
104
? !currentPolicy.NoTabsAfterNonTabs
105
: DefaultSourceEditorOptions.Instance.AllowTabsAfterNonTabs;
109
public int IndentationSize {
110
get { return TabSize; }
113
public string IndentationString {
115
return this.TabsToSpaces ? new string (' ', this.TabSize) : "\t";
119
#region ITextEditorOptions implementation
121
public bool AutoIndent {
122
get { return DefaultSourceEditorOptions.Instance.AutoIndent; }
125
public bool CanResetZoom {
126
get { return DefaultSourceEditorOptions.Instance.CanResetZoom; }
129
public bool CanZoomIn {
130
get { return DefaultSourceEditorOptions.Instance.CanZoomIn; }
133
public bool CanZoomOut {
134
get { return DefaultSourceEditorOptions.Instance.CanZoomOut; }
137
public event EventHandler Changed {
141
DefaultSourceEditorOptions.Instance.Changed += HandleDefaultsChanged;
146
DefaultSourceEditorOptions.Instance.Changed -= HandleDefaultsChanged;
150
void HandleDefaultsChanged (object sender, EventArgs e)
152
changed (this, EventArgs.Empty);
155
public string ColorScheme {
156
get { return DefaultSourceEditorOptions.Instance.ColorScheme; }
159
public bool EnableSyntaxHighlighting {
160
get { return DefaultSourceEditorOptions.Instance.EnableSyntaxHighlighting; }
163
public Pango.FontDescription Font {
164
get { return DefaultSourceEditorOptions.Instance.Font; }
167
public string FontName {
168
get { return DefaultSourceEditorOptions.Instance.FontName; }
171
public Mono.TextEditor.Highlighting.Style GetColorStyle (Gtk.Widget widget)
173
return DefaultSourceEditorOptions.Instance.GetColorStyle (widget);
176
public bool HighlightCaretLine {
177
get { return DefaultSourceEditorOptions.Instance.HighlightCaretLine; }
180
public bool HighlightMatchingBracket {
181
get { return DefaultSourceEditorOptions.Instance.HighlightMatchingBracket; }
184
public bool ShowEolMarkers {
185
get { return DefaultSourceEditorOptions.Instance.ShowEolMarkers; }
188
public bool ShowFoldMargin {
189
get { return DefaultSourceEditorOptions.Instance.ShowFoldMargin; }
192
public bool ShowIconMargin {
193
get { return DefaultSourceEditorOptions.Instance.ShowIconMargin; }
196
public bool ShowInvalidLines {
197
get { return DefaultSourceEditorOptions.Instance.ShowInvalidLines; }
200
public bool ShowLineNumberMargin {
201
get { return DefaultSourceEditorOptions.Instance.ShowLineNumberMargin; }
204
public bool ShowRuler {
205
get { return DefaultSourceEditorOptions.Instance.ShowRuler; }
208
public bool ShowSpaces {
209
get { return DefaultSourceEditorOptions.Instance.ShowSpaces; }
212
public bool ShowTabs {
213
get { return DefaultSourceEditorOptions.Instance.ShowTabs; }
216
public Mono.TextEditor.IWordFindStrategy WordFindStrategy {
217
get { return DefaultSourceEditorOptions.Instance.WordFindStrategy; }
221
get { return DefaultSourceEditorOptions.Instance.Zoom; }
224
public void ZoomIn ()
226
DefaultSourceEditorOptions.Instance.ZoomIn ();
229
public void ZoomOut ()
231
DefaultSourceEditorOptions.Instance.ZoomOut ();
234
public void ZoomReset ()
236
DefaultSourceEditorOptions.Instance.ZoomReset ();
242
#region ISourceEditorOptions implementation
244
public bool AutoInsertMatchingBracket {
245
get { return DefaultSourceEditorOptions.Instance.AutoInsertMatchingBracket; }
248
public bool DefaultCommentFolding {
249
get { return DefaultSourceEditorOptions.Instance.DefaultCommentFolding; }
252
public bool DefaultRegionsFolding {
253
get { return DefaultSourceEditorOptions.Instance.DefaultRegionsFolding; }
256
public EditorFontType EditorFontType {
257
get { return DefaultSourceEditorOptions.Instance.EditorFontType; }
260
public bool EnableAutoCodeCompletion {
261
get { return DefaultSourceEditorOptions.Instance.EnableAutoCodeCompletion; }
264
public bool EnableCodeCompletion {
265
get { return DefaultSourceEditorOptions.Instance.EnableCodeCompletion; }
268
public bool EnableQuickFinder {
269
get { return DefaultSourceEditorOptions.Instance.EnableQuickFinder; }
272
public bool EnableSemanticHighlighting {
273
get { return DefaultSourceEditorOptions.Instance.EnableSemanticHighlighting; }
276
public IndentStyle IndentStyle {
277
get { return DefaultSourceEditorOptions.Instance.IndentStyle; }
280
public bool TabIsReindent {
281
get { return DefaultSourceEditorOptions.Instance.TabIsReindent; }
284
public bool UnderlineErrors {
285
get { return DefaultSourceEditorOptions.Instance.UnderlineErrors; }
288
public bool UseViModes {
289
get { return DefaultSourceEditorOptions.Instance.UseViModes; }
294
public void Dispose ()
296
UpdateStyleParent (null);
297
if (changed != null) {
298
DefaultSourceEditorOptions.Instance.Changed -= HandleDefaultsChanged;