mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-17 00:02:52 +03:00
ecode: Added version number and Help menu. Moved all project source files into the "ecode" namespace.
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
#ifndef ECODE_FORMATTERPLUGIN_HPP
|
|
#define ECODE_FORMATTERPLUGIN_HPP
|
|
|
|
#include <eepp/config.hpp>
|
|
#include <eepp/system/mutex.hpp>
|
|
#include <eepp/system/threadpool.hpp>
|
|
#include <eepp/ui/uicodeeditor.hpp>
|
|
#include <set>
|
|
using namespace EE;
|
|
using namespace EE::System;
|
|
using namespace EE::UI;
|
|
|
|
namespace ecode {
|
|
|
|
class FormatterPlugin : public UICodeEditorPlugin {
|
|
public:
|
|
FormatterPlugin( const std::string& formatterPath, std::shared_ptr<ThreadPool> pool );
|
|
|
|
virtual ~FormatterPlugin();
|
|
|
|
std::string getTitle() { return "Auto Formatter"; }
|
|
|
|
std::string getDescription() { return "Enables the code formatter/prettifier plugin."; }
|
|
|
|
void onRegister( UICodeEditor* );
|
|
|
|
void onUnregister( UICodeEditor* );
|
|
|
|
bool getAutoFormatOnSave() const;
|
|
|
|
void setAutoFormatOnSave( bool autoFormatOnSave );
|
|
|
|
protected:
|
|
enum class FormatterType { Inplace, Output };
|
|
|
|
struct Formatter {
|
|
std::vector<std::string> files;
|
|
std::string command;
|
|
FormatterType type{ FormatterType::Output };
|
|
};
|
|
|
|
std::shared_ptr<ThreadPool> mPool;
|
|
std::vector<Formatter> mFormatters;
|
|
std::set<UICodeEditor*> 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 );
|
|
|
|
FormatterPlugin::Formatter supportsFormatter( std::shared_ptr<TextDocument> doc );
|
|
};
|
|
|
|
}
|
|
|
|
#endif // ECODE_FORMATTERPLUGIN_HPP
|