| 1 |
////////////////////////////////////////////////////////////////////////////// |
| 2 |
////////////////////////////////////////////////////////////////////////////// |
| 3 |
// |
| 4 |
// copyright : (C) 2008 by Eran Ifrah |
| 5 |
// file name : codeformatter.h |
| 6 |
// |
| 7 |
// ------------------------------------------------------------------------- |
| 8 |
// A |
| 9 |
// _____ _ _ _ _ |
| 10 |
// / __ \ | | | | (_) | |
| 11 |
// | / \/ ___ __| | ___| | _| |_ ___ |
| 12 |
// | | / _ \ / _ |/ _ \ | | | __/ _ ) |
| 13 |
// | \__/\ (_) | (_| | __/ |___| | || __/ |
| 14 |
// \____/\___/ \__,_|\___\_____/_|\__\___| |
| 15 |
// |
| 16 |
// F i l e |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
////////////////////////////////////////////////////////////////////////////// |
| 24 |
////////////////////////////////////////////////////////////////////////////// |
| 25 |
#ifndef CODEFORMATTER_H |
| 26 |
#define CODEFORMATTER_H |
| 27 |
|
| 28 |
#include "CodeFormatterManager.hpp" |
| 29 |
#include "CodeLiteRemoteHelper.hpp" |
| 30 |
#include "cl_command_event.h" |
| 31 |
#include "fileextmanager.h" |
| 32 |
#include "plugin.h" |
| 33 |
|
| 34 |
#include <memory> |
| 35 |
|
| 36 |
class CodeFormatter : public IPlugin |
| 37 |
{ |
| 38 |
CodeFormatterManager m_manager; |
| 39 |
std::shared_ptr<CodeLiteRemoteHelper> m_remoteHelper; |
| 40 |
|
| 41 |
protected: |
| 42 |
wxString m_selectedFolder; |
| 43 |
|
| 44 |
private: |
| 45 |
std::shared_ptr<GenericFormatter> FindFormatter(const wxString& filepath, |
| 46 |
const wxString& content = wxEmptyString) const; |
| 47 |
bool DoFormatFile(const wxString& fileName, bool is_remote_format); |
| 48 |
bool DoFormatString(const wxString& content, const wxString& fileName, wxString* output); |
| 49 |
bool DoFormatEditor(IEditor* editor); |
| 50 |
void OnScanFilesCompleted(const std::vector<wxString>& files); |
| 51 |
void ReloadCurrentEditor(); |
| 52 |
void OnWorkspaceLoaded(clWorkspaceEvent& e); |
| 53 |
void OnWorkspaceClosed(clWorkspaceEvent& e); |
| 54 |
void OnFileSaved(clCommandEvent& e); |
| 55 |
|
| 56 |
void OnFormatCompleted(clSourceFormatEvent& event); |
| 57 |
void OnInplaceFormatCompleted(clSourceFormatEvent& event); |
| 58 |
|
| 59 |
public: |
| 60 |
/** |
| 61 |
* @brief format list of files |
| 62 |
*/ |
| 63 |
void BatchFormat(const std::vector<wxString>& files, bool silent = true); |
| 64 |
void OnContextMenu(clContextMenuEvent& event); |
| 65 |
|
| 66 |
CodeFormatter(IManager* manager); |
| 67 |
virtual ~CodeFormatter(); |
| 68 |
virtual void CreateToolBar(clToolBarGeneric* toolbar); |
| 69 |
virtual void CreatePluginMenu(wxMenu* pluginsMenu); |
| 70 |
virtual void HookPopupMenu(wxMenu* menu, MenuType type); |
| 71 |
virtual void UnPlug(); |
| 72 |
|
| 73 |
IManager* GetManager(); |
| 74 |
// event handlers |
| 75 |
void OnFormatEditor(wxCommandEvent& e); |
| 76 |
void OnSettings(wxCommandEvent& e); |
| 77 |
void OnFormatEditorUI(wxUpdateUIEvent& e); |
| 78 |
void OnSettingsUI(wxUpdateUIEvent& e); |
| 79 |
|
| 80 |
void OnFormatString(clSourceFormatEvent& e); |
| 81 |
void OnFormatFile(clSourceFormatEvent& e); |
| 82 |
void OnFormatFiles(wxCommandEvent& e); |
| 83 |
void OnFormatProject(wxCommandEvent& e); |
| 84 |
}; |
| 85 |
|
| 86 |
#endif // CODEFORMATTER_H |