private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (TreeListViewItem tlvi in solutionExplorerTreeView.SelectedItems)
            {
                ILuaEditDocumentEditable doc = tlvi.Tag as ILuaEditDocumentEditable;

                if (doc != null)
                {
                    DocumentsManager.Instance.OpenDocument(doc);
                }
            }
        }
示例#2
0
        public Breakpoint GetBreakpointAtLine(string fileName, int line)
        {
            if (_breakpoints.ContainsKey(fileName))
            {
                ILuaEditDocument         doc         = DocumentsManager.Instance.OpenDocument(fileName, false);
                ILuaEditDocumentEditable editableDoc = doc as ILuaEditDocumentEditable;
                Row row = editableDoc.Document.LineToRow(line);

                if (editableDoc != null && row != null && _breakpoints[fileName].ContainsKey(row))
                {
                    return(_breakpoints[fileName][row]);
                }
            }

            return(null);
        }
示例#3
0
        private void PerformFindNext(bool shouldBookmark)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                string findWhatText = cboFindWhat.Text;
                string lookIn       = cboLookIn.Text;

                // Determine list of documents in which to perform the search
                // Only do this when search parameters have changed
                if (_needSearchListRebuild)
                {
                    _currentSearchList.Clear();

                    if (lookIn == CurrentDocumentString && _currentDoc is ILuaEditDocumentEditable)
                    {
                        _currentSearchList.Add(_currentDoc as ILuaEditDocumentEditable);
                    }
                    else if (lookIn == CurrentProjectString)
                    {
                        DocumentsManager.Instance.CurrentSolution.ActiveProject.GetAllDocumentsOfType <ILuaEditDocumentEditable>(_currentSearchList);
                    }
                    else if (lookIn == AllOpenDocumentsString)
                    {
                        foreach (ILuaEditDocument doc in DocumentsManager.Instance.OpenedDocuments.Values)
                        {
                            if (doc is ILuaEditDocumentEditable && doc.DockContent != null)
                            {
                                _currentSearchList.Add(doc as ILuaEditDocumentEditable);
                            }
                        }
                    }

                    if (_currentDoc != null && _currentDoc is ILuaEditDocumentEditable)
                    {
                        _currentSearchIndex = _currentSearchList.IndexOf(_currentDoc as ILuaEditDocumentEditable);
                    }
                    else
                    {
                        _currentSearchIndex = 0;
                    }

                    _currentSearchStartIndex = _currentSearchIndex;
                    _currentEndOfSearch      = chkSearchUp.Checked ? 0 : _currentSearchList.Count;
                    _isFirstSearch           = true;
                    _needSearchListRebuild   = false;
                }

                // Perform search through the document list (if required)
                if (_currentSearchList.Count > 0)
                {
                    while (chkSearchUp.Checked ? _currentSearchIndex >= _currentEndOfSearch : _currentSearchIndex < _currentEndOfSearch)
                    {
                        ILuaEditDocumentEditable doc = _currentSearchList[_currentSearchIndex];
                        FindResult res = new FindResult(0, 0, 0, false, true);

                        if (!_isFirstSearch && _previouslySearchedDoc != doc.FileName)
                        {
                            doc.DocumentUI.Editor.Caret.Position = new TextPoint(0, chkSearchUp.Checked ? doc.Document.Count - 1 : 0);
                        }

                        _previouslySearchedDoc = doc.FileName;

                        while (res.Matched)
                        {
                            _isFirstSearch = false;
                            res            = doc.DocumentUI.Editor.ActiveViewControl.FindNext(findWhatText,
                                                                                              chkMatchCase.Checked,
                                                                                              chkMatchWholeWord.Checked,
                                                                                              chkUseRegEx.Checked,
                                                                                              chkSearchUp.Checked);

                            if (res.PassedEndOfDocument)
                            {
                                if (lookIn != CurrentDocumentString || shouldBookmark)
                                {
                                    break;
                                }
                            }

                            if (res.Matched)
                            {
                                _canInitialize = false;
                                DocumentsManager.Instance.OpenDocument(doc);
                                this.Focus();
                                _canInitialize = true;

                                if (res.PassedEndOfDocument)
                                {
                                    ShowPassedEndOfDocStatusMessage();
                                }

                                // Select found text
                                doc.DocumentUI.Editor.ActiveViewControl.SelectText(res.RowIndex, res.Column, res.Length);

                                if (shouldBookmark)
                                {
                                    // Bookmark the line if required
                                    doc.DocumentUI.ToggleBookmark(doc.Document[res.RowIndex]);
                                }
                                else
                                {
                                    // Display search status to user
                                    if (!res.PassedEndOfDocument)
                                    {
                                        string findOptionsString = string.Empty;
                                        string lookInStr         = lookIn;

                                        if (chkSearchUp.Checked)
                                        {
                                            findOptionsString += ", Search up";
                                        }
                                        if (chkMatchCase.Checked)
                                        {
                                            findOptionsString += ", Match case";
                                        }
                                        if (chkMatchWholeWord.Checked)
                                        {
                                            findOptionsString += ", Match whole word";
                                        }
                                        if (chkUseRegEx.Checked)
                                        {
                                            findOptionsString += ", Regular expressions";
                                        }

                                        if (lookIn == CurrentProjectString)
                                        {
                                            lookInStr += ": " + Path.GetFileName(DocumentsManager.Instance.CurrentSolution.ActiveProject.FileName);
                                        }

                                        string statusMsg = string.Format("Find \"{0}\"{1}, {2}", findWhatText, findOptionsString, lookIn);
                                        FrameworkManager.Instance.RequestStatusMessage(statusMsg, SystemColors.Control, Color.Black);
                                    }

                                    return;
                                }
                            }
                            else if (lookIn == CurrentDocumentString)
                            {
                                if (res.PassedEndOfDocument)
                                {
                                    ShowPassedEndOfDocStatusMessage();
                                }

                                string msg = string.Format("The following specified text was not found:\n\n{0}", findWhatText);
                                MessageBox.Show(msg, "LuaEdit", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }

                        if (chkSearchUp.Checked)
                        {
                            if (_currentSearchIndex == 0)
                            {
                                _currentSearchIndex = _currentSearchList.Count - 1;
                            }
                            else
                            {
                                --_currentSearchIndex;
                            }
                        }
                        else
                        {
                            if (_currentSearchIndex == _currentSearchList.Count - 1 && _currentSearchStartIndex != 0)
                            {
                                _currentSearchIndex = 0;
                            }
                            else
                            {
                                ++_currentSearchIndex;
                            }
                        }
                    }
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }