[DEV] transform plugin manager in unique resource
This commit is contained in:
parent
b8962cc3b9
commit
2c3a64933d
@ -41,6 +41,7 @@ appl::TextViewer::TextViewer() :
|
|||||||
|
|
||||||
// load buffer manager:
|
// load buffer manager:
|
||||||
m_bufferManager = appl::BufferManager::create();
|
m_bufferManager = appl::BufferManager::create();
|
||||||
|
m_pluginManager = appl::textPluginManager::create();
|
||||||
m_viewerManager = appl::ViewerManager::create();
|
m_viewerManager = appl::ViewerManager::create();
|
||||||
|
|
||||||
// load color properties
|
// load color properties
|
||||||
@ -58,7 +59,7 @@ appl::TextViewer::TextViewer() :
|
|||||||
void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) {
|
void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) {
|
||||||
ewol::widget::WidgetScrolled::init();
|
ewol::widget::WidgetScrolled::init();
|
||||||
m_displayText.setFont(_fontName, _fontSize);
|
m_displayText.setFont(_fontName, _fontSize);
|
||||||
appl::textPluginManager::connect(*this);
|
m_pluginManager->connect(*this);
|
||||||
// last created has focus ...
|
// last created has focus ...
|
||||||
setCurrentSelect();
|
setCurrentSelect();
|
||||||
signalShortcut.bind(shared_from_this(), &appl::TextViewer::onCallbackShortCut);
|
signalShortcut.bind(shared_from_this(), &appl::TextViewer::onCallbackShortCut);
|
||||||
@ -76,11 +77,11 @@ void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
appl::TextViewer::~TextViewer() {
|
appl::TextViewer::~TextViewer() {
|
||||||
appl::textPluginManager::disconnect(*this);
|
m_pluginManager->disconnect(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::TextViewer::onCallbackShortCut(const std::string& _value) {
|
void appl::TextViewer::onCallbackShortCut(const std::string& _value) {
|
||||||
if (appl::textPluginManager::onReceiveShortCut(*this, _value) == true) {
|
if (m_pluginManager->onReceiveShortCut(*this, _value) == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -383,7 +384,7 @@ bool appl::TextViewer::onEventEntry(const ewol::event::Entry& _event) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// First call plugin
|
// First call plugin
|
||||||
if (appl::textPluginManager::onEventEntry(*this, _event) == true) {
|
if (m_pluginManager->onEventEntry(*this, _event) == true) {
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -505,7 +506,7 @@ bool appl::TextViewer::onEventInput(const ewol::event::Input& _event) {
|
|||||||
}
|
}
|
||||||
APPL_VERBOSE("event : " << _event);
|
APPL_VERBOSE("event : " << _event);
|
||||||
// Second call plugin
|
// Second call plugin
|
||||||
if (appl::textPluginManager::onEventInput(*this, _event) == true) {
|
if (m_pluginManager->onEventInput(*this, _event) == true) {
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -751,7 +752,7 @@ bool appl::TextViewer::moveCursor(const appl::Buffer::Iterator& _pos) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
if (appl::textPluginManager::onCursorMove(*this, _pos) == true) {
|
if (m_pluginManager->onCursorMove(*this, _pos) == true) {
|
||||||
updateScrolling();
|
updateScrolling();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -775,13 +776,13 @@ bool appl::TextViewer::write(const std::string& _data, const appl::Buffer::Itera
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
if (appl::textPluginManager::onWrite(*this, _pos, _data) == true) {
|
if (m_pluginManager->onWrite(*this, _pos, _data) == true) {
|
||||||
// no call of the move cursor, because pluging might call theses function to copy and cut data...
|
// no call of the move cursor, because pluging might call theses function to copy and cut data...
|
||||||
updateScrolling();
|
updateScrolling();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool ret = m_buffer->write(_data, _pos);
|
bool ret = m_buffer->write(_data, _pos);
|
||||||
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor());
|
m_pluginManager->onCursorMove(*this, m_buffer->cursor());
|
||||||
updateScrolling();
|
updateScrolling();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -791,13 +792,13 @@ bool appl::TextViewer::replace(const std::string& _data, const appl::Buffer::Ite
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
if (appl::textPluginManager::onReplace(*this, _pos, _data, _posEnd) == true) {
|
if (m_pluginManager->onReplace(*this, _pos, _data, _posEnd) == true) {
|
||||||
// no call of the move cursor, because pluging might call theses function to copy and cut data...
|
// no call of the move cursor, because pluging might call theses function to copy and cut data...
|
||||||
updateScrolling();
|
updateScrolling();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool ret = m_buffer->replace(_data, _pos, _posEnd);
|
bool ret = m_buffer->replace(_data, _pos, _posEnd);
|
||||||
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor());
|
m_pluginManager->onCursorMove(*this, m_buffer->cursor());
|
||||||
updateScrolling();
|
updateScrolling();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -821,11 +822,11 @@ void appl::TextViewer::remove() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
markToRedraw();
|
markToRedraw();
|
||||||
if (appl::textPluginManager::onRemove(*this, m_buffer->selectStart(), m_buffer->selectStop()) == true) {
|
if (m_pluginManager->onRemove(*this, m_buffer->selectStart(), m_buffer->selectStop()) == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_buffer->removeSelection();
|
m_buffer->removeSelection();
|
||||||
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor());
|
m_pluginManager->onCursorMove(*this, m_buffer->cursor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
|
class textPluginManager;
|
||||||
class TextViewer : public ewol::widget::WidgetScrolled {
|
class TextViewer : public ewol::widget::WidgetScrolled {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<appl::GlyphPainting> m_paintingProperties; //!< element painting property
|
std::shared_ptr<appl::GlyphPainting> m_paintingProperties; //!< element painting property
|
||||||
@ -34,6 +35,7 @@ namespace appl {
|
|||||||
int32_t m_colorNormal;
|
int32_t m_colorNormal;
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
|
std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
|
||||||
|
std::shared_ptr<appl::textPluginManager> m_pluginManager; //!< Plugin manager interface
|
||||||
std::shared_ptr<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager
|
std::shared_ptr<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager
|
||||||
protected:
|
protected:
|
||||||
TextViewer();
|
TextViewer();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <appl/TextPlugin.h>
|
#include <appl/TextPlugin.h>
|
||||||
|
#include <appl/TextPluginManager.h>
|
||||||
#include <appl/debug.h>
|
#include <appl/debug.h>
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
@ -28,6 +29,8 @@ appl::TextViewerPlugin::TextViewerPlugin() :
|
|||||||
if (m_menuInterface.expired() == true) {
|
if (m_menuInterface.expired() == true) {
|
||||||
APPL_ERROR("Can not acces to the Menu interface");
|
APPL_ERROR("Can not acces to the Menu interface");
|
||||||
}
|
}
|
||||||
|
// get a reference on the plugin manager...
|
||||||
|
m_pluginManager = appl::textPluginManager::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::TextViewerPlugin::init() {
|
void appl::TextViewerPlugin::init() {
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
#include <ewol/widget/Menu.h>
|
#include <ewol/widget/Menu.h>
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
|
class textPluginManager;
|
||||||
class TextViewerPlugin : public ewol::Object {
|
class TextViewerPlugin : public ewol::Object {
|
||||||
friend class appl::TextViewer;
|
friend class appl::TextViewer;
|
||||||
|
protected:
|
||||||
|
std::weak_ptr<appl::textPluginManager> m_pluginManager;
|
||||||
protected:
|
protected:
|
||||||
TextViewerPlugin();
|
TextViewerPlugin();
|
||||||
void init();
|
void init();
|
||||||
|
@ -149,7 +149,10 @@ bool appl::TextPluginHistory::onDataWrite(appl::TextViewer& _textDrawer,
|
|||||||
clearRedo(_data);
|
clearRedo(_data);
|
||||||
_data.m_undo.push_back(tmpElement);
|
_data.m_undo.push_back(tmpElement);
|
||||||
}
|
}
|
||||||
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
std::shared_ptr<appl::textPluginManager> mng = m_pluginManager.lock();
|
||||||
|
if (mng!=nullptr) {
|
||||||
|
mng->onCursorMove(_textDrawer, _textDrawer.cursor());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +177,10 @@ bool appl::TextPluginHistory::onDataReplace(appl::TextViewer& _textDrawer,
|
|||||||
clearRedo(_data);
|
clearRedo(_data);
|
||||||
_data.m_undo.push_back(tmpElement);
|
_data.m_undo.push_back(tmpElement);
|
||||||
}
|
}
|
||||||
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
std::shared_ptr<appl::textPluginManager> mng = m_pluginManager.lock();
|
||||||
|
if (mng!=nullptr) {
|
||||||
|
mng->onCursorMove(_textDrawer, _textDrawer.cursor());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +202,10 @@ bool appl::TextPluginHistory::onDataRemove(appl::TextViewer& _textDrawer,
|
|||||||
_data.m_undo.push_back(tmpElement);
|
_data.m_undo.push_back(tmpElement);
|
||||||
}
|
}
|
||||||
_textDrawer.removeDirect();
|
_textDrawer.removeDirect();
|
||||||
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor());
|
std::shared_ptr<appl::textPluginManager> mng = m_pluginManager.lock();
|
||||||
|
if (mng!=nullptr) {
|
||||||
|
mng->onCursorMove(_textDrawer, _textDrawer.cursor());
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,58 +19,11 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "textPluginManager"
|
#define __class__ "textPluginManager"
|
||||||
|
|
||||||
static std::list<std::shared_ptr<appl::TextViewerPlugin>>& getList() {
|
appl::textPluginManager::textPluginManager() {
|
||||||
static std::list<std::shared_ptr<appl::TextViewerPlugin>> s_list;
|
|
||||||
return s_list;
|
|
||||||
}
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnEventEntry() {
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
|
|
||||||
return s_list;
|
|
||||||
}
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnEventInput() {
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
|
|
||||||
return s_list;
|
|
||||||
}
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnWrite() {
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
|
|
||||||
return s_list;
|
|
||||||
}
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnReplace() {
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
|
|
||||||
return s_list;
|
|
||||||
}
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnRemove() {
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
|
|
||||||
return s_list;
|
|
||||||
}
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListonReceiveShortCutViewer() {
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
|
|
||||||
return s_list;
|
|
||||||
}
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnCursorMove() {
|
|
||||||
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
|
|
||||||
return s_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::weak_ptr<appl::TextViewer>& getViewerConnected() {
|
|
||||||
static std::weak_ptr<appl::TextViewer> s_widget;
|
|
||||||
return s_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
void appl::textPluginManager::init() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void appl::textPluginManager::init(const std::string& _name) {
|
||||||
void appl::textPluginManager::unInit() {
|
ewol::Resource::init(_name);
|
||||||
// remove all sub plugin class:
|
|
||||||
getListOnEventEntry().clear();
|
|
||||||
getListOnEventInput().clear();
|
|
||||||
getListOnWrite().clear();
|
|
||||||
getListOnReplace().clear();
|
|
||||||
getListOnRemove().clear();
|
|
||||||
getListonReceiveShortCutViewer().clear();
|
|
||||||
getListOnCursorMove().clear();
|
|
||||||
getList().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::textPluginManager::addDefaultPlugin() {
|
void appl::textPluginManager::addDefaultPlugin() {
|
||||||
@ -88,37 +41,37 @@ void appl::textPluginManager::addPlugin(const std::shared_ptr<appl::TextViewerPl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
APPL_DEBUG("Add plugin : " << _plugin->getObjectType());
|
APPL_DEBUG("Add plugin : " << _plugin->getObjectType());
|
||||||
getList().push_back(_plugin);
|
m_list.push_back(_plugin);
|
||||||
if (_plugin->isAvaillableOnEventEntry() == true) {
|
if (_plugin->isAvaillableOnEventEntry() == true) {
|
||||||
getListOnEventEntry().push_back(_plugin);
|
m_listOnEventEntry.push_back(_plugin);
|
||||||
}
|
}
|
||||||
if (_plugin->isAvaillableOnEventInput() == true) {
|
if (_plugin->isAvaillableOnEventInput() == true) {
|
||||||
getListOnEventInput().push_back(_plugin);
|
m_listOnEventInput.push_back(_plugin);
|
||||||
}
|
}
|
||||||
if (_plugin->isAvaillableOnWrite() == true) {
|
if (_plugin->isAvaillableOnWrite() == true) {
|
||||||
getListOnWrite().push_back(_plugin);
|
m_listOnWrite.push_back(_plugin);
|
||||||
}
|
}
|
||||||
if (_plugin->isAvaillableOnReplace() == true) {
|
if (_plugin->isAvaillableOnReplace() == true) {
|
||||||
getListOnReplace().push_back(_plugin);
|
m_listOnReplace.push_back(_plugin);
|
||||||
}
|
}
|
||||||
if (_plugin->isAvaillableOnRemove() == true) {
|
if (_plugin->isAvaillableOnRemove() == true) {
|
||||||
getListOnRemove().push_back(_plugin);
|
m_listOnRemove.push_back(_plugin);
|
||||||
}
|
}
|
||||||
if (_plugin->isAvaillableOnReceiveShortCut() == true) {
|
if (_plugin->isAvaillableOnReceiveShortCut() == true) {
|
||||||
getListonReceiveShortCutViewer().push_back(_plugin);
|
m_listOnReceiveShortCutViewer.push_back(_plugin);
|
||||||
}
|
}
|
||||||
if (_plugin->isAvaillableOnCursorMove() == true) {
|
if (_plugin->isAvaillableOnCursorMove() == true) {
|
||||||
getListOnCursorMove().push_back(_plugin);
|
m_listOnCursorMove.push_back(_plugin);
|
||||||
}
|
}
|
||||||
std::shared_ptr<appl::TextViewer> viewer = getViewerConnected().lock();
|
std::shared_ptr<appl::TextViewer> viewer = m_currentViewer.lock();
|
||||||
if (viewer != nullptr) {
|
if (viewer != nullptr) {
|
||||||
_plugin->onPluginEnable(*viewer);
|
_plugin->onPluginEnable(*viewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::textPluginManager::connect(appl::TextViewer& _widget) {
|
void appl::textPluginManager::connect(appl::TextViewer& _widget) {
|
||||||
getViewerConnected() = std::dynamic_pointer_cast<appl::TextViewer>(_widget.shared_from_this());
|
m_currentViewer = std::dynamic_pointer_cast<appl::TextViewer>(_widget.shared_from_this());
|
||||||
for (auto &it : getList()) {
|
for (auto &it : m_list) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -127,8 +80,8 @@ void appl::textPluginManager::connect(appl::TextViewer& _widget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void appl::textPluginManager::disconnect(appl::TextViewer& _widget) {
|
void appl::textPluginManager::disconnect(appl::TextViewer& _widget) {
|
||||||
getViewerConnected().reset();
|
m_currentViewer.reset();
|
||||||
for (auto &it : getList()) {
|
for (auto &it : m_list) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -138,7 +91,7 @@ void appl::textPluginManager::disconnect(appl::TextViewer& _widget) {
|
|||||||
|
|
||||||
bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer,
|
bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer,
|
||||||
const ewol::event::Entry& _event) {
|
const ewol::event::Entry& _event) {
|
||||||
for (auto &it : getListOnEventEntry()) {
|
for (auto &it : m_listOnEventEntry) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -151,7 +104,7 @@ bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer,
|
|||||||
|
|
||||||
bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer,
|
bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer,
|
||||||
const ewol::event::Input& _event) {
|
const ewol::event::Input& _event) {
|
||||||
for (auto &it : getListOnEventInput()) {
|
for (auto &it : m_listOnEventInput) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -165,7 +118,7 @@ bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer,
|
|||||||
bool appl::textPluginManager::onWrite(appl::TextViewer& _textDrawer,
|
bool appl::textPluginManager::onWrite(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const std::string& _data) {
|
const std::string& _data) {
|
||||||
for (auto &it : getListOnWrite()) {
|
for (auto &it : m_listOnWrite) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -180,7 +133,7 @@ bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer,
|
|||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const std::string& _data,
|
const std::string& _data,
|
||||||
const appl::Buffer::Iterator& _posEnd) {
|
const appl::Buffer::Iterator& _posEnd) {
|
||||||
for (auto &it : getListOnReplace()) {
|
for (auto &it : m_listOnReplace) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -194,7 +147,7 @@ bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer,
|
|||||||
bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer,
|
bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const appl::Buffer::Iterator& _posEnd) {
|
const appl::Buffer::Iterator& _posEnd) {
|
||||||
for (auto &it : getListOnRemove()) {
|
for (auto &it : m_listOnRemove) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -207,7 +160,7 @@ bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer,
|
|||||||
|
|
||||||
bool appl::textPluginManager::onReceiveShortCut(appl::TextViewer& _textDrawer,
|
bool appl::textPluginManager::onReceiveShortCut(appl::TextViewer& _textDrawer,
|
||||||
const std::string& _shortCutName) {
|
const std::string& _shortCutName) {
|
||||||
for (auto &it : getListonReceiveShortCutViewer()) {
|
for (auto &it : m_listOnReceiveShortCutViewer) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -220,7 +173,7 @@ bool appl::textPluginManager::onReceiveShortCut(appl::TextViewer& _textDrawer,
|
|||||||
|
|
||||||
bool appl::textPluginManager::onCursorMove(appl::TextViewer& _textDrawer,
|
bool appl::textPluginManager::onCursorMove(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos) {
|
const appl::Buffer::Iterator& _pos) {
|
||||||
for (auto &it : getListOnCursorMove()) {
|
for (auto &it : m_listOnCursorMove) {
|
||||||
if (it == nullptr) {
|
if (it == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -16,98 +16,106 @@
|
|||||||
#include <appl/TextPlugin.h>
|
#include <appl/TextPlugin.h>
|
||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
namespace textPluginManager {
|
class textPluginManager : public ewol::Resource {
|
||||||
/**
|
private:
|
||||||
* @brief Init the plugin manager for writer.
|
std::weak_ptr<appl::TextViewer> m_currentViewer;
|
||||||
*/
|
std::list<std::shared_ptr<appl::TextViewerPlugin>> m_list;
|
||||||
void init();
|
std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnEventEntry;
|
||||||
/**
|
std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnEventInput;
|
||||||
* @brief UnInit the plugin manager for writer.
|
std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnWrite;
|
||||||
*/
|
std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnReplace;
|
||||||
void unInit();
|
std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnRemove;
|
||||||
/**
|
std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnReceiveShortCutViewer;
|
||||||
* @brief Add default plugin list
|
std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnCursorMove;
|
||||||
*/
|
protected:
|
||||||
void addDefaultPlugin();
|
textPluginManager();
|
||||||
/**
|
void init(const std::string& _name);
|
||||||
* @brief Add a plugin.
|
public:
|
||||||
* @param[in] _plugin Plugin pointer to add.
|
DECLARE_RESOURCE_SINGLE_FACTORY(textPluginManager, "plugin-Manager");
|
||||||
*/
|
virtual ~textPluginManager() {};
|
||||||
void addPlugin(const std::shared_ptr<appl::TextViewerPlugin>& _plugin);
|
/**
|
||||||
/**
|
* @brief Add default plugin list
|
||||||
* @brief connect a new widget to the plugin.
|
*/
|
||||||
* @param[in] _widget Reference on the widget caller.
|
void addDefaultPlugin();
|
||||||
*/
|
/**
|
||||||
void connect(appl::TextViewer& _widget);
|
* @brief Add a plugin.
|
||||||
/**
|
* @param[in] _plugin Plugin pointer to add.
|
||||||
* @brief dis-connect a new widget to the plugin.
|
*/
|
||||||
* @param[in] _widget Reference on the widget caller.
|
void addPlugin(const std::shared_ptr<appl::TextViewerPlugin>& _plugin);
|
||||||
*/
|
/**
|
||||||
void disconnect(appl::TextViewer& _widget);
|
* @brief connect a new widget to the plugin.
|
||||||
/**
|
* @param[in] _widget Reference on the widget caller.
|
||||||
* @brief On entry event call.
|
*/
|
||||||
* @param[in] _widget Reference on the widget caller.
|
void connect(appl::TextViewer& _widget);
|
||||||
* @param[in] _event Generic event.
|
/**
|
||||||
* @return true if the event might not propagate anymore.
|
* @brief dis-connect a new widget to the plugin.
|
||||||
*/
|
* @param[in] _widget Reference on the widget caller.
|
||||||
bool onEventEntry(appl::TextViewer& _widget,
|
*/
|
||||||
const ewol::event::Entry& _event);
|
void disconnect(appl::TextViewer& _widget);
|
||||||
/**
|
/**
|
||||||
* @brief On Input event call.
|
* @brief On entry event call.
|
||||||
* @param[in] _widget Reference on the widget caller.
|
* @param[in] _widget Reference on the widget caller.
|
||||||
* @param[in] _event Generic event.
|
* @param[in] _event Generic event.
|
||||||
* @return true if the event might not propagate anymore
|
* @return true if the event might not propagate anymore.
|
||||||
*/
|
*/
|
||||||
bool onEventInput(appl::TextViewer& _textDrawer,
|
bool onEventEntry(appl::TextViewer& _widget,
|
||||||
const ewol::event::Input& _event);
|
const ewol::event::Entry& _event);
|
||||||
/**
|
/**
|
||||||
* @brief Called when data is written in the buffer.
|
* @brief On Input event call.
|
||||||
* @param[in] _widget Reference on the widget caller.
|
* @param[in] _widget Reference on the widget caller.
|
||||||
* @param[in] _pos Position in the buffer where data might be witten.
|
* @param[in] _event Generic event.
|
||||||
* @param[in] _data Input stream written.
|
* @return true if the event might not propagate anymore
|
||||||
* @return true if the event might not propagate anymore
|
*/
|
||||||
*/
|
bool onEventInput(appl::TextViewer& _textDrawer,
|
||||||
bool onWrite(appl::TextViewer& _textDrawer,
|
const ewol::event::Input& _event);
|
||||||
const appl::Buffer::Iterator& _pos,
|
/**
|
||||||
const std::string& _data);
|
* @brief Called when data is written in the buffer.
|
||||||
/**
|
* @param[in] _widget Reference on the widget caller.
|
||||||
* @brief Called when data is written in the buffer, and some are removed.
|
* @param[in] _pos Position in the buffer where data might be witten.
|
||||||
* @param[in] _widget Reference on the widget caller.
|
* @param[in] _data Input stream written.
|
||||||
* @param[in] _pos Position in the buffer where data might be witten.
|
* @return true if the event might not propagate anymore
|
||||||
* @param[in] _data Input stream written.
|
*/
|
||||||
* @param[in] _posEnd end replace position.
|
bool onWrite(appl::TextViewer& _textDrawer,
|
||||||
* @return true if the event might not propagate anymore
|
const appl::Buffer::Iterator& _pos,
|
||||||
*/
|
const std::string& _data);
|
||||||
bool onReplace(appl::TextViewer& _textDrawer,
|
/**
|
||||||
const appl::Buffer::Iterator& _pos,
|
* @brief Called when data is written in the buffer, and some are removed.
|
||||||
const std::string& _data,
|
* @param[in] _widget Reference on the widget caller.
|
||||||
const appl::Buffer::Iterator& _posEnd);
|
* @param[in] _pos Position in the buffer where data might be witten.
|
||||||
/**
|
* @param[in] _data Input stream written.
|
||||||
* @brief Called when data is removed.
|
* @param[in] _posEnd end replace position.
|
||||||
* @param[in] _widget Reference on the widget caller.
|
* @return true if the event might not propagate anymore
|
||||||
* @param[in] _pos Position in the buffer where data might be witten.
|
*/
|
||||||
* @param[in] _posEnd end replace position.
|
bool onReplace(appl::TextViewer& _textDrawer,
|
||||||
* @return true if the event might not propagate anymore
|
const appl::Buffer::Iterator& _pos,
|
||||||
*/
|
const std::string& _data,
|
||||||
bool onRemove(appl::TextViewer& _textDrawer,
|
const appl::Buffer::Iterator& _posEnd);
|
||||||
const appl::Buffer::Iterator& _pos,
|
/**
|
||||||
const appl::Buffer::Iterator& _posEnd);
|
* @brief Called when data is removed.
|
||||||
/**
|
* @param[in] _widget Reference on the widget caller.
|
||||||
* @brief Called when a message arrive.
|
* @param[in] _pos Position in the buffer where data might be witten.
|
||||||
* @param[in] _widget Reference on the widget caller.
|
* @param[in] _posEnd end replace position.
|
||||||
* @param[in] _shortCutName shortcut properties.
|
* @return true if the event might not propagate anymore
|
||||||
* @return true if the event might not propagate anymore
|
*/
|
||||||
*/
|
bool onRemove(appl::TextViewer& _textDrawer,
|
||||||
bool onReceiveShortCut(appl::TextViewer& _textDrawer,
|
const appl::Buffer::Iterator& _pos,
|
||||||
const std::string& _shortCutName);
|
const appl::Buffer::Iterator& _posEnd);
|
||||||
/**
|
/**
|
||||||
* @brief Called when Cursor move of position.
|
* @brief Called when a message arrive.
|
||||||
* @param[in] _widget Reference on the widget caller.
|
* @param[in] _widget Reference on the widget caller.
|
||||||
* @param[in] _pos New cursor position.
|
* @param[in] _shortCutName shortcut properties.
|
||||||
* @return true if the event might not propagate anymore
|
* @return true if the event might not propagate anymore
|
||||||
*/
|
*/
|
||||||
bool onCursorMove(appl::TextViewer& _textDrawer,
|
bool onReceiveShortCut(appl::TextViewer& _textDrawer,
|
||||||
const appl::Buffer::Iterator& _pos);
|
const std::string& _shortCutName);
|
||||||
|
/**
|
||||||
|
* @brief Called when Cursor move of position.
|
||||||
|
* @param[in] _widget Reference on the widget caller.
|
||||||
|
* @param[in] _pos New cursor position.
|
||||||
|
* @return true if the event might not propagate anymore
|
||||||
|
*/
|
||||||
|
bool onCursorMove(appl::TextViewer& _textDrawer,
|
||||||
|
const appl::Buffer::Iterator& _pos);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) {
|
|||||||
m_menuIdSelectNone = -1;
|
m_menuIdSelectNone = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer,
|
bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer,
|
||||||
const std::string& _shortCutName) {
|
const std::string& _shortCutName) {
|
||||||
if (isEnable() == false) {
|
if (isEnable() == false) {
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
class MainApplication : public ewol::context::Application {
|
class MainApplication : public ewol::context::Application {
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<appl::BufferManager> m_bufferManager;
|
std::shared_ptr<appl::BufferManager> m_bufferManager;
|
||||||
|
std::shared_ptr<appl::textPluginManager> m_pluginManager;
|
||||||
public:
|
public:
|
||||||
bool init(ewol::Context& _context, size_t _initId) {
|
bool init(ewol::Context& _context, size_t _initId) {
|
||||||
APPL_INFO(" == > init APPL v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
|
APPL_INFO(" == > init APPL v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
|
||||||
@ -58,9 +59,9 @@ class MainApplication : public ewol::context::Application {
|
|||||||
// init ALL Singleton :
|
// init ALL Singleton :
|
||||||
//()CTagsManager::getInstance();
|
//()CTagsManager::getInstance();
|
||||||
m_bufferManager = appl::BufferManager::create();
|
m_bufferManager = appl::BufferManager::create();
|
||||||
|
m_pluginManager = appl::textPluginManager::create();
|
||||||
|
|
||||||
appl::highlightManager::init();
|
appl::highlightManager::init();
|
||||||
appl::textPluginManager::init();
|
|
||||||
|
|
||||||
// Request load of the user configuration ...
|
// Request load of the user configuration ...
|
||||||
//ewol::userConfig::load();
|
//ewol::userConfig::load();
|
||||||
@ -84,8 +85,7 @@ class MainApplication : public ewol::context::Application {
|
|||||||
_context.setWindows(basicWindows);
|
_context.setWindows(basicWindows);
|
||||||
|
|
||||||
// need to add default plugin, because they depend on the Menu widget wich might be named : "appl-menu-interface"
|
// need to add default plugin, because they depend on the Menu widget wich might be named : "appl-menu-interface"
|
||||||
appl::textPluginManager::addDefaultPlugin();
|
m_pluginManager->addDefaultPlugin();
|
||||||
|
|
||||||
|
|
||||||
// add files
|
// add files
|
||||||
APPL_INFO("show list of files : ");
|
APPL_INFO("show list of files : ");
|
||||||
@ -113,10 +113,10 @@ class MainApplication : public ewol::context::Application {
|
|||||||
}
|
}
|
||||||
void unInit(ewol::Context& _context) {
|
void unInit(ewol::Context& _context) {
|
||||||
APPL_INFO(" == > Un-Init " PROJECT_NAME " (START)");
|
APPL_INFO(" == > Un-Init " PROJECT_NAME " (START)");
|
||||||
appl::textPluginManager::unInit();
|
|
||||||
APPL_INFO("Stop Hightlight");
|
APPL_INFO("Stop Hightlight");
|
||||||
appl::highlightManager::unInit();
|
appl::highlightManager::unInit();
|
||||||
//Kill all singleton
|
//Kill all singleton
|
||||||
|
m_pluginManager.reset();
|
||||||
m_bufferManager.reset();
|
m_bufferManager.reset();
|
||||||
APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)");
|
APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user