예제 #1
0
 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);
     }
 }
예제 #2
0
        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;
            }
        }
예제 #3
0
        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();
        }
예제 #4
0
 public static LineViewSnapshot TakeSnapshot(this ILineView lineView)
 {
     return(new LineViewSnapshot(lineView));
 }
예제 #5
0
 public void ApplyTo(ILineView lineView)
 {
     lineView.ReplaceWith(Content);
     lineView.MoveTo(Position);
 }
예제 #6
0
 public LineViewSnapshot(ILineView lineView)
 {
     Content  = lineView.ToString();
     Position = lineView.Position;
 }
예제 #7
0
 public DeclarationFinder(CompiledProject compiledProject, ILineView lineView, string fileName)
 {
     this.compiledProject = compiledProject;
     this.lineView = lineView;
     this.fileName = fileName;
 }