Example #1
0
 public MockReplWindow(IReplEvaluator eval, string contentType = "Python")
 {
     _eval        = eval;
     _contentType = contentType;
     _view        = new MockTextView(new MockTextBuffer(String.Empty, contentType, filename: "text"));
     _eval.Initialize(this);
 }
Example #2
0
 public void SaveReplInfo(int id, IReplEvaluator evaluator, IContentType contentType, string title, Guid languageServiceGuid, Guid replId) {
     using (var repl = UserRegistryRoot.CreateSubKey(ActiveReplsKey)) {
         using (var curRepl = repl.CreateSubKey(id.ToString())) {
             curRepl.SetValue("EvaluatorType", evaluator.GetType().FullName);
             curRepl.SetValue("EvaluatorAssembly", evaluator.GetType().Assembly.FullName);
             curRepl.SetValue("ContentType", contentType.TypeName);
             curRepl.SetValue("Title", title);
             curRepl.SetValue("Guid", replId.ToString());
             curRepl.SetValue("LanguageServiceGuid", languageServiceGuid.ToString());
         }
     }
 }
 private void SaveReplInfo(int id, IReplEvaluator evaluator, IContentType contentType, string[] roles, string title, Guid languageServiceGuid, string replId)
 {
     using (var root = GetRegistryRoot()) {
         if (root != null)
         {
             using (var replInfo = root.CreateSubKey(id.ToString())) {
                 replInfo.SetValue(ContentTypeKey, contentType.TypeName);
                 replInfo.SetValue(TitleKey, title);
                 replInfo.SetValue(ReplIdKey, replId.ToString());
                 replInfo.SetValue(LanguageServiceGuidKey, languageServiceGuid.ToString());
             }
         }
     }
 }
Example #4
0
        public ToolWindowPane CreateReplWindow(IReplEvaluator/*!*/ evaluator, IContentType contentType, string/*!*/ title, Guid languageServiceGuid, Guid replGuid)
        {
            int curId = 0;

            ToolWindowPane window;
            do {
                curId++;
                window = FindReplWindow(curId);
            } while (window != null);

            window = CreateReplWindow(evaluator, contentType, curId, title, languageServiceGuid, replGuid);
            if ((null == window) || (null == window.Frame)) {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }

            return window;
        }
        private ReplWindow CreateReplWindowInternal(IReplEvaluator evaluator, IContentType contentType, string[] roles, int id, string title, Guid languageServiceGuid, string replId)
        {
            var service = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell));
            var model   = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel));

            SaveReplInfo(id, evaluator, contentType, roles, title, languageServiceGuid, replId);

            var replWindow = new ReplWindow(model, evaluator, contentType, roles, title, languageServiceGuid, replId);

            Guid           clsId    = replWindow.ToolClsid;
            Guid           toolType = typeof(ReplWindow).GUID;
            Guid           empty    = Guid.Empty;
            IVsWindowFrame frame;

            // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are
            // destroyed when closed.  We are really multi instance but we don't want to be closed.  This
            // seems to work fine.
            var creationFlags = __VSCREATETOOLWIN.CTW_fInitNew;

            if (!roles.Contains("DontPersist"))
            {
                creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate;
            }
            ErrorHandler.ThrowOnFailure(
                service.CreateToolWindow(
                    (uint)(creationFlags),
                    (uint)id,
                    replWindow.GetIVsWindowPane(),
                    ref clsId,
                    ref toolType,
                    ref empty,
                    null,
                    title,
                    null,
                    out frame
                    )
                );

            replWindow.Frame = frame;

            replWindow.OnToolBarAdded();
            _windows[id] = replWindow;

            return(replWindow);
        }
Example #6
0
        public ToolWindowPane CreateReplWindow(IReplEvaluator /*!*/ evaluator, IContentType contentType, string /*!*/ title, Guid languageServiceGuid, Guid replGuid)
        {
            int curId = 0;

            ToolWindowPane window;

            do
            {
                curId++;
                window = FindReplWindow(curId);
            } while (window != null);

            window = CreateReplWindow(evaluator, contentType, curId, title, languageServiceGuid, replGuid);
            if ((null == window) || (null == window.Frame))
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }

            return(window);
        }
        /// <summary>
        /// Standard constructor for the tool window.
        /// </summary>
        public VsReplWindow(IComponentModel /*!*/ model, IReplEvaluator /*!*/ evaluator, IContentType /*!*/ contentType, string /*!*/ title, Guid languageServiceGuid, Guid replGuid, int?id) :
            base(null)
        {
            if (id != null)
            {
                IronStudioPackage.Instance.SaveReplInfo(id.Value, evaluator, contentType, title, languageServiceGuid, replGuid);
            }
            _replWindow = new VsReplWindowImpl(model, this, evaluator, contentType, title);

            _guid        = replGuid;
            _langSvcGuid = languageServiceGuid;

            // Set the window title reading it from the resources.z
            Caption = _replWindow.Title;

            // Set the image that will appear on the tab of the window frame
            // when docked with an other window
            // The resource ID correspond to the one defined in the resx file
            // while the Index is the offset in the bitmap strip. Each image in
            // the strip being 16x16.
            BitmapResourceID = 301;
            BitmapIndex      = 1;
        }
