diff --git a/src/TyroApp.cpp b/src/TyroApp.cpp index c0b7a4b..cd213ee 100644 --- a/src/TyroApp.cpp +++ b/src/TyroApp.cpp @@ -46,7 +46,7 @@ public: this->SetVendorName(APP_VENDOR); // Initialize globals - this->InitLexerMap(); + TyroApp::InitLexerMap(); Glob_config = wxConfigBase::Get(); Glob_menu_bar = new TyroMenu(); Glob_main_frame = new MainFrame(nullptr, APP_NAME, CalculateWindowSize()); @@ -122,7 +122,7 @@ private: /** * Set up mapping for lexers */ - void InitLexerMap() + void static InitLexerMap() { Glob_lexer_map[""] = wxSTC_LEX_NULL; Glob_lexer_map["batch"] = wxSTC_LEX_BATCH; @@ -167,4 +167,4 @@ private: }; // Set up the main method and event loop -IMPLEMENT_APP(TyroApp); +wxIMPLEMENT_APP(TyroApp); diff --git a/src/settings/LangConfig.cpp b/src/settings/LangConfig.cpp index 04fe749..3c5546f 100644 --- a/src/settings/LangConfig.cpp +++ b/src/settings/LangConfig.cpp @@ -7,7 +7,7 @@ LangConfig::LangConfig() { this->LoadJson(languages_json); - this->lang = ""; + this->language = ""; // "cache" reverse map of languages to their keys JsonValue langList = this->GetRoot(); @@ -62,7 +62,7 @@ string LangConfig::GetLangByFile(wxFileName &fileName) ) { this->SetLang(lang); - return this->lang; + return this->language; } // Go to the next pattern for this language @@ -71,7 +71,7 @@ string LangConfig::GetLangByFile(wxFileName &fileName) } this->SetLang(""); - return this->lang; + return this->language; } /** @@ -82,7 +82,7 @@ string LangConfig::GetLangByFile(wxFileName &fileName) */ JsonValue LangConfig::GetKeywordList(string lang) { - if (lang == "none") lang = this->lang; + if (lang == "none") lang = this->language; return this->GetRoot() .get(lang, JsonValue()) @@ -97,7 +97,7 @@ JsonValue LangConfig::GetKeywordList(string lang) */ JsonValue LangConfig::GetLexerMap(string lang) { - if (lang == "none") lang = this->lang; + if (lang == "none") lang = this->language; return this->GetRoot() .get(lang, JsonValue()) @@ -112,7 +112,7 @@ JsonValue LangConfig::GetLexerMap(string lang) */ void LangConfig::SetLang(string lang) { - this->lang = lang; + this->language = lang; } /** @@ -120,7 +120,7 @@ void LangConfig::SetLang(string lang) */ string LangConfig::GetLang() { - return this->lang; + return this->language; } /** @@ -131,7 +131,7 @@ string LangConfig::GetLang() string LangConfig::GetCurrentLangName() { return this->GetRoot() - .get(this->lang, JsonValue()) + .get(this->language, JsonValue()) .get("name", JsonValue()) .asString(); } diff --git a/src/settings/LangConfig.h b/src/settings/LangConfig.h index a73ca4f..82665f6 100644 --- a/src/settings/LangConfig.h +++ b/src/settings/LangConfig.h @@ -16,6 +16,6 @@ public: string GetCurrentLangName(); string GetLangByName(string name); private: - string lang; + string language; StringMap reverseMap; }; diff --git a/src/widgets/EditPane.cpp b/src/widgets/EditPane.cpp index 119053e..c1b1aaf 100644 --- a/src/widgets/EditPane.cpp +++ b/src/widgets/EditPane.cpp @@ -84,7 +84,7 @@ void EditPane::Highlight(wxString filePath) * @param string theme * @return void */ -void EditPane::ApplyTheme(string lang, string theme) +void EditPane::ApplyTheme(const string &lang, const string &theme) { this->StyleClearAll(); @@ -138,7 +138,7 @@ void EditPane::ApplyTheme(string lang, string theme) * @param string [theme] * @return void */ -void EditPane::ReApplyTheme(string theme) +void EditPane::ReApplyTheme(const string &theme) { this->ApplyTheme(lang_config->GetLangByName(this->GetCurrentLang()), theme); } @@ -302,16 +302,16 @@ void EditPane::OnCharAdded(wxStyledTextEvent& event) * Iterate through the theme settings and apply them * * @param JsonValue lexer_map - Maps token types to theme colors - * @param int addtoi - Offset for some languages * @return void */ void EditPane::_ApplyTheme(JsonValue &lexer_map) { // Font setup - wxFont *defaultFont = wxFont::New( + wxFont defaultFont( TYRO_DEFAULT_FONT_SIZE, - wxFONTFAMILY_MODERN, - wxFONTFLAG_ANTIALIASED + wxFONTFAMILY_TELETYPE, + wxFONTFLAG_DEFAULT, + wxFONTWEIGHT_NORMAL ); static const wxColor default_background = this->theme_config->GetThemeColor("background", "default"); @@ -334,7 +334,7 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map) wxString fontFace; if ( ! Glob_config->Read("global_font", &globalFont)) { - this->StyleSetFont(i, *defaultFont); + this->StyleSetFont(i, defaultFont); } else { @@ -358,11 +358,11 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map) this->MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUSCONNECTED, "WHITE", "BLACK"); this->MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUSCONNECTED, "WHITE", "BLACK"); - this->MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "BLACK", "BLACK"); + this->MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, "BLACK", "BLACK"); this->MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_CIRCLEPLUSCONNECTED, "WHITE", "BLACK"); this->MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_CIRCLEMINUSCONNECTED, "WHITE", "BLACK"); - this->MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "BLACK", "BLACK"); - this->MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "BLACK", "BLACK"); + this->MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, "BLACK", "BLACK"); + this->MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, "BLACK", "BLACK"); } else { @@ -452,7 +452,7 @@ string EditPane::GetCurrentLang() * @param string name * @return void */ -void EditPane::SetCurrentLang(string name) +void EditPane::SetCurrentLang(const string &name) { // Update the current lang in the config string langKey = this->lang_config->GetLangByName(name); diff --git a/src/widgets/EditPane.h b/src/widgets/EditPane.h index 7cd64af..e9e751a 100644 --- a/src/widgets/EditPane.h +++ b/src/widgets/EditPane.h @@ -7,7 +7,7 @@ class EditPane: public wxStyledTextCtrl { public: - EditPane( + explicit EditPane( wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &post = wxDefaultPosition, @@ -19,10 +19,10 @@ public: void Highlight(wxString filePath); bool SaveFile(); bool SaveFile(const wxString &filename); - void ReApplyTheme(string theme=""); - void ApplyTheme(string lang, string theme=""); + void ReApplyTheme(const string &theme=""); + void ApplyTheme(const string &lang, const string &theme=""); string GetCurrentLang(); - void SetCurrentLang(string name); + void SetCurrentLang(const string &name); protected: StringConstMap::iterator lexerMapIt; LangConfig *lang_config = nullptr; @@ -31,6 +31,6 @@ protected: bool FileWritable(); void BindEvents(); void OnCharAdded(wxStyledTextEvent &event); - void SetTheme(string theme_name); + // void SetTheme(const string &theme_name); void _ApplyTheme(JsonValue &lexer_map); };