4
using System.Collections;
10
using MonoDevelop.Components;
12
using MonoDevelop.Core;
13
using MonoDevelop.Core.Gui.Dialogs;
15
using MonoDevelop.Ide.Gui.Content;
17
namespace MonoDevelop.SourceEditor.Gui.OptionPanels
19
class SyntaxHighlightingPanel : AbstractOptionPanel
21
SyntaxHighlightingPanelWidget widget;
23
public override void LoadPanelContents()
25
Add (widget = new SyntaxHighlightingPanelWidget ());
28
public override bool StorePanelContents()
34
class SyntaxHighlightingPanelWidget : GladeWidgetExtract
36
[Glade.Widget] CheckButton enableSyntaxHighlighting;
37
[Glade.Widget] ComboBox sourceLanguages;
38
[Glade.Widget] Gtk.TreeView stylesTreeView;
39
[Glade.Widget] ToggleButton boldToggle;
40
[Glade.Widget] ToggleButton italicToggle;
41
[Glade.Widget] ToggleButton underlineToggle;
42
[Glade.Widget] ToggleButton strikeToggle;
43
[Glade.Widget] ColorButton fgColorButton;
44
[Glade.Widget] ColorButton bgColorButton;
45
[Glade.Widget] Button restoreDefaultButton;
46
[Glade.Widget] VBox childrenVBox;
47
[Glade.Widget] CheckButton checkColor;
48
[Glade.Widget] CheckButton checkBackground;
50
SourceLanguage currentLanguage;
51
SourceStyleScheme currentStyle;
54
public SyntaxHighlightingPanelWidget () : base ("EditorBindings.glade", "SyntaxHighlightingPanel")
56
enableSyntaxHighlighting.Active = TextEditorProperties.SyntaxHighlight;
58
// add available sourceLanguages
59
ListStore store = new ListStore (typeof (string));
60
foreach (SourceLanguage sl in SourceViewService.AvailableLanguages)
61
store.AppendValues (sl.Name);
62
store.SetSortColumnId (0, SortType.Ascending);
63
sourceLanguages.Model = store;
65
CellRendererText cr = new CellRendererText ();
66
sourceLanguages.PackStart (cr, true);
67
sourceLanguages.AddAttribute (cr, "text", 0);
68
sourceLanguages.Active = 0;
70
stylesTreeView.AppendColumn ("styles", new CellRendererText (), "text", 0);
71
stylesTreeView.Selection.Changed += new EventHandler (OnStyleChanged);
76
TextEditorProperties.SyntaxHighlight = enableSyntaxHighlighting.Active;
79
void SetCurrentLanguage (string name)
81
currentLanguage = SourceViewService.FindLanguage (name);
85
void SetSourceTagStyle ()
89
SourceTagStyle sts = currentStyle;
90
boldToggle.Active = sts.Bold;
91
italicToggle.Active = sts.Italic;
92
underlineToggle.Active = sts.Underline;
93
strikeToggle.Active = sts.Strikethrough;
94
fgColorButton.Color = sts.Foreground;
95
bgColorButton.Color = sts.Background;
96
checkColor.Active = (sts.Mask & 2) != 0;
97
checkBackground.Active = (sts.Mask & 1) != 0;
98
fgColorButton.Sensitive = checkColor.Active;
99
bgColorButton.Sensitive = checkBackground.Active;
100
restoreDefaultButton.Sensitive = !sts.IsDefault;*/
103
void SetTreeValues ()
108
ListStore store = new ListStore (typeof (string), typeof (string));
109
foreach (SourceTag t in currentLanguage.Tags)
110
store.AppendValues (t.Name, t.Id);
111
stylesTreeView.Model = store;
114
store.GetIterFirst (out first);
115
stylesTreeView.Selection.SelectIter (first);*/
118
protected void OnButtonToggled (object sender, EventArgs a)
122
SourceTagStyle sts = currentStyle;
123
sts.Bold = boldToggle.Active;
124
sts.Italic = italicToggle.Active;
125
sts.Underline = underlineToggle.Active;
126
sts.Strikethrough = strikeToggle.Active;
127
sts.IsDefault = false;
128
currentLanguage.SetTagStyle (styleid, sts);
129
restoreDefaultButton.Sensitive = true;*/
132
protected void OnColorSet (object sender, EventArgs a)
136
SourceTagStyle sts = currentStyle;
137
sts.Foreground = fgColorButton.Color;
138
sts.Background = bgColorButton.Color;
139
sts.Mask = checkColor.Active ? 2u : 0u;
140
sts.Mask += checkBackground.Active ? 1u : 0u;
141
fgColorButton.Sensitive = checkColor.Active;
142
bgColorButton.Sensitive = checkBackground.Active;
143
sts.IsDefault = false;
144
currentLanguage.SetTagStyle (styleid, sts);
145
restoreDefaultButton.Sensitive = true;*/
148
protected void OnHighlightingToggled (object sender, EventArgs a)
150
CheckButton cb = sender as CheckButton;
151
childrenVBox.Sensitive = cb.Active;
154
protected void OnLanguageSelected (object sender, EventArgs a)
157
if (sourceLanguages.GetActiveIter (out iter)) {
158
SetCurrentLanguage ((string) sourceLanguages.Model.GetValue (iter, 0));
162
protected void OnRestoreClicked (object sender, EventArgs a)
166
currentLanguage = svs.RestoreDefaults (currentLanguage);
167
OnStyleChanged (stylesTreeView.Selection, EventArgs.Empty);
171
private void OnStyleChanged (object sender, EventArgs a)
177
TreeSelection selection = sender as TreeSelection;
179
if (selection.GetSelected (out model, out iter)) {
180
styleid = (string) model.GetValue (iter, 1);
181
currentStyle = currentLanguage.GetTagStyle (styleid);
182
SetSourceTagStyle ();