private void FromSkipToNoSkip(int line, bool hasText, int textAt) { for (int i = 0; i < _activeSpans.Count; ++i) { var span = _activeSpans[i]; if (span == null) { continue; } bool remove = false; if (hasText) { if (span.Indent > textAt || (span.Indent == textAt && !_options.VisibleAtTextEnd)) { remove = true; } } else if (!_options.VisibleEmpty) { remove = true; } if (remove) { LineSpan.Unlink(span, CancellationToken.None); _activeSpans[i] = null; } else { span.FirstLine = span.LastLine = line; } } if (!hasText && _options.VisibleEmpty) { var indents = GetIndents(_previousLine.TextAt); for (int i = 0; i < _activeSpans.Count; ++i) { var span = _activeSpans[i]; if (span == null) { continue; } if (indents.Remove(span.Indent)) { span.FirstLine = span.LastLine = line; } } StartSpans(indents, line, int.MaxValue); } }
public override void AddLine(LineSpan lineSpan, bool willUpdateImmediately) { if (lineSpan.Highlight) { lineSpan.Highlight = false; if (!willUpdateImmediately) { Modified.Add(lineSpan); } } }
public override IEnumerable <LineSpan> GetModified() { if (Nearest != null) { while (Modified.Remove(Nearest)) { } Nearest.Highlight = true; Modified.Add(Nearest); Modified.AddRange(Nearest.LinkedLines); Nearest = null; } return(Modified); }
private LineSpan StartSpan(int line, int indent, LineSpanType lineType) { var span = new LineSpan(line, line, indent, lineType); for (int i = 0; i < _activeSpans.Count; ++i) { if (_activeSpans[i] == null) { _activeSpans[i] = span; return(span); } } _activeSpans.Add(span); return(span); }
private void FromNoSkipToSkip(int line) { for (int i = 0; i < _activeSpans.Count; ++i) { var span = _activeSpans[i]; if (span == null) { continue; } span.LastLine = line - 1; _completedSpans.Add(span); var newSpan = new LineSpan(line, line, span.Indent, span.Type); LineSpan.Link(span, newSpan, CancellationToken.None); _activeSpans[i] = newSpan; } }
public override void AddLine(LineSpan line, bool willUpdateImmediately) { bool isTouching = false; if (line.FirstLine - 1 == LineNumber || line.LastLine + 1 == LineNumber) { isTouching = true; } if (line.Highlight != isTouching) { line.Highlight = isTouching; if (!willUpdateImmediately) { Modified.Add(line); } Modified.AddRange(line.LinkedLines); } }
void UpdateGuide(LineSpan lineSpan, Line adornment, double left, double top, double bottom) { if (bottom <= top) { adornment.Visibility = Visibility.Collapsed; } else { adornment.X1 = left + 0.5; #if DEBUG adornment.X2 = left + 1.5; #else adornment.X2 = left + 0.5; #endif adornment.Y1 = top; adornment.Y2 = bottom; adornment.StrokeDashOffset = top; adornment.Visibility = Visibility.Visible; UpdateGuide(lineSpan, adornment); } }
public override void AddLine(LineSpan line, bool willUpdateImmediately) { if (line.FirstLine <= LineNumber && LineNumber <= line.LastLine && ((line.LastLine - line.FirstLine) >= MinimumLength || line.LinkedLines.Any()) && line.Indent <= Position && (Nearest == null || line.Indent > Nearest.Indent)) { Nearest = line; } if (line.Highlight) { line.Highlight = false; if (!willUpdateImmediately) { Modified.Add(line); } Modified.AddRange(line.LinkedLines); } }
public override void AddLine(LineSpan line, bool willUpdateImmediately) { bool isTouching = false; if (line.FirstLine - 1 <= LineNumber && LineNumber <= line.LastLine + 1 && (line.LastLine - line.FirstLine) >= MinimumLength && line.Indent == Position) { isTouching = true; } if (line.Highlight != isTouching) { line.Highlight = isTouching; if (!willUpdateImmediately) { Modified.Add(line); } Modified.AddRange(line.LinkedLines); } }
/// <summary> /// Updates the line <paramref name="guide"/> with a new format. /// </summary> /// <param name="guide">The <see cref="Line"/> to update.</param> /// <param name="formatIndex">The new format index.</param> void UpdateGuide(LineSpan lineSpan, Line adornment) { if (lineSpan == null || adornment == null) { return; } LineFormat format; if (lineSpan.Type == LineSpanType.PageWidthMarker) { if (!Theme.PageWidthMarkers.TryGetValue(lineSpan.Indent, out format)) { format = Theme.DefaultLineFormat; } } else if (!Theme.LineFormats.TryGetValue(lineSpan.FormatIndex, out format)) { format = Theme.DefaultLineFormat; } if (!format.Visible) { adornment.Visibility = Visibility.Hidden; return; } bool highlight = lineSpan.Highlight || lineSpan.LinkedLines.Any(ls => ls.Highlight); var lineStyle = highlight ? format.HighlightStyle : format.LineStyle; var lineColor = (highlight && !lineStyle.HasFlag(LineStyle.Glow)) ? format.HighlightColor : format.LineColor; Brush brush; if (!GuideBrushCache.TryGetValue(lineColor, out brush)) { brush = new SolidColorBrush(lineColor.ToSWMC()); if (brush.CanFreeze) { brush.Freeze(); } GuideBrushCache[lineColor] = brush; } adornment.Stroke = brush; adornment.StrokeThickness = lineStyle.GetStrokeThickness(); adornment.StrokeDashArray = lineStyle.GetStrokeDashArray(); if (lineStyle.HasFlag(LineStyle.Dotted) || lineStyle.HasFlag(LineStyle.Dashed)) { adornment.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Unspecified); } else { adornment.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased); } if (lineStyle.HasFlag(LineStyle.Glow)) { Effect effect; var glowColor = highlight ? format.HighlightColor : format.LineColor; if (!GlowEffectCache.TryGetValue(glowColor, out effect)) { effect = new DropShadowEffect { Color = glowColor.ToSWMC(), BlurRadius = LineStyle.Thick.GetStrokeThickness(), Opacity = 1.0, ShadowDepth = 0.0, RenderingBias = RenderingBias.Performance }; if (effect.CanFreeze) { effect.Freeze(); } GlowEffectCache[glowColor] = effect; } try { adornment.Effect = effect; } catch (COMException) { // No sensible way to deal with this exception, so we'll // fall back on changing the color. adornment.Effect = null; if (!GuideBrushCache.TryGetValue(glowColor, out brush)) { brush = new SolidColorBrush(glowColor.ToSWMC()); if (brush.CanFreeze) { brush.Freeze(); } GuideBrushCache[glowColor] = brush; } adornment.Stroke = brush; } } else { adornment.Effect = null; } }
/// <summary> /// Updates the internal state based on the line. All lines should be /// passed. /// </summary> /// <param name="lineSpan"> /// The line to use and potentially update. /// </param> /// <param name="willUpdateImmediately"> /// If True, lines modified directly will not be returned again by /// GetModified(). However, some lines may be modified indirectly, so a /// call to GetModified() is still required.</param> public abstract void AddLine(LineSpan lineSpan, bool willUpdateImmediately);
protected CaretNearestLeftBase(VirtualSnapshotPoint location, int tabSize, int minimumLength) : base(location, tabSize) { Nearest = null; MinimumLength = minimumLength - 1; }