Exemple #1
0
void SFTP::OnEditorClosed(wxCommandEvent& e)
{
    e.Skip();
    IEditor* editor = (IEditor*)e.GetClientData();
    if(editor) {
        wxString localFile = editor->GetFileName().GetFullPath();
        if(m_remoteFiles.count(localFile)) {

            wxLogNull noLog;

            // Remove the file from our cache
            ::wxRemoveFile(localFile);
            m_remoteFiles.erase(localFile);
        }
    }
}
Exemple #2
0
void LLDBPlugin::DestroyTooltip()
{
    if(m_tooltip) {
        m_tooltip->Destroy();
        m_tooltip = NULL;

        // Raise codelite back
        EventNotifier::Get()->TopFrame()->Raise();

        // If we destroyed the tooltip, set the focus back to the active editor
        IEditor* editor = m_mgr->GetActiveEditor();
        if(editor) {
            editor->SetActive();
        }
    }
}
void OpenResourceDialog::OpenSelection(const OpenResourceDialogItemData& selection, IManager* manager)
{
    // send event to the plugins to see if they want
    // to open this file
    wxString file_path = selection.m_file;
    clCommandEvent activateEvent(wxEVT_TREE_ITEM_FILE_ACTIVATED);
    activateEvent.SetFileName(file_path);
    if(EventNotifier::Get()->ProcessEvent(activateEvent)) return;

    if(manager && manager->OpenFile(selection.m_file, wxEmptyString, selection.m_line - 1)) {
        IEditor* editor = manager->GetActiveEditor();
        if(editor && !selection.m_name.IsEmpty() && !selection.m_pattern.IsEmpty()) {
            editor->FindAndSelectV(selection.m_pattern, selection.m_name);
        }
    }
}
Exemple #4
0
void OutlineTab::OnFilesTagged(wxCommandEvent& e)
{
    e.Skip();
    IEditor* editor = m_mgr->GetActiveEditor();
    if( editor ) {
        m_tree->BuildTree( editor->GetFileName() );
        
        if(editor->GetSTC()) {
            // make sure we dont steal the focus from the editor...
            editor->GetSTC()->SetFocus();
        }
        
    } else {
        m_tree->Clear();
    }
}
	void AudioOutputCollectionClassPropertyIterator::toBack()
	{
		ActiveAudioTracks* tracks = _editor->getPoolOfActiveAudioTrack();

		_index = tracks->size();
		_last = -1;
	}
bool PHPEditorContextMenu::IsIncludeOrRequireStatement(wxString& includeWhat)
{
    // Do a basic check to see whether this line is include statement or not.
    // Don't bother in full parsing the file since it can be a quite an expensive operation
    // (include|require_once|require|include_once)[ \t\\(]*(.*?)[\\) \t)]*;
    static wxRegEx reInclude(wxT("(include|require_once|require|include_once)[ \t\\(]*(.*?)[\\) \t]*;"), wxRE_ADVANCED);

    IEditor* editor = m_manager->GetActiveEditor();
    if(!editor) return false;

    wxString line = editor->GetCtrl()->GetLine(editor->GetCurrentLine());
    if(reInclude.IsValid() && reInclude.Matches(line)) {
        includeWhat = reInclude.GetMatch(line, 2);
        return true;
    }
    return false;
}
Exemple #7
0
void WebTools::OnTimer(wxTimerEvent& event)
{
    event.Skip();

    time_t curtime = time(NULL);
    if((curtime - m_lastColourUpdate) < 5) return;
    IEditor* editor = m_mgr->GetActiveEditor();

    // Sanity
    CHECK_PTR_RET(editor);
    CHECK_PTR_RET(editor->IsModified());
    if(!IsJavaScriptFile(editor->GetFileName())) return;

    // This file is a modified JS file
    m_lastColourUpdate = time(NULL);
    m_jsColourThread->QueueBuffer(editor->GetFileName().GetFullPath(), editor->GetTextRange(0, editor->GetLength()));
}
Exemple #8
0
void ZoomText::OnIdle(wxIdleEvent& event)
{
    event.Skip();
    // sanity
    if(!m_classes.IsEmpty() || IsEmpty()) return;
    
    IEditor* editor = clGetManager()->GetActiveEditor();
    if(!editor) return;

    if(m_classes.IsEmpty() && !editor->GetKeywordClasses().IsEmpty() &&
       (editor->GetFileName().GetFullPath() == m_filename)) {
        // Sync between the keywords
        SetKeyWords(1, editor->GetKeywordClasses()); // classes
        SetKeyWords(3, editor->GetKeywordLocals());  // locals
        Colourise(0, GetLength());
    }
}
void LanguageServerCluster::OnSymbolFound(LSPEvent& event)
{
    const LSP::Location& location = event.GetLocation();
    wxFileName fn(location.GetUri());
    clDEBUG() << "LSP: Opening file:" << fn << "(" << location.GetRange().GetStart().GetLine() << ":"
              << location.GetRange().GetStart().GetCharacter() << ")";

    // Manage the browser (BACK and FORWARD) ourself
    BrowseRecord from;
    IEditor* oldEditor = clGetManager()->GetActiveEditor();
    if(oldEditor) { from = oldEditor->CreateBrowseRecord(); }
    IEditor* editor = clGetManager()->OpenFile(fn.GetFullPath(), "", wxNOT_FOUND, OF_None);
    if(editor) {
        editor->SelectRange(location.GetRange());
        if(oldEditor) { NavMgr::Get()->AddJump(from, editor->CreateBrowseRecord()); }
    }
}
Exemple #10
0
void PHPOutlineTree::ItemSelected(const wxTreeItemId& item, bool focusEditor)
{
    QItemData* itemData = dynamic_cast<QItemData*>(GetItemData(item));
    CHECK_PTR_RET(itemData);

    IEditor* editor = m_manager->GetActiveEditor();
    CHECK_PTR_RET(editor);

    // Define the pattern to search

    editor->FindAndSelect(itemData->m_entry->GetShortName(), itemData->m_entry->GetShortName(),
                          editor->PosFromLine(itemData->m_entry->GetLine()), NavMgr::Get());
    // set the focus to the editor
    if(focusEditor) {
        CallAfter(&PHPOutlineTree::SetEditorActive, editor);
    }
}
Exemple #11
0
void XDebugManager::OnDeleteBreakpoint(PHPEvent& e)
{
    e.Skip();
    wxString filename = e.GetFileName();
    int line = e.GetLineNumber();
    int bpid = e.GetInt();
    
    if ( bpid != wxNOT_FOUND ) {
        // breakpoint was applied
        DoDeleteBreakpoint(bpid);
    }
    IEditor * editor = m_plugin->GetManager()->FindEditor( filename );
    if ( editor ) {
        editor->GetSTC()->MarkerDelete(line-1, smt_breakpoint);
    }
    m_breakpointsMgr.DeleteBreakpoint(filename, line);
}
void PHPCodeCompletion::OnFindSymbol(clCodeCompletionEvent& e)
{
    if(PHPWorkspace::Get()->IsOpen()) {
        if(!CanCodeComplete(e)) return;

        IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor());
        if(editor) {
            PHPEntityBase::Ptr_t resolved = GetPHPEntryUnderTheAtPos(editor, editor->GetCurrentPosition());
            if(resolved) {
                m_manager->OpenFile(resolved->GetFilename().GetFullPath(), "", resolved->GetLine());
            }
        }

    } else {
        e.Skip();
    }
}
Exemple #13
0
void CppCheckPlugin::OnCheckFileEditorItem(wxCommandEvent& e)
{
    if(m_cppcheckProcess) {
        clLogMessage(_("CppCheckPlugin: CppCheck is currently busy please wait for it to complete the current check"));
        return;
    }

    ProjectPtr proj;
    IEditor* editor = m_mgr->GetActiveEditor();
    if(editor) {
        wxString projectName = editor->GetProjectName();
        if(!projectName.IsEmpty()) { proj = clCxxWorkspaceST::Get()->GetProject(projectName); }
        m_filelist.Add(editor->GetFileName().GetFullPath());
    }

    DoStartTest();
}
QList<FilterEntry> FileSystemFilter::matchesFor(const QString &entry)
{
    QList<FilterEntry> value;
    QFileInfo entryInfo(entry);
    QString name = entryInfo.fileName();
    QString directory = entryInfo.path();
    QString filePath = entryInfo.filePath();
    if (entryInfo.isRelative()) {
        if (filePath.startsWith("~/")) {
            directory.replace(0, 1, QDir::homePath());
        } else {
            IEditor *editor = m_editorManager->currentEditor();
            if (editor && !editor->file()->fileName().isEmpty()) {
                QFileInfo info(editor->file()->fileName());
                directory.prepend(info.absolutePath()+"/");
            }
        }
    }
    QDir dirInfo(directory);
    QDir::Filters dirFilter = QDir::Dirs|QDir::Drives;
    QDir::Filters fileFilter = QDir::Files;
    if (m_includeHidden) {
        dirFilter |= QDir::Hidden;
        fileFilter |= QDir::Hidden;
    }
    QStringList dirs = dirInfo.entryList(dirFilter,
                                      QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
    QStringList files = dirInfo.entryList(fileFilter,
                                      QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
    foreach (const QString &dir, dirs) {
        if (dir != "." && (name.isEmpty() || dir.startsWith(name, Qt::CaseInsensitive))) {
            FilterEntry entry(this, dir, dirInfo.filePath(dir));
            entry.resolveFileIcon = true;
            value.append(entry);
        }
    }
    foreach (const QString &file, files) {
        if (name.isEmpty() || file.startsWith(name, Qt::CaseInsensitive)) {
            const QString fullPath = dirInfo.filePath(file);
            FilterEntry entry(this, file, fullPath);
            entry.resolveFileIcon = true;
            value.append(entry);
        }
    }
    return value;
}
Exemple #15
0
// TODO: Can this be improved? This code is ripped from CppEditor, especially CppElementEvaluater
// We cannot depend on this since CppEditor plugin code is internal and requires building the implementation files ourselves
CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor()
{
    EditorManager *editorManager = EditorManager::instance();
    if (!editorManager)
        return 0;
    IEditor *editor = editorManager->currentEditor();
    if (!editor)
        return 0;
    TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
    if (!textEditor)
        return 0;
    TextEditor::BaseTextEditorWidget *editorWidget = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
    if (!editorWidget)
        return 0;

    QPlainTextEdit *ptEdit = qobject_cast<QPlainTextEdit *>(editor->widget());
    if (!ptEdit)
        return 0;

    QTextCursor tc;
    tc = ptEdit->textCursor();
    int line = 0;
    int column = 0;
    const int pos = tc.position();
    editorWidget->convertPosition(pos, &line, &column);

    const CPlusPlus::Snapshot &snapshot = CPlusPlus::CppModelManagerInterface::instance()->snapshot();
    CPlusPlus::Document::Ptr doc = snapshot.document(editor->document()->fileName());
    QTC_ASSERT(doc, return 0)

    // fetch the expression's code
    CPlusPlus::ExpressionUnderCursor expressionUnderCursor;
    moveCursorToEndOfName(&tc);
    const QString &expression = expressionUnderCursor(tc);
    CPlusPlus::Scope *scope = doc->scopeAt(line, column);

    CPlusPlus::TypeOfExpression typeOfExpression;
    typeOfExpression.init(doc, snapshot);
    const QList<CPlusPlus::LookupItem> &lookupItems = typeOfExpression(expression.toUtf8(), scope);
    if (lookupItems.isEmpty())
        return 0;

    const CPlusPlus::LookupItem &lookupItem = lookupItems.first(); // ### TODO: select best candidate.
    return lookupItem.declaration();
}
Exemple #16
0
void CscopeTab::DoItemActivated(const wxDataViewItem& item )
{
    CscopeTabClientData *data = dynamic_cast<CscopeTabClientData*>(m_dataviewModel->GetClientObject(item));
    if (data) {
        wxString wsp_path = clCxxWorkspaceST::Get()->GetPrivateFolder();
        //a single entry was activated, open the file
        //convert the file path to absolut path. We do it here, to improve performance
        wxFileName fn(data->GetEntry().GetFile());

        if ( !fn.MakeAbsolute(wsp_path) ) {
            wxLogMessage(wxT("failed to convert file to absolute path"));
        }

        if(m_mgr->OpenFile(fn.GetFullPath(), wxEmptyString, data->GetEntry().GetLine()-1)) {
            IEditor *editor = m_mgr->GetActiveEditor();
            if( editor && editor->GetFileName().GetFullPath() == fn.GetFullPath() && !GetFindWhat().IsEmpty()) {
                // We can't use data->GetEntry().GetPattern() as the line to search for as any appended comments have been truncated
                // For some reason LEditor::DoFindAndSelect checks it against the whole current line
                // and won't believe a match unless their lengths are the same
                int line = data->GetEntry().GetLine() - 1;
                int start = editor->PosFromLine(line);	// PosFromLine() returns the line start position
                int end = editor->LineEnd(line);
                wxString searchline(editor->GetTextRange(start, end));
                // Find and select the entry in the file
                editor->FindAndSelectV(searchline, GetFindWhat(), start); // The async version of FindAndSelect()
                editor->DelayedSetActive(); // We need to SetActive() editor. At least in wxGTK, this won't work synchronously
            }
        }
    } else {
        // Parent item, expand it
        m_dataview->Expand( item );
    }
}
void ZoomNavigator::OnPreviewClicked(wxMouseEvent& e)
{
    IEditor* curEditor = m_mgr->GetActiveEditor();

    // user clicked on the preview
    CHECK_CONDITION(m_startupCompleted);
    CHECK_CONDITION(curEditor);
    CHECK_CONDITION(m_enabled);

    // the first line is taken from the preview
    int pos = m_text->PositionFromPoint(e.GetPosition());
    if(pos == wxSTC_INVALID_POSITION) {
        return;
    }
    int first = m_text->LineFromPosition(pos);
    int nLinesOnScreen = curEditor->GetCtrl()->LinesOnScreen();
    first -= (nLinesOnScreen / 2);
    if(first < 0) first = 0;

    // however, the last line is set according to the actual editor
    int last = nLinesOnScreen + first;

    PatchUpHighlights(first, last);
    curEditor->GetCtrl()->SetFirstVisibleLine(first);
    curEditor->SetCaretAt(curEditor->PosFromLine(first + (nLinesOnScreen / 2)));

    // reset the from/last members to avoid unwanted movements in the 'OnTimer' function
    m_markerFirstLine = curEditor->GetCtrl()->GetFirstVisibleLine();
    m_markerLastLine = m_markerFirstLine + curEditor->GetCtrl()->LinesOnScreen();
}
void PHPCodeCompletion::GotoDefinition(IEditor* editor, int pos)
{

    CHECK_PTR_RET(editor);
    wxStyledTextCtrl* sci = editor->GetCtrl();
    CHECK_PTR_RET(sci);

    PHPLocation::Ptr_t definitionLocation = FindDefinition(editor, pos);
    CHECK_PTR_RET(definitionLocation);

    // Open the file (make sure we use the 'OpenFile' so we will get a browsing record)
    IEditor* activeEditor =
        m_manager->OpenFile(definitionLocation->filename, wxEmptyString, definitionLocation->linenumber);
    if(activeEditor) {
        int selectFromPos = activeEditor->GetCtrl()->PositionFromLine(definitionLocation->linenumber);
        DoSelectInEditor(activeEditor, definitionLocation->what, selectFromPos);
    }
}
void OutlineTab::OnFilesTagged(wxCommandEvent& e)
{
    e.Skip();
    IEditor* editor = m_mgr->GetActiveEditor();
    if(editor) {

        wxWindow* oldFocusedWindow = wxWindow::FindFocus();
        m_tree->BuildTree(editor->GetFileName(), false);
        wxWindow* focusedWindow = wxWindow::FindFocus();
        if(oldFocusedWindow != focusedWindow && oldFocusedWindow) {
            // restore the focus back the old window
            oldFocusedWindow->SetFocus();
        }

    } else {
        m_tree->Clear();
    }
}
void wxCodeCompletionBoxManager::InsertSelection(const wxString& selection)
{
    IManager* manager = ::clGetManager();
    IEditor* editor = manager->GetActiveEditor();
    if(editor) {
        wxStyledTextCtrl* ctrl = editor->GetSTC();
        // Default behviour: remove the partial text from teh editor and replace it
        // with the selection
        int start = ctrl->WordStartPosition(ctrl->GetCurrentPos(), true);
        int end = ctrl->GetCurrentPos();
        ctrl->SetSelection(start, end);

        wxString entryText = selection;
        if(entryText.Find("(") != wxNOT_FOUND) {
            // a function like
            wxString textToInsert = entryText.BeforeFirst('(');

            // Build the function signature
            wxString funcSig = entryText.AfterFirst('(');
            funcSig = funcSig.BeforeLast(')');
            funcSig.Trim().Trim(false);

            CL_DEBUG("Inserting selection: %s", textToInsert);
            CL_DEBUG("Signature is: %s", funcSig);

            textToInsert << "()";
            ctrl->ReplaceSelection(textToInsert);
            if(!funcSig.IsEmpty()) {
                // Place the caret between the parenthesis
                int caretPos = start + textToInsert.Len() - 1;
                ctrl->SetCurrentPos(caretPos);
                ctrl->SetSelection(caretPos, caretPos);

                // trigger a code complete for function calltip.
                // We do this by simply mimicing the user action of going to the menubar:
                // Edit->Display Function Calltip
                wxCommandEvent event(wxEVT_MENU, XRCID("function_call_tip"));
                wxTheApp->GetTopWindow()->GetEventHandler()->AddPendingEvent(event);
            }
        } else {
            ctrl->ReplaceSelection(entryText);
        }
    }
}
Exemple #21
0
void AbbreviationPlugin::OnAbbreviations(wxCommandEvent& e)
{
    IEditor *editor = m_mgr->GetActiveEditor();
    if (!editor) {
        return;
    }

    AbbreviationJSONEntry jsonData;
    if ( !m_config.ReadItem( &jsonData ) ) {
        // merge the data from the old configuration
        AbbreviationEntry data;
        m_mgr->GetConfigTool()->ReadObject(wxT("AbbreviationsData"), &data);
    
        jsonData.SetAutoInsert( data.GetAutoInsert() );
        jsonData.SetEntries( data.GetEntries() );
        m_config.WriteItem( &jsonData );
    }
    
    wxString wordAtCaret = editor->GetWordAtCaret();
    
    bool autoInsert = (jsonData.IsAutoInsert() && wordAtCaret.IsEmpty() == false);
    if  ( autoInsert ){
        autoInsert = InsertExpansion(wordAtCaret);
    }
    
    if ( !autoInsert ) {
        static wxBitmap bmp = LoadBitmapFile(wxT("abbrev.png")) ;
        if (bmp.IsOk()) {
            editor->RegisterImageForKind(wxT("Abbreviation"), bmp);
            std::vector<TagEntryPtr> tags;

            // search for the old item
            const JSONElement::wxStringMap_t& entries = jsonData.GetEntries();
            JSONElement::wxStringMap_t::const_iterator iter = entries.begin();
            for (; iter != entries.end(); ++iter) {
                TagEntryPtr t(new TagEntry());
                t->SetName(iter->first);
                t->SetKind(wxT("Abbreviation"));
                tags.push_back(t);
            }
            editor->ShowCompletionBox(tags, editor->GetWordAtCaret(), false, this);
        }
    }
}
Exemple #22
0
void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e)
{
    wxTreeItemId item = DoGetSingleSelection();
    CHECK_ITEM_RET(item);

    ItemData *data = DoGetItemData(item);
    CHECK_PTR_RET(data);
    CHECK_ID_FILE(data);

    wxFileName old_file_name = data->GetFile();
    wxString new_name = ::wxGetTextFromUser(_("New file name:"), _("Rename file"), old_file_name.GetFullName() );
    if ( new_name.IsEmpty() )
        return;

    if ( new_name == old_file_name.GetFullName() )
        return;

    // Check to see if we got a file with the old path opened
    bool reopenFile = false;
    IEditor *editor = m_mgr->FindEditor(old_file_name.GetFullPath());
    if ( editor ) {
        m_mgr->ClosePage( editor->GetFileName().GetFullName() );
        reopenFile = true;
        editor = NULL;
    }

    PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(DoGetSelectedProject());
    CHECK_PTR_RET(pProject);

    if ( pProject->RenameFile(old_file_name.GetFullPath(), new_name) ) {
        // Locate the folder
        pProject->Save();
        m_treeCtrlView->SetItemText(item, new_name);
        // Update the item data
        old_file_name.SetFullName(new_name);
        data->SetFile( old_file_name.GetFullPath() );
        
        // Open the file if it was opened earlier
        // old_file_name now contains the new full path to the new file
        if ( reopenFile ) {
            m_mgr->OpenFile( old_file_name.GetFullPath() );
        }
    }
}
Exemple #23
0
void AbbreviationPlugin::OnAbbreviations(wxCommandEvent& e)
{
    IEditor* editor = m_mgr->GetActiveEditor();
    if(!editor) {
        return;
    }

    AbbreviationJSONEntry jsonData;
    if(!m_config.ReadItem(&jsonData)) {
        // merge the data from the old configuration
        AbbreviationEntry data;
        m_mgr->GetConfigTool()->ReadObject(wxT("AbbreviationsData"), &data);

        jsonData.SetAutoInsert(data.GetAutoInsert());
        jsonData.SetEntries(data.GetEntries());
        m_config.WriteItem(&jsonData);
    }

    wxString wordAtCaret = editor->GetWordAtCaret();

    bool autoInsert = (jsonData.IsAutoInsert() && wordAtCaret.IsEmpty() == false);
    if(autoInsert) {
        autoInsert = InsertExpansion(wordAtCaret);
    }

    if(!autoInsert) {
        static wxBitmap bmp = LoadBitmapFile(wxT("abbrev.png"));
        if(bmp.IsOk()) {
            wxCodeCompletionBoxEntry::Vec_t ccEntries;
            wxCodeCompletionBox::BmpVec_t bitmaps;
            bitmaps.push_back(bmp);

            // search for the old item
            const JSONElement::wxStringMap_t& entries = jsonData.GetEntries();
            JSONElement::wxStringMap_t::const_iterator iter = entries.begin();
            for(; iter != entries.end(); ++iter) {
                ccEntries.push_back(wxCodeCompletionBoxEntry::New(iter->first, 0));
            }
            wxCodeCompletionBoxManager::Get().ShowCompletionBox(
                editor->GetCtrl(), ccEntries, bitmaps, wxCodeCompletionBox::kNone, wxNOT_FOUND, this);
        }
    }
}
void PHPCodeCompletion::OnFindSymbol(clCodeCompletionEvent& e)
{
    e.Skip();
    if(PHPWorkspace::Get()->IsOpen()) {
        if(!CanCodeComplete(e)) return;
        e.Skip(false);
        IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor());
        if(editor) {
            wxString word = editor->GetWordAtCaret();
            if(word.IsEmpty()) return;
            PHPEntityBase::List_t symbols = m_lookupTable.FindSymbol(word);
            if(symbols.size() == 1) {
                PHPEntityBase::Ptr_t match = *symbols.begin();
                DoOpenEditorForEntry(match);

            } else {

                // Convert the matches to clSelectSymbolDialogEntry::List_t
                clSelectSymbolDialogEntry::List_t entries;
                std::for_each(symbols.begin(), symbols.end(), [&](PHPEntityBase::Ptr_t entry) {
                    TagEntryPtr tag = DoPHPEntityToTagEntry(entry);
                    wxBitmap bmp = wxCodeCompletionBox::GetBitmap(tag);

                    clSelectSymbolDialogEntry m;
                    m.bmp = bmp;
                    m.name = entry->GetFullName();
                    m.clientData = new PHPFindSymbol_ClientData(entry);
                    m.help = tag->GetKind();
                    entries.push_back(m);
                });

                // Show selection dialog
                clSelectSymbolDialog dlg(EventNotifier::Get()->TopFrame(), entries);
                if(dlg.ShowModal() != wxID_OK) return;
                PHPFindSymbol_ClientData* cd = dynamic_cast<PHPFindSymbol_ClientData*>(dlg.GetSelection());
                if(cd) {
                    DoOpenEditorForEntry(cd->m_ptr);
                }
            }
        }
    }
}
CodeFormatterDlg::CodeFormatterDlg(wxWindow* parent,
                                   IManager* mgr,
                                   CodeFormatter* cf,
                                   const FormatOptions& opts,
                                   const wxString& sampleCode)
    : CodeFormatterBaseDlg(parent)
    , m_cf(cf)
    , m_sampleCode(sampleCode)
    , m_isDirty(false)
    , m_mgr(mgr)
{
    ::wxPGPropertyBooleanUseCheckbox(m_pgMgrAstyle->GetGrid());
    ::wxPGPropertyBooleanUseCheckbox(m_pgMgrClang->GetGrid());
    ::wxPGPropertyBooleanUseCheckbox(m_pgMgrPhp->GetGrid());
    
    // center the dialog
    Centre();

    m_options = opts;
    m_textCtrlPreview->SetText(m_sampleCode);
    GetSizer()->Fit(this);
    InitDialog();
    UpdatePreview();
    
    // Clear the modified status 
    m_pgMgrPhp->GetGrid()->ClearModifiedStatus();
    m_pgMgrAstyle->GetGrid()->ClearModifiedStatus();
    m_pgMgrClang->GetGrid()->ClearModifiedStatus();
    
    // set the selection based on the editor
    IEditor* editor = m_mgr->GetActiveEditor();
    if(editor && FileExtManager::IsPHPFile(editor->GetFileName())) {
        m_treebook->SetSelection(4);
    } else if(editor && FileExtManager::IsCxxFile(editor->GetFileName())) {
        m_treebook->SetSelection(1);
    } else {
        m_treebook->SetSelection(0);
    }
    
    SetName("CodeFormatterDlg");
    WindowAttrManager::Load(this);
}
Exemple #26
0
void PhpPlugin::OnOpenResource(wxCommandEvent& e)
{
    if(PHPWorkspace::Get()->IsOpen()) {
        OpenResourceDlg dlg(FRAME, m_mgr);
        if(dlg.ShowModal() == wxID_OK) {
            ResourceItem* itemData = dlg.GetSelectedItem();
            if(itemData) {
                if(m_mgr->OpenFile(itemData->filename.GetFullPath())) {
                    IEditor* editor = m_mgr->GetActiveEditor();
                    if(editor && itemData->line != wxNOT_FOUND) {
                        editor->FindAndSelect(
                            itemData->displayName, itemData->displayName, editor->PosFromLine(itemData->line), NULL);
                    }
                }
            }
        }
    } else {
        e.Skip();
    }
}
Exemple #27
0
void Tweaks::OnColourTab(clColourEvent& e)
{
#ifdef __WXGTK__
#if CL_USE_NATIVEBOOK
    // Not supported with native notebooks
    e.Skip();
    return;
#endif
#endif

    TWEAKS_ENABLED_EVENT_HANDLER();
    
    IEditor* editor = FindEditorByPage( e.GetPage() );
    if ( !editor ) {
        
        if ( m_settings.GetGlobalFgColour().IsOk() && m_settings.GetGlobalBgColour().IsOk() ) {
            // Non editor tab
            e.SetBgColour( e.IsActiveTab() ? EditorConfigST::Get()->GetCurrentOutputviewBgColour() : m_settings.GetGlobalBgColour() );
            e.SetFgColour( e.IsActiveTab() ? EditorConfigST::Get()->GetCurrentOutputviewFgColour() : m_settings.GetGlobalFgColour() );
            
        } else {
            e.Skip();
        }
    
    } else {
        
        const ProjectTweaks& tw = m_settings.GetProjectTweaks( editor->GetProjectName() );
        if ( tw.IsOk() ) {
            e.SetBgColour( e.IsActiveTab() ? EditorConfigST::Get()->GetCurrentOutputviewBgColour() : tw.GetTabBgColour() );
            e.SetFgColour( e.IsActiveTab() ? EditorConfigST::Get()->GetCurrentOutputviewFgColour() : tw.GetTabFgColour() );
            
        } else if ( m_settings.GetGlobalBgColour().IsOk() && m_settings.GetGlobalFgColour().IsOk() ) {
            e.SetBgColour( e.IsActiveTab() ? EditorConfigST::Get()->GetCurrentOutputviewBgColour() : m_settings.GetGlobalBgColour() );
            e.SetFgColour( e.IsActiveTab() ? EditorConfigST::Get()->GetCurrentOutputviewFgColour() : m_settings.GetGlobalFgColour() );
            
        } else {
            e.Skip();
        }
    
    }
}
Exemple #28
0
wxString Cscope::GetSearchPattern() const
{
    wxString pattern;
    if(m_mgr->IsShutdownInProgress()) {
        return pattern;
    }

    IEditor* editor = m_mgr->GetActiveEditor();
    if(editor) {
        pattern = editor->GetWordAtCaret();
    }

    if(pattern.IsEmpty()) {
        pattern = wxGetTextFromUser(_("Enter the symbol to search for:"),
                                    _("cscope: find symbol"),
                                    wxT(""),
                                    m_mgr->GetTheApp()->GetTopWindow());
    }

    return pattern;
}
Exemple #29
0
void CMakeHelpTab::CreateHelpPage(const wxString& content, const wxString& subject)
{
    wxString text = content;
    text.Replace("<br />", "\n");
    text.Replace("&lt;" , "<");
    text.Replace("&gt;" , ">");
    text.Replace("\r", "");
    text.Replace("\n\n", "\n");
    text.Replace("::\n", "\n\n");
    IManager* manager = ::clGetManager();
    
    // Write the content of the help into a temporary file
    wxFileName fnTemp = wxFileName::CreateTempFileName("cmake");
    wxFileName fnCMakeHelpFile = fnTemp;
    fnCMakeHelpFile.SetFullName("CMakeHelp.cmake");
    
    if(!FileUtils::WriteFileContent(fnCMakeHelpFile, text)) return;
    
    if(manager->OpenFile(fnCMakeHelpFile.GetFullPath())) {
        IEditor* activeEditor = manager->GetActiveEditor();
        if(activeEditor && activeEditor->GetFileName().GetFullPath() == fnCMakeHelpFile.GetFullPath()) {
            activeEditor->GetCtrl()->SetEditable(true);
            activeEditor->ReloadFile();
            activeEditor->GetCtrl()->SetFirstVisibleLine(0);
            activeEditor->GetCtrl()->SetEditable(false);
        }
    }
}
void PHPWorkspaceView::OnEditorChanged(wxCommandEvent& e)
{
    e.Skip();
    IEditor* editor = reinterpret_cast<IEditor*>(e.GetClientData());
    wxUnusedVar(editor);

    CHECK_PTR_RET(editor);
    wxFileName filename = editor->GetFileName();

    // FIXME : Load all breakpoints for this file and apply them to the UI

    // Locate the editor for this file
    PHPProject::Ptr_t pProject(NULL);
    const PHPProject::Map_t& projects = PHPWorkspace::Get()->GetProjects();
    PHPProject::Map_t::const_iterator iter = projects.begin();
    for(; iter != projects.end(); ++iter) {
        if(filename.GetPath().StartsWith(iter->second->GetFilename().GetPath())) {
            // found our project
            pProject = iter->second;
            break;
        }
    }

    CHECK_PTR_RET(pProject);

    PHPFolder::Ptr_t pFolder = pProject->FolderByFileFullPath(filename.GetFullPath());
    CHECK_PTR_RET(pFolder);

    wxTreeItemId projectItem = DoGetProjectItem(pProject->GetName());
    CHECK_ITEM_RET(projectItem);

    wxTreeItemId folderItem = DoGetFolderItem(projectItem, pFolder);
    CHECK_ITEM_RET(folderItem);

    wxTreeItemId fileItem = DoGetFileItem(folderItem, filename.GetFullPath());
    CHECK_ITEM_RET(fileItem);

    m_treeCtrlView->SelectItem(fileItem);
    m_treeCtrlView->EnsureVisible(fileItem);
}