Example #8
0
        public ToolWindowPane CreateReplWindow(IReplEvaluator /*!*/ evaluator, IContentType /*!*/ contentType, int id, string /*!*/ title, Guid languageServiceGuid, Guid replGuid)
        {
            var service = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell));
            var model   = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel));

            var replWindow = new VsReplWindow(model, evaluator, contentType, title, languageServiceGuid, replGuid, id);

            Guid           clsId    = replWindow.ToolClsid;
            Guid           toolType = typeof(VsReplWindow).GUID;
            Guid           empty    = Guid.Empty;
            IVsWindowFrame frame;

            // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are
            // destroyed when closed.  We are really multi instance but we don't want to be closed.  This
            // seems to work fine.
            ErrorHandler.ThrowOnFailure(
                service.CreateToolWindow(
                    (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fForceCreate),
                    (uint)id,
                    replWindow.GetIVsWindowPane(),
                    ref clsId,
                    ref toolType,
                    ref empty,
                    null,
                    title,
                    null,
                    out frame
                    )
                );

            replWindow.Frame = frame;

            replWindow.OnToolBarAdded();
            _windows[id] = replWindow;

            return(replWindow);
        }
Example #9
0
        public ToolWindowPane CreateReplWindow(IReplEvaluator/*!*/ evaluator, IContentType/*!*/ contentType, int id, string/*!*/ title, Guid languageServiceGuid, Guid replGuid)
        {
            var service = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell));
            var model = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel));

            var replWindow = new VsReplWindow(model, evaluator, contentType, title, languageServiceGuid, replGuid, id);

            Guid clsId = replWindow.ToolClsid;
            Guid toolType = typeof(VsReplWindow).GUID;
            Guid empty = Guid.Empty;
            IVsWindowFrame frame;

            // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are
            // destroyed when closed.  We are really multi instance but we don't want to be closed.  This
            // seems to work fine.
            ErrorHandler.ThrowOnFailure(
                service.CreateToolWindow(
                    (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fForceCreate),
                    (uint)id,
                    replWindow.GetIVsWindowPane(),
                    ref clsId,
                    ref toolType,
                    ref empty,
                    null,
                    title,
                    null,
                    out frame
                )
            );

            replWindow.Frame = frame;

            replWindow.OnToolBarAdded();
            _windows[id] = replWindow;

            return replWindow;
        }
 public IReplWindow CreateReplWindow(IReplEvaluator /*!*/ evaluator, IContentType /*!*/ contentType, string[] roles, int id, string /*!*/ title, Guid languageServiceGuid, string replId)
 {
     return(CreateReplWindowInternal(evaluator, contentType, roles, id, title, languageServiceGuid, replId));
 }
Example #11
0
 public static Task <ExecutionResult> _Initialize(this IReplEvaluator self, IReplWindow window)
 {
     return(self.Initialize(window));
 }
Example #12
0
        /// <summary>
        /// Standard constructor for the tool window.
        /// </summary>
        public VsReplWindow(IComponentModel/*!*/ model, IReplEvaluator/*!*/ evaluator, IContentType/*!*/ contentType, string/*!*/ title, Guid languageServiceGuid, Guid replGuid, int? id)
            : base(null)
        {
            if (id != null) {
                IronStudioPackage.Instance.SaveReplInfo(id.Value, evaluator, contentType, title, languageServiceGuid, replGuid);
            }
            _replWindow = new VsReplWindowImpl(model, this, evaluator, contentType, title);

            _guid = replGuid;
            _langSvcGuid = languageServiceGuid;

            // Set the window title reading it from the resources.z
            Caption = _replWindow.Title;

            // Set the image that will appear on the tab of the window frame
            // when docked with an other window
            // The resource ID correspond to the one defined in the resx file
            // while the Index is the offset in the bitmap strip. Each image in
            // the strip being 16x16.
            BitmapResourceID = 301;
            BitmapIndex = 1;
        }
