private void okButton_Click(object sender, EventArgs e)
        {
            var refs = _projectService.FindAllReferences(_extractedMethod);

            foreach (var file in refs)
            {
                string fileName = file.First().File;

                TextEditorControl editor = new WabbitcodeTextEditor();
                editor.LoadFile(fileName);

                foreach (var reference in file)
                {
                    int offset = editor.Document.GetOffsetForLineNumber(reference.Line) + reference.Col;
                    int len    = reference.ReferenceString.Length;
                    editor.Document.Replace(offset, len, nameBox.Text);
                }

                try
                {
                    editor.SaveFile(fileName);
                }
                catch (Exception ex)
                {
                    DockingService.ShowError("Error saving refactor", ex);
                }
            }
        }
        private void SetupPreview()
        {
            tabControl.Visible = true;
            tabControl.TabPages.Clear();
            Height += PreviewHeight;
            prevRefButton.Visible = true;
            nextRefButton.Visible = true;

            foreach (var file in _references)
            {
                string fileName = file.First().File;
                var    tab      = new TabPage(Path.GetFileName(fileName))
                {
                    Tag = fileName
                };
                tabControl.TabPages.Add(tab);
                var editor = new WabbitcodeTextEditor
                {
                    Dock = DockStyle.Fill
                };
                editor.LoadFile(fileName);

                tab.Controls.Add(editor);
                _editors.Add(fileName, editor);

                editor.Document.ReadOnly = true;
            }
        }
 public virtual void SetupDataProvider(string fileName, TextArea textArea)
 {
     _textArea      = textArea;
     TextEditor     = textArea.MotherTextEditorControl as WabbitcodeTextEditor;
     _initialOffset = textArea.Caret.Offset;
     Data           = new List <string>();
 }
Example #4
0
        public void Execute(TextArea textArea)
        {
            WabbitcodeTextEditor editor = textArea.MotherTextEditorControl as WabbitcodeTextEditor;

            if (editor != null)
            {
                editor.StartCtrlSpaceCompletion();
            }
        }
        public void ShowFor(Form owner, WabbitcodeTextEditor editor, SearchMode mode)
        {
            _editor = editor;
            IFileService fileService = DependencyFactory.Resolve <IFileService>();
            string       fileText    = editor == null ? string.Empty : fileService.GetFileText(new FilePath(editor.FileName));

            _search = new TextEditorSearcher(fileText);

            Owner = owner;
            Show();

            findNextFindButton.Focus();
            findFindBox.SelectAll();
            findFindBox.Focus();
            string word = string.Empty;

            if (editor != null)
            {
                word = editor.ActiveTextAreaControl.SelectionManager.HasSomethingSelected ?
                       editor.ActiveTextAreaControl.SelectionManager.SelectedText :
                       editor.GetWordAtCaret();
            }

            switch (mode)
            {
            case SearchMode.Find:
                findTabs.SelectTab(findPage);
                findFindBox.Text = word;
                findFindBox.Focus();
                findFindBox.SelectAll();
                break;

            case SearchMode.Replace:
                findTabs.SelectTab(replacePage);
                replaceFindBox.Text = word;
                replaceFindBox.Focus();
                replaceFindBox.SelectAll();
                break;

            case SearchMode.FindInFiles:
                findTabs.SelectTab(findInFilesPage);
                findFilesBox.Text = word;
                findFilesBox.Focus();
                findFilesBox.SelectAll();
                break;
            }
        }
Example #6
0
        public bool HandleKeyPress(WabbitcodeTextEditor editor, char ch)
        {
            if (!Settings.Default.EnableAutoTrigger)
            {
                return(false);
            }
            switch (ch)
            {
            case ' ':
                string word = editor.GetWordBeforeCaret();
                switch (word.FirstOrDefault())
                {
                case '#':
                    editor.ShowInsightWindow(new PreprocessorInsightProvider());
                    break;

                case ',':
                    editor.ShowCompletionWindow(new CtrlSpaceCompletionProvider(editor), ch);
                    break;

                default:
                    editor.ShowInsightWindow(new Z80InsightProvider());
                    break;
                }
                break;

            case ',':
            case '(':
                editor.ShowCompletionWindow(new CtrlSpaceCompletionProvider(editor), ch);
                editor.ShowInsightWindow(new MacroInsightProvider());
                break;

            case '#':
                editor.ShowCompletionWindow(new PreprocessorCompletionProvider(editor), ch);
                break;

            case '.':
                editor.ShowCompletionWindow(new DirectiveCompletionProvider(editor), ch);
                break;
            }

            return(false);
        }
Example #7
0
        private void SetupPreview()
        {
            tabControl.Visible = true;
            tabControl.TabPages.Clear();
            Height += PreviewHeight;
            prevRefButton.Visible = true;
            nextRefButton.Visible = true;

            foreach (var file in _references)
            {
                string fileName = file.First().File;
                if (_editors.ContainsKey(fileName))
                {
                    continue;
                }

                var tab = new TabPage(Path.GetFileName(fileName))
                {
                    Tag = fileName
                };
                tabControl.TabPages.Add(tab);
                var editor = new WabbitcodeTextEditor
                {
                    Dock                = DockStyle.Fill,
                    IsIconBarVisible    = false,
                    UseTextHighlighting = false,
                };
                editor.LoadFile(fileName);

                tab.Controls.Add(editor);
                _editors.Add(fileName, editor);

                editor.Document.ReadOnly = true;
            }

            _hasBeenInited = true;
        }
        public EditorContextMenu(WabbitcodeTextEditor editor, IDebuggerService debuggerService,
                                 IParserService parserService, IProjectService projectService)
        {
            var refactorContext = new MenuItem("Refactor", new[] { _renameContext, _extractMethodContext });

            MenuItems.AddRange(new[]
            {
                _cutContext,
                _copyContext,
                _pasteContext,
                _separator1,
                refactorContext,
                _findRefContext,
                _separator2,
                _selectAllContext,
                _setNextStateMenuItem,
                _fixCaseContext,
                _gotoButton
            });

            _cutContext.Click           += cutContext_Click;
            _copyContext.Click          += copyContext_Click;
            _pasteContext.Click         += pasteContext_Click;
            _selectAllContext.Click     += selectAllContext_Click;
            _setNextStateMenuItem.Click += setNextStateMenuItem_Click;
            _fixCaseContext.Click       += fixCaseContext_Click;
            _gotoButton.Click           += gotoButton_Click;
            _gotoButton.Shortcut         = Shortcut.F12;

            Popup += contextMenu_Popup;

            _editor          = editor;
            _debuggerService = debuggerService;
            _parserService   = parserService;
            _projectService  = projectService;
        }
Example #9
0
 public CtrlSpaceCompletionProvider(WabbitcodeTextEditor textEditor)
     : base(textEditor)
 {
     _parserService = DependencyFactory.Resolve <IParserService>();
 }
Example #10
0
 public PreprocessorCompletionProvider(WabbitcodeTextEditor textEditor)
     : base(textEditor)
 {
 }
Example #11
0
 public bool CtrlSpace(WabbitcodeTextEditor editor)
 {
     editor.ShowCompletionWindow(new CtrlSpaceCompletionProvider(editor), '\0');
     return(true);
 }
Example #12
0
 protected CompletionProviderBase(WabbitcodeTextEditor textEditor)
 {
     TextEditor = textEditor;
 }