示例#1
0
bool IsPHPFileByExt(const wxString& filename)
{
    wxFileName fileName = filename;
    LexerConf::Ptr_t lexer = EditorConfigST::Get()->GetLexer(wxT("php"));
    wxString fileSpec;

    if(!lexer) {
        // Incase somehow we failed in retrieving the lexer (corrupted XML file)
        // use some hardcoded file spec
        fileSpec = wxT("*.php;*.inc;*.phtml");

    } else {
        fileSpec = lexer->GetFileSpec();
    }

    wxStringTokenizer tkz(fileSpec, wxT(";"));
    while(tkz.HasMoreTokens()) {
        wxString fileExt = tkz.NextToken();
        wxString fullname = fileName.GetFullName();

        fileExt.MakeLower();
        fullname.MakeLower();
        if(wxMatchWild(fileExt, fullname)) {
            return true;
        }
    }
    return false;
}
void OutlineTab::OnActiveEditorChanged(wxCommandEvent& e)
{
    e.Skip();
    IEditor* editor = m_mgr->GetActiveEditor();
    LexerConf::Ptr_t phpLexer = ColoursAndFontsManager::Get().GetLexer("php");
    LexerConf::Ptr_t cxxLexer = ColoursAndFontsManager::Get().GetLexer("c++");

    // Use the lexer to determine if we can show outline
    if(editor && cxxLexer && FileUtils::WildMatch(cxxLexer->GetFileSpec(), editor->GetFileName())) {
        m_tree->BuildTree(editor->GetFileName(), false);
        m_simpleBook->SetSelection(OUTLINE_TAB_CXX);
        m_textCtrlSearch->Enable(true);

    } else if(editor && phpLexer && FileUtils::WildMatch(phpLexer->GetFileSpec(), editor->GetFileName())) {
        m_treeCtrlPhp->BuildTree(editor->GetFileName());
        m_simpleBook->SetSelection(OUTLINE_TAB_PHP);
        m_textCtrlSearch->Enable(true);

    } else {
        m_simpleBook->SetSelection(OUTLINE_PLACE_HOLDER_PAGE);
        m_textCtrlSearch->Enable(false);
    }
}