Ugly progress commit

This commit is contained in:
Timothy Warren 2020-07-16 10:09:19 -04:00
parent 37faa83103
commit 68624456f1
8 changed files with 88 additions and 74 deletions

View File

@ -61,7 +61,7 @@ include_directories(${INCLUDE_DIRS})
# set some platform-specific flags # set some platform-specific flags
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#set(MACOSX_DEPLOYMENT_TARGET 10.9) #set(MACOSX_DEPLOYMENT_TARGET 10.4)
#set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -stdlib=libc++") #set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -stdlib=libc++")
add_definitions(-D__WXMAC__) add_definitions(-D__WXMAC__)
else() else()

View File

@ -19,8 +19,6 @@ MainFrame *Glob_main_frame = nullptr;
TyroMenu *Glob_menu_bar = nullptr; TyroMenu *Glob_menu_bar = nullptr;
wxStatusBar *Glob_status_bar = nullptr; wxStatusBar *Glob_status_bar = nullptr;
StringConstMap Glob_lexer_map;
/** /**
* Class with main method * Class with main method
*/ */
@ -39,7 +37,6 @@ public:
this->SetVendorName(APP_VENDOR); this->SetVendorName(APP_VENDOR);
// Initialize globals // Initialize globals
TyroApp::InitLexerMap();
Glob_config = wxConfigBase::Get(); Glob_config = wxConfigBase::Get();
Glob_lang_config = new LangConfig(); Glob_lang_config = new LangConfig();
Glob_theme_config = new ThemeConfig(); Glob_theme_config = new ThemeConfig();
@ -117,43 +114,6 @@ private:
wxArrayString files; wxArrayString files;
size_t param_count = 0; size_t param_count = 0;
/**
* Set up mapping for lexers
*/
void const static InitLexerMap()
{
Glob_lexer_map[""] = wxSTC_LEX_NULL;
Glob_lexer_map["batch"] = wxSTC_LEX_BATCH;
Glob_lexer_map["caml"] = wxSTC_LEX_CAML;
Glob_lexer_map["cmake"] = wxSTC_LEX_CMAKE;
Glob_lexer_map["cpp"] = wxSTC_LEX_CPP;
Glob_lexer_map["css"] = wxSTC_LEX_CSS;
Glob_lexer_map["fortran"] = wxSTC_LEX_FORTRAN;
Glob_lexer_map["haskell"] = wxSTC_LEX_HASKELL;
Glob_lexer_map["java"] = wxSTC_LEX_CPP;
Glob_lexer_map["js"] = wxSTC_LEX_CPP;
Glob_lexer_map["lisp"] = wxSTC_LEX_LISP;
Glob_lexer_map["lua"] = wxSTC_LEX_LUA;
Glob_lexer_map["makefile"] = wxSTC_LEX_MAKEFILE;
Glob_lexer_map["markdown"] = wxSTC_LEX_MARKDOWN;
Glob_lexer_map["php"] = wxSTC_LEX_HTML;
Glob_lexer_map["perl"] = wxSTC_LEX_PERL;
Glob_lexer_map["properties"] = wxSTC_LEX_PROPERTIES;
Glob_lexer_map["python"] = wxSTC_LEX_PYTHON;
Glob_lexer_map["ruby"] = wxSTC_LEX_RUBY;
#ifdef wxSTC_LEX_RUST
Glob_lexer_map["rust"] = wxSTC_LEX_RUST;
#endif
#ifndef wxSTC_LEX_RUST
Glob_lexer_map["rust"] = wxSTC_LEX_CPP;
#endif
Glob_lexer_map["scheme"] = wxSTC_LEX_LISP;
Glob_lexer_map["shell"] = wxSTC_LEX_BASH;
Glob_lexer_map["sql"] = wxSTC_LEX_SQL;
Glob_lexer_map["xml"] = wxSTC_LEX_XML;
Glob_lexer_map["yaml"] = wxSTC_LEX_YAML;
}
/** /**
* Toolkit-specific settings * Toolkit-specific settings
*/ */

View File

@ -56,7 +56,7 @@ const int TYRO_DEFAULT_FONT_SIZE = 10;
enum myMargins enum myMargins
{ {
MARGIN_FOLD, MARGIN_FOLD,
MARGIN_LINE_NUMBERS MARGIN_LINE_NUMBERS,
}; };
// Status bar sections // Status bar sections
@ -66,7 +66,7 @@ enum myStatusBarSections {
STATUS_CURRENT_LANGUAGE, STATUS_CURRENT_LANGUAGE,
STATUS_LINE_ENDINGS, STATUS_LINE_ENDINGS,
STATUS_CODE_PAGE, STATUS_CODE_PAGE,
STATUS_INDENT STATUS_INDENT,
}; };
// Top level menus // Top level menus
@ -75,7 +75,7 @@ enum myMenuIds {
myEDIT_MENU, myEDIT_MENU,
myVIEW_MENU, myVIEW_MENU,
myLANG_MENU, myLANG_MENU,
myHELP_MENU myHELP_MENU,
}; };
// General Menu ids // General Menu ids
@ -94,7 +94,7 @@ enum myMenuItemIds {
myID_PREFS_LINE_NUMBERS, myID_PREFS_LINE_NUMBERS,
myID_PREFS_CODE_FOLDING, myID_PREFS_CODE_FOLDING,
myID_PREFS_IDENT_GUIDES, myID_PREFS_IDENT_GUIDES,
myID_PREFS_FONT myID_PREFS_FONT,
}; };
const wxString TYRO_FILE_OPEN_WILDCARDS = const wxString TYRO_FILE_OPEN_WILDCARDS =

View File

