diff --git a/src/TyroApp.cpp b/src/TyroApp.cpp index f916181..dd4e538 100644 --- a/src/TyroApp.cpp +++ b/src/TyroApp.cpp @@ -9,11 +9,12 @@ // Some global stuff -wxConfigBase *Glob_config; -TyroMenu *Glob_menu_bar; -MainFrame *Glob_main_frame; +wxConfigBase *Glob_config = nullptr; +TyroMenu *Glob_menu_bar = nullptr; +wxStatusBar *Glob_status_bar = nullptr; +MainFrame *Glob_main_frame = nullptr; +PrefPane *Glob_pref_pane = nullptr; StringConstMap Glob_lexer_map; -PrefPane *Glob_pref_pane; // Static app loading variables static wxArrayString files; @@ -69,7 +70,7 @@ public: { // Deallocate config object delete wxConfigBase::Set((wxConfigBase *) NULL); - + return close(true); } diff --git a/src/definitions.h b/src/definitions.h index 67ca8c2..ebcd141 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -8,7 +8,7 @@ // Application config const wxString APP_NAME = "Tyro"; const wxString APP_VENDOR = "Aviat Ion"; -const wxString APP_VERSION = "0.5.0"; +const wxString APP_VERSION = "0.9.0"; const wxString APP_VERSION_MORE = "Pre-release"; // Command-line arguments @@ -48,6 +48,13 @@ enum myMargins MARGIN_LINE_NUMBERS }; +// Status bar sections +enum myStatusBarSections { + STATUS_MESSAGES, + STATUS_CURSOR_LOCATION, + STATUS_CURRENT_LANGUAGE +}; + // Top level menus enum myMenuIds { myFILE_MENU, diff --git a/src/settings/LangConfig.cpp b/src/settings/LangConfig.cpp index 96198f7..f193dd9 100644 --- a/src/settings/LangConfig.cpp +++ b/src/settings/LangConfig.cpp @@ -1,12 +1,9 @@ -/** - * Lexer configuration object - * - * @extends TyroConfig - */ - #include "LangConfig.h" #include +/** + * Constructor + */ LangConfig::LangConfig() { this->LoadJson(languages_json); @@ -26,6 +23,9 @@ LangConfig::LangConfig() } } +/** + * Destructor + */ LangConfig::~LangConfig() { wxLogDebug("Called LangConfig Destructor"); @@ -107,6 +107,12 @@ JsonValue LangConfig::GetLexerMap(string lang) .get("lexer_map", JsonValue()); } +/** + * Set the selected language key + * + * @param string lang + * @return void + */ void LangConfig::SetLang(string lang) { this->lang = lang; @@ -163,4 +169,4 @@ StringMap LangConfig::GetLangList() } return outputList; -} \ No newline at end of file +} diff --git a/src/settings/ThemeConfig.cpp b/src/settings/ThemeConfig.cpp index a7081f2..7f4dfc1 100644 --- a/src/settings/ThemeConfig.cpp +++ b/src/settings/ThemeConfig.cpp @@ -5,23 +5,40 @@ #include "ThemeConfig.h" #include +/** + * Constructor + */ ThemeConfig::ThemeConfig() { this->LoadJson(themes_json); this->SetTheme("Solarized"); } +/** + * Destructor + */ ThemeConfig::~ThemeConfig() { wxLogDebug("Called ThemeConfig Destructor"); } +/** + * Set the current theme + * + * @param string theme_name + * @return void + */ void ThemeConfig::SetTheme(string theme_name) { JsonValue theme_list = this->GetRoot(); this->current_theme = theme_list.get(theme_name, JsonValue()); } +/** + * Get the name of the currently selected theme + * + * @return string + */ JsonValue ThemeConfig::GetTheme() { return this->current_theme; diff --git a/src/widgets/EditPane.h b/src/widgets/EditPane.h index f70d388..5552905 100644 --- a/src/widgets/EditPane.h +++ b/src/widgets/EditPane.h @@ -25,8 +25,8 @@ public: void SetCurrentLang(string name); private: StringConstMap::iterator lexerMapIt; - LangConfig *lang_config; - ThemeConfig *theme_config; + LangConfig *lang_config = nullptr; + ThemeConfig *theme_config = nullptr; bool FileReadable(); bool FileWritable(); void BindEvents(); diff --git a/src/widgets/MainFrame.cpp b/src/widgets/MainFrame.cpp index 4748451..f05cfb7 100644 --- a/src/widgets/MainFrame.cpp +++ b/src/widgets/MainFrame.cpp @@ -6,7 +6,8 @@ // Nasty globals extern TyroMenu *Glob_menu_bar; extern PrefPane *Glob_pref_pane; -static TabContainer *notebook; +extern wxStatusBar *Glob_status_bar; +static TabContainer *notebook = nullptr; // Frame icon #include "../../resources/xpm/tyro.xpm" @@ -27,9 +28,12 @@ MainFrame::MainFrame(wxFrame *frame, const wxString &title) // Apply the menu bar to the current frame this->SetMenuBar(Glob_menu_bar); - this->SetupStatusBar(); + // Setup StatusBar + Glob_status_bar = new wxStatusBar(this, wxID_ANY); + Glob_status_bar->SetFieldsCount(3); this->DoLayout(); + this->BindEvents(); } @@ -47,6 +51,8 @@ MainFrame::~MainFrame() wxDELETE(this->replaceDlg); wxDELETE(this->findReplaceData); + Glob_status_bar->Destroy(); + manager->UnInit(); } @@ -74,6 +80,14 @@ void MainFrame::DoLayout() notebookPaneInfo.CenterPane(); this->manager->AddPane(notebook, notebookPaneInfo); + wxAuiPaneInfo statusPaneInfo; + statusPaneInfo.Bottom() + .ToolbarPane() + .Gripper(false) + .DockFixed(true) + .Resizable(true); + this->manager->AddPane(Glob_status_bar, statusPaneInfo); + // Update everything this->EnableEditControls(false); } diff --git a/src/widgets/MainFrame.h b/src/widgets/MainFrame.h index 05a015d..d475ec5 100644 --- a/src/widgets/MainFrame.h +++ b/src/widgets/MainFrame.h @@ -16,8 +16,8 @@ class MainFrame: public wxFrame void OpenFiles(wxArrayString filelist); void OnPrefsChanged(wxCommandEvent &event); private: - wxAuiManager *manager; - wxAuiToolBar *toolBar; + wxAuiManager *manager = nullptr; + wxAuiToolBar *toolBar = nullptr; wxFindReplaceData *findReplaceData = nullptr; wxFindReplaceData *findData = nullptr; wxFindReplaceDialog *findDlg = nullptr; diff --git a/src/widgets/PrefPane.h b/src/widgets/PrefPane.h index e0e7950..9efd6bd 100644 --- a/src/widgets/PrefPane.h +++ b/src/widgets/PrefPane.h @@ -12,7 +12,7 @@ public: void Show(wxWindow *parent); protected: - wxPreferencesEditor *pref_window; + wxPreferencesEditor *pref_window = nullptr; }; #endif /* TYRO_PREF_PANE_H */ diff --git a/src/widgets/TabContainer.cpp b/src/widgets/TabContainer.cpp index dda76fd..655e9dd 100644 --- a/src/widgets/TabContainer.cpp +++ b/src/widgets/TabContainer.cpp @@ -5,6 +5,7 @@ #include "widget.h" extern TyroMenu *Glob_menu_bar; +extern wxStatusBar *Glob_status_bar; static unsigned long untitled_document_count = 0; /** @@ -163,6 +164,8 @@ void TabContainer::OnClosed(wxAuiNotebookEvent &WXUNUSED(event)) if (this->GetPageCount() == 0) { this->parent->EnableEditControls(false); + Glob_status_bar->SetStatusText("", STATUS_CURSOR_LOCATION); + Glob_status_bar->SetStatusText("", STATUS_CURRENT_LANGUAGE); } } @@ -209,4 +212,7 @@ void TabContainer::OnTabSwitch(wxAuiNotebookEvent &event) // Update language menu selection Glob_menu_bar->SetCurrentLanguage(editor->GetCurrentLang()); + + // Update status bar + Glob_status_bar->SetStatusText(editor->GetCurrentLang(), STATUS_CURRENT_LANGUAGE); } \ No newline at end of file diff --git a/src/widgets/TabContainer.h b/src/widgets/TabContainer.h index de4348f..8fb0b7d 100644 --- a/src/widgets/TabContainer.h +++ b/src/widgets/TabContainer.h @@ -29,7 +29,7 @@ public: EditPane *GetEditor(size_t page_idx); void OnCloseAll(wxCommandEvent &event); private: - MainFrame *parent; + MainFrame *parent = nullptr; void OnTabSwitch(wxAuiNotebookEvent &event); void OnClose(wxAuiNotebookEvent &event); void OnClosed(wxAuiNotebookEvent &event); diff --git a/src/widgets/TyroMenu.cpp b/src/widgets/TyroMenu.cpp index 30c323d..322c68a 100644 --- a/src/widgets/TyroMenu.cpp +++ b/src/widgets/TyroMenu.cpp @@ -1,7 +1,7 @@ #include "widget.h" #include "../settings/LangConfig.h" -static LangConfig *lang_config; +static LangConfig *lang_config = nullptr; /** * Constructor diff --git a/src/widgets/TyroMenu.h b/src/widgets/TyroMenu.h index d069a73..3074635 100644 --- a/src/widgets/TyroMenu.h +++ b/src/widgets/TyroMenu.h @@ -14,11 +14,11 @@ public: void SetIdChecked(int id, bool checked); void SetCurrentLanguage(string lang); private: - wxMenu *fileMenu; - wxMenu *editMenu; - wxMenu *viewMenu; - wxMenu *langMenu; - wxMenu *helpMenu; + wxMenu *fileMenu = nullptr; + wxMenu *editMenu = nullptr; + wxMenu *viewMenu = nullptr; + wxMenu *langMenu = nullptr; + wxMenu *helpMenu = nullptr; void SetupMainMenus(); void SetupLangMenu(); void EnableEntireMenu(size_t menuId, wxMenu *menu, bool enable);