#ifndef ECODE_HPP #define ECODE_HPP #include "appconfig.hpp" #include "docsearchcontroller.hpp" #include "filelocator.hpp" #include "filesystemlistener.hpp" #include "globalsearchcontroller.hpp" #include "notificationcenter.hpp" #include "projectdirectorytree.hpp" #include "projectsearch.hpp" #include "uitreeviewglobalsearch.hpp" #include "widgetcommandexecuter.hpp" #include #include namespace ecode { class AutoCompletePlugin; class LinterPlugin; class FormatterPlugin; class App : public UICodeEditorSplitter::Client { public: App(); ~App(); void createWidgetTreeView(); void init( std::string file, const Float& pidelDensity, const std::string& colorScheme ); void setAppTitle( const std::string& title ); void openFileDialog(); void openFolderDialog(); void openFontDialog( std::string& fontPath, bool loadingMonoFont ); void downloadFileWeb( const std::string& url ); UIFileDialog* saveFileDialog( UICodeEditor* editor, bool focusOnClose = true ); void closeApp(); void mainLoop(); void runCommand( const std::string& command ); void loadConfig(); void saveConfig(); std::string getKeybind( const std::string& command ); std::vector getUnlockedCommands(); void saveAll(); ProjectDirectoryTree* getDirTree() const; std::shared_ptr getThreadPool() const; void loadFileFromPath( const std::string& path, bool inNewTab = true, UICodeEditor* codeEditor = nullptr, std::function onLoaded = std::function() ); void hideGlobalSearchBar(); void hideSearchBar(); void hideLocateBar(); bool isDirTreeReady() const; NotificationCenter* getNotificationCenter() const; protected: EE::Window::Window* mWindow{ nullptr }; UISceneNode* mUISceneNode{ nullptr }; Console* mConsole{ nullptr }; std::string mWindowTitle{ "ecode" }; UILayout* mMainLayout{ nullptr }; UILayout* mBaseLayout{ nullptr }; UILayout* mImageLayout{ nullptr }; UIPopUpMenu* mSettingsMenu{ nullptr }; UITextView* mSettingsButton{ nullptr }; std::vector mColorSchemeMenues; Float mColorSchemeMenuesCreatedWithHeight{ 0 }; std::vector mFileTypeMenues; Float mFileTypeMenuesCreatedWithHeight{ 0 }; UILinearLayout* mDocInfo{ nullptr }; UITextView* mDocInfoText{ nullptr }; std::vector mRecentFiles; std::vector mRecentFolders; AppConfig mConfig; UIPopUpMenu* mDocMenu{ nullptr }; UIPopUpMenu* mViewMenu{ nullptr }; UIPopUpMenu* mWindowMenu{ nullptr }; UIPopUpMenu* mToolsMenu{ nullptr }; UIPopUpMenu* mProjectTreeMenu{ nullptr }; UIPopUpMenu* mProjectMenu{ nullptr }; UISplitter* mProjectSplitter{ nullptr }; UITabWidget* mSidePanel{ nullptr }; UICodeEditorSplitter* mEditorSplitter{ nullptr }; std::string mInitColorScheme; std::unordered_map mKeybindings; std::unordered_map mKeybindingsInvert; std::unordered_map mGlobalSearchKeybindings; std::unordered_map mDocumentSearchKeybindings; std::string mConfigPath; std::string mPluginsPath; std::string mKeybindingsPath; Float mDisplayDPI{ 96 }; std::string mResPath; AutoCompletePlugin* mAutoCompletePlugin{ nullptr }; LinterPlugin* mLinterPlugin{ nullptr }; FormatterPlugin* mFormatterPlugin{ nullptr }; std::shared_ptr mThreadPool; std::shared_ptr mDirTree; UITreeView* mProjectTreeView{ nullptr }; std::shared_ptr mFileSystemModel; size_t mMenuIconSize; bool mDirTreeReady{ false }; bool mIsBundledApp{ false }; ProjectDocumentConfig mProjectDocConfig; std::unordered_set mTmpDocs; std::string mCurrentProject; FontTrueType* mFont{ nullptr }; FontTrueType* mFontMono{ nullptr }; efsw::FileWatcher* mFileWatcher{ nullptr }; FileSystemListener* mFileSystemListener{ nullptr }; Mutex mWatchesLock; std::unordered_set mFolderWatches; std::unordered_map mFilesFolderWatches; std::unique_ptr mGlobalSearchController; std::unique_ptr mDocSearchController; std::unique_ptr mFileLocator; std::unique_ptr mNotificationCenter; std::string mLastFileFolder; ColorSchemePreference mUIColorScheme; void saveAllProcess(); void initLocateBar(); void initProjectTreeView( const std::string& path ); void initImageView(); void loadDirTree( const std::string& path ); void showSidePanel( bool show ); void onFileDropped( String file ); void onTextDropped( String text ); void updateEditorTitle( UICodeEditor* editor ); void updateEditorTabTitle( UICodeEditor* editor ); std::string titleFromEditor( UICodeEditor* editor ); bool tryTabClose( UICodeEditor* editor ); bool onCloseRequestCallback( EE::Window::Window* ); void addRemainingTabWidgets( Node* widget ); void createSettingsMenu(); UIMenu* createColorSchemeMenu(); void updateColorSchemeMenu(); UIMenu* createFileTypeMenu(); void updateCurrentFileType(); void updateEditorState(); void saveDoc(); void updateRecentFiles(); void updateRecentFolders(); void loadFolder( const std::string& path ); UIMenu* createViewMenu(); UIMenu* createEditMenu(); UIMenu* createWindowMenu(); UIMenu* createHelpMenu(); Drawable* findIcon( const std::string& name ); String i18n( const std::string& key, const String& def ); void updateProjectSettingsMenu(); UIMenu* createDocumentMenu(); void updateDocumentMenu(); void loadKeybindings(); std::map getDefaultKeybindings(); std::map getLocalKeybindings(); void onDocumentStateChanged( UICodeEditor*, TextDocument& ); void onDocumentModified( UICodeEditor* editor, TextDocument& ); void onColorSchemeChanged( const std::string& ); void onDocumentLoaded( UICodeEditor* editor, const std::string& path ); const CodeEditorConfig& getCodeEditorConfig() const; void onCodeEditorCreated( UICodeEditor*, TextDocument& doc ); void onDocumentSelectionChange( UICodeEditor* editor, TextDocument& ); void onDocumentCursorPosChange( UICodeEditor* editor, TextDocument& ); void onCodeEditorFocusChange( UICodeEditor* editor ); bool setAutoComplete( bool enable ); bool setLinter( bool enable ); bool setFormatter( bool enable ); void updateDocInfo( TextDocument& doc ); void setFocusEditorOnClose( UIMessageBox* msgBox ); UIPopUpMenu* createToolsMenu(); bool trySendUnlockedCmd( const KeyEvent& keyEvent ); void loadCurrentDirectory(); void toggleSettingsMenu(); FontTrueType* loadFont( const std::string& name, std::string fontPath, const std::string& fallback = "" ); void closeFolder(); void closeEditors(); void switchSidePanel(); void panelPosition( const PanelPosition& panelPosition ); void removeFolderWatches(); void createDocAlert( UICodeEditor* editor ); void syncProjectTreeWithEditor( UICodeEditor* editor ); void createProjectTreeMenu( const FileInfo& file ); void setUIColorScheme( const ColorSchemePreference& colorScheme ); }; } // namespace ecode #endif // ECODE_HPP