@ -5,11 +5,45 @@
#include "src/widgets/EditorPane.h" #include "src/widgets/EditorPane.h"
#include "src/widgets/TabContainer.h" #include "src/widgets/TabContainer.h"
extern StringConstMap Glob_lexer_map;
extern LangConfig *Glob_lang_config; extern LangConfig *Glob_lang_config;
extern ThemeConfig *Glob_theme_config; extern ThemeConfig *Glob_theme_config;
extern wxConfigBase *Glob_config; extern wxConfigBase *Glob_config;
/**
* Map language names to their appropriate lexers
*/
static StringConstMap LexerMap = {
{"", wxSTC_LEX_NULL},
{"batch", wxSTC_LEX_BATCH},
{"caml", wxSTC_LEX_CAML},
{"cmake", wxSTC_LEX_CMAKE},
{"cpp", wxSTC_LEX_CPP},
{"css", wxSTC_LEX_CSS},
{"fortran", wxSTC_LEX_FORTRAN},
{"haskell", wxSTC_LEX_HASKELL},
{"java", wxSTC_LEX_CPP},
{"js", wxSTC_LEX_CPP},
{"lisp", wxSTC_LEX_LISP},
{"lua", wxSTC_LEX_LUA},
{"makefile", wxSTC_LEX_MAKEFILE},
{"markdown", wxSTC_LEX_MARKDOWN},
{"php", wxSTC_LEX_HTML},
{"perl", wxSTC_LEX_PERL},
{"properties", wxSTC_LEX_PROPERTIES},
{"python", wxSTC_LEX_PYTHON},
{"ruby", wxSTC_LEX_RUBY},
#ifdef wxSTC_LEX_RUST
{"rust", wxSTC_LEX_RUST},
#else
{"rust", wxSTC_LEX_CPP},
#endif
{"scheme", wxSTC_LEX_LISP},
{"shell", wxSTC_LEX_BASH},
{"sql", wxSTC_LEX_SQL},
{"xml", wxSTC_LEX_XML},
{"yaml", wxSTC_LEX_YAML},
};
/** /**
* Constructor * Constructor
* *
@ -85,9 +119,9 @@ void EditorPane::ApplyTheme(const string &lang, const string &theme)
{ {
this->StyleClearAll(); this->StyleClearAll();
if (Glob_lexer_map.count(lang) > 0) if (LexerMap.count(lang) > 0)
{ {
this->SetLexer(Glob_lexer_map[lang]); this->SetLexer(LexerMap[lang]);
} }
else else
{ {

View File

@ -3,7 +3,6 @@
#include "src/settings/LangConfig.h" #include "src/settings/LangConfig.h"
#include "src/settings/ThemeConfig.h" #include "src/settings/ThemeConfig.h"
class EditorPane: public wxStyledTextCtrl class EditorPane: public wxStyledTextCtrl
{ {
public: public:

View File

@ -20,7 +20,9 @@ MainFrame::MainFrame(wxFrame *frame, const wxString &title, const wxSize &size)
this->notebook = new TabContainer(this); this->notebook = new TabContainer(this);
// Initialize other widgets // Initialize other widgets
#ifdef TYRO_FILETREE
this->fileTreePane = new FileTreePane(this); this->fileTreePane = new FileTreePane(this);
#endif
this->prefFrame = new PrefFrame(); this->prefFrame = new PrefFrame();
// Set the frame icon // Set the frame icon
@ -52,7 +54,9 @@ MainFrame::~MainFrame()
wxDELETE(this->findReplaceData); wxDELETE(this->findReplaceData);
wxDELETE(this->toolBar); wxDELETE(this->toolBar);
wxDELETE(this->prefFrame); wxDELETE(this->prefFrame);
#ifdef TYRO_FILETREE
wxDELETE(this->fileTreePane); wxDELETE(this->fileTreePane);
#endif
this->manager->UnInit(); this->manager->UnInit();
wxDELETE(this->notebook); wxDELETE(this->notebook);
@ -80,6 +84,7 @@ void MainFrame::MainLayout()
.Resizable(true); .Resizable(true);
this->manager->AddPane(this->toolBar, toolBarPaneInfo); this->manager->AddPane(this->toolBar, toolBarPaneInfo);
#ifdef TYRO_FILETREE
wxAuiPaneInfo filePaneInfo; wxAuiPaneInfo filePaneInfo;
filePaneInfo.Left() filePaneInfo.Left()
.MinSize(225, 550) .MinSize(225, 550)
@ -87,6 +92,7 @@ void MainFrame::MainLayout()
.LeftDockable(true) .LeftDockable(true)
.Resizable(true); .Resizable(true);
this->manager->AddPane(this->fileTreePane, filePaneInfo); this->manager->AddPane(this->fileTreePane, filePaneInfo);
#endif
wxAuiPaneInfo notebookPaneInfo; wxAuiPaneInfo notebookPaneInfo;
notebookPaneInfo.CenterPane(); notebookPaneInfo.CenterPane();
@ -142,7 +148,9 @@ wxAuiToolBar* MainFrame::SetupToolbar()
toolBar->AddTool(wxID_NEW, "New", new_file_icon, "New file"); toolBar->AddTool(wxID_NEW, "New", new_file_icon, "New file");
toolBar->AddTool(wxID_OPEN, "Open", open_file_icon, "Open file"); toolBar->AddTool(wxID_OPEN, "Open", open_file_icon, "Open file");
#ifdef __WXGTK__ #ifdef __WXGTK__
#ifdef TYRO_FILETREE
toolBar->AddTool(myID_OPEN_DIR, "Open Dir", open_folder_icon, "Open folder"); toolBar->AddTool(myID_OPEN_DIR, "Open Dir", open_folder_icon, "Open folder");
#endif
#endif #endif
toolBar->AddTool(wxID_SAVE, "Save", save_file_icon, "Save file"); toolBar->AddTool(wxID_SAVE, "Save", save_file_icon, "Save file");
@ -168,7 +176,9 @@ void MainFrame::BindEvents()
// File Menu Events // File Menu Events
this->Bind(wxEVT_MENU, &MainFrame::OnNew, this, wxID_NEW); this->Bind(wxEVT_MENU, &MainFrame::OnNew, this, wxID_NEW);
this->Bind(wxEVT_MENU, &MainFrame::OnOpen, this, wxID_OPEN); this->Bind(wxEVT_MENU, &MainFrame::OnOpen, this, wxID_OPEN);
#ifdef TYRO_FILETREE
this->Bind(wxEVT_MENU, &MainFrame::OnOpenFolder, this, myID_OPEN_DIR); this->Bind(wxEVT_MENU, &MainFrame::OnOpenFolder, this, myID_OPEN_DIR);
#endif
this->Bind(wxEVT_MENU, &MainFrame::OnSave, this, wxID_SAVE); this->Bind(wxEVT_MENU, &MainFrame::OnSave, this, wxID_SAVE);
this->Bind(wxEVT_MENU, &MainFrame::OnSaveAs, this, wxID_SAVEAS); this->Bind(wxEVT_MENU, &MainFrame::OnSaveAs, this, wxID_SAVEAS);
this->Bind(wxEVT_MENU, &MainFrame::OnCloseTab, this, wxID_CLOSE); this->Bind(wxEVT_MENU, &MainFrame::OnCloseTab, this, wxID_CLOSE);
@ -279,6 +289,7 @@ void MainFrame::OnOpen(wxCommandEvent &WXUNUSED(event))
this->OpenFiles(filelist); this->OpenFiles(filelist);
} }
#ifdef TYRO_FILETREE
void MainFrame::OnOpenFolder(wxCommandEvent &event) void MainFrame::OnOpenFolder(wxCommandEvent &event)
{ {
wxDirDialog dlg(this, "Select Project Dir", wxEmptyString, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_CHANGE_DIR); wxDirDialog dlg(this, "Select Project Dir", wxEmptyString, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_CHANGE_DIR);
@ -289,6 +300,7 @@ void MainFrame::OnOpenFolder(wxCommandEvent &event)
this->fileTreePane->CreateTree(path); this->fileTreePane->CreateTree(path);
} }
#endif
/** /**
* Open tabs containing the files passed * Open tabs containing the files passed

View File

@ -7,7 +7,10 @@
#include "src/widgets/EditorPane.h" #include "src/widgets/EditorPane.h"
#include "src/widgets/TabContainer.h" #include "src/widgets/TabContainer.h"
#include "src/widgets/PrefFrame.h" #include "src/widgets/PrefFrame.h"
#ifdef TYRO_FILETREE
#include "src/widgets/FileTreePane.h" #include "src/widgets/FileTreePane.h"
#endif
class MainFrame: public wxFrame class MainFrame: public wxFrame
{ {
@ -19,7 +22,9 @@ class MainFrame: public wxFrame
void OnPrefsChanged(); void OnPrefsChanged();
private: private:
PrefFrame *prefFrame = nullptr; PrefFrame *prefFrame = nullptr;
#ifdef TYRO_FILETREE
FileTreePane *fileTreePane = nullptr; FileTreePane *fileTreePane = nullptr;
#endif
TabContainer *notebook = nullptr; TabContainer *notebook = nullptr;
wxAuiManager *manager = nullptr; wxAuiManager *manager = nullptr;
wxAuiToolBar *toolBar = nullptr; wxAuiToolBar *toolBar = nullptr;
@ -34,7 +39,9 @@ class MainFrame: public wxFrame
// Main Menu Event handlers // Main Menu Event handlers
void OnNew(wxCommandEvent &event); void OnNew(wxCommandEvent &event);
void OnOpen(wxCommandEvent &event); void OnOpen(wxCommandEvent &event);
#ifdef TYRO_FILETREE
void OnOpenFolder(wxCommandEvent &event); void OnOpenFolder(wxCommandEvent &event);
#endif
void OnCloseAll(wxCommandEvent &event); void OnCloseAll(wxCommandEvent &event);
void OnSave(wxCommandEvent &event); void OnSave(wxCommandEvent &event);
void OnSaveAs(wxCommandEvent &event); void OnSaveAs(wxCommandEvent &event);

View File

@ -43,7 +43,9 @@ void TyroMenu::SetupMainMenus()
this->fileMenu->Append(wxID_NEW, "&New\tCtrl+N", "Create a new file"); this->fileMenu->Append(wxID_NEW, "&New\tCtrl+N", "Create a new file");
this->fileMenu->AppendSeparator(); this->fileMenu->AppendSeparator();
this->fileMenu->Append(wxID_OPEN, "&Open\tCtrl+O", "Opens an existing file"); this->fileMenu->Append(wxID_OPEN, "&Open\tCtrl+O", "Opens an existing file");
#ifdef TYRO_FILETREE
this->fileMenu->Append(myID_OPEN_DIR, "&Open Dir\tShift+Ctrl+O", "Opens the selected folder in the sidebar"); this->fileMenu->Append(myID_OPEN_DIR, "&Open Dir\tShift+Ctrl+O", "Opens the selected folder in the sidebar");
#endif
this->fileMenu->AppendSeparator(); this->fileMenu->AppendSeparator();
this->fileMenu->Append(wxID_SAVE, "&Save\tCtrl+S", "Save the content"); this->fileMenu->Append(wxID_SAVE, "&Save\tCtrl+S", "Save the content");
this->fileMenu->Append(wxID_SAVEAS, "Save &As...\tShift+Ctrl+S", "Save current file as..."); this->fileMenu->Append(wxID_SAVEAS, "Save &As...\tShift+Ctrl+S", "Save current file as...");