Example #13
0
 public static Task <ExecutionResult> Reset(this IReplEvaluator self)
 {
     return(self.ResetAsync());
 }
Example #14
0
 public static Task <ExecutionResult> Initialize(this IReplEvaluator self, IReplWindow window)
 {
     self.CurrentWindow = window;
     return(self.InitializeAsync());
 }
Example #15
0
 public void SaveReplInfo(int id, IReplEvaluator evaluator, IContentType contentType, string title, Guid languageServiceGuid, Guid replId)
 {
     using (var repl = UserRegistryRoot.CreateSubKey(ActiveReplsKey)) {
         using (var curRepl = repl.CreateSubKey(id.ToString())) {
             curRepl.SetValue("EvaluatorType", evaluator.GetType().FullName);
             curRepl.SetValue("EvaluatorAssembly", evaluator.GetType().Assembly.FullName);
             curRepl.SetValue("ContentType", contentType.TypeName);
             curRepl.SetValue("Title", title);
             curRepl.SetValue("Guid", replId.ToString());
             curRepl.SetValue("LanguageServiceGuid", languageServiceGuid.ToString());
         }
     }
 }
 public VsReplWindowImpl(IComponentModel /*!*/ model, VsReplWindow /*!*/ window, IReplEvaluator /*!*/ evaluator, IContentType /*!*/ contentType, string /*!*/ title)
     : base(model, evaluator, contentType, title)
 {
     Assert.NotNull(window);
     _window = window;
 }
Example #17
0
 public MockReplWindow(IReplEvaluator eval, string contentType = "Python") {            
     _eval = eval;
     _contentType = contentType;
     _view = new MockTextView(new MockTextBuffer(String.Empty, "text"));
     _eval.Initialize(this);
 }
 private void SaveReplInfo(int id, IReplEvaluator evaluator, IContentType contentType, string[] roles, string title, Guid languageServiceGuid, string replId) {
     using (var root = GetRegistryRoot()) {
         if (root != null) {
             using (var replInfo = root.CreateSubKey(id.ToString())) {
                 replInfo.SetValue(ContentTypeKey, contentType.TypeName);
                 replInfo.SetValue(TitleKey, title);
                 replInfo.SetValue(ReplIdKey, replId.ToString());
                 replInfo.SetValue(LanguageServiceGuidKey, languageServiceGuid.ToString());
             }
         }
     }
 }
Example #19
0
 public static Task <ExecutionResult> ExecuteText(this IReplEvaluator self, string text)
 {
     return(self.ExecuteCodeAsync(text));
 }
 public IReplWindow CreateReplWindow(IReplEvaluator/*!*/ evaluator, IContentType/*!*/ contentType, string[] roles, int id, string/*!*/ title, Guid languageServiceGuid, string replId) {
     return CreateReplWindowInternal(evaluator, contentType, roles, id, title, languageServiceGuid, replId);
 }
        private ReplWindow CreateReplWindowInternal(IReplEvaluator evaluator, IContentType contentType, string[] roles, int id, string title, Guid languageServiceGuid, string replId) {
            var service = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell));
            var model = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel));

            SaveReplInfo(id, evaluator, contentType, roles, title, languageServiceGuid, replId);

            var replWindow = new ReplWindow(model, evaluator, contentType, roles, title, languageServiceGuid, replId);

            Guid clsId = replWindow.ToolClsid;
            Guid toolType = typeof(ReplWindow).GUID;
            Guid empty = Guid.Empty;
            IVsWindowFrame frame;

            // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are
            // destroyed when closed.  We are really multi instance but we don't want to be closed.  This
            // seems to work fine.
            var creationFlags = __VSCREATETOOLWIN.CTW_fInitNew;
            if (!roles.Contains("DontPersist")) {
                creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate;
            }
            ErrorHandler.ThrowOnFailure(
                service.CreateToolWindow(
                    (uint)(creationFlags),
                    (uint)id,
                    replWindow.GetIVsWindowPane(),
                    ref clsId,
                    ref toolType,
                    ref empty,
                    null,
                    title,
                    null,
                    out frame
                )
            );

            replWindow.Frame = frame;

            replWindow.OnToolBarAdded();
            _windows[id] = replWindow;

            return replWindow;
        }
Example #22
0
 public VsReplWindowImpl(IComponentModel/*!*/ model, VsReplWindow/*!*/ window, IReplEvaluator/*!*/ evaluator, IContentType/*!*/ contentType, string/*!*/ title)
     : base(model, evaluator, contentType, title)
 {
     Assert.NotNull(window);
     _window = window;
 }