-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathColorSet.cs
More file actions
234 lines (207 loc) · 7.49 KB
/
Copy pathColorSet.cs
File metadata and controls
234 lines (207 loc) · 7.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
using System.Windows.Media;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;
using System.ComponentModel.Composition;
using System.Windows;
using Microsoft.VisualStudio.Text.Editor;
namespace ProgressiveScroll
{
public class FormatNames
{
public const string Text = "Progressive Scroll Text";
public const string VisibleRegion = "Progressive Scroll Visible Region";
public const string Comments = "Progressive Scroll Comments";
public const string Strings = "Progressive Scroll Strings";
public const string Changes = "Progressive Scroll Changes";
public const string UnsavedChanges = "Progressive Scroll Unsaved Changes";
public const string Highlights = "Progressive Scroll Highlights";
public const string Breakpoints = "Progressive Scroll Breakpoints";
public const string Bookmarks = "Progressive Scroll Bookmarks";
public const string Errors = "Progressive Scroll Errors";
}
public class ClassificationNames
{
public const string Highlights = "PSHighlightWordClassification";
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.Text)]
[UserVisible(true)]
internal class TextFormatDefinition : MarkerFormatDefinition
{
public TextFormatDefinition()
{
DisplayName = FormatNames.Text;
BackgroundColor = Color.FromRgb(238, 238, 238);
ForegroundColor = Colors.Gray;
}
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.VisibleRegion)]
[UserVisible(true)]
internal class VisibleRegionFormatDefinition : MarkerFormatDefinition
{
public VisibleRegionFormatDefinition()
{
DisplayName = FormatNames.VisibleRegion;
BackgroundColor = Colors.Gray;
ForegroundColor = Colors.Black;
}
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.Comments)]
[UserVisible(true)]
internal class CommentsFormatDefinition : MarkerFormatDefinition
{
public CommentsFormatDefinition()
{
DisplayName = FormatNames.Comments;
BackgroundColor = Colors.Black;
BackgroundCustomizable = false;
ForegroundColor = Colors.Green;
}
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.Strings)]
[UserVisible(true)]
internal class StringsFormatDefinition : MarkerFormatDefinition
{
public StringsFormatDefinition()
{
DisplayName = FormatNames.Strings;
BackgroundColor = Colors.Black;
BackgroundCustomizable = false;
ForegroundColor = Color.FromRgb(190, 80, 80);
}
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.Changes)]
[UserVisible(true)]
internal class ChangesFormatDefinition : MarkerFormatDefinition
{
public ChangesFormatDefinition()
{
DisplayName = FormatNames.Changes;
BackgroundColor = Colors.Black;
BackgroundCustomizable = false;
ForegroundColor = Color.FromRgb(108, 226, 108);
}
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.UnsavedChanges)]
[UserVisible(true)]
internal class UnsavedChangesFormatDefinition : MarkerFormatDefinition
{
public UnsavedChangesFormatDefinition()
{
DisplayName = FormatNames.UnsavedChanges;
BackgroundColor = Colors.Black;
BackgroundCustomizable = false;
ForegroundColor = Color.FromRgb(255, 238, 98);
}
}
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = ClassificationNames.Highlights)]
[Name(FormatNames.Highlights)]
[UserVisible(true)]
[Order(After = Priority.High)]
public sealed class HighlightsFormatDefinition : ClassificationFormatDefinition
{
public HighlightsFormatDefinition()
{
DisplayName = FormatNames.Highlights;
BackgroundColor = Colors.Orange;
ForegroundColor = Colors.Black;
}
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.Breakpoints)]
[UserVisible(true)]
internal class BreakpointsFormatDefinition : MarkerFormatDefinition
{
public BreakpointsFormatDefinition()
{
DisplayName = FormatNames.Breakpoints;
BackgroundColor = Colors.Black;
BackgroundCustomizable = false;
ForegroundColor = Colors.Red;
}
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.Bookmarks)]
[UserVisible(true)]
internal class BookmarksFormatDefinition : MarkerFormatDefinition
{
public BookmarksFormatDefinition()
{
DisplayName = FormatNames.Bookmarks;
BackgroundColor = Colors.Black;
BackgroundCustomizable = false;
ForegroundColor = Colors.Blue;
}
}
[Export(typeof(EditorFormatDefinition))]
[Name(FormatNames.Errors)]
[UserVisible(true)]
internal class ErrorsFormatDefinition : MarkerFormatDefinition
{
public ErrorsFormatDefinition()
{
DisplayName = FormatNames.Errors;
BackgroundColor = Colors.Black;
BackgroundCustomizable = false;
ForegroundColor = Colors.Maroon;
}
}
class ColorSet
{
private readonly IEditorFormatMap _formatMap;
public SolidColorBrush WhitespaceBrush { get; private set; }
public SolidColorBrush TextBrush { get; private set; }
public SolidColorBrush CommentsBrush { get; private set; }
public SolidColorBrush StringsBrush { get; private set; }
public SolidColorBrush VisibleRegionBrush { get; private set; }
public Pen VisibleRegionBorderPen { get; private set; }
public SolidColorBrush ChangesBrush { get; private set; }
public SolidColorBrush UnsavedChangesBrush { get; private set; }
public SolidColorBrush HighlightsBrush { get; private set; }
public SolidColorBrush BreakpointsBrush { get; private set; }
public SolidColorBrush BookmarksBrush { get; private set; }
public SolidColorBrush ErrorsBrush { get; private set; }
public ColorSet(IEditorFormatMap formatMap)
{
_formatMap = formatMap;
_formatMap.FormatMappingChanged += OnFormatMappingChanged;
ReloadColors();
}
private void OnFormatMappingChanged(object sender, FormatItemsEventArgs e)
{
ProgressiveScroll.SettingsChanged();
}
public void ReloadColors()
{
ResourceDictionary resDict = _formatMap.GetProperties(FormatNames.Text);
WhitespaceBrush = (SolidColorBrush)resDict[EditorFormatDefinition.BackgroundBrushId];
TextBrush = (SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId];
resDict = _formatMap.GetProperties(FormatNames.VisibleRegion);
Color c = (Color)resDict[EditorFormatDefinition.BackgroundColorId];
VisibleRegionBrush = new SolidColorBrush(Color.FromArgb((byte)(Options.CursorOpacity * 255), c.R, c.G, c.B));
VisibleRegionBorderPen = new Pen((SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId], 1.0);
resDict = _formatMap.GetProperties(FormatNames.Comments);
CommentsBrush = (SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId];
resDict = _formatMap.GetProperties(FormatNames.Strings);
StringsBrush = (SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId];
resDict = _formatMap.GetProperties(FormatNames.Changes);
ChangesBrush = (SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId];
resDict = _formatMap.GetProperties(FormatNames.UnsavedChanges);
UnsavedChangesBrush = (SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId];
resDict = _formatMap.GetProperties(FormatNames.Highlights);
HighlightsBrush = (SolidColorBrush)resDict[EditorFormatDefinition.BackgroundBrushId];
resDict = _formatMap.GetProperties(FormatNames.Breakpoints);
BreakpointsBrush = (SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId];
resDict = _formatMap.GetProperties(FormatNames.Bookmarks);
BookmarksBrush = (SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId];
resDict = _formatMap.GetProperties(FormatNames.Errors);
ErrorsBrush = (SolidColorBrush)resDict[EditorFormatDefinition.ForegroundBrushId];
}
}
}