Ugly progress commit

This commit is contained in:
Timothy Warren 2019-03-20 16:49:25 -04:00
parent d774f08e71
commit 45cc064ec8
7 changed files with 82 additions and 43 deletions

View File

@ -141,7 +141,7 @@
},
"lisp": {
"name": "Lisp",
"file_pattern": "*.lsp;*.lisp",
"file_pattern": "*.lsp;*.lisp;*.scm",
"keywords": [
"not defun + - * / = < > <= >= princ eval apply funcall quote identity function complement backquote lambda set setq setf defun defmacro gensym make symbol intern symbol name symbol value symbol plist get getf putprop remprop hash make array aref car cdr caar cadr cdar cddr caaar caadr cadar caddr cdaar cdadr cddar cdddr caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr cons list append reverse last nth nthcdr member assoc subst sublis nsubst nsublis remove length list length mapc mapcar mapl maplist mapcan mapcon rplaca rplacd nconc delete atom symbolp numberp boundp null listp consp minusp zerop plusp evenp oddp eq eql equal cond case and or let l if prog prog1 prog2 progn go return do dolist dotimes catch throw error cerror break continue errset baktrace evalhook truncate float rem min max abs sin cos tan expt exp sqrt random logand logior logxor lognot bignums logeqv lognand lognor logorc2 logtest logbitp logcount integer length nil"
],

View File

@ -51,7 +51,7 @@ public:
this->InitLexerMap();
Glob_config = wxConfigBase::Get();
Glob_menu_bar = new TyroMenu();
Glob_main_frame = new MainFrame(0L, APP_NAME, this->CalculateWindowSize());
Glob_main_frame = new MainFrame(nullptr, APP_NAME, this->CalculateWindowSize());
#ifndef TRAVIS
Glob_pref_pane = new PrefPane();
#endif
@ -74,13 +74,13 @@ public:
/**
* Exit handler
*
*
* @return int
*/
int OnExit()
{
// Deallocate config object
delete wxConfigBase::Set((wxConfigBase *) NULL);
delete wxConfigBase::Set((wxConfigBase *) nullptr);
return close(true);
}

View File

@ -97,7 +97,7 @@ void EditPane::ApplyTheme(string lang, string theme)
this->SetLexer(wxSTC_LEX_NULL);
}
if (theme != "")
if ( ! theme.empty())
{
theme_config->SetTheme(theme);
}
@ -115,7 +115,7 @@ void EditPane::ApplyTheme(string lang, string theme)
}
else
{
if (lang != "")
if ( ! lang.empty())
{
string typeMap[] = {"null", "int", "unsigned int", "double", "string", "boolean", "array", "object"};
stringstream output;
@ -272,7 +272,7 @@ void EditPane::BindEvents()
}
}, wxID_ANY);
this->Bind(wxEVT_STC_CHARADDED, &EditPane::OnCharAdded, this, wxID_ANY);
// this->Bind(wxEVT_STC_CHARADDED, &EditPane::OnCharAdded, this, wxID_ANY);
}
/**
@ -316,14 +316,14 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map)
wxFONTFLAG_ANTIALIASED
);
static const wxColor default_background = theme_config->GetThemeColor("background", "default");
static const wxColor default_foreground = theme_config->GetThemeColor("foreground", "default");
wxColor line_number_background = ( ! theme_config->GetThemeValue("line_numbers", "background").isNull())
? (theme_config->GetThemeColor("line_numbers", "background"))
static const wxColor default_background = this->theme_config->GetThemeColor("background", "default");
static const wxColor default_foreground = this->theme_config->GetThemeColor("foreground", "default");
wxColor line_number_background = ( ! this->theme_config->GetThemeValue("line_numbers", "background").isNull())
? (this->theme_config->GetThemeColor("line_numbers", "background"))
: default_background;
wxColor line_number_foreground = ( ! theme_config->GetThemeValue("line_numbers", "foreground").isNull())
? (theme_config->GetThemeColor("line_numbers", "foreground"))
wxColor line_number_foreground = ( ! this->theme_config->GetThemeValue("line_numbers", "foreground").isNull())
? (this->theme_config->GetThemeColor("line_numbers", "foreground"))
: default_foreground;
// Set default colors/ fonts
@ -452,7 +452,7 @@ void EditPane::_ApplyTheme(JsonValue &lexer_map)
*/
string EditPane::GetCurrentLang()
{
return lang_config->GetCurrentLangName();
return this->lang_config->GetCurrentLangName();
}
/**
@ -464,8 +464,8 @@ string EditPane::GetCurrentLang()
void EditPane::SetCurrentLang(string name)
{
// Update the current lang in the config
string langKey = lang_config->GetLangByName(name);
lang_config->SetLang(langKey);
string langKey = this->lang_config->GetLangByName(name);
this->lang_config->SetLang(langKey);
// Re-highlight the page with the new langauge
this->ApplyTheme(langKey);

View File

@ -20,8 +20,8 @@ FilePane::FilePane(
this->SetImageList(this->img_list);
wxString defaultPath(".");
wxFileName fname(defaultPath);
fname.MakeAbsolute(defaultPath);
wxFileName filename(defaultPath);
filename.MakeAbsolute(defaultPath);
wxTreeListItem root = this->GetRootItem();
this->CreateTree(defaultPath, root);
@ -41,6 +41,7 @@ FilePane::~FilePane()
void FilePane::BindEvents()
{
this->Bind(wxEVT_TREELIST_ITEM_EXPANDING, &FilePane::OpenFolder, this, wxID_ANY);
this->Bind(wxEVT_TREELIST_ITEM_ACTIVATED, &FilePane::OpenFileInEditor, this, wxID_ANY);
}
void FilePane::OpenFolder(wxTreeListEvent& event)
@ -59,39 +60,68 @@ void FilePane::OpenFolder(wxTreeListEvent& event)
* @param wxString &path
* @param wxTreeListItem &root
*/
void FilePane::CreateTree(const wxString &path, wxTreeListItem &root)
void FilePane::CreateTree(const wxString &path, wxTreeListItem &root, int level)
{
wxArrayString *files = new wxArrayString();
// So yeah, this doesn't really work right.
// It seems I need to create a tree from the list of file paths,
// after which this should be much simpler.
// @TODO Fix
auto *files = new wxArrayString();
wxDir::GetAllFiles(path, files);
vector<wxString> examined;
vector<wxString>::iterator it;
for (wxString filename : *files)
for (const wxString &item : *files)
{
wxFileName fname(filename);
wxFileName filename(item);
// For loose files, just add directly to the tree
if (fname.GetDirCount() == 1)
if (filename.GetDirCount() == 1)
{
this->AppendItem(root, fname.GetFullName(), Icon_File, Icon_File);
auto fullFileName = filename.GetFullPath();
auto fileData = new wxStringClientData();
fileData->SetData(fullFileName);
examined.push_back(fullFileName);
this->AppendItem(root, filename.GetFullName(), Icon_File, Icon_File, fileData);
continue;
}
else
// Remove the directory component closest to the root
filename.RemoveDir(0);
wxArrayString folders = filename.GetDirs();
wxLogDebug(item);
wxTreeListItem newRootNode = root;
for (const wxString &curr_folder: folders)
{
fname.RemoveDir(0);
wxArrayString folders = fname.GetDirs();
wxString curr_folder = folders[0];
// Check if directory has already been created
it = find(examined.begin(), examined.end(), curr_folder);
// If the directory already exists, continue;
if (it != examined.end()) continue;
wxTreeListItem current = this->AppendItem(root, curr_folder, Icon_FolderClosed, Icon_FolderOpened);
// Create the directory node if it doesn't exist
auto fileData = new wxStringClientData();
fileData->SetData(curr_folder);
wxTreeListItem current = this->AppendItem(
newRootNode,
curr_folder,
Icon_FolderClosed,
Icon_FolderOpened,
fileData);
examined.push_back(curr_folder);
// Recurse to create sub dirs
this->CreateTree(fname.GetPath(), current);
newRootNode = current;
this->CreateTree(curr_folder, root);
}
}
}
@ -101,6 +131,14 @@ void FilePane::CreateTree(const wxString &path, wxTreeListItem &root)
}*/
void FilePane::OpenFileInEditor(wxTreeListEvent& event)
{
wxTreeListItem item = event.GetItem();
auto path = this->GetItemText(item, 0);
wxLogMessage(path);
}
/**
* Create the image list object for the file pane widget
*/
@ -122,10 +160,10 @@ void FilePane::InitImageList()
wxART_FOLDER_OPEN
};
for (unsigned n = 0; n < WXSIZEOF(icons); n++)
for (auto icon : icons)
{
this->img_list->Add(
wxArtProvider::GetIcon(icons[n], wxART_LIST, iconSize)
wxArtProvider::GetIcon(icon, wxART_LIST, iconSize)
);
}
}

View File

@ -4,7 +4,7 @@
class FilePane : public wxTreeListCtrl {
public:
FilePane(
explicit FilePane(
wxWindow *parent,
wxWindowID id=wxID_ANY,
const wxPoint &pos=wxDefaultPosition,
@ -12,13 +12,14 @@ public:
long style=wxTL_DEFAULT_STYLE,
const wxString &name=wxTreeListCtrlNameStr
);
~FilePane();
~FilePane() override;
private:
wxString curr_path = "";
wxImageList *img_list = nullptr;
void BindEvents();
void OpenFolder(wxTreeListEvent& event);
void OpenFileInEditor(wxTreeListEvent& event);
void InitImageList();
void CreateTree(const wxString &path, wxTreeListItem &root);
void CreateTree(const wxString &path, wxTreeListItem &root, int level = 0);
};

View File

@ -475,7 +475,7 @@ void MainFrame::OnAbout(wxCommandEvent &WXUNUSED(event))
info.SetDescription(desc);
info.SetCopyright(" (C) 2015");
info.SetCopyright(" (C) 2015-2019");
wxAboutBox(info);
}

View File

@ -88,7 +88,7 @@ void TyroMenu::SetupLangMenu()
{
StringMap languages = lang_config->GetLangList();
for (auto lang: languages)
for (const auto lang: languages)
{
langMenu->Append(wxID_ANY, lang.second, "Highlight file as " + lang.second, wxITEM_RADIO);
}