AddIncludeFileDlg::AddIncludeFileDlg( wxWindow* parent, const wxString &fullpath, const wxString &text, int lineNo ) : AddIncludeFileDlgBase( parent ) , m_fullpath(fullpath) , m_text(text) , m_line(lineNo) { UpdateLineToAdd(); // Initialise the preview window LexerConfPtr cppLex = EditorConfigST::Get()->GetLexer("C++"); cppLex->Apply( m_textCtrlPreview, true ); //--------------------------------------------------------- m_textCtrlPreview->MarkerDefine(0x7, wxSTC_MARK_ARROW); m_textCtrlPreview->MarkerSetBackground(0x7, wxT("YELLOW GREEN")); // Set the initial text m_textCtrlPreview->SetReadOnly(false); m_textCtrlPreview->AddText(m_text); m_textCtrlPreview->EmptyUndoBuffer(); SetAndMarkLine(); Centre(); m_textCtrlLineToAdd->SetFocus(); WindowAttrManager::Load(this, "AddIncludeFileDlg", NULL); }
void DbViewerPanel::InitStyledTextCtrl(wxStyledTextCtrl *sci) { LexerConfPtr lexer = EditorConfigST::Get()->GetLexer("SQL"); if ( lexer ) { lexer->Apply( sci, true ); } }
SQLCommandPanel::SQLCommandPanel(wxWindow *parent,IDbAdapter* dbAdapter, const wxString& dbName, const wxString& dbTable) : _SqlCommandPanel(parent) { LexerConfPtr lexerSQL = EditorConfigST::Get()->GetLexer("SQL"); if ( lexerSQL ) { lexerSQL->Apply(m_scintillaSQL, true); } else { DbViewerPanel::InitStyledTextCtrl( m_scintillaSQL ); } m_pDbAdapter = dbAdapter; m_dbName = dbName; m_dbTable = dbTable; wxTheApp->Connect(wxID_SELECTALL, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SQLCommandPanel::OnEdit), NULL, this); wxTheApp->Connect(wxID_COPY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SQLCommandPanel::OnEdit), NULL, this); wxTheApp->Connect(wxID_PASTE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SQLCommandPanel::OnEdit), NULL, this); wxTheApp->Connect(wxID_CUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SQLCommandPanel::OnEdit), NULL, this); wxTheApp->Connect(wxID_UNDO, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SQLCommandPanel::OnEdit), NULL, this); wxTheApp->Connect(wxID_REDO, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SQLCommandPanel::OnEdit), NULL, this); m_scintillaSQL->AddText(wxString::Format(wxT(" -- selected database %s\n"), m_dbName.c_str())); if (!dbTable.IsEmpty()) { m_scintillaSQL->AddText(m_pDbAdapter->GetDefaultSelect(m_dbName, m_dbTable)); wxCommandEvent event(wxEVT_EXECUTE_SQL); GetEventHandler()->AddPendingEvent(event); } #if CL_USE_NATIVEBOOK gtk_widget_show_all(this->m_widget); #endif }
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())); }
wxFont NewBuildTab::DoGetFont() const { wxFont font = wxNullFont; LexerConfPtr lexerConf = EditorConfigST::Get()->GetLexer("C++"); if ( lexerConf ) { font = lexerConf->GetFontForSyle(wxSTC_C_DEFAULT); } if ( font.IsOk() == false ) { font = wxSystemSettings::GetFont(wxSYS_ANSI_FIXED_FONT); } return font; }
SvnCommitDialog::SvnCommitDialog(wxWindow* parent, const wxArrayString &paths, const wxString &url, Subversion2 *plugin, const wxString &repoPath) : SvnCommitDialogBaseClass(parent) , m_plugin(plugin) , m_url(url) , m_repoPath(repoPath) , m_process(NULL) { m_stcDiff->SetReadOnly(true); wxString title = GetTitle(); title << wxT(" - ") << url; SetTitle(title); for (size_t i=0; i<paths.GetCount(); i++) { int index = m_checkListFiles->Append(paths.Item(i)); m_checkListFiles->Check((unsigned int)index); } wxArrayString lastMessages, previews; m_plugin->GetCommitMessagesCache().GetMessages(lastMessages, previews); for(size_t i=0; i<previews.GetCount(); i++) { m_choiceMessages->Append(previews.Item(i), new CommitMessageStringData(lastMessages.Item(i))); } if ( !paths.IsEmpty() ) { m_checkListFiles->Select(0); DoShowDiff(0); } WindowAttrManager::Load(this, wxT("SvnCommitDialog"), m_plugin->GetManager()->GetConfigTool()); int sashPos = m_plugin->GetSettings().GetCommitDlgSashPos(); if ( sashPos != wxNOT_FOUND ) { m_splitterH->SetSashPosition(sashPos); } int sashHPos = m_plugin->GetSettings().GetCommitDlgHSashPos(); if ( sashHPos != wxNOT_FOUND ) { m_splitterV->SetSashPosition(sashHPos); } LexerConfPtr diffLexer = EditorConfigST::Get()->GetLexer("Diff"); if ( diffLexer ) { m_stcDiff->SetLexer(wxSTC_LEX_DIFF); diffLexer->Apply( m_stcDiff ); } LexerConfPtr textLexer = EditorConfigST::Get()->GetLexer("text"); if ( textLexer ) { textLexer->Apply( m_stcMessage ); } }
GitCommitDlg::GitCommitDlg(wxWindow* parent, const wxString& repoDir) : GitCommitDlgBase(parent) , m_workingDir(repoDir) { // read the configuration clConfig conf("git.conf"); GitEntry data; conf.ReadItem( &data ); m_splitterInner->SetSashPosition(data.GetGitCommitDlgHSashPos()); m_splitterMain->SetSashPosition(data.GetGitCommitDlgVSashPos()); WindowAttrManager::Load(this, wxT("GitCommitDlg"), NULL); LexerConfPtr lex = EditorConfigST::Get()->GetLexer("text"); lex->Apply(m_stcCommitMessage); }
ContextGeneric::ContextGeneric(LEditor *container, const wxString &name) : ContextBase(container) { //----------------------------------------------- // Load laguage settings from configuration file //----------------------------------------------- SetName(name); // Set the key words and the lexer wxString keyWords; std::list<StyleProperty> styles; LexerConfPtr lexPtr; // Read the configuration file if(EditorConfigST::Get()->IsOk()){ lexPtr = EditorConfigST::Get()->GetLexer(name); } // Update the control LEditor &rCtrl = GetCtrl(); rCtrl.SetLexer(lexPtr->GetLexerId()); rCtrl.SetKeyWords(0, lexPtr->GetKeyWords()); rCtrl.StyleClearAll(); styles = lexPtr->GetProperties(); std::list<StyleProperty>::iterator iter = styles.begin(); for(; iter != styles.end(); iter++) { StyleProperty st = (*iter); int size = st.GetFontSize(); wxString face = st.GetFaceName(); bool bold = st.IsBold(); wxFont font(size, wxFONTFAMILY_TELETYPE, wxNORMAL, bold ? wxBOLD : wxNORMAL, false, face); if(st.GetId() == 0){ //default rCtrl.StyleSetFont(wxSCI_STYLE_DEFAULT, font); rCtrl.StyleSetSize(wxSCI_STYLE_DEFAULT, (*iter).GetFontSize()); rCtrl.StyleSetForeground(wxSCI_STYLE_DEFAULT, (*iter).GetFgColour()); } rCtrl.StyleSetFont(st.GetId(), font); rCtrl.StyleSetSize(st.GetId(), (*iter).GetFontSize()); rCtrl.StyleSetForeground(st.GetId(), (*iter).GetFgColour()); } }
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")); } }
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; }
SvnCommitDialog::SvnCommitDialog(wxWindow* parent, Subversion2* plugin) : SvnCommitDialogBaseClass(parent) , m_plugin(plugin) , m_process(NULL) { m_stcDiff->SetReadOnly(true); m_checkListFiles->Clear(); // Hide the bug tracker ID m_textCtrlBugID->Clear(); m_textCtrlBugID->Hide(); m_staticTextBugID->Hide(); m_textCtrlFrID->Clear(); m_staticText32->Hide(); m_textCtrlFrID->Hide(); m_checkListFiles->Disable(); m_panel1->Disable(); wxArrayString lastMessages, previews; m_plugin->GetCommitMessagesCache().GetMessages(lastMessages, previews); for(size_t i=0; i<previews.GetCount(); i++) { m_choiceMessages->Append(previews.Item(i), new CommitMessageStringData(lastMessages.Item(i))); } WindowAttrManager::Load(this, wxT("SvnCommitDialog"), m_plugin->GetManager()->GetConfigTool()); int sashPos = m_plugin->GetSettings().GetCommitDlgSashPos(); if ( sashPos != wxNOT_FOUND ) { m_splitterH->SetSashPosition(sashPos); } LexerConfPtr textLexer = EditorConfigST::Get()->GetLexer("text"); if ( textLexer ) { textLexer->Apply( m_stcMessage ); } }
void EditorConfig::SetLexer(LexerConfPtr lexer) { m_lexers[lexer->GetName()] = lexer; lexer->Save(); }
void CCBoxTipWindow::DoInitialize(const wxString& tip, size_t numOfTips, bool simpleTip) { m_tip = tip; m_numOfTips = numOfTips; //Invalidate the rectangles m_leftTipRect = wxRect(); m_rightTipRect = wxRect(); if ( !simpleTip && m_numOfTips > 1 ) m_tip.Prepend(wxT("\n\n")); // Make room for the arrows Hide(); wxBitmap bmp(1, 1); wxMemoryDC dc(bmp); wxSize size; LexerConfPtr cppLex = EditorConfigST::Get()->GetLexer("C++"); if ( cppLex ) { // use the lexer default font m_codeFont = cppLex->GetFontForSyle(0); } else { m_codeFont = wxFont(10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); } m_commentFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxString codePart, commentPart; wxString strippedTip = DoStripMarkups(); size_t from = 0; int hr_count = 0; size_t hrPos = strippedTip.find("<hr>"); while ( hrPos != wxString::npos ) { ++hr_count; from = hrPos + 4; hrPos = strippedTip.find("<hr>", from); } int where= strippedTip.Find("<hr>"); if ( where != wxNOT_FOUND ) { codePart = strippedTip.Mid(0, where); commentPart = strippedTip.Mid(where + 5); } else { codePart = strippedTip; } int commentWidth = 0; int codeWidth = 0; // Use bold font for measurements m_codeFont.SetWeight(wxFONTWEIGHT_BOLD); m_commentFont.SetWeight(wxFONTWEIGHT_BOLD); if ( !simpleTip ) { dc.GetMultiLineTextExtent(codePart, &codeWidth, NULL, NULL, &m_codeFont); dc.GetMultiLineTextExtent(commentPart, &commentWidth, NULL, NULL, &m_commentFont); } else { dc.GetMultiLineTextExtent(strippedTip, &codeWidth, NULL, NULL, &m_commentFont); } m_codeFont.SetWeight(wxFONTWEIGHT_NORMAL); m_commentFont.SetWeight(wxFONTWEIGHT_NORMAL); // Set the width commentWidth > codeWidth ? size.x = commentWidth : size.x = codeWidth; dc.GetTextExtent(wxT("Tp"), NULL, &m_lineHeight, NULL, NULL, &m_codeFont); int nLineCount = ::wxStringTokenize(m_tip, wxT("\r\n"), wxTOKEN_RET_EMPTY_ALL).GetCount(); size.y = nLineCount * m_lineHeight; size.y += (hr_count * 10) + 10; // each <hr> uses 10 pixels height size.x += 40; SetSize(size); Connect(wxEVT_PAINT, wxPaintEventHandler(CCBoxTipWindow::OnPaint), NULL, this); Connect(wxEVT_ERASE_BACKGROUND, wxEraseEventHandler(CCBoxTipWindow::OnEraseBG), NULL, this); Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(CCBoxTipWindow::OnMouseLeft), NULL, this); }
void CodeFormatterDlg::InitDialog() { UpdateCheckBox(m_checkBoxFormatBreakBlocks,AS_BREAK_BLOCKS); UpdateCheckBox(m_checkBoxFormatBreakBlocksAll,AS_BREAK_BLOCKS_ALL); UpdateCheckBox(m_checkBoxFormatBreakElseif,AS_BREAK_ELSEIF); UpdateCheckBox(m_checkBoxFormatFillEmptyLines,AS_FILL_EMPTY_LINES); UpdateCheckBox(m_checkBoxFormatOneLineKeepBlocks,AS_ONE_LINE_KEEP_BLOCKS); UpdateCheckBox(m_checkBoxFormatOneLineKeepStmnt,AS_ONE_LINE_KEEP_STATEMENT); UpdateCheckBox(m_checkBoxFormatPadOperators,AS_PAD_OPER); UpdateCheckBox(m_checkBoxFormatPadParenth,AS_PAD_PARENTHESIS); UpdateCheckBox(m_checkBoxFormatPadParentIn,AS_PAD_PARENTHESIS_IN); UpdateCheckBox(m_checkBoxFormatPadParentOut,AS_PAD_PARENTHESIS_OUT); UpdateCheckBox(m_checkBoxFormatUnPadParent,AS_UNPAD_PARENTHESIS); UpdateCheckBox(m_checkBoxIndentBrackets,AS_INDENT_BRACKETS); UpdateCheckBox(m_checkBoxIndentLabels,AS_INDENT_LABELS); UpdateCheckBox(m_checkBoxIndentMaxInst,AS_MAX_INSTATEMENT_INDENT); UpdateCheckBox(m_checkBoxIndentMinCond,AS_MIN_COND_INDENT); UpdateCheckBox(m_checkBoxIndentNamespaces,AS_INDENT_NAMESPACES); UpdateCheckBox(m_checkBoxIndentPreprocessors,AS_INDENT_PREPROCESSORS); UpdateCheckBox(m_checkBoxIndetBlocks,AS_INDENT_BLOCKS); UpdateCheckBox(m_checkBoxIndetCase,AS_INDENT_CASE); UpdateCheckBox(m_checkBoxIndetClass,AS_INDENT_CLASS); UpdateCheckBox(m_checkBoxIndetSwitch,AS_INDENT_SWITCHES); //update the two radio box controls int selection(3); //AS_LINUX if (m_options.GetOptions() & AS_LINUX) { selection = 3; } else if (m_options.GetOptions() & AS_GNU) { selection =0; } else if (m_options.GetOptions() & AS_ANSI) { selection = 4; } else if (m_options.GetOptions() & AS_JAVA) { selection = 1; } else if (m_options.GetOptions() & AS_KR) { selection = 2; } m_radioBoxPredefinedStyle->SetSelection(selection); selection = 4; // None if (m_options.GetOptions() & AS_BRACKETS_BREAK_CLOSING) { selection = 0; } else if (m_options.GetOptions() & AS_BRACKETS_ATTACH) { selection = 1; } else if (m_options.GetOptions() & AS_BRACKETS_LINUX) { selection = 2; } else if (m_options.GetOptions() & AS_BRACKETS_BREAK) { selection = 3; } m_textCtrlPreview->SetLexer(wxSTC_LEX_CPP); LexerConfPtr lexer = EditorConfigST::Get()->GetLexer("C++"); if ( lexer ) { lexer->Apply( m_textCtrlPreview, true ); } m_radioBoxBrackets->SetSelection(selection); m_textCtrlUserFlags->SetValue(m_options.GetCustomFlags()); m_splitterSettingsPreview->Connect( wxEVT_IDLE, wxIdleEventHandler( CodeFormatterDlg::OnSplitterIdle), NULL, this ); }