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
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++")
add_definitions(-D__WXMAC__)
else()

View File

@ -19,8 +19,6 @@ MainFrame *Glob_main_frame = nullptr;
TyroMenu *Glob_menu_bar = nullptr;
wxStatusBar *Glob_status_bar = nullptr;
StringConstMap Glob_lexer_map;
/**
* Class with main method
*/
@ -39,7 +37,6 @@ public:
this->SetVendorName(APP_VENDOR);
// Initialize globals
TyroApp::InitLexerMap();
Glob_config = wxConfigBase::Get();
Glob_lang_config = new LangConfig();
Glob_theme_config = new ThemeConfig();
@ -116,43 +113,6 @@ private:
// app loading variables
wxArrayString files;
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

View File

@ -34,7 +34,7 @@ const wxCmdLineEntryDesc Glob_cmdLineDesc[] = {
nullptr,
"input file(s)",
wxCMD_LINE_VAL_STRING,
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE
wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE
},
{wxCMD_LINE_NONE}
};
@ -56,7 +56,7 @@ const int TYRO_DEFAULT_FONT_SIZE = 10;
enum myMargins
{
MARGIN_FOLD,
MARGIN_LINE_NUMBERS
MARGIN_LINE_NUMBERS,
};
// Status bar sections
@ -66,7 +66,7 @@ enum myStatusBarSections {
STATUS_CURRENT_LANGUAGE,
STATUS_LINE_ENDINGS,
STATUS_CODE_PAGE,
STATUS_INDENT
STATUS_INDENT,
};
// Top level menus
@ -75,7 +75,7 @@ enum myMenuIds {
myEDIT_MENU,
myVIEW_MENU,
myLANG_MENU,
myHELP_MENU
myHELP_MENU,
};
// General Menu ids
@ -89,12 +89,12 @@ enum myMenuItemIds {
myID_CLOSE_ALL,
myID_CLOSE_ALL_BUT_THIS,
myID_LINE_WRAP,
// Preferences, to apply to all files
myID_PREFS_LINE_NUMBERS,
myID_PREFS_CODE_FOLDING,
myID_PREFS_IDENT_GUIDES,
myID_PREFS_FONT
myID_PREFS_FONT,
};
const wxString TYRO_FILE_OPEN_WILDCARDS =

View File

@ -5,11 +5,45 @@
#include "src/widgets/EditorPane.h"
#include "src/widgets/TabContainer.h"
extern StringConstMap Glob_lexer_map;
extern LangConfig *Glob_lang_config;
extern ThemeConfig *Glob_theme_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
*
@ -85,9 +119,9 @@ void EditorPane::ApplyTheme(const string &lang, const string &theme)
{
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
{

View File

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

View File

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

View File

@ -7,7 +7,10 @@
#include "src/widgets/EditorPane.h"
#include "src/widgets/TabContainer.h"
#include "src/widgets/PrefFrame.h"
#ifdef TYRO_FILETREE
#include "src/widgets/FileTreePane.h"
#endif
class MainFrame: public wxFrame
{
@ -19,7 +22,9 @@ class MainFrame: public wxFrame
void OnPrefsChanged();
private:
PrefFrame *prefFrame = nullptr;
#ifdef TYRO_FILETREE
FileTreePane *fileTreePane = nullptr;
#endif
TabContainer *notebook = nullptr;
wxAuiManager *manager = nullptr;
wxAuiToolBar *toolBar = nullptr;
@ -30,25 +35,27 @@ class MainFrame: public wxFrame
wxAuiToolBar* SetupToolbar();
void BindEvents();
void MainLayout();
// Main Menu Event handlers
void OnNew(wxCommandEvent &event);
void OnOpen(wxCommandEvent &event);
#ifdef TYRO_FILETREE
void OnOpenFolder(wxCommandEvent &event);
#endif
void OnCloseAll(wxCommandEvent &event);
void OnSave(wxCommandEvent &event);
void OnSaveAs(wxCommandEvent &event);
void OnEditFind(wxCommandEvent &event);
void OnEditReplace(wxCommandEvent &event);
void OnFindDialog(wxFindDialogEvent &event);
void OnToggleWhitespace(wxCommandEvent &event);
void OnToggleLineWrap(wxCommandEvent &event);
void OnToggleLineEndings(wxCommandEvent &event);
void OnLangSelect(wxCommandEvent &event);
void OnCloseTab(wxCommandEvent &event);
void OnQuit(wxCommandEvent &event);
void OnAbout(wxCommandEvent &event);

View File

@ -4,7 +4,7 @@ extern LangConfig *Glob_lang_config;
/**
* Constructor
*/
*/
TyroMenu::TyroMenu()
{
this->fileMenu = new wxMenu();
@ -15,7 +15,7 @@ TyroMenu::TyroMenu()
this->SetupMainMenus();
this->SetupLangMenu();
// Add the menus to the menubar
this->Insert(myFILE_MENU, fileMenu, "&File");
this->Insert(myEDIT_MENU, editMenu, "&Edit");
@ -26,7 +26,7 @@ TyroMenu::TyroMenu()
/**
* Destructor
*/
*/
TyroMenu::~TyroMenu()
{
wxLogDebug("TyroMenu Destructor Called.");
@ -34,16 +34,18 @@ TyroMenu::~TyroMenu()
/**
* Setup basic menu items
*
*
* @return void
*/
*/
void TyroMenu::SetupMainMenus()
{
// Add items to top-level menus
this->fileMenu->Append(wxID_NEW, "&New\tCtrl+N", "Create a new file");
this->fileMenu->AppendSeparator();
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");
#endif
this->fileMenu->AppendSeparator();
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...");
@ -51,7 +53,7 @@ void TyroMenu::SetupMainMenus()
this->fileMenu->Append(wxID_CLOSE, "&Close\tCtrl+W", "Close the current document");
this->fileMenu->Append(myID_CLOSE_ALL, "C&lose All\tShift+Ctrl+W", "Close all open documents.");
this->fileMenu->Append(wxID_EXIT, "&Quit\tCtrl+Q", "Quit the application");
this->editMenu->Append(wxID_UNDO, "&Undo\tCtrl+Z", "Undo last action");
this->editMenu->Append(wxID_REDO, "&Redo\tCtrl+Y", "Redo last action");
this->editMenu->AppendSeparator();
@ -70,7 +72,7 @@ void TyroMenu::SetupMainMenus()
this->viewMenu->AppendCheckItem(myID_VIEW_WHITESPACE, "Show Invisible Characters\tCtrl+Shift+I", "Toggle visibility of white space characters");
this->viewMenu->AppendCheckItem(myID_VIEW_LINE_ENDINGS, "Show line endings", "Toggle visibility of line ending characters");
this->viewMenu->AppendCheckItem(myID_LINE_WRAP, "Word Wrap", "Toggle wrapping of long lines");
this->helpMenu->Append(wxID_ABOUT, "About Tyro", "Show info about this application");
}
@ -78,11 +80,11 @@ void TyroMenu::SetupMainMenus()
* Create the language selection menu
*
* @return void
*/
*/
void TyroMenu::SetupLangMenu()
{
StringMap languages = Glob_lang_config->GetLangList();
for (const auto lang: languages)
{
langMenu->Append(wxID_ANY, lang.second, "Highlight file as " + lang.second, wxITEM_RADIO);
@ -92,16 +94,16 @@ void TyroMenu::SetupLangMenu()
/**
* Enable/disable controls that require a file to be open
*
* @param bool enable
* @param bool enable
* @return void
*/
*/
void TyroMenu::EnableEditControls(bool enable)
{
this->fileMenu->Enable(wxID_SAVE, enable);
this->fileMenu->Enable(wxID_SAVEAS, enable);
this->fileMenu->Enable(wxID_CLOSE, enable);
this->fileMenu->Enable(myID_CLOSE_ALL, enable);
this->editMenu->Enable(wxID_UNDO, enable);
this->editMenu->Enable(wxID_REDO, enable);
this->editMenu->Enable(wxID_CUT, enable);
@ -110,7 +112,7 @@ void TyroMenu::EnableEditControls(bool enable)
this->editMenu->Enable(wxID_SELECTALL, enable);
this->editMenu->Enable(wxID_FIND, enable);
this->editMenu->Enable(wxID_REPLACE, enable);
// Enable/disable top level menus
this->EnableEntireMenu(myVIEW_MENU, this->viewMenu, enable);
this->EnableEntireMenu(myLANG_MENU, this->langMenu, enable);
@ -118,7 +120,7 @@ void TyroMenu::EnableEditControls(bool enable)
/**
* Check the menu item associated with the specified id
*
*
* @param int id
* @param bool checked
* @return void
@ -136,7 +138,7 @@ void TyroMenu::SetIdChecked(int id, bool checked)
* @param wxMenu* menu
* @param bool enable
* @return void
*/
*/
void TyroMenu::EnableEntireMenu(size_t menuId, wxMenu *menu, bool enable)
{
// Toggle the top of the menu
@ -148,7 +150,7 @@ void TyroMenu::EnableEntireMenu(size_t menuId, wxMenu *menu, bool enable)
for(auto item: list)
{
item->Enable(enable);
// Uncheck all the items
if (item->IsCheckable())
{
@ -159,7 +161,7 @@ void TyroMenu::EnableEntireMenu(size_t menuId, wxMenu *menu, bool enable)
/**
* Change the language used for highlighting
*
*
* @param string lang
* @return void
*/
@ -169,6 +171,6 @@ void TyroMenu::SetCurrentLanguage(string lang)
{
lang = "Plain Text";
}
this->Check(this->FindMenuItem("&Language", lang), true);
}