Misc code cleanup
This commit is contained in:
parent
7635609d13
commit
f63cc9df32
@ -17,7 +17,7 @@ Required packages:
|
||||
* build-essential
|
||||
* cmake
|
||||
* libssh2-1-dev
|
||||
* libwxgtk3.0-dev
|
||||
* libwxgtk3.0-dev or libwxgtk3.0-gtk3-dev
|
||||
|
||||
After these packages are installed, the project should build with a simple `make` command.
|
||||
|
||||
@ -35,7 +35,7 @@ Build the app:
|
||||
|
||||
### Windows
|
||||
|
||||
See the guide for building on Windows: [Windows-Build](./Windows-Build.md)
|
||||
* Todo
|
||||
|
||||
## Make commands
|
||||
Please note that make commands are chainable. For a typical programming loop, `make clean dev run` is very useful.
|
||||
|
@ -68,7 +68,10 @@ public:
|
||||
*/
|
||||
int OnExit() override
|
||||
{
|
||||
wxLogDebug("Closing App...");
|
||||
|
||||
// Deallocate config object
|
||||
wxLogDebug("Deleting wxConfigBase");
|
||||
delete wxConfigBase::Set((wxConfigBase *) nullptr);
|
||||
|
||||
return close(true);
|
||||
@ -117,7 +120,7 @@ private:
|
||||
/**
|
||||
* Set up mapping for lexers
|
||||
*/
|
||||
void static InitLexerMap()
|
||||
void const static InitLexerMap()
|
||||
{
|
||||
Glob_lexer_map[""] = wxSTC_LEX_NULL;
|
||||
Glob_lexer_map["batch"] = wxSTC_LEX_BATCH;
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
TyroConfig::TyroConfig() {}
|
||||
TyroConfig::~TyroConfig() {}
|
||||
TyroConfig::TyroConfig() = default;
|
||||
TyroConfig::~TyroConfig() = default;
|
||||
|
||||
void TyroConfig::LoadJson(const char json[])
|
||||
{
|
||||
|
@ -26,7 +26,10 @@ LangConfig::LangConfig()
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
LangConfig::~LangConfig() {}
|
||||
LangConfig::~LangConfig()
|
||||
{
|
||||
wxLogDebug("LangConfig Destructor Called.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the format of the current file by
|
||||
@ -110,7 +113,7 @@ JsonValue LangConfig::GetLexerMap(string lang)
|
||||
* @param string lang
|
||||
* @return void
|
||||
*/
|
||||
void LangConfig::SetLang(string lang)
|
||||
void LangConfig::SetLang(const string &lang)
|
||||
{
|
||||
this->language = lang;
|
||||
}
|
||||
@ -142,7 +145,7 @@ string LangConfig::GetCurrentLangName()
|
||||
* @param string name
|
||||
* @return string
|
||||
*/
|
||||
string LangConfig::GetLangByName(string name)
|
||||
string LangConfig::GetLangByName(const string &name)
|
||||
{
|
||||
int count = this->reverseMap.count(name);
|
||||
return (count > 0) ? this->reverseMap[name] : "";
|
||||
|
@ -7,14 +7,14 @@ class LangConfig : TyroConfig {
|
||||
public:
|
||||
LangConfig();
|
||||
~LangConfig();
|
||||
void SetLang(string lang);
|
||||
void SetLang(const string &lang);
|
||||
string GetLang();
|
||||
string GetLangByFile(wxFileName &fileName);
|
||||
JsonValue GetKeywordList(string lang="none");
|
||||
JsonValue GetLexerMap(string lang="none");
|
||||
StringMap GetLangList();
|
||||
string GetCurrentLangName();
|
||||
string GetLangByName(string name);
|
||||
string GetLangByName(const string &name);
|
||||
private:
|
||||
string language;
|
||||
StringMap reverseMap;
|
||||
|
@ -17,7 +17,10 @@ ThemeConfig::ThemeConfig()
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
ThemeConfig::~ThemeConfig() {}
|
||||
ThemeConfig::~ThemeConfig()
|
||||
{
|
||||
wxLogDebug("ThemeConfig Destructor Called.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current theme
|
||||
@ -58,7 +61,7 @@ JsonValue ThemeConfig::GetTheme()
|
||||
* @param string key
|
||||
* @return JsonValue
|
||||
*/
|
||||
JsonValue ThemeConfig::GetThemeValue(string type, string key)
|
||||
JsonValue ThemeConfig::GetThemeValue(const string &type, const string &key)
|
||||
{
|
||||
JsonValue value = this->current_theme
|
||||
.get(type, JsonValue())
|
||||
@ -73,7 +76,7 @@ JsonValue ThemeConfig::GetThemeValue(string type, string key)
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
wxColor ThemeConfig::GetThemeColor(string type, string key)
|
||||
wxColor ThemeConfig::GetThemeColor(const string &type, const string &key)
|
||||
{
|
||||
JsonValue color_value = this->GetThemeValue(type, key);
|
||||
|
||||
|
@ -12,8 +12,8 @@ public:
|
||||
~ThemeConfig();
|
||||
bool SetTheme(const string &theme_name);
|
||||
JsonValue GetTheme();
|
||||
JsonValue GetThemeValue(string type, string key);
|
||||
wxColor GetThemeColor(string type, string key);
|
||||
JsonValue GetThemeValue(const string &type, const string &key);
|
||||
wxColor GetThemeColor(const string &type, const string &key);
|
||||
private:
|
||||
JsonValue current_theme;
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ EditPane::EditPane(
|
||||
*/
|
||||
EditPane::~EditPane()
|
||||
{
|
||||
wxLogDebug("Called EditPane Destructor");
|
||||
wxLogDebug("EditPane Destructor Called.");
|
||||
delete this->lang_config;
|
||||
delete this->theme_config;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ FilePane::FilePane(
|
||||
|
||||
FilePane::~FilePane()
|
||||
{
|
||||
wxLogDebug("FilePane Destructor Called.");
|
||||
delete this->img_list;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,8 @@ MainFrame::~MainFrame()
|
||||
|
||||
Glob_status_bar->Destroy();
|
||||
|
||||
manager->UnInit();
|
||||
|
||||
this->manager->UnInit();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -682,7 +683,8 @@ void MainFrame::OnToggleLineEndings(wxCommandEvent &event)
|
||||
void MainFrame::EnableEditControls(bool enable)
|
||||
{
|
||||
// Update menu items
|
||||
Glob_menu_bar->EnableEditControls(enable);
|
||||
auto menu_bar = (TyroMenu *) this->GetMenuBar();
|
||||
menu_bar->EnableEditControls(enable);
|
||||
|
||||
// Toggle toolbar items
|
||||
this->toolBar->EnableTool(wxID_SAVE, enable);
|
||||
|
@ -5,8 +5,14 @@ extern wxConfigBase *Glob_config;
|
||||
|
||||
class GeneralPrefPanePage : public wxPanel {
|
||||
public:
|
||||
GeneralPrefPanePage(wxWindow *parent)
|
||||
: wxPanel(parent)
|
||||
explicit GeneralPrefPanePage(
|
||||
wxWindow *parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
|
||||
const wxString& name = wxPanelNameStr
|
||||
) : wxPanel(parent, winid, pos, size, style, name)
|
||||
{
|
||||
auto BASE_MARGIN = 30;
|
||||
|
||||
@ -70,8 +76,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
~GeneralPrefPanePage()
|
||||
~GeneralPrefPanePage() override
|
||||
{
|
||||
wxLogDebug("GeneralPrefPanePage Destructor Called.");
|
||||
wxDELETE(this->showLineNumbers);
|
||||
wxDELETE(this->showIndentGuides);
|
||||
wxDELETE(this->showCodeFolding);
|
||||
@ -83,7 +90,7 @@ public:
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
virtual bool TransferDataToWindow()
|
||||
bool TransferDataToWindow() override
|
||||
{
|
||||
this->showLineNumbers->SetValue(Glob_config->ReadBool("show_line_numbers", true));
|
||||
this->showIndentGuides->SetValue(Glob_config->ReadBool("show_indent_guides", false));
|
||||
@ -103,7 +110,7 @@ public:
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
virtual bool TransferDataFromWindow()
|
||||
bool TransferDataFromWindow() override
|
||||
{
|
||||
Glob_config->Write("show_line_numbers", this->showLineNumbers->IsChecked());
|
||||
Glob_config->Write("show_indent_guides", this->showIndentGuides->IsChecked());
|
||||
@ -132,7 +139,7 @@ private:
|
||||
class GeneralPrefPane: public wxStockPreferencesPage {
|
||||
public:
|
||||
GeneralPrefPane() : wxStockPreferencesPage(Kind_General) {}
|
||||
virtual wxWindow *CreateWindow(wxWindow *parent)
|
||||
wxWindow *CreateWindow(wxWindow *parent) override
|
||||
{
|
||||
return new GeneralPrefPanePage(parent);
|
||||
}
|
||||
@ -150,7 +157,8 @@ PrefPane::PrefPane()
|
||||
|
||||
PrefPane::~PrefPane()
|
||||
{
|
||||
//delete this->pref_window;
|
||||
wxLogDebug("PrefPane Destructor Called.");
|
||||
delete this->pref_window;
|
||||
}
|
||||
|
||||
void PrefPane::Show(wxWindow *parent)
|
||||
|
@ -36,7 +36,7 @@ TabContainer::TabContainer(
|
||||
*/
|
||||
TabContainer::~TabContainer()
|
||||
{
|
||||
wxLogDebug("TabContainer destructor called");
|
||||
wxLogDebug("TabContainer Destructor Called.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +71,7 @@ void TabContainer::AddTab()
|
||||
* @param wxString filePath
|
||||
* @return void
|
||||
*/
|
||||
void TabContainer::AddTab(wxString filePath)
|
||||
void TabContainer::AddTab(const wxString &filePath)
|
||||
{
|
||||
wxFileName fileName(filePath);
|
||||
|
||||
@ -104,7 +104,7 @@ void TabContainer::AddTab(wxString filePath)
|
||||
*
|
||||
* @return *EditPane
|
||||
*/
|
||||
EditPane *TabContainer::GetCurrentEditor()
|
||||
EditPane* TabContainer::GetCurrentEditor()
|
||||
{
|
||||
return (EditPane *) this->GetCurrentPage();
|
||||
}
|
||||
@ -115,7 +115,7 @@ EditPane *TabContainer::GetCurrentEditor()
|
||||
* @param size_t page_idx
|
||||
* @return *EditPane
|
||||
*/
|
||||
EditPane *TabContainer::GetEditor(size_t page_idx)
|
||||
EditPane* TabContainer::GetEditor(size_t page_idx)
|
||||
{
|
||||
return (EditPane *) this->GetPage(page_idx);
|
||||
}
|
||||
@ -184,7 +184,7 @@ void TabContainer::OnClosed(wxAuiNotebookEvent &WXUNUSED(event))
|
||||
void TabContainer::OnTabContextMenu(wxAuiNotebookEvent &WXUNUSED(event))
|
||||
{
|
||||
// Create Menu
|
||||
wxMenu *contextMenu = new wxMenu();
|
||||
auto *contextMenu = new wxMenu();
|
||||
contextMenu->Append(wxID_CLOSE, "&Close\tCtrl+W", "Close the current tab");
|
||||
contextMenu->Append(myID_CLOSE_ALL, "C&lose All\tShift+Ctrl+W", "Close all open documents.");
|
||||
contextMenu->Append(myID_CLOSE_ALL_BUT_THIS, "Close All but this\tCtrl+Shift+Alt+W", "Close all open documents, except the one selected");
|
||||
|
@ -13,16 +13,16 @@ static long tab_style = wxBORDER_NONE | wxAUI_NB_TAB_SPLIT |wxAUI_NB_TAB_MOVE
|
||||
class TabContainer: public wxAuiNotebook
|
||||
{
|
||||
public:
|
||||
TabContainer(
|
||||
explicit TabContainer(
|
||||
wxWindow *parent,
|
||||
wxWindowID id=wxID_ANY,
|
||||
const wxPoint &pos=wxDefaultPosition,
|
||||
const wxSize &size=wxDefaultSize,
|
||||
long style=tab_style
|
||||
);
|
||||
~TabContainer();
|
||||
~TabContainer() override;
|
||||
void AddTab();
|
||||
void AddTab(wxString filePath);
|
||||
void AddTab(const wxString &filePath);
|
||||
EditPane *GetCurrentEditor();
|
||||
EditPane *GetEditor(size_t page_idx);
|
||||
void OnCloseAll(wxCommandEvent &event);
|
||||
|
@ -166,7 +166,7 @@ void TyroMenu::EnableEntireMenu(size_t menuId, wxMenu *menu, bool enable)
|
||||
*/
|
||||
void TyroMenu::SetCurrentLanguage(string lang)
|
||||
{
|
||||
if (lang == "")
|
||||
if (lang.empty())
|
||||
{
|
||||
lang = "Plain Text";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user