From 8ab0a5096047a185ae8f2322a181691c80f848d6 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 30 May 2019 15:09:42 -0400 Subject: [PATCH] Add menu item to select sidebar folder, misc tweaks --- config/languages.json | 24 ++++--- src/TyroApp.cpp | 3 +- src/definitions.h | 9 ++- src/widgets/EditPane.cpp | 4 +- src/widgets/EditPane.h | 4 +- src/widgets/FilePane.cpp | 24 ++++--- src/widgets/FilePane.h | 2 +- src/widgets/MainFrame.cpp | 12 ++++ src/widgets/MainFrame.h | 1 + src/widgets/PrefPane.cpp | 127 ++++++++++++++++++++++++++++---------- src/widgets/TyroMenu.cpp | 4 +- 11 files changed, 158 insertions(+), 56 deletions(-) diff --git a/config/languages.json b/config/languages.json index baaee1c..1331347 100644 --- a/config/languages.json +++ b/config/languages.json @@ -23,14 +23,14 @@ }, "cmake": { "name": "Cmake", - "file_pattern": "*.cmake", + "file_pattern": "*.cmake;CMakeLists.txt", "keywords": [ "add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library add_subdirectory add_test aux_source_directory build_command build_name cmake_minimum_required configure_file create_test_sourcelist else elseif enable_language enable_testing endforeach endif endmacro endwhile exec_program execute_process export_library_dependencies file find_file find_library find_package find_path find_program fltk_wrap_ui foreach get_cmake_property get_directory_property get_filename_component get_source_file_property get_target_property get_test_property if include include_directories include_external_msproject include_regular_expression install install_files install_programs install_targets link_directories link_libraries list load_cache load_command macro make_directory mark_as_advanced math message option output_required_files project qt_wrap_cpp qt_wrap_ui remove remove_definitions separate_arguments set set_directory_properties set_source_files_properties set_target_properties set_tests_properties site_name source_group string subdir_depends subdirs target_link_libraries try_compile try_run use_mangled_mesa utility_source variable_requires vtk_make_instantiator vtk_wrap_java vtk_wrap_python vtk_wrap_tcl while write_file", "ABSOLUTE ABSTRACT ADDITIONAL_MAKE_CLEAN_FILES ALL AND APPEND ARGS ASCII BEFORE CACHE CACHE_VARIABLES CLEAR COMMAND COMMANDS COMMAND_NAME COMMENT COMPARE COMPILE_FLAGS COPYONLY DEFINED DEFINE_SYMBOL DEPENDS DOC EQUAL ESCAPE_QUOTES EXCLUDE EXCLUDE_FROM_ALL EXISTS EXPORT_MACRO EXT EXTRA_INCLUDE FATAL_ERROR FILE FILES FORCE FUNCTION GENERATED GLOB GLOB_RECURSE GREATER GROUP_SIZE HEADER_FILE_ONLY HEADER_LOCATION IMMEDIATE INCLUDES INCLUDE_DIRECTORIES INCLUDE_INTERNALS INCLUDE_REGULAR_EXPRESSION LESS LINK_DIRECTORIES LINK_FLAGS LOCATION MACOSX_BUNDLE MACROS MAIN_DEPENDENCY MAKE_DIRECTORY MATCH MATCHALL MATCHES MODULE NAME NAME_WE NOT NOTEQUAL NO_SYSTEM_PATH OBJECT_DEPENDS OPTIONAL OR OUTPUT OUTPUT_VARIABLE PATH PATHS POST_BUILD POST_INSTALL_SCRIPT PREFIX PREORDER PRE_BUILD PRE_INSTALL_SCRIPT PRE_LINK PROGRAM PROGRAM_ARGS PROPERTIES QUIET RANGE READ REGEX REGULAR_EXPRESSION REPLACE REQUIRED RETURN_VALUE RUNTIME_DIRECTORY SEND_ERROR SHARED SOURCES STATIC STATUS STREQUAL STRGREATER STRLESS SUFFIX TARGET TOLOWER TOUPPER VAR VARIABLES VERSION WIN32 WRAP_EXCLUDE WRITE APPLE MINGW MSYS CYGWIN BORLAND WATCOM MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 CMAKE_COMPILER_2005 OFF ON", "" ], "lexer_map": [ - "default", "comment", "string", "string", "string" + "default", "comment", "keyword1", "string", "keyword2", "string", "string", "string" ] }, "coffeescript": { @@ -129,7 +129,7 @@ }, "js": { "name": "JavaScript", - "file_pattern": "*.js;*.json;*.ts", + "file_pattern": "*.js;*.json;*.ts;*.jsx;*.tsx;*.mjs", "keywords": [ "abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends final finally float for function goto if implements import in instanceof int interface long native new package private protected public return short static super switch synchronized this throw throws transient try typeof var void volatile while with true false prototype", "console window document", @@ -141,9 +141,9 @@ }, "lisp": { "name": "Lisp", - "file_pattern": "*.lsp;*.lisp;*.scm", + "file_pattern": "*.lsp;*.lisp", "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" + "not define 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" ], "lexer_map": [ "default", "comment", "number", "keyword1", "keyword2", "default", "string", "string_eol", "identifier", "operator", "default", "comment_doc" @@ -224,8 +224,18 @@ "default", "comment", "comment_line", "comment_doc", "number", "keyword1", "string", "character", "uuid", "preprocessor", "operator", "identifier", "string_eol", "default", "regex", "comment_special", "keyword2", "keyword3", "error" ] }, + "scheme": { + "name": "Scheme", + "file_pattern": "*.scm", + "keywords": [ + "* + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation let* letrec list list->vector list-tail load magnitude make-rectangular make-vector max memq min negative? not null? number? odd? open-output-file output-port? peek-char procedure? quote rational? read real-part remainder round scheme-report-environment set! set-cdr! sqrt string->list string->symbol string-ci<=? string-ci=? string-ci>? string-fill! string-ref string<=? string=? string>? substring symbol? truncate vector vector-fill! vector-ref vector? with-output-to-file write-char let-syntax letrec-syntax list->string list-ref list? log make-polar make-string map member memv modulo newline null-environment number->string numerator open-input-file or pair? positive? quasiquote quotient rationalize read-char real? reverse set-car! sin string string->number string-append string-ci=? string-copy string-length string-set! string=? string? symbol->string tan values vector->list vector-length vector-set! with-input-from-file write zero? call-with-input-file call-with-values case cdaadr cdadar cdadr cddaar cddar cddddr cddr ceiling char-alphabetic? char-ci=? char-downcase char-numeric? char-upcase char-whitespace? char=? char? close-output-port cond cos current-output-port define-syntax denominator do eof-object? equal? eval exact->inexact exp floor force if inexact->exact input-port? integer? lambda length call-with-output-file car cdaaar cdaar cdaddr cdar cddadr cdddar cdddr cdr char->integer char-ci<=? char-ci=? char-ci>? char-lower-case? char-ready? char-upper-case? char<=? char=? char>? close-input-port complex? cons current-input-port define delay display dynamic-wind eq? eqv? even? exact? expt for-each gcd imag-part inexact? integer->char interaction-environment lcm let" + ], + "lexer_map": [ + "default", "comment", "number", "keyword1", "keyword2", "default", "string", "string_eol", "identifier", "operator", "default", "comment_doc" + ] + }, "shell": { - "name": "Shell script", + "name": "Bash Shell script", "file_pattern": "*.sh;*.bsh;*.run", "keywords": [ "alias ar asa awk banner basename bash bc bdiff break bunzip2 bzip2 cal calendar case cat cc cd chmod cksum clear cmp col comm compress continue cp cpio crypt csplit ctags cut date dc dd declare deroff dev df diff diff3 dircmp dirname do done du echo ed egrep elif else env esac eval ex exec exit expand export expr false fc fgrep fi file find fmt fold for function functions getconf getopt getopts grep gres hash head help history iconv id if in integer jobs join kill local lc let line ln logname look ls m4 mail mailx make man mkdir more mt mv newgrp nl nm nohup ntps od pack paste patch pathchk pax pcat perl pg pr print printf ps pwd read readonly red return rev rm rmdir sed select set sh shift size sleep sort spell split start stop strings strip stty sum suspend sync tail tar tee test then time times touch tr trap true tsort tty type typeset ulimit umask unalias uname uncompress unexpand uniq unpack unset until uudecode uuencode vi vim vpax wait wc whence which while who wpaste wstart xargs zcat" @@ -246,7 +256,7 @@ }, "xml": { "name": "XML", - "file_pattern": "*.xml;*.svg;*.xsml;*.xsl;*.xsd;*.kml;*.wsdl;*.xlf;*.xliff", + "file_pattern": "*.xml;*.svg;*.xsml;*.xsl;*.xsd;*.kml;*.wsdl;*.xlf;*.xliff;*.plist", "keywords": [ "" ], diff --git a/src/TyroApp.cpp b/src/TyroApp.cpp index cd213ee..2e25ef3 100644 --- a/src/TyroApp.cpp +++ b/src/TyroApp.cpp @@ -50,9 +50,7 @@ public: Glob_config = wxConfigBase::Get(); Glob_menu_bar = new TyroMenu(); Glob_main_frame = new MainFrame(nullptr, APP_NAME, CalculateWindowSize()); -#ifndef TRAVIS Glob_pref_pane = new PrefPane(); -#endif // Setup Main Window Glob_main_frame->Layout(); @@ -144,6 +142,7 @@ private: Glob_lexer_map["python"] = wxSTC_LEX_PYTHON; Glob_lexer_map["ruby"] = wxSTC_LEX_RUBY; Glob_lexer_map["rust"] = wxSTC_LEX_CPP; + 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; diff --git a/src/definitions.h b/src/definitions.h index 0385ef8..5683326 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -68,8 +68,11 @@ enum myMenuIds { // General Menu ids enum myMenuItemIds { + // Menu options for sidebar + myID_OPEN_DIR = wxID_HIGHEST + 1, + // Menu options for immediate file - myID_VIEW_WHITESPACE = wxID_HIGHEST + 1, + myID_VIEW_WHITESPACE, myID_VIEW_LINE_ENDINGS, myID_CLOSE_ALL, myID_CLOSE_ALL_BUT_THIS, @@ -104,6 +107,7 @@ const wxString TYRO_FILE_OPEN_WILDCARDS = "Python (*.py,*.pyw)|*.py;*.pyw|" "Ruby (*.rb)|*.rb|" "Rust (*.rs)|*.rs|" + "Scheme (*.scm)|*.scm" "Shell (*.sh, *.bsh)|*.sh;*.bsh|" "SQL (*.sql)|*.sql|" "Text (*.txt)|*.txt|" @@ -131,7 +135,8 @@ const wxString TYRO_FILE_SAVE_WILDCARDS = "Python (*.py,*.pyw)|*.py;*.pyw|" "Ruby (*.rb)|*.rb|" "Rust (*.rs)|*.rs|" + "Scheme (*.scm)|*.scm|" "Shell (*.sh, *.bsh)|*.sh;*.bsh|" "SQL (*.sql)|*.sql|" "Text (*.txt)|*.txt|" - "Yaml (.yml,*.yaml)| *.yml;*.yaml"; \ No newline at end of file + "Yaml (.yml,*.yaml)| *.yml;*.yaml"; diff --git a/src/widgets/EditPane.cpp b/src/widgets/EditPane.cpp index c1b1aaf..27c9cc5 100644 --- a/src/widgets/EditPane.cpp +++ b/src/widgets/EditPane.cpp @@ -60,7 +60,7 @@ EditPane::~EditPane() * @param wxString filePath * @return void */ -void EditPane::Highlight(wxString filePath) +void EditPane::Highlight(const wxString &filePath) { this->fileName.Assign(filePath); @@ -149,7 +149,7 @@ void EditPane::ReApplyTheme(const string &theme) * @param wxString filePath * @return bool */ -bool EditPane::Load(wxString filePath) +bool EditPane::Load(const wxString &filePath) { this->fileName.Assign(filePath); diff --git a/src/widgets/EditPane.h b/src/widgets/EditPane.h index e9e751a..74acf64 100644 --- a/src/widgets/EditPane.h +++ b/src/widgets/EditPane.h @@ -15,8 +15,8 @@ public: ); ~EditPane(); wxFileName fileName; - bool Load(wxString filePath); - void Highlight(wxString filePath); + bool Load(const wxString &filePath); + void Highlight(const wxString &filePath); bool SaveFile(); bool SaveFile(const wxString &filename); void ReApplyTheme(const string &theme=""); diff --git a/src/widgets/FilePane.cpp b/src/widgets/FilePane.cpp index 9b1620d..882490c 100644 --- a/src/widgets/FilePane.cpp +++ b/src/widgets/FilePane.cpp @@ -5,6 +5,8 @@ extern MainFrame *Glob_main_frame; +auto DIR_SEP = wxFileName::GetPathSeparator(); + enum { Icon_File, @@ -35,6 +37,8 @@ FilePane::FilePane( wxCOL_WIDTH_AUTOSIZE, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE); + + this->SetSortColumn(0); } @@ -60,11 +64,14 @@ void FilePane::OpenFolder(wxTreeListEvent& event) /** * Iterates through the specified folder and creates the tree view - * - * @access private */ void FilePane::CreateTree(const wxString &path) { + // Clear the tree! + this->DeleteAllItems(); + this->file_set.clear(); + this->dir_set.clear(); + wxTreeListItem root = this->GetRootItem(); auto *files = new wxArrayString(); @@ -93,7 +100,7 @@ void FilePane::CreateTree(const wxString &path) wxArrayString dirs = fileName.GetDirs(); - this->AddDirToTree(root, dirs[0], wxString("")); + this->AddDirToTree(root, dirs[0], wxString(""), true); } delete files; @@ -107,24 +114,24 @@ void FilePane::CreateTree(const wxString &path) * * @access private */ -void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wxString &parent) +void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wxString &parent, bool recurse) { wxLogInfo("AddDirToTree path: %s, parent: %s", path, parent); auto fullPath = this->base_path; if ( ! parent.empty()) { - fullPath += "/"; + fullPath += DIR_SEP; auto par = parent.Clone(); - par.Replace((wxString)this->base_path + "/", ""); + par.Replace((wxString)this->base_path + DIR_SEP, ""); fullPath += par.ToStdString(); } if ( ! fullPath.Contains(path)) { - fullPath += "/"; + fullPath += DIR_SEP; fullPath += path; } @@ -148,6 +155,7 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx // ------------------------------------------------------------------------------------ // Find folder(s) to recurse // ------------------------------------------------------------------------------------ + if ( ! recurse) return; auto *files = new wxArrayString(); wxDir::GetAllFiles(fullPath, files); @@ -181,7 +189,7 @@ void FilePane::AddDirToTree(wxTreeListItem &root, const wxString &path, const wx if ( ! newParent.Contains(BaseName(fullPath))) { - newParent += "/" + BaseName(fullPath); + newParent += DIR_SEP + BaseName(fullPath); } wxArrayString dirs = fileName.GetDirs(); diff --git a/src/widgets/FilePane.h b/src/widgets/FilePane.h index 89f9a32..a7bd333 100644 --- a/src/widgets/FilePane.h +++ b/src/widgets/FilePane.h @@ -24,7 +24,7 @@ private: void OpenFolder(wxTreeListEvent& event); void OpenFileInEditor(wxTreeListEvent& event); void InitImageList(); - void AddDirToTree(wxTreeListItem &root, const wxString &path, const wxString &parent); + void AddDirToTree(wxTreeListItem &root, const wxString &path, const wxString &parent, bool recurse = false); void AddDirFiles(wxTreeListItem &root, const wxString &path); }; diff --git a/src/widgets/MainFrame.cpp b/src/widgets/MainFrame.cpp index 85f3176..a08825f 100644 --- a/src/widgets/MainFrame.cpp +++ b/src/widgets/MainFrame.cpp @@ -178,6 +178,7 @@ void MainFrame::BindEvents() // File Menu Events this->Bind(wxEVT_MENU, &MainFrame::OnNew, this, wxID_NEW); this->Bind(wxEVT_MENU, &MainFrame::OnOpen, this, wxID_OPEN); + this->Bind(wxEVT_MENU, &MainFrame::OnOpenFolder, this, myID_OPEN_DIR); 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); @@ -289,6 +290,17 @@ void MainFrame::OnOpen(wxCommandEvent &WXUNUSED(event)) this->OpenFiles(filelist); } +void MainFrame::OnOpenFolder(wxCommandEvent &event) +{ + wxString path; + + wxDirDialog dlg(this, "Select Project Dir", wxEmptyString, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_CHANGE_DIR); + + if (dlg.ShowModal() != wxID_OK) return; + + filePane->CreateTree(dlg.GetPath()); +} + /** * Open tabs containing the files passed * diff --git a/src/widgets/MainFrame.h b/src/widgets/MainFrame.h index 8236ad1..d3bd642 100644 --- a/src/widgets/MainFrame.h +++ b/src/widgets/MainFrame.h @@ -34,6 +34,7 @@ class MainFrame: public wxFrame // Main Menu Event handlers void OnNew(wxCommandEvent &event); void OnOpen(wxCommandEvent &event); + void OnOpenFolder(wxCommandEvent &event); void OnCloseAll(wxCommandEvent &event); void OnFileClose(wxCommandEvent &event); void OnSave(wxCommandEvent &event); diff --git a/src/widgets/PrefPane.cpp b/src/widgets/PrefPane.cpp index 602d4a0..4ec8619 100644 --- a/src/widgets/PrefPane.cpp +++ b/src/widgets/PrefPane.cpp @@ -15,23 +15,6 @@ public: this->showCodeFolding = new wxCheckBox(this, myID_PREFS_CODE_FOLDING, "Show code folding"); wxSizer *sizer = new wxBoxSizer(wxVERTICAL); - - this->fontPicker = new wxFontPickerCtrl( - this, - myID_PREFS_FONT, - this->GetFont(), - wxDefaultPosition, - wxDefaultSize, - wxFNTP_FONTDESC_AS_LABEL - ); - this->fontPicker->SetLabelText("Editor Font"); - wxSizer *fontSizer = new wxBoxSizer(wxHORIZONTAL); - fontSizer->AddSpacer(50); - fontSizer->Add(this->fontPicker, wxSizerFlags().Border()); - fontSizer->AddSpacer(50); - sizer->Add(fontSizer, wxSizerFlags().Border()); - - sizer->Add(this->showLineNumbers, wxSizerFlags().Border()); sizer->Add(this->showIndentGuides, wxSizerFlags().Border()); sizer->Add(this->showCodeFolding, wxSizerFlags().Border()); @@ -42,12 +25,6 @@ public: // On supported platforms if (wxPreferencesEditor::ShouldApplyChangesImmediately()) { - this->fontPicker->Bind(wxEVT_FONTPICKER_CHANGED, [=] (wxFontPickerEvent &event) { - Glob_config->Write("global_font", event.GetFont()); - this->frame->OnPrefsChanged(event); - Glob_config->Flush(); - }, myID_PREFS_FONT); - this->showLineNumbers->Bind(wxEVT_CHECKBOX, [=] (wxCommandEvent &event) { Glob_config->Write("show_line_numbers", event.IsChecked()); this->frame->OnPrefsChanged(event); @@ -70,6 +47,9 @@ public: ~GeneralPrefPanePage() { + wxDELETE(this->showLineNumbers); + wxDELETE(this->showIndentGuides); + wxDELETE(this->showCodeFolding); } /** @@ -83,11 +63,6 @@ public: this->showIndentGuides->SetValue(Glob_config->ReadBool("show_indent_guides", false)); this->showCodeFolding->SetValue(Glob_config->ReadBool("show_code_folding", false)); - wxFont globalFont; - Glob_config->Read("global_font", &globalFont); - - this->fontPicker->SetSelectedFont(globalFont); - return true; } @@ -103,6 +78,86 @@ public: Glob_config->Write("show_indent_guides", this->showIndentGuides->IsChecked()); Glob_config->Write("show_code_folding", this->showCodeFolding->IsChecked()); + wxCommandEvent evt = wxCommandEvent(); + this->frame->OnPrefsChanged(evt); + + Glob_config->Flush(); + + return true; + } + +private: + MainFrame *frame; + wxCheckBox *showLineNumbers = nullptr; + wxCheckBox *showIndentGuides = nullptr; + wxCheckBox *showCodeFolding = nullptr; +}; + +class FontPrefPanePage : public wxPanel{ +public: + FontPrefPanePage(wxWindow *parent): wxPanel(parent) + { + this->frame = (MainFrame *) parent; + + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); + + this->fontPicker = new wxFontPickerCtrl( + this, + myID_PREFS_FONT, + this->GetFont(), + wxDefaultPosition, + wxDefaultSize, + wxFNTP_FONTDESC_AS_LABEL + ); + this->fontPicker->SetLabelText("Editor Font"); + wxSizer *fontSizer = new wxBoxSizer(wxHORIZONTAL); + fontSizer->AddSpacer(50); + fontSizer->Add(this->fontPicker, wxSizerFlags().Border()); + fontSizer->AddSpacer(50); + sizer->Add(fontSizer, wxSizerFlags().Border()); + + this->SetSizerAndFit(sizer); + + // Change settings on selection, rather than on apply button + // On supported platforms + if (wxPreferencesEditor::ShouldApplyChangesImmediately()) + { + this->fontPicker->Bind(wxEVT_FONTPICKER_CHANGED, [=] (wxFontPickerEvent &event) { + Glob_config->Write("global_font", event.GetFont()); + this->frame->OnPrefsChanged(event); + Glob_config->Flush(); + }, myID_PREFS_FONT); + } + } + + ~FontPrefPanePage() + { + wxDELETE(this->fontPicker); + } + + /** + * Apply current settings to the pref window + * + * @return bool + */ + virtual bool TransferDataToWindow() + { + wxFont globalFont; + Glob_config->Read("global_font", &globalFont); + + this->fontPicker->SetSelectedFont(globalFont); + + return true; + } + + /** + * Called on platforms with modal preferences dialog to save + * and apply the changes + * + * @return bool + */ + virtual bool TransferDataFromWindow() + { Glob_config->Write("global_font", this->fontPicker->GetSelectedFont()); wxCommandEvent evt = wxCommandEvent(); @@ -116,11 +171,11 @@ public: private: MainFrame *frame; wxFontPickerCtrl *fontPicker = nullptr; - wxCheckBox *showLineNumbers = nullptr; - wxCheckBox *showIndentGuides = nullptr; - wxCheckBox *showCodeFolding = nullptr; }; +/* + * Creates the "General" pane on the pref window + * */ class GeneralPrefPane: public wxStockPreferencesPage { public: GeneralPrefPane() : wxStockPreferencesPage(Kind_General) {} @@ -130,6 +185,15 @@ public: } }; +class FontPrefPane: public wxStockPreferencesPage { +public: + FontPrefPane() : wxStockPreferencesPage(Kind_Advanced) {} + virtual wxWindow *CreateWindow(wxWindow *parent) + { + return new FontPrefPanePage(parent); + } +}; + // ----------------------------------------------------------------------------- // ! Implementation of PrefPane Class // ----------------------------------------------------------------------------- @@ -138,6 +202,7 @@ PrefPane::PrefPane() { this->pref_window = new wxPreferencesEditor(); this->pref_window->AddPage(new GeneralPrefPane()); + // this->pref_window->AddPage(new FontPrefPane()); } PrefPane::~PrefPane() diff --git a/src/widgets/TyroMenu.cpp b/src/widgets/TyroMenu.cpp index 6e2b19e..c7399c1 100644 --- a/src/widgets/TyroMenu.cpp +++ b/src/widgets/TyroMenu.cpp @@ -47,6 +47,8 @@ void TyroMenu::SetupMainMenus() fileMenu->Append(wxID_NEW, "&New\tCtrl+N", "Create a new file"); fileMenu->AppendSeparator(); fileMenu->Append(wxID_OPEN, "&Open\tCtrl+O", "Opens an existing file"); + fileMenu->Append(myID_OPEN_DIR, "&Open Dir\tShift+Ctrl+O", "Opens the selected folder in the sidebar"); + fileMenu->Append(wxID_SAVE, "&Save\tCtrl+S", "Save the content"); fileMenu->Append(wxID_SAVEAS, "Save &As...\tShift+Ctrl+S", "Save current file as..."); fileMenu->AppendSeparator(); @@ -176,4 +178,4 @@ void TyroMenu::SetCurrentLanguage(string lang) } this->Check(this->FindMenuItem("&Language", lang), true); -} \ No newline at end of file +}