static OffsetAndCachedColors() { var coll = new CachedTextColorsCollection(); coll.Freeze(); Default = new OffsetAndCachedColors(0, coll); }
/// <summary> /// Constructor /// </summary> /// <param name="text">Text</param> /// <param name="colorCollection">Colors</param> /// <param name="referenceCollection">References</param> /// <param name="customDataDict">Custom data dictionary</param> internal DocumentViewerContent(string text, CachedTextColorsCollection colorCollection, SpanDataCollection <ReferenceInfo> referenceCollection, Dictionary <string, object> customDataDict) { if (text == null) { throw new ArgumentNullException(nameof(text)); } if (colorCollection == null) { throw new ArgumentNullException(nameof(colorCollection)); } if (referenceCollection == null) { throw new ArgumentNullException(nameof(referenceCollection)); } if (customDataDict == null) { throw new ArgumentNullException(nameof(customDataDict)); } colorCollection.Freeze(); Text = text; ColorCollection = colorCollection; ReferenceCollection = referenceCollection; this.customDataDict = customDataDict; MethodDebugInfos = GetCustomData <ReadOnlyCollection <MethodDebugInfo> >(DocumentViewerContentDataIds.DebugInfo) ?? emptyMethodDebugInfos; }
void SetNewDocument() { cachedTextColorsCollection = new CachedTextColorsCollection(); wpfTextView.TextBuffer.Replace(new Span(0, wpfTextView.TextBuffer.CurrentSnapshot.Length), string.Empty); ClearUndoRedoHistory(); cachedColorsList.Clear(); cachedColorsList.Add(0, cachedTextColorsCollection); }
DocumentViewerOutput() { this.cachedTextColorsCollection = new CachedTextColorsCollection(); this.stringBuilder = new StringBuilder(); this.referenceBuilder = SpanDataCollectionBuilder <ReferenceInfo> .CreateBuilder(); this.canBeCached = true; this.customDataDict = new Dictionary <string, object>(StringComparer.Ordinal); }
void AddNewDocument() { docVersion++; prevCommandTextChangedState?.Cancel(); subBuffers.Clear(); scriptOutputCachedTextColorsCollection = null; cachedColorsList.Clear(); OffsetOfPrompt = null; wpfTextView.TextBuffer.Replace(new Span(0, wpfTextView.TextBuffer.CurrentSnapshot.Length), string.Empty); ClearUndoRedoHistory(); }
DocumentViewerOutput() { state = State.GeneratingContent; cachedTextColorsCollection = new CachedTextColorsCollection(); stringBuilder = new StringBuilder(); referenceBuilder = SpanDataCollectionBuilder <ReferenceInfo> .CreateBuilder(); canBeCached = true; customDataDict = new Dictionary <string, object>(StringComparer.Ordinal); indenter = new Indenter(4, 4, true); }
public void Reset() { ClearPendingOutput(); ClearUndoRedoHistory(); CreateEmptyLastLineIfNeededAndMoveCaret(); if (OffsetOfPrompt != null) { AddCodeSubBuffer(); } scriptOutputCachedTextColorsCollection = null; WriteOffsetOfPrompt(null, true); }
public void AddOrUpdate(int docOffset, CachedTextColorsCollection newCachedTextColorsCollection) { for (int i = 0; i < cachedColorsList.Count; i++) { int mi = (previousReturnedIndex + i) % cachedColorsList.Count; var info = cachedColorsList[mi]; if (info.Offset == docOffset) { cachedColorsList[mi] = new OffsetAndCachedColors(docOffset, newCachedTextColorsCollection); return; } } Add(docOffset, newCachedTextColorsCollection); }
void WriteOffsetOfPrompt(int?newValue, bool force = false) { if (force || OffsetOfPrompt.HasValue != newValue.HasValue) { if (newValue == null) { Debug.Assert(scriptOutputCachedTextColorsCollection == null); scriptOutputCachedTextColorsCollection = new CachedTextColorsCollection(); Debug.Assert(LastLine.Length == 0); cachedColorsList.AddOrUpdate(wpfTextView.TextSnapshot.Length, scriptOutputCachedTextColorsCollection); } else { Debug.Assert(scriptOutputCachedTextColorsCollection != null); scriptOutputCachedTextColorsCollection = null; } } OffsetOfPrompt = newValue; }
public OffsetAndCachedColors(int offset, CachedTextColorsCollection cachedColors) { Offset = offset; CachedColors = cachedColors; }
public void Add(int offset, CachedTextColorsCollection cachedTextColorsCollection) { Debug.Assert((cachedColorsList.Count == 0 && offset == 0) || (cachedColorsList.Count > 0 && cachedColorsList.Last().Offset + cachedColorsList.Last().CachedColors.TextLength <= offset)); cachedColorsList.Add(new OffsetAndCachedColors(offset, cachedTextColorsCollection)); }
public CachedTextColorsCollectionBuilder(ReplEditor owner, int totalLength) { this.owner = owner; this.cachedTextColorsCollection = new CachedTextColorsCollection(); this.totalLength = totalLength; }
public TextBlockColorOutput() { this.cachedTextColorsCollection = new CachedTextColorsCollection(); this.sb = new StringBuilder(); }