mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-07-14 23:12:49 +03:00
Added panel location configuration (left or right). Added default key modifier (CTRL on Linux and windows, META on macOS, ALT on Haiku). Optimized GlobalSearchController. Allow using $FILENAME in linter warning pattern. Optimized ProjectSearch. Added TextDocument delete on close option (default for temporal files downloaded from the Internet).
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
#ifndef FORMATTERMODULE_HPP
|
|
#define FORMATTERMODULE_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;
|
|
|
|
class FormatterModule : public UICodeEditorModule {
|
|
public:
|
|
FormatterModule( const std::string& formatterPath, std::shared_ptr<ThreadPool> 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<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 );
|
|
|
|
FormatterModule::Formatter supportsFormatter( std::shared_ptr<TextDocument> doc );
|
|
};
|
|
|
|
#endif // FORMATTERMODULE_HPP
|