コード例 #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
ファイル: LineViewEditor.cs プロジェクト: TheTrigger/VoidMain
        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;
 }