|
18 | 18 |
|
19 | 19 | namespace Emoji.Adornment
|
20 | 20 | {
|
21 |
| - /// <summary> |
22 |
| - /// Helper class for producing intra-text adornments from data tags. |
23 |
| - /// </summary> |
24 |
| - /// <remarks> |
25 |
| - /// For cases where intra-text adornments do not correspond exactly to tags, |
26 |
| - /// use the <see cref="IntraTextAdornmentTagger"/> base class. |
27 |
| - /// </remarks> |
28 |
| - internal abstract class IntraTextAdornmentTagTransformer<TDataTag, TAdornment> |
29 |
| - : IntraTextAdornmentTagger<TDataTag, TAdornment>, IDisposable |
30 |
| - where TDataTag : ITag |
31 |
| - where TAdornment : UIElement |
32 |
| - { |
33 |
| - protected readonly ITagAggregator<TDataTag> dataTagger; |
34 |
| - protected readonly PositionAffinity? adornmentAffinity; |
| 21 | + /// <summary> |
| 22 | + /// Helper class for producing intra-text adornments from data tags. |
| 23 | + /// </summary> |
| 24 | + /// <remarks> |
| 25 | + /// For cases where intra-text adornments do not correspond exactly to tags, |
| 26 | + /// use the <see cref="IntraTextAdornmentTagger"/> base class. |
| 27 | + /// </remarks> |
| 28 | + internal abstract class IntraTextAdornmentTagTransformer<TDataTag, TAdornment> |
| 29 | + : IntraTextAdornmentTagger<TDataTag, TAdornment>, IDisposable |
| 30 | + where TDataTag : ITag |
| 31 | + where TAdornment : UIElement |
| 32 | + { |
| 33 | + protected readonly ITagAggregator<TDataTag> dataTagger; |
| 34 | + protected readonly PositionAffinity? adornmentAffinity; |
35 | 35 |
|
36 |
| - /// <param name="adornmentAffinity">Determines whether adornments based on data tags with zero-length spans |
37 |
| - /// will stick with preceding or succeeding text characters.</param> |
38 |
| - protected IntraTextAdornmentTagTransformer(IWpfTextView view, ITagAggregator<TDataTag> dataTagger, PositionAffinity adornmentAffinity = PositionAffinity.Successor) |
39 |
| - : base(view) |
40 |
| - { |
41 |
| - this.adornmentAffinity = adornmentAffinity; |
42 |
| - this.dataTagger = dataTagger; |
| 36 | + /// <param name="adornmentAffinity">Determines whether adornments based on data tags with zero-length spans |
| 37 | + /// will stick with preceding or succeeding text characters.</param> |
| 38 | + protected IntraTextAdornmentTagTransformer(IWpfTextView view, ITagAggregator<TDataTag> dataTagger, PositionAffinity adornmentAffinity = PositionAffinity.Successor) |
| 39 | + : base(view) |
| 40 | + { |
| 41 | + this.adornmentAffinity = adornmentAffinity; |
| 42 | + this.dataTagger = dataTagger; |
43 | 43 |
|
44 |
| - this.dataTagger.TagsChanged += HandleDataTagsChanged; |
45 |
| - } |
| 44 | + this.dataTagger.TagsChanged += HandleDataTagsChanged; |
| 45 | + } |
46 | 46 |
|
47 |
| - protected override IEnumerable<Tuple<SnapshotSpan, PositionAffinity?, TDataTag>> GetAdornmentData(NormalizedSnapshotSpanCollection spans) |
48 |
| - { |
49 |
| - if (spans.Count == 0) |
50 |
| - yield break; |
| 47 | + protected override IEnumerable<Tuple<SnapshotSpan, PositionAffinity?, TDataTag>> GetAdornmentData(NormalizedSnapshotSpanCollection spans) |
| 48 | + { |
| 49 | + if (spans.Count == 0) |
| 50 | + yield break; |
51 | 51 |
|
52 |
| - ITextSnapshot snapshot = spans[0].Snapshot; |
| 52 | + ITextSnapshot snapshot = spans[0].Snapshot; |
53 | 53 |
|
54 |
| - foreach (IMappingTagSpan<TDataTag> dataTagSpan in dataTagger.GetTags(spans)) |
55 |
| - { |
56 |
| - NormalizedSnapshotSpanCollection dataTagSpans = dataTagSpan.Span.GetSpans(snapshot); |
| 54 | + foreach (IMappingTagSpan<TDataTag> dataTagSpan in dataTagger.GetTags(spans)) |
| 55 | + { |
| 56 | + NormalizedSnapshotSpanCollection dataTagSpans = dataTagSpan.Span.GetSpans(snapshot); |
57 | 57 |
|
58 |
| - // Ignore data tags that are split by projection. |
59 |
| - // This is theoretically possible but unlikely in current scenarios. |
60 |
| - if (dataTagSpans.Count != 1) |
61 |
| - continue; |
| 58 | + // Ignore data tags that are split by projection. |
| 59 | + // This is theoretically possible but unlikely in current scenarios. |
| 60 | + if (dataTagSpans.Count != 1) |
| 61 | + continue; |
62 | 62 |
|
63 |
| - SnapshotSpan span = dataTagSpans[0]; |
| 63 | + SnapshotSpan span = dataTagSpans[0]; |
64 | 64 |
|
65 |
| - PositionAffinity? affinity = span.Length > 0 ? null : adornmentAffinity; |
| 65 | + PositionAffinity? affinity = span.Length > 0 ? null : adornmentAffinity; |
66 | 66 |
|
67 |
| - yield return Tuple.Create(span, affinity, dataTagSpan.Tag); |
68 |
| - } |
69 |
| - } |
| 67 | + yield return Tuple.Create(span, affinity, dataTagSpan.Tag); |
| 68 | + } |
| 69 | + } |
70 | 70 |
|
71 |
| - private void HandleDataTagsChanged(object sender, TagsChangedEventArgs args) |
72 |
| - { |
73 |
| - var changedSpans = args.Span.GetSpans(view.TextBuffer.CurrentSnapshot); |
74 |
| - InvalidateSpans(changedSpans); |
75 |
| - } |
| 71 | + private void HandleDataTagsChanged(object sender, TagsChangedEventArgs args) |
| 72 | + { |
| 73 | + var changedSpans = args.Span.GetSpans(view.TextBuffer.CurrentSnapshot); |
| 74 | + InvalidateSpans(changedSpans); |
| 75 | + } |
76 | 76 |
|
77 |
| - public virtual void Dispose() |
78 |
| - { |
79 |
| - dataTagger.Dispose(); |
80 |
| - } |
81 |
| - } |
| 77 | + public virtual void Dispose() |
| 78 | + { |
| 79 | + dataTagger.Dispose(); |
| 80 | + } |
| 81 | + } |
82 | 82 | }
|
0 commit comments