Ejemplo n.º 1
0
void SyntaxHighlightDlg::LoadLexers(const wxString& theme)
{
#ifdef __WXMSW__
    wxWindowUpdateLocker locker(this);
#endif

    // get the current open editor's lexer name
    wxString currentLexer;
    LEditor *editor = clMainFrame::Get()->GetMainBook()->GetActiveEditor();
    if(editor) {
        currentLexer = editor->GetContext()->GetName();
        currentLexer.MakeLower();
    }

    //remove old lexers
    if (m_lexersBook->GetPageCount() > 0) {
        m_lexersBook->DeleteAllPages();
    }

    //update the theme name
    EditorConfigST::Get()->SaveStringValue(wxT("LexerTheme"), theme);

    //load all lexers
    EditorConfigST::Get()->LoadLexers(false);

    std::map<wxString, LexerConfPtr>::const_iterator iter = EditorConfigST::Get()->LexerBegin();
    for (; iter != EditorConfigST::Get()->LexerEnd(); iter++) {
        LexerConfPtr lexer = iter->second;

        wxString lexName = lexer->GetName();
        lexName.Trim().Trim(false);
        if(lexName.IsEmpty())
            continue;

        // get the parent node for this lexer
        wxString firstChar = lexName.Mid(0, 1).MakeUpper();
        size_t parentIndex(wxString::npos);
        for(size_t i=0; i<m_lexersBook->GetPageCount(); i++) {
            wxString pageText = m_lexersBook->GetPageText(i);
            pageText.MakeUpper();
            if( pageText.StartsWith(firstChar) ) {
                parentIndex = i;
                break;
            }
        }

        if(parentIndex == wxString::npos) {
            // add parent node
            m_lexersBook->AddPage(CreateLexerPage(m_lexersBook, lexer), lexer->GetName(), currentLexer == iter->second->GetName());

        } else {
            m_lexersBook->InsertPage(parentIndex, CreateLexerPage(m_lexersBook, lexer), lexer->GetName(), currentLexer == iter->second->GetName());
        }
    }
    // The outputview colours are global to all a theme's lexors, so are dealt with separately
    m_colourPickerOutputPanesFgColour->SetColour(wxColour(EditorConfigST::Get()->GetCurrentOutputviewFgColour()));
    m_colourPickerOutputPanesBgColour->SetColour(wxColour(EditorConfigST::Get()->GetCurrentOutputviewBgColour()));
}
Ejemplo n.º 2
0
ContextManager::ContextManager()
{
	// register available contexts
	m_contextPool[wxT("C++")] = new ContextCpp();
    m_contextPool[wxT("Diff")] = new ContextDiff();

	// load generic lexers
	EditorConfig::ConstIterator iter = EditorConfigST::Get()->LexerBegin();
    for(; iter != EditorConfigST::Get()->LexerEnd(); iter++){
		LexerConfPtr lex = iter->second;
        if (m_contextPool.find(lex->GetName()) == m_contextPool.end()) {
            m_contextPool[lex->GetName()] = new ContextGeneric(lex->GetName());
		}
	}

    // make sure there is a "fallback" lexer for unrecognized file types
    if (m_contextPool.find(wxT("Text")) == m_contextPool.end()) {
        m_contextPool[wxT("Text")] = new ContextGeneric(wxT("Text"));
    }
}
Ejemplo n.º 3
0
ContextBasePtr ContextManager::NewContextByFileName (LEditor *parent, const wxFileName &fileName)
{
	EditorConfig::ConstIterator iter = EditorConfigST::Get()->LexerBegin();
	for ( ; iter != EditorConfigST::Get()->LexerEnd(); iter++ ) {
		LexerConfPtr lexer = iter->second;
		wxString lexExt = lexer->GetFileSpec();
		wxStringTokenizer tkz ( lexExt, wxT ( ";") );
		while ( tkz.HasMoreTokens() ) {
			wxString ext      = tkz.NextToken();
			wxString fullname = fileName.GetFullName();

			ext.MakeLower(); fullname.MakeLower();
			if ( wxMatchWild ( ext, fullname ) ) {
				return ContextManager::Get()->NewContext ( parent, lexer->GetName() );
			}
		}
	}

	// return the default context
	return ContextManager::Get()->NewContext ( parent, wxT ( "Text") );
}
wxPanel *OptionsDlg::CreateSyntaxHighlightPage()
{
	wxPanel *page = new wxPanel( m_book, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
	wxBoxSizer *sz = new wxBoxSizer(wxVERTICAL);
	page->SetSizer(sz);

	long style = wxFNB_FF2 | wxFNB_NO_NAV_BUTTONS | wxFNB_DROPDOWN_TABS_LIST | wxFNB_NO_X_BUTTON;
	m_lexersBook = new wxFlatNotebook(page, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
	sz->Add(m_lexersBook, 1, wxEXPAND | wxALL, 5);
	m_lexersBook->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));

	bool selected = true;
	EditorConfig::ConstIterator iter = EditorConfigST::Get()->LexerBegin();
	for(; iter != EditorConfigST::Get()->LexerEnd(); iter++){
		LexerConfPtr lexer = iter->second;
		m_lexersBook->AddPage(CreateLexerPage(m_lexersBook, lexer), lexer->GetName(), selected);
		selected = false;
	}

	return page;
}
void EditorConfig::SetLexer(LexerConfPtr lexer)
{
	m_lexers[lexer->GetName()] = lexer;
	lexer->Save();
}