81
86
lineHover = lineSegment;
88
foreach (FoldSegment segment in editor.Document.GetFoldingContaining (lineSegment)) {
89
if (segment.StartLine.Offset == lineSegment.Offset) {
97
foldings = editor.Document.GetFoldingContaining (lineSegment);
98
if (editor.TextViewMargin.BackgroundRenderer == null) {
101
DelayTimerElapsed (this, null);
104
RemoveBackgroundRenderer ();
109
IEnumerable<FoldSegment> foldings;
110
void DelayTimerElapsed (object sender, ElapsedEventArgs e)
112
editor.TextViewMargin.BackgroundRenderer = new FoldingScreenbackgroundRenderer (editor, foldings);
116
void RemoveBackgroundRenderer ()
118
if (editor.TextViewMargin.BackgroundRenderer != null) {
119
editor.TextViewMargin.BackgroundRenderer = null;
85
124
internal protected override void MouseLeft ()
104
145
foldLineHighlightedGC = new Gdk.GC (editor.GdkWindow);
105
146
foldLineHighlightedGC.RgbFgColor = editor.ColorStyle.FoldLineHighlighted;
148
HslColor hslColor = new HslColor (editor.ColorStyle.Default.BackgroundColor);
149
double brightness = HslColor.Brightness (editor.ColorStyle.Default.BackgroundColor);
150
if (brightness < 0.5) {
151
hslColor.L = hslColor.L * 0.85 + hslColor.L * 0.25;
153
hslColor.L = hslColor.L * 0.9;
156
foldLineHighlightedGCBg = new Gdk.GC (editor.GdkWindow);
157
foldLineHighlightedGCBg.RgbFgColor = hslColor;
107
159
foldToggleMarkerGC = new Gdk.GC (editor.GdkWindow);
108
160
foldToggleMarkerGC.RgbFgColor = editor.ColorStyle.FoldToggleMarker;
113
165
lineStateDirtyGC = new Gdk.GC (editor.GdkWindow);
114
166
lineStateDirtyGC.RgbFgColor = new Gdk.Color (255, 238, 98);
116
foldDashedLineGC = new Gdk.GC (editor.GdkWindow);
117
foldDashedLineGC.RgbBgColor = editor.ColorStyle.FoldLine.Color;
118
foldDashedLineGC.SetLineAttributes (1, Gdk.LineStyle.OnOffDash, Gdk.CapStyle.NotLast, Gdk.JoinStyle.Bevel);
119
foldDashedLineGC.SetDashes (0, new sbyte[] { 1, 1 }, 2);
121
170
layout.FontDescription = editor.Options.Font;
122
171
layout.SetText ("!");
124
173
layout.GetPixelSize (out tmp, out this.marginWidth);
125
174
marginWidth *= 8;
126
175
marginWidth /= 10;
176
marginWidth--; // was dashed line.
129
Gdk.GC foldBgGC, foldLineGC, foldLineHighlightedGC, foldToggleMarkerGC, foldDashedLineGC;
179
Gdk.GC foldBgGC, foldLineGC, foldLineHighlightedGC, foldLineHighlightedGCBg, foldToggleMarkerGC;
130
180
Gdk.GC lineStateChangedGC, lineStateDirtyGC;
131
181
public override void Dispose ()
184
if (delayTimer != null) {
186
delayTimer.Dispose ();
133
189
layout = layout.Kill ();
139
195
foldBgGC = foldBgGC.Kill ();
140
196
foldLineGC = foldLineGC.Kill ();
141
197
foldLineHighlightedGC = foldLineHighlightedGC.Kill ();
198
foldLineHighlightedGCBg = foldLineHighlightedGCBg.Kill ();
142
199
foldToggleMarkerGC = foldToggleMarkerGC.Kill ();
143
200
lineStateChangedGC = lineStateChangedGC.Kill ();
144
201
lineStateDirtyGC = lineStateDirtyGC.Kill ();
145
foldDashedLineGC = foldDashedLineGC.Kill ();
148
204
void DrawFoldSegment (Gdk.Drawable win, int x, int y, bool isOpen, bool isSelected)
190
239
Gdk.Rectangle drawArea = new Gdk.Rectangle (x, y, Width, editor.LineHeight);
191
240
Document.LineState state = editor.Document.GetLineState (line);
193
if (state == Document.LineState.Changed) {
194
win.DrawRectangle (lineStateChangedGC, true, x , y, 4, editor.LineHeight);
195
win.DrawRectangle (foldBgGC, true, x + 3 , y, Width, editor.LineHeight);
196
} else if (state == Document.LineState.Dirty) {
197
win.DrawRectangle (lineStateDirtyGC, true, x , y, 4, editor.LineHeight);
198
win.DrawRectangle (foldBgGC, true, x + 3 , y, Width, editor.LineHeight);
200
win.DrawRectangle (foldBgGC, true, drawArea);
202
DrawDashedVLine (win, x, drawArea.Top, drawArea.Bottom, line);
242
bool isFoldStart = false;
243
bool isContaining = false;
244
bool isFoldEnd = false;
246
bool isStartSelected = false;
247
bool isContainingSelected = false;
248
bool isEndSelected = false;
204
250
if (line < editor.Document.LineCount) {
205
251
LineSegment lineSegment = editor.Document.GetLine (line);
219
bool isFoldStart = startFoldings.Count > 0;
220
bool isContaining = containingFoldings.Count > 0;
221
bool isFoldEnd = endFoldings.Count > 0;
265
isFoldStart = startFoldings.Count > 0;
266
isContaining = containingFoldings.Count > 0;
267
isFoldEnd = endFoldings.Count > 0;
223
bool isStartSelected = this.lineHover != null && IsMouseHover (startFoldings);
224
bool isContainingSelected = this.lineHover != null && IsMouseHover (containingFoldings);
225
bool isEndSelected = this.lineHover != null && IsMouseHover (endFoldings);
269
isStartSelected = this.lineHover != null && IsMouseHover (startFoldings);
270
isContainingSelected = this.lineHover != null && IsMouseHover (containingFoldings);
271
isEndSelected = this.lineHover != null && IsMouseHover (endFoldings);
274
Gdk.GC bgGC = foldBgGC;
275
if (editor.TextViewMargin.BackgroundRenderer != null) {
276
if (isContainingSelected || isStartSelected || isEndSelected) {
279
bgGC = foldLineHighlightedGCBg;
283
if (state == Document.LineState.Changed) {
284
win.DrawRectangle (lineStateChangedGC, true, x , y, 4, editor.LineHeight);
285
win.DrawRectangle (bgGC, true, x + 3 , y, Width - 3, editor.LineHeight);
286
} else if (state == Document.LineState.Dirty) {
287
win.DrawRectangle (lineStateDirtyGC, true, x , y, 4, editor.LineHeight);
288
win.DrawRectangle (bgGC, true, x + 3 , y, Width - 3, editor.LineHeight);
290
win.DrawRectangle (bgGC, true, drawArea);
293
if (line < editor.Document.LineCount) {
227
295
int foldSegmentYPos = y + (editor.LineHeight - foldSegmentSize) / 2;
228
296
int xPos = x + Width / 2;
231
bool isVisible = true;
232
bool moreLinedOpenFold = false;
233
foreach (FoldSegment foldSegment in startFoldings) {
234
if (foldSegment.IsFolded) {
237
moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset;
240
bool isFoldEndFromUpperFold = false;
241
foreach (FoldSegment foldSegment in endFoldings) {
242
if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded)
243
isFoldEndFromUpperFold = true;
299
bool isVisible = true;
300
bool moreLinedOpenFold = false;
301
foreach (FoldSegment foldSegment in startFoldings) {
302
if (foldSegment.IsFolded) {
305
moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset;
308
bool isFoldEndFromUpperFold = false;
309
foreach (FoldSegment foldSegment in endFoldings) {
310
if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded)
311
isFoldEndFromUpperFold = true;
245
313
DrawFoldSegment (win, x, y, isVisible, isStartSelected);
246
314
if (isContaining || isFoldEndFromUpperFold)
247
win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, foldSegmentYPos - 1);
248
if (isContaining || moreLinedOpenFold)
315
win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, foldSegmentYPos - 1);
316
if (isContaining || moreLinedOpenFold)
249
317
win.DrawLine (isEndSelected || (isStartSelected && isVisible) || isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, foldSegmentYPos + foldSegmentSize + 1, xPos, drawArea.Bottom);
253
321
win.DrawLine (isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid, xPos + foldSegmentSize / 2, yMid);
254
322
win.DrawLine (isContainingSelected || isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, yMid);
255
323
if (isContaining)
256
win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid + 1, xPos, drawArea.Bottom);
324
win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid + 1, xPos, drawArea.Bottom);
257
325
} else if (isContaining) {
258
326
win.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Top, xPos, drawArea.Bottom);