Various code cleanup
This commit is contained in:
parent
c13750b06e
commit
f2dc0a9eae
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -16,6 +16,6 @@ public:
|
||||
string GetCurrentLangName();
|
||||
string GetLangByName(string name);
|
||||
private:
|
||||
string lang;
|
||||
string language;
|
||||
StringMap reverseMap;
|
||||
};
|
||||
|
@ -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
|
||||
{
|
||||
@ -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);
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user