Example #1
0
        /// <summary>
        /// Creates a new ConsoleWindow object.
        /// This constructor uses the service provider passed as an argument to create and initialize
        /// the text buffer.
        /// </summary>
        public ConsoleWindow(IServiceProvider provider) :
            base(null)
        {
            if (null == provider)
            {
                throw new ArgumentNullException("provider");
            }
            globalProvider = provider;

            // Create the text buffer.
            textLines = (IVsTextLines)CreateObject(typeof(VsTextBufferClass), typeof(IVsTextLines));
            // Get a reference to the global service provider.
            IOleServiceProvider nativeProvider = (IOleServiceProvider)globalProvider.GetService(typeof(IOleServiceProvider));

            // The text buffer must be sited with the global service provider.
            ((IObjectWithSite)textLines).SetSite(nativeProvider);
            // Set the buffer as read-only. The user should be able to change the content of the
            // buffer only if the engine is started.
            uint flags;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                textLines.GetStateFlags(out flags));
            flags |= (uint)Microsoft.VisualStudio.TextManager.Interop.BUFFERSTATEFLAGS.BSF_USER_READONLY;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                textLines.SetStateFlags(flags));

            // Set the GUID of the language service that will handle this text buffer
            Guid languageGuid = typeof(PythonLanguage).GUID;

            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                textLines.SetLanguageServiceID(ref languageGuid));

            // Initialize the history
            history = new HistoryBuffer();

            // Create the stream on top of the text buffer.
            textStream = new TextBufferStream(textLines);

            // Initialize the engine.
            InitializeEngine();

            // Set the title of the window.
            this.Caption = Resources.ToolWindowTitle;

            // Set the icon of the toolwindow.
            this.BitmapResourceID = 301;
            this.BitmapIndex      = 0;
        }
Example #2
0
        /// <summary>
        /// Performs the clean-up operations for this object.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    // Dispose the stream.
                    if (null != textStream)
                    {
                        ((IDisposable)textStream).Dispose();
                        textStream = null;
                    }

                    // Close the text view.
                    if (null != textView)
                    {
                        // Remove the command filter.
                        textView.RemoveCommandFilter((IOleCommandTarget)this);
                        // Release the text view.
                        textView.CloseView();
                        textView = null;
                    }

                    // Dispose the command service.
                    if (null != commandService)
                    {
                        commandService.Dispose();
                        commandService = null;
                    }
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }
        /// <summary>
        /// Performs the clean-up operations for this object.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    // Dispose the stream.
                    if (null != textStream)
                    {
                        ((IDisposable)textStream).Dispose();
                        textStream = null;
                    }

                    // Close the text view.
                    if (null != textView)
                    {
                        // Remove the command filter.
                        textView.RemoveCommandFilter((IOleCommandTarget)this);
                        // Release the text view.
                        textView.CloseView();
                        textView = null;
                    }

                    // Dispose the command service.
                    if (null != commandService)
                    {
                        commandService.Dispose();
                        commandService = null;
                    }
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }
        /// <summary>
        /// Creates a new ConsoleWindow object.
        /// This constructor uses the service provider passed as an argument to create and initialize
        /// the text buffer.
        /// </summary>
        public ConsoleWindow(IServiceProvider provider)
            : base(null)
        {
            if (null == provider)
                throw new ArgumentNullException("provider");
            globalProvider = provider;

            // Create the text buffer.
            textLines = (IVsTextLines)CreateObject(typeof(VsTextBufferClass), typeof(IVsTextLines));
            // Get a reference to the global service provider.
            IOleServiceProvider nativeProvider = (IOleServiceProvider)globalProvider.GetService(typeof(IOleServiceProvider));
            // The text buffer must be sited with the global service provider.
            ((IObjectWithSite)textLines).SetSite(nativeProvider);
            // Set the buffer as read-only. The user should be able to change the content of the
            // buffer only if the engine is started.
            uint flags;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                textLines.GetStateFlags(out flags));
            flags |= (uint)Microsoft.VisualStudio.TextManager.Interop.BUFFERSTATEFLAGS.BSF_USER_READONLY;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                textLines.SetStateFlags(flags));

            // Set the GUID of the language service that will handle this text buffer
            Guid languageGuid = typeof(PythonLanguage).GUID;
            Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                textLines.SetLanguageServiceID(ref languageGuid));

            // Initialize the history
            history = new HistoryBuffer();

            // Create the stream on top of the text buffer.
            textStream = new TextBufferStream(textLines);

            // Initialize the engine.
            InitializeEngine();

            // Set the title of the window.
            this.Caption = Resources.ToolWindowTitle;

            // Set the icon of the toolwindow.
            this.BitmapResourceID = 301;
            this.BitmapIndex = 0;
        }