Пример #1
0
            public void ClearView()
            {
                if (_window._stdInputStart != null)
                {
                    CancelStandardInput();
                }

                _window._adornmentToMinimize = false;
                InlineAdornmentProvider.RemoveAllAdornments(_window._textView);

                // remove all the spans except our initial span from the projection buffer
                _window._promptLineMapping.Clear();
                UncommittedInput = null;

                // Clear the projection and buffers last as this might trigger events that might access other state of the REPL window:
                RemoveProtection(_window._outputBuffer, _outputProtection);
                RemoveProtection(_window._standardInputBuffer, StandardInputProtection);

                using (var edit = _window._outputBuffer.CreateEdit(EditOptions.None, null, s_suppressPromptInjectionTag))
                {
                    edit.Delete(0, _window._outputBuffer.CurrentSnapshot.Length);
                    edit.Apply();
                }

                _window._buffer.Reset();
                OutputClassifierProvider.ClearSpans(_window._outputBuffer);
                _outputTrackingCaretPosition = 0;

                using (var edit = _window._standardInputBuffer.CreateEdit(EditOptions.None, null, s_suppressPromptInjectionTag))
                {
                    edit.Delete(0, _window._standardInputBuffer.CurrentSnapshot.Length);
                    edit.Apply();
                }

                RemoveProjectionSpans(0, _window._projectionSpans.Count);

                // Insert an empty output buffer.
                // We do it for two reasons:
                // 1) When output is written to asynchronously we need a buffer to store it.
                //    This may happen when clearing screen while background thread is writing to the console.
                // 2) We need at least one non-inert span due to bugs in projection buffer.
                AppendNewOutputProjectionBuffer();

                _window._history.ForgetOriginalBuffers();

                // If we were waiting for input, we need to restore the prompt that we just cleared.
                // If we are in any other state, then we'll let normal transitions trigger the next prompt.
                if (State == State.WaitingForInput)
                {
                    PrepareForInput();
                }
            }
Пример #2
0
        void IInteractiveWindow.Write(UIElement element)
        {
            if (element == null)
            {
                return;
            }

            _buffer.Flush();
            InlineAdornmentProvider.AddInlineAdornment(_textView, element, OnAdornmentLoaded);
            _adornmentToMinimize = true; // TODO (https://github.com/dotnet/roslyn/issues/4044): probably ui only
            WriteLine(string.Empty);
            WriteLine(string.Empty);
        }
Пример #3
0
            private void FinishCurrentSubmissionInput()
            {
                _window.AppendLineNoPromptInjection(_window._currentLanguageBuffer);
                ApplyProtection(_window._currentLanguageBuffer, regions: null);

                if (_window._adornmentToMinimize)
                {
                    // TODO (tomat): remember the index of the adornment(s) in the current output and minimize those instead of the last one
                    InlineAdornmentProvider.MinimizeLastInlineAdornment(_window._textView);
                    _window._adornmentToMinimize = false;
                }

                NewOutputBuffer();
            }