public static void ReplaceWith(this ILineView lineView, string value) { lineView.MoveTo(0); lineView.TypeOver(value); if (lineView.Position != lineView.Length) { lineView.Delete(lineView.Length - lineView.Position); } }
private void AddSnapshot(ILineView lineView) { var now = _clock.UtcNow(); if (now - _lastSnapshotTime < _minSnapshotTime) { return; // Too soon. } var snapshot = lineView.TakeSnapshot(); if (_undoRedoManager.TryAddSnapshot(snapshot)) { _lastSnapshotTime = now; } }
public async Task Edit(ILineView lineView, CancellationToken token = default) { if (lineView == null) { throw new ArgumentNullException(nameof(lineView)); } token.ThrowIfCancellationRequested(); var inputLifecycle = lineView as ILineViewInputLifecycle; var eventArgs = new InputEventArgs(); inputLifecycle?.BeforeLineReading(); try { while (!token.IsCancellationRequested) { var keyInfo = await _keyReader.ReadKeyAsync(intercept : true, token : token) .ConfigureAwait(false); eventArgs.Input = keyInfo; eventArgs.IsHandledHint = false; eventArgs.LineView = lineView; inputLifecycle?.BeforeInputHandling(keyInfo.HasMoreInput); for (int i = 0; i < _inputHandlers.Length; i++) { _inputHandlers[i].Handle(eventArgs); } inputLifecycle?.AfterInputHandling(keyInfo.HasMoreInput); if (keyInfo.Key == InputKey.Enter) { return; } } } finally { inputLifecycle?.AfterLineReading(); } token.ThrowIfCancellationRequested(); }
public static LineViewSnapshot TakeSnapshot(this ILineView lineView) { return(new LineViewSnapshot(lineView)); }
public void ApplyTo(ILineView lineView) { lineView.ReplaceWith(Content); lineView.MoveTo(Position); }
public LineViewSnapshot(ILineView lineView) { Content = lineView.ToString(); Position = lineView.Position; }
public DeclarationFinder(CompiledProject compiledProject, ILineView lineView, string fileName) { this.compiledProject = compiledProject; this.lineView = lineView; this.fileName = fileName; }