#ifndef FORMATTERMODULE_HPP #define FORMATTERMODULE_HPP #include #include #include #include #include using namespace EE; using namespace EE::System; using namespace EE::UI; class FormatterModule : public UICodeEditorModule { public: FormatterModule( const std::string& formatterPath, std::shared_ptr pool ); virtual ~FormatterModule(); std::string getTitle() { return "Auto Formatter"; } std::string getDescription() { return "Enables the code formatter/prettifier module."; } void onRegister( UICodeEditor* ); void onUnregister( UICodeEditor* ); bool getAutoFormatOnSave() const; void setAutoFormatOnSave( bool autoFormatOnSave ); protected: enum class FormatterType { Inplace, Output }; struct Formatter { std::vector files; std::string command; FormatterType type{ FormatterType::Output }; }; std::shared_ptr mPool; std::vector mFormatters; std::set mEditors; bool mAutoFormatOnSave{ false }; bool mClosing{ false }; bool mReady{ false }; void load( const std::string& formatterPath ); void formatDoc( UICodeEditor* editor ); void runFormatter( UICodeEditor* editor, const Formatter& formatter, const std::string& path ); FormatterModule::Formatter supportsFormatter( std::shared_ptr doc ); }; #endif // FORMATTERMODULE_HPP