A little pointer and docblock cleanup, show current language in status bar
This commit is contained in:
parent
b39e63060b
commit
1fa24545d2
@ -9,11 +9,12 @@
|
|||||||
|
|
||||||
|
|
||||||
// Some global stuff
|
// Some global stuff
|
||||||
wxConfigBase *Glob_config;
|
wxConfigBase *Glob_config = nullptr;
|
||||||
TyroMenu *Glob_menu_bar;
|
TyroMenu *Glob_menu_bar = nullptr;
|
||||||
MainFrame *Glob_main_frame;
|
wxStatusBar *Glob_status_bar = nullptr;
|
||||||
|
MainFrame *Glob_main_frame = nullptr;
|
||||||
|
PrefPane *Glob_pref_pane = nullptr;
|
||||||
StringConstMap Glob_lexer_map;
|
StringConstMap Glob_lexer_map;
|
||||||
PrefPane *Glob_pref_pane;
|
|
||||||
|
|
||||||
// Static app loading variables
|
// Static app loading variables
|
||||||
static wxArrayString files;
|
static wxArrayString files;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
// Application config
|
// Application config
|
||||||
const wxString APP_NAME = "Tyro";
|
const wxString APP_NAME = "Tyro";
|
||||||
const wxString APP_VENDOR = "Aviat Ion";
|
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";
|
const wxString APP_VERSION_MORE = "Pre-release";
|
||||||
|
|
||||||
// Command-line arguments
|
// Command-line arguments
|
||||||
@ -48,6 +48,13 @@ enum myMargins
|
|||||||
MARGIN_LINE_NUMBERS
|
MARGIN_LINE_NUMBERS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Status bar sections
|
||||||
|
enum myStatusBarSections {
|
||||||
|
STATUS_MESSAGES,
|
||||||
|
STATUS_CURSOR_LOCATION,
|
||||||
|
STATUS_CURRENT_LANGUAGE
|
||||||
|
};
|
||||||
|
|
||||||
// Top level menus
|
// Top level menus
|
||||||
enum myMenuIds {
|
enum myMenuIds {
|
||||||
myFILE_MENU,
|
myFILE_MENU,
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
/**
|
|
||||||
* Lexer configuration object
|
|
||||||
*
|
|
||||||
* @extends TyroConfig
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "LangConfig.h"
|
#include "LangConfig.h"
|
||||||
#include <config/languages_json.h>
|
#include <config/languages_json.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
LangConfig::LangConfig()
|
LangConfig::LangConfig()
|
||||||
{
|
{
|
||||||
this->LoadJson(languages_json);
|
this->LoadJson(languages_json);
|
||||||
@ -26,6 +23,9 @@ LangConfig::LangConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
LangConfig::~LangConfig()
|
LangConfig::~LangConfig()
|
||||||
{
|
{
|
||||||
wxLogDebug("Called LangConfig Destructor");
|
wxLogDebug("Called LangConfig Destructor");
|
||||||
@ -107,6 +107,12 @@ JsonValue LangConfig::GetLexerMap(string lang)
|
|||||||
.get("lexer_map", JsonValue());
|
.get("lexer_map", JsonValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the selected language key
|
||||||
|
*
|
||||||
|
* @param string lang
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void LangConfig::SetLang(string lang)
|
void LangConfig::SetLang(string lang)
|
||||||
{
|
{
|
||||||
this->lang = lang;
|
this->lang = lang;
|
||||||
|
@ -5,23 +5,40 @@
|
|||||||
#include "ThemeConfig.h"
|
#include "ThemeConfig.h"
|
||||||
#include <config/themes_json.h>
|
#include <config/themes_json.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
ThemeConfig::ThemeConfig()
|
ThemeConfig::ThemeConfig()
|
||||||
{
|
{
|
||||||
this->LoadJson(themes_json);
|
this->LoadJson(themes_json);
|
||||||
this->SetTheme("Solarized");
|
this->SetTheme("Solarized");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor
|
||||||
|
*/
|
||||||
ThemeConfig::~ThemeConfig()
|
ThemeConfig::~ThemeConfig()
|
||||||
{
|
{
|
||||||
wxLogDebug("Called ThemeConfig Destructor");
|
wxLogDebug("Called ThemeConfig Destructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the current theme
|
||||||
|
*
|
||||||
|
* @param string theme_name
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
void ThemeConfig::SetTheme(string theme_name)
|
void ThemeConfig::SetTheme(string theme_name)
|
||||||
{
|
{
|
||||||
JsonValue theme_list = this->GetRoot();
|
JsonValue theme_list = this->GetRoot();
|
||||||
this->current_theme = theme_list.get(theme_name, JsonValue());
|
this->current_theme = theme_list.get(theme_name, JsonValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of the currently selected theme
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
JsonValue ThemeConfig::GetTheme()
|
JsonValue ThemeConfig::GetTheme()
|
||||||
{
|
{
|
||||||
return this->current_theme;
|
return this->current_theme;
|
||||||
|
@ -25,8 +25,8 @@ public:
|
|||||||
void SetCurrentLang(string name);
|
void SetCurrentLang(string name);
|
||||||
private:
|
private:
|
||||||
StringConstMap::iterator lexerMapIt;
|
StringConstMap::iterator lexerMapIt;
|
||||||
LangConfig *lang_config;
|
LangConfig *lang_config = nullptr;
|
||||||
ThemeConfig *theme_config;
|
ThemeConfig *theme_config = nullptr;
|
||||||
bool FileReadable();
|
bool FileReadable();
|
||||||
bool FileWritable();
|
bool FileWritable();
|
||||||
void BindEvents();
|
void BindEvents();
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
// Nasty globals
|
// Nasty globals
|
||||||
extern TyroMenu *Glob_menu_bar;
|
extern TyroMenu *Glob_menu_bar;
|
||||||
extern PrefPane *Glob_pref_pane;
|
extern PrefPane *Glob_pref_pane;
|
||||||
static TabContainer *notebook;
|
extern wxStatusBar *Glob_status_bar;
|
||||||
|
static TabContainer *notebook = nullptr;
|
||||||
|
|
||||||
// Frame icon
|
// Frame icon
|
||||||
#include "../../resources/xpm/tyro.xpm"
|
#include "../../resources/xpm/tyro.xpm"
|
||||||
@ -27,9 +28,12 @@ MainFrame::MainFrame(wxFrame *frame, const wxString &title)
|
|||||||
// Apply the menu bar to the current frame
|
// Apply the menu bar to the current frame
|
||||||
this->SetMenuBar(Glob_menu_bar);
|
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->DoLayout();
|
||||||
|
|
||||||
this->BindEvents();
|
this->BindEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +51,8 @@ MainFrame::~MainFrame()
|
|||||||
wxDELETE(this->replaceDlg);
|
wxDELETE(this->replaceDlg);
|
||||||
wxDELETE(this->findReplaceData);
|
wxDELETE(this->findReplaceData);
|
||||||
|
|
||||||
|
Glob_status_bar->Destroy();
|
||||||
|
|
||||||
manager->UnInit();
|
manager->UnInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +80,14 @@ void MainFrame::DoLayout()
|
|||||||
notebookPaneInfo.CenterPane();
|
notebookPaneInfo.CenterPane();
|
||||||
this->manager->AddPane(notebook, notebookPaneInfo);
|
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
|
// Update everything
|
||||||
this->EnableEditControls(false);
|
this->EnableEditControls(false);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ class MainFrame: public wxFrame
|
|||||||
void OpenFiles(wxArrayString filelist);
|
void OpenFiles(wxArrayString filelist);
|
||||||
void OnPrefsChanged(wxCommandEvent &event);
|
void OnPrefsChanged(wxCommandEvent &event);
|
||||||
private:
|
private:
|
||||||
wxAuiManager *manager;
|
wxAuiManager *manager = nullptr;
|
||||||
wxAuiToolBar *toolBar;
|
wxAuiToolBar *toolBar = nullptr;
|
||||||
wxFindReplaceData *findReplaceData = nullptr;
|
wxFindReplaceData *findReplaceData = nullptr;
|
||||||
wxFindReplaceData *findData = nullptr;
|
wxFindReplaceData *findData = nullptr;
|
||||||
wxFindReplaceDialog *findDlg = nullptr;
|
wxFindReplaceDialog *findDlg = nullptr;
|
||||||
|
@ -12,7 +12,7 @@ public:
|
|||||||
void Show(wxWindow *parent);
|
void Show(wxWindow *parent);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxPreferencesEditor *pref_window;
|
wxPreferencesEditor *pref_window = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TYRO_PREF_PANE_H */
|
#endif /* TYRO_PREF_PANE_H */
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
|
|
||||||
extern TyroMenu *Glob_menu_bar;
|
extern TyroMenu *Glob_menu_bar;
|
||||||
|
extern wxStatusBar *Glob_status_bar;
|
||||||
static unsigned long untitled_document_count = 0;
|
static unsigned long untitled_document_count = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,6 +164,8 @@ void TabContainer::OnClosed(wxAuiNotebookEvent &WXUNUSED(event))
|
|||||||
if (this->GetPageCount() == 0)
|
if (this->GetPageCount() == 0)
|
||||||
{
|
{
|
||||||
this->parent->EnableEditControls(false);
|
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
|
// Update language menu selection
|
||||||
Glob_menu_bar->SetCurrentLanguage(editor->GetCurrentLang());
|
Glob_menu_bar->SetCurrentLanguage(editor->GetCurrentLang());
|
||||||
|
|
||||||
|
// Update status bar
|
||||||
|
Glob_status_bar->SetStatusText(editor->GetCurrentLang(), STATUS_CURRENT_LANGUAGE);
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ public:
|
|||||||
EditPane *GetEditor(size_t page_idx);
|
EditPane *GetEditor(size_t page_idx);
|
||||||
void OnCloseAll(wxCommandEvent &event);
|
void OnCloseAll(wxCommandEvent &event);
|
||||||
private:
|
private:
|
||||||
MainFrame *parent;
|
MainFrame *parent = nullptr;
|
||||||
void OnTabSwitch(wxAuiNotebookEvent &event);
|
void OnTabSwitch(wxAuiNotebookEvent &event);
|
||||||
void OnClose(wxAuiNotebookEvent &event);
|
void OnClose(wxAuiNotebookEvent &event);
|
||||||
void OnClosed(wxAuiNotebookEvent &event);
|
void OnClosed(wxAuiNotebookEvent &event);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "../settings/LangConfig.h"
|
#include "../settings/LangConfig.h"
|
||||||
|
|
||||||
static LangConfig *lang_config;
|
static LangConfig *lang_config = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -14,11 +14,11 @@ public:
|
|||||||
void SetIdChecked(int id, bool checked);
|
void SetIdChecked(int id, bool checked);
|
||||||
void SetCurrentLanguage(string lang);
|
void SetCurrentLanguage(string lang);
|
||||||
private:
|
private:
|
||||||
wxMenu *fileMenu;
|
wxMenu *fileMenu = nullptr;
|
||||||
wxMenu *editMenu;
|
wxMenu *editMenu = nullptr;
|
||||||
wxMenu *viewMenu;
|
wxMenu *viewMenu = nullptr;
|
||||||
wxMenu *langMenu;
|
wxMenu *langMenu = nullptr;
|
||||||
wxMenu *helpMenu;
|
wxMenu *helpMenu = nullptr;
|
||||||
void SetupMainMenus();
|
void SetupMainMenus();
|
||||||
void SetupLangMenu();
|
void SetupLangMenu();
|
||||||
void EnableEntireMenu(size_t menuId, wxMenu *menu, bool enable);
|
void EnableEntireMenu(size_t menuId, wxMenu *menu, bool enable);
|
||||||
|
Loading…
Reference in New Issue
Block a user