Esempio n. 1
0
        public void CreateRepl(string replPath, string projectPath)
        {
            var interactiveText = ReplUserInterfaceFactory.CreateInteractiveText();
            var closeButton = ReplUserInterfaceFactory.CreateCloseButton();
            var name = ReplUserInterfaceFactory.CreateTabLabel();
            var grid = ReplUserInterfaceFactory.CreateTextBoxGrid(interactiveText);
            var headerPanel = ReplUserInterfaceFactory.CreateHeaderPanel(name, closeButton);
            var tabItem = ReplUserInterfaceFactory.CreateTabItem(headerPanel, grid);
            var replProcess = CreateReplProcess(replPath, projectPath);
            var replEntity = new Entity<ReplState> {CurrentState = new ReplState()};
            var repl = new Repl(replProcess, new TextBoxWriter(interactiveText, replEntity));

            WireUpTheTextBoxInputToTheReplProcess(repl, interactiveText, replEntity);
            WireUpTheOutputOfTheReplProcessToTheTextBox(interactiveText, replProcess, replEntity);
            WireUpTheReplEditorCommandsToTheEditor(repl, tabItem);

            closeButton.Click +=
                (o, e) =>
                {
                    replProcess.Kill();
                    _replManager.Items.Remove(tabItem);
                };

            _replManager.Items.Add(tabItem);
            _replManager.SelectedItem = tabItem;
        }
 public InputKeyHandler(KeyboardExaminer keyboardExaminer, Entity<ReplState> replEntity, TextBox interactiveTextBox, Repl repl)
 {
     _keyboardExaminer = keyboardExaminer;
     _replEntity = replEntity;
     _repl = repl;
     _interactiveTextBox = interactiveTextBox;
 }
Esempio n. 3
0
        private void WireUpTheReplEditorCommandsToTheEditor(Repl repl, TabItem tabItem)
        {
            var dte = (DTE2)_serviceProvider.GetService(typeof(DTE));

            var menuCommandListWirer = new MenuCommandListWirer(
                (OleMenuCommandService)_serviceProvider.GetService(typeof(IMenuCommandService)),
                CreateMenuCommands(repl),
                () => dte.ActiveDocument != null && dte.ActiveDocument.FullName.ToLower().EndsWith(".clj") && _replManager.SelectedItem == tabItem);

            dte.Events.WindowEvents.WindowActivated += (o, e) => menuCommandListWirer.TryToShowMenuCommands();
            _replManager.SelectionChanged += (sender, eventData) => menuCommandListWirer.TryToShowMenuCommands();
        }
Esempio n. 4
0
        private List<MenuCommand> CreateMenuCommands(Repl repl)
        {
            var dte = (DTE2) _serviceProvider.GetService(typeof (DTE));
            repl.OnInvisibleWrite += () => _replToolWindow.ShowNoActivate();

            Action loadSelectedFilesIntoRepl =
                () => dte.ToolWindows.SolutionExplorer.GetSelectedFiles().LoadFilesInto(repl);

            Action loadSelectedProjectIntoRepl =
                () => dte.ToolWindows.SolutionExplorer.GetSelectedProject().GetAllFiles().LoadFilesInto(repl);

            Action loadActiveFileIntoRepl =
                () => dte.ActiveDocument.FullName.SingletonAsList().LoadFilesInto(repl);

            var componentModel = (IComponentModel) _serviceProvider.GetService(typeof (SComponentModel));
            var namespaceParser = new NamespaceParser(NamespaceParser.NamespaceSymbols);

            var activeTextBufferStateProvider =
                new ActiveTextBufferStateProvider(
                    componentModel.GetService<IVsEditorAdaptersFactoryService>(),
                    (IVsTextManager) _serviceProvider.GetService(typeof (SVsTextManager)));

            var menuCommands = new List<MenuCommand>();
            menuCommands.Add(new MenuCommand((sender, args) => loadSelectedProjectIntoRepl(), new CommandID(Guids.GuidClojureExtensionCmdSet, 11)));
            menuCommands.Add(new MenuCommand((sender, args) => loadSelectedFilesIntoRepl(), new CommandID(Guids.GuidClojureExtensionCmdSet, 12)));
            menuCommands.Add(new MenuCommand((sender, args) => loadActiveFileIntoRepl(), new CommandID(Guids.GuidClojureExtensionCmdSet, 13)));
            menuCommands.Add(new MenuCommand((sender, args) => repl.ChangeNamespace(namespaceParser.Execute(activeTextBufferStateProvider.Get())), new CommandID(Guids.GuidClojureExtensionCmdSet, 14)));
            menuCommands.Add(new MenuCommand((sender, args) => repl.WriteInvisibly((string)dte.ActiveDocument.Selection), new CommandID(Guids.GuidClojureExtensionCmdSet, 15)));
            return menuCommands;
        }
Esempio n. 5
0
        private static void WireUpTheTextBoxInputToTheReplProcess(Repl repl, TextBox replTextBox, Entity<ReplState> replEntity)
        {
            var inputKeyHandler = new InputKeyHandler(new KeyboardExaminer(), replEntity, replTextBox, repl);
            var history = new History(new KeyboardExaminer(), replEntity, replTextBox);

            replTextBox.PreviewKeyDown += history.PreviewKeyDown;
            replTextBox.PreviewTextInput += inputKeyHandler.PreviewTextInput;
            replTextBox.PreviewKeyDown += inputKeyHandler.PreviewKeyDown;
        }
 public static void WriteInvisiblyTo(this string expresion, Repl repl)
 {
     repl.WriteInvisibly(expresion);
 }
 public static void LoadFilesInto(this List<string> fileList, Repl repl)
 {
     repl.LoadFiles(fileList);
 }