static CachedTextColorsCollection() { var empty = new CachedTextColorsCollection(); empty.Freeze(); Empty = empty; }
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); }
public CachedTextColorsCollectionBuilder(ReplEditor owner, int totalLength) { this.owner = owner; cachedTextColorsCollection = new CachedTextColorsCollection(); this.totalLength = totalLength; }
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(); }
public void Reset() { ClearPendingOutput(); ClearUndoRedoHistory(); CreateEmptyLastLineIfNeededAndMoveCaret(); if (OffsetOfPrompt != null) AddCodeSubBuffer(); scriptOutputCachedTextColorsCollection = null; WriteOffsetOfPrompt(null, true); }
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; }
void SetNewDocument() { cachedTextColorsCollection = new CachedTextColorsCollection(); wpfTextView.TextBuffer.Replace(new Span(0, wpfTextView.TextBuffer.CurrentSnapshot.Length), string.Empty); ClearUndoRedoHistory(); cachedColorsList.Clear(); cachedColorsList.Add(0, cachedTextColorsCollection); }
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 OffsetAndCachedColors(int offset, CachedTextColorsCollection cachedColors) { Offset = offset; CachedColors = cachedColors; }