Ejemplo n.º 1
0
 public void Initialize()
 {
     _selectedLines = new List<string>();
     _textBufferAdapter = MockRepository.GenerateStub<ITextBufferAdapter>();
     _textBufferAdapter.Stub(t => t.GetSelectedLines()).Return(_selectedLines);
     _blockUncomment = new BlockUncomment(_textBufferAdapter);
 }
Ejemplo n.º 2
0
        private void EnableMenuCommandsOnNewClojureBuffers()
        {
            var componentModel = (IComponentModel) GetService(typeof (SComponentModel));
            ITextEditorFactoryService editorFactoryService = componentModel.GetService<ITextEditorFactoryService>();

            editorFactoryService.TextViewCreated += (o, e) => e.TextView.GotAggregateFocus +=
                (sender, args) =>
                {
                    _thirdPartyEditorCommands.Clear();
                    if (e.TextView.TextSnapshot.ContentType.TypeName.ToLower() != "clojure") return;

                    var editorOptionsBuilder = new EditorOptionsBuilder(componentModel.GetService<IEditorOptionsFactoryService>().GetOptions(e.TextView));
                    var tokenizedBuffer = TokenizedBufferBuilder.TokenizedBuffers[e.TextView.TextBuffer];
                    var formatter = new AutoFormatter(new TextBufferAdapter(e.TextView), tokenizedBuffer);
                    var blockComment = new BlockComment(new TextBufferAdapter(e.TextView));
                    var blockUncomment = new BlockUncomment(new TextBufferAdapter(e.TextView));
                    _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => formatter.Format(editorOptionsBuilder.Get()), CommandIDs.FormatDocument));
                    _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => blockComment.Execute(), CommandIDs.BlockComment));
                    _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => blockUncomment.Execute(), CommandIDs.BlockUncomment));
                    _thirdPartyEditorCommands.AddCommand(new MenuCommand((commandSender, commandArgs) => { }, CommandIDs.GotoDefinition));
                };
        }