diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..fa6ae6f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,39 @@ +# language type: +language: cpp + +# compilator system: +compiler: +- clang +- gcc + +# build branch requested +branches: + only: + - master + - dev + +# previous actions: +before_script: + - git clone https://github.com/HeeroYui/ewol.git + - cd ewol; git checkout origin/dev -b dev; cd .. + - cd ewol; git submodule init; cd .. + - cd ewol; git submodule update; cd .. + +install: + - if [ "$CXX" == "g++" ]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y; fi + - if [ "$CXX" == "g++" ]; then sudo apt-get update -qq; fi + - if [ "$CXX" == "g++" ]; then sudo apt-get install -qq g++-4.8; fi + - if [ "$CXX" == "g++" ]; then sudo rm /usr/bin/gcc /usr/bin/g++; fi + - if [ "$CXX" == "g++" ]; then sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc; fi + - if [ "$CXX" == "g++" ]; then sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++; fi + + +# build sequence with Lutin : +script: + - if [ "$CXX" == "clang++" ]; then ./ewol/build/lutin.py -cclang -mdebug -p edn; fi + - if [ "$CXX" == "g++" ]; then ./ewol/build/lutin.py -cgcc -mdebug -p edn; fi + +#send e-mail on compilation result: +notifications: + email: + - yui.heero@gmail.com diff --git a/data/languages/bash/highlight.xml b/data/languages/bash/highlight.xml index 6f32014..cc334a6 100644 --- a/data/languages/bash/highlight.xml +++ b/data/languages/bash/highlight.xml @@ -28,10 +28,12 @@ keyword [\$]+[a-zA-Z_][a-zA-Z0-9_]* + boolean ==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}| diff --git a/data/languages/c/highlight.xml b/data/languages/c/highlight.xml index d0ea594..941f4fc 100644 --- a/data/languages/c/highlight.xml +++ b/data/languages/c/highlight.xml @@ -44,7 +44,7 @@ doubleQuoteText - "(\\[\\"]|.)*" + "(\\[\\"]|.)*" doubleQuoteText @@ -99,11 +99,14 @@ inputFunction \@_[A-Za-z_0-9]*\@ + false + boolean ==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}| diff --git a/data/languages/cmake/highlight.xml b/data/languages/cmake/highlight.xml index 8144806..3713d9a 100644 --- a/data/languages/cmake/highlight.xml +++ b/data/languages/cmake/highlight.xml @@ -41,10 +41,11 @@ macro \@[A-Z_][A-Z_0-9]{3,500}\@ + diff --git a/data/languages/java/highlight.xml b/data/languages/java/highlight.xml index 68e3a55..73c11b7 100644 --- a/data/languages/java/highlight.xml +++ b/data/languages/java/highlight.xml @@ -64,10 +64,12 @@ macro \@[A-Z_][A-Z_0-9]{3,500}\@ + boolean ==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}| diff --git a/data/languages/lua/highlight.xml b/data/languages/lua/highlight.xml index ad52fbf..baff8d4 100644 --- a/data/languages/lua/highlight.xml +++ b/data/languages/lua/highlight.xml @@ -40,10 +40,12 @@ macro \@[A-Z_][A-Z_0-9]{3,500}\@ + boolean ==|<=|>=|~=|<{1,2}|>{1,2}|&&|\{|\}| diff --git a/data/languages/matlab/highlight.xml b/data/languages/matlab/highlight.xml index ebb5afe..511101e 100644 --- a/data/languages/matlab/highlight.xml +++ b/data/languages/matlab/highlight.xml @@ -33,10 +33,12 @@ boolean \@true|false\@ + boolean ==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}| diff --git a/data/languages/php/highlight.xml b/data/languages/php/highlight.xml index 1b9bac6..c8661ff 100644 --- a/data/languages/php/highlight.xml +++ b/data/languages/php/highlight.xml @@ -55,10 +55,12 @@ boolean \@true|TRUE|false|FALSE\@ + boolean ==|<=|>=|!=|<|>|&&|\{|\}| diff --git a/data/languages/python/highlight.xml b/data/languages/python/highlight.xml index 83b8b21..11d8865 100644 --- a/data/languages/python/highlight.xml +++ b/data/languages/python/highlight.xml @@ -56,10 +56,12 @@ macro \@[A-Z_][A-Z_0-9]{3,500}\@ + boolean ==|<=|>=|!=|<{1,2}|>{1,2}|&&|\{|\}| diff --git a/lutinBase.py b/lutinBase.py deleted file mode 100755 index 66fc5f2..0000000 --- a/lutinBase.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/python -import lutinModule -import lutinTools - -lutinModule.import_path(lutinTools.get_current_path(__file__) + "/sources/") -lutinModule.import_path(lutinTools.get_current_path(__file__) + "/../ewol/") diff --git a/sources/appl/Buffer.cpp b/sources/appl/Buffer.cpp index edeaa2c..182593e 100644 --- a/sources/appl/Buffer.cpp +++ b/sources/appl/Buffer.cpp @@ -17,11 +17,6 @@ #undef __class__ #define __class__ "Buffer" -const char* const appl::Buffer::eventIsModify = "edn-is-modify"; -const char* const appl::Buffer::eventIsSave = "edn-is-save"; -const char* const appl::Buffer::eventSelectChange = "edn-select-change"; -const char* const appl::Buffer::eventChangeName = "edn-buffer-name-change"; - appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ () { m_value = u32char::Null; if (m_current < 0) { @@ -119,8 +114,11 @@ appl::Buffer::Iterator appl::Buffer::selectStop() { return position( getStopSelectionPos() ); } - appl::Buffer::Buffer() : + signalIsModify(*this, "is-modify"), + signalIsSave(*this, "is-save"), + signalSelectChange(*this, "select-change"), + signalChangeName(*this, "change-name"), m_hasFileName(false), m_fileName(""), m_isModify(false), @@ -133,10 +131,6 @@ appl::Buffer::Buffer() : static int32_t bufferBaseId = 0; m_fileName = "No Name " + etk::to_string(bufferBaseId); bufferBaseId++; - addEventId(eventIsModify); - addEventId(eventIsSave); - addEventId(eventSelectChange); - addEventId(eventChangeName); } void appl::Buffer::init() { @@ -144,7 +138,7 @@ void appl::Buffer::init() { } appl::Buffer::~Buffer() { - + APPL_ERROR("REAL remove buffer : '" << m_name << "'"); } bool appl::Buffer::loadFile(const std::string& _name) { @@ -176,7 +170,7 @@ void appl::Buffer::setFileName(const std::string& _name) { } m_fileName = name; m_hasFileName = true; - generateEventId(eventChangeName); + signalChangeName.emit(); setModification(true); } @@ -195,9 +189,9 @@ void appl::Buffer::setModification(bool _status) { } m_isModify = _status; if (m_isModify == true) { - generateEventId(eventIsModify); + signalIsModify.emit(); } else { - generateEventId(eventIsSave); + signalIsSave.emit(); } } @@ -420,13 +414,13 @@ void appl::Buffer::moveCursor(int64_t _pos) { if (m_cursorPos == m_cursorSelectPos) { m_cursorSelectPos = -1; } - generateEventId(eventSelectChange); + signalSelectChange.emit(); return; } // move mode m_cursorPos = _pos; m_cursorSelectPos = -1; - generateEventId(eventSelectChange); + signalSelectChange.emit(); } bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos, @@ -519,12 +513,12 @@ bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos, void appl::Buffer::setSelectionPos(const appl::Buffer::Iterator& _pos) { m_cursorSelectPos = _pos; - generateEventId(eventSelectChange); + signalSelectChange.emit(); } void appl::Buffer::unSelect() { m_cursorSelectPos = -1; - generateEventId(eventSelectChange); + signalSelectChange.emit(); } static const char *ControlCodeTable[32] = { @@ -993,3 +987,41 @@ uint32_t appl::Buffer::getCursorLinesId() { } return line; } + +namespace etk { + template<> std::string to_string>(const std::shared_ptr& _obj) { + if (_obj != nullptr) { + return _obj->getFileName(); + } + return ""; + } + template<> std::u32string to_u32string>(const std::shared_ptr& _obj) { + return etk::to_u32string(etk::to_string(_obj)); + } + + template<> bool from_string>(std::shared_ptr& _variableRet, const std::string& _value) { + if (_variableRet != nullptr) { + _variableRet->loadFile(_value); + return true; + } + return false; + } + template<> bool from_string>(std::shared_ptr& _variableRet, const std::u32string& _value) { + return from_string(_variableRet, etk::to_string(_value)); + } + template<> std::string to_string(const appl::Buffer& _obj) { + return _obj.getFileName(); + } + template<> std::u32string to_u32string(const appl::Buffer& _obj) { + return etk::to_u32string(etk::to_string(_obj)); + } + + template<> bool from_string(appl::Buffer& _variableRet, const std::string& _value) { + _variableRet.loadFile(_value); + return true; + } + template<> bool from_string(appl::Buffer& _variableRet, const std::u32string& _value) { + return from_string(_variableRet, etk::to_string(_value)); + } +}; + diff --git a/sources/appl/Buffer.h b/sources/appl/Buffer.h index 9891212..d413227 100644 --- a/sources/appl/Buffer.h +++ b/sources/appl/Buffer.h @@ -17,6 +17,7 @@ #include #include #include +#include namespace appl { @@ -288,10 +289,10 @@ namespace appl { friend class Buffer; }; public: - static const char* const eventIsModify; - static const char* const eventIsSave; - static const char* const eventSelectChange; - static const char* const eventChangeName; + ewol::object::Signal signalIsModify; + ewol::object::Signal signalIsSave; + ewol::object::Signal signalSelectChange; + ewol::object::Signal signalChangeName; protected: Buffer(); void init(); @@ -305,14 +306,14 @@ namespace appl { /** * @brief get the curent filename of the Buffer */ - const std::string& getFileName() { + const std::string& getFileName() const { return m_fileName; } /** * @brief Check if the buffer has a real filename. * @return the status of the existance of a name. */ - bool hasFileName() { + bool hasFileName() const { return m_hasFileName; } /** diff --git a/sources/appl/BufferManager.cpp b/sources/appl/BufferManager.cpp index 591a08f..0a71571 100644 --- a/sources/appl/BufferManager.cpp +++ b/sources/appl/BufferManager.cpp @@ -18,7 +18,11 @@ #undef __class__ #define __class__ "BufferManager" -appl::BufferManager::BufferManager() { +appl::BufferManager::BufferManager() : + signalNewBuffer(*this, "new-buffer"), + signalSelectFile(*this, "select-buffer"), + signalTextSelectionChange(*this, "text-selection-change"), + signalRemoveBuffer(*this, "remove-buffer") { addObjectType("appl::BufferManager"); } @@ -37,13 +41,19 @@ std::shared_ptr appl::BufferManager::createNewBuffer() { APPL_ERROR("Can not allocate the Buffer (empty)."); return nullptr; } + tmp->setParent(shared_from_this()); m_list.push_back(tmp); - sendMultiCast(appl::MsgSelectNewFile, tmp->getFileName()); + APPL_INFO("Create a new Buffer"); + signalNewBuffer.emit(tmp->getFileName()); + APPL_INFO("Create a new Buffer (done)"); + APPL_INFO("select Buffer"); + signalSelectFile.emit(tmp->getFileName()); + APPL_INFO("select Buffer (done)"); return tmp; } std::shared_ptr appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) { - APPL_INFO("get(" << _fileName << "," << _createIfNeeded << ")"); + APPL_INFO("get('" << _fileName << "'," << _createIfNeeded << ")"); for (auto &it : m_list) { if (it == nullptr) { continue; @@ -63,15 +73,26 @@ std::shared_ptr appl::BufferManager::get(const std::string& _fileN APPL_ERROR("Can not allocate the Buffer class : " << _fileName); return nullptr; } + tmp->setParent(shared_from_this()); tmp->loadFile(_fileName); m_list.push_back(tmp); + APPL_INFO("Creata a open Buffer"); + signalNewBuffer.emit(tmp->getFileName()); + APPL_INFO("Creata a open Buffer (done)"); return tmp; } return nullptr; } + void appl::BufferManager::setBufferSelected(std::shared_ptr _bufferSelected) { m_bufferSelected = _bufferSelected; - sendMultiCast(appl::MsgSelectChange, ""); + if (m_bufferSelected == nullptr) { + APPL_ERROR("select a NULL buffer ..."); + return; + } + APPL_INFO("Set buffer selected"); + //signalSelectFile.emit(m_bufferSelected->getName()); + APPL_INFO("Set buffer selected (done)"); } std::shared_ptr appl::BufferManager::get(int32_t _id) { @@ -99,15 +120,42 @@ bool appl::BufferManager::exist(const std::string& _fileName) { void appl::BufferManager::open(const std::string& _fileName) { if (exist(_fileName) == true) { + APPL_WARNING(" the element '" << _fileName << "' already exist ... just reselect it ..."); + signalSelectFile.emit(_fileName); return; } if (get(_fileName, true) == nullptr) { + APPL_ERROR("Error get '" << _fileName << "' ... "); return; } - sendMultiCast(appl::MsgSelectNewFile, _fileName); + signalSelectFile.emit(_fileName); } -void appl::BufferManager::onReceiveMessage(const ewol::object::Message& _msg) { - APPL_DEBUG("receive message !!! " << _msg); -} +void appl::BufferManager::requestDestroyFromChild(const std::shared_ptr& _child) { + APPL_WARNING("Buffer request a close..."); + bool find = false; + int32_t newValue = -1; + auto it = m_list.begin(); + while(it != m_list.end()) { + if (*it == nullptr) { + it = m_list.erase(it); + continue; + } + if (*it == _child) { + it = m_list.erase(it); + find = true; + break; + } + newValue++; + ++it; + } + if (find == true) { + signalRemoveBuffer.emit(std::dynamic_pointer_cast(_child)); + } + if (m_bufferSelected == _child) { + APPL_ERROR("is selected"); + signalSelectFile.emit(""); + m_bufferSelected = nullptr; + } +} diff --git a/sources/appl/BufferManager.h b/sources/appl/BufferManager.h index af749de..c27fe89 100644 --- a/sources/appl/BufferManager.h +++ b/sources/appl/BufferManager.h @@ -18,6 +18,11 @@ namespace appl { class BufferManager : public ewol::Resource { public: + ewol::object::Signal signalNewBuffer; + ewol::object::Signal signalSelectFile; + ewol::object::Signal signalTextSelectionChange; + ewol::object::Signal> signalRemoveBuffer; + protected: BufferManager(); void init(const std::string& _uniqueName); public: @@ -77,8 +82,8 @@ namespace appl { std::shared_ptr getBufferSelected() { return m_bufferSelected; }; - public: // herited function - void onReceiveMessage(const ewol::object::Message& _msg); + private: + void requestDestroyFromChild(const std::shared_ptr& _child); }; }; diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index b3d9c5f..bb05ba5 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -17,20 +17,15 @@ #undef __class__ #define __class__ "BufferView" -static void SortElementList(std::vector& _list) { - std::vector tmpList = _list; +// TODO : write it better +static void SortElementList(std::vector& _list) { + std::vector tmpList = _list; _list.clear(); for(size_t iii=0; iiim_bufferName.getNameFile() > _list[jjj]->m_bufferName.getNameFile()) { + if (tmpList[iii].m_bufferName.getNameFile() > _list[jjj].m_bufferName.getNameFile()) { findPos = jjj+1; } } @@ -59,12 +54,11 @@ BufferView::BufferView() : void BufferView::init() { ewol::widget::List::init(); - registerMultiCast(ednMsgBufferListChange); - registerMultiCast(ednMsgBufferState); - registerMultiCast(ednMsgBufferId); - registerMultiCast(appl::MsgSelectNewFile); - registerMultiCast(appl::MsgSelectChange); - registerMultiCast(appl::MsgNameChange); + if (m_bufferManager != nullptr) { + m_bufferManager->signalNewBuffer.bind(shared_from_this(), &BufferView::onCallbackNewBuffer); + m_bufferManager->signalSelectFile.bind(shared_from_this(), &BufferView::onCallbackselectNewFile); + m_bufferManager->signalRemoveBuffer.bind(shared_from_this(), &BufferView::onCallbackBufferRemoved); + } } BufferView::~BufferView() { @@ -72,154 +66,95 @@ BufferView::~BufferView() { } void BufferView::removeAllElement() { - for(auto &it : m_list) { - delete(it); - it = nullptr; - } m_list.clear(); } -void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition) { - if (_dataStruct == nullptr) { - return; - } +void BufferView::insertAlphabetic(const appl::dataBufferStruct& _dataStruct, bool _selectNewPosition) { // alphabetical order: for (size_t iii = 0; iii < m_list.size(); ++iii) { - if (m_list[iii] == nullptr) { - continue; - } - if (etk::tolower(m_list[iii]->m_bufferName.getNameFile()) > etk::tolower(_dataStruct->m_bufferName.getNameFile())) { + if (etk::tolower(m_list[iii].m_bufferName.getNameFile()) > etk::tolower(_dataStruct.m_bufferName.getNameFile())) { m_list.insert(m_list.begin() + iii, _dataStruct); - _dataStruct = nullptr; if (_selectNewPosition == true) { m_selectedID = iii; } - break; + return; } } - if (_dataStruct != nullptr) { - m_list.push_back(_dataStruct); - if (_selectNewPosition == true) { - m_selectedID = m_list.size()-1; - } + m_list.push_back(_dataStruct); + if (_selectNewPosition == true) { + m_selectedID = m_list.size()-1; } } +void BufferView::onCallbackNewBuffer(const std::string& _value) { + std::shared_ptr buffer = m_bufferManager->get(_value); + if (buffer == nullptr) { + APPL_ERROR("event on element nor exist : " << _value); + return; + } + buffer->signalIsSave.bind(shared_from_this(), &BufferView::onCallbackIsSave); + buffer->signalIsModify.bind(shared_from_this(), &BufferView::onCallbackIsModify); + buffer->signalChangeName.bind(shared_from_this(), &BufferView::onCallbackChangeName); + appl::dataBufferStruct tmp(_value, buffer); + if (m_openOrderMode == true) { + m_list.push_back(tmp); + } else { + insertAlphabetic(tmp); + } + markToRedraw(); +} -void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { - APPL_VERBOSE("message : " << _msg); - ewol::widget::List::onReceiveMessage(_msg); - if (_msg.getMessage() == appl::MsgSelectNewFile) { - std::shared_ptr buffer = m_bufferManager->get(_msg.getData()); - if (buffer == nullptr) { - APPL_ERROR("event on element nor exist : " << _msg.getData()); - return; +// TODO : Review this callback with the real shared_ptr on the buffer ... +void BufferView::onCallbackselectNewFile(const std::string& _value) { + m_selectedID = -1; + for (size_t iii=0; iiiregisterOnEvent(shared_from_this(), appl::Buffer::eventIsSave); - buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify); - buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventChangeName); - appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer); - if (tmp == nullptr) { - APPL_ERROR("Allocation error of the tmp buffer list element"); - return; + if (m_list[iii].m_buffer->getFileName() != _value) { + continue; } - if (m_openOrderMode == true) { - m_list.push_back(tmp); - } else { - insertAlphabetic(tmp); - } - markToRedraw(); - return; + m_selectedID = iii; + break; } - if (_msg.getMessage() == appl::Buffer::eventChangeName) { - for (size_t iii = 0; iii < m_list.size(); ++iii) { - if (m_list[iii] == nullptr) { - continue; - } - if (m_list[iii]->m_bufferName != m_list[iii]->m_buffer->getFileName()) { - m_list[iii]->m_bufferName = m_list[iii]->m_buffer->getFileName(); - if (m_openOrderMode == false) { - // re-order the fine in the correct position - appl::dataBufferStruct* tmp = m_list[iii]; - m_list[iii] = nullptr; - m_list.erase(m_list.begin() + iii); - insertAlphabetic(tmp, ((int64_t)iii == m_selectedID)); - break; - } - } - } - markToRedraw(); - return; - } - if (_msg.getMessage() == appl::Buffer::eventIsSave) { - markToRedraw(); - return; - } - if (_msg.getMessage() == appl::Buffer::eventIsModify) { - markToRedraw(); - return; - } - if (_msg.getMessage() == appl::MsgSelectChange) { - m_selectedID = -1; - std::shared_ptr tmpBuffer; - if (m_bufferManager != nullptr) { - tmpBuffer = m_bufferManager->getBufferSelected(); - } - if (tmpBuffer != nullptr) { - for (size_t iii=0; iiim_buffer != tmpBuffer) { - continue; - } - m_selectedID = iii; + markToRedraw(); +} + +void BufferView::onCallbackChangeName() { + for (size_t iii = 0; iii < m_list.size(); ++iii) { + if (m_list[iii].m_bufferName != m_list[iii].m_buffer->getFileName()) { + m_list[iii].m_bufferName = m_list[iii].m_buffer->getFileName(); + if (m_openOrderMode == false) { + // re-order the fine in the correct position + appl::dataBufferStruct tmp = m_list[iii]; + m_list.erase(m_list.begin() + iii); + insertAlphabetic(tmp, ((int64_t)iii == m_selectedID)); break; } } - markToRedraw(); - return; - } - if (_msg.getMessage() == ednMsgBufferListChange) { - // clean The list - removeAllElement(); - // get all the buffer name and properties: - size_t nbBufferOpen = 0; // BufferManager::size(); - for (size_t iii=0; iiiisModify(); - etk::FSNode name = tmpBuffer->getFileName(); - appl::dataBufferStruct* tmpElement = new appl::dataBufferStruct(name, iii, isModify); - if (nullptr != tmpElement) { - m_list.push_back(tmpElement); - } else { - APPL_ERROR("Allocation error of the tmp buffer list element"); - } - } - } - */ - } - if (true == globals::OrderTheBufferList() ) { - SortElementList(m_list); - } - markToRedraw(); - }else if (_msg.getMessage() == ednMsgBufferId) { - m_selectedIdRequested = 0; //BufferManager::getSelected(); - markToRedraw(); - }else if (_msg.getMessage() == ednMsgBufferState) { - // update list of modify section ... - for (auto &it : m_list) { - if (it != nullptr) { - //it->m_isModify = BufferManager::get(it->m_bufferID)->isModify(); - } - } - markToRedraw(); } + markToRedraw(); } +void BufferView::onCallbackBufferRemoved(const std::shared_ptr& _buffer) { + APPL_ERROR("request remove buffer:"); + auto it = m_list.begin(); + while (it != m_list.end()) { + if (it->m_buffer == _buffer) { + it = m_list.erase(it); + m_selectedID = -1; + } else { + ++it; + } + } + markToRedraw(); +} +void BufferView::onCallbackIsSave() { + markToRedraw(); +} +void BufferView::onCallbackIsModify() { + markToRedraw(); +} etk::Color<> BufferView::getBasicBG() { return (*m_paintingProperties)[m_colorBackground1].getForeground(); @@ -240,12 +175,11 @@ uint32_t BufferView::getNuberOfRaw() { bool BufferView::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) { if( _raw >= 0 - && _raw<(int64_t)m_list.size() - && m_list[_raw] != nullptr) { - _myTextToWrite = m_list[_raw]->m_bufferName.getNameFile(); + && _raw<(int64_t)m_list.size() ) { + _myTextToWrite = m_list[_raw].m_bufferName.getNameFile(); - if ( m_list[_raw]->m_buffer != nullptr - && m_list[_raw]->m_buffer->isModify() == false) { + if ( m_list[_raw].m_buffer != nullptr + && m_list[_raw].m_buffer->isModify() == false) { _fg = (*m_paintingProperties)[m_colorTextNormal].getForeground(); } else { _fg = (*m_paintingProperties)[m_colorTextModify].getForeground(); @@ -265,17 +199,16 @@ bool BufferView::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextT return true; } -bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) -{ +bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) { if (1 == _IdInput && _typeEvent == ewol::key::statusSingle) { APPL_INFO("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw ); if( _raw >= 0 - && _raw<(int64_t)m_list.size() - && nullptr != m_list[_raw]) { - if (m_list[_raw]->m_buffer != nullptr) { - sendMultiCast(appl::MsgSelectNewFile, m_list[_raw]->m_buffer->getFileName()); - m_selectedID = _raw; - markToRedraw(); + && _raw<(int64_t)m_list.size()) { + if (m_list[_raw].m_buffer != nullptr) { + if (m_bufferManager != nullptr) { + APPL_INFO("Select file :" << m_list[_raw].m_buffer->getFileName() << " in list"); + m_bufferManager->open(m_list[_raw].m_buffer->getFileName()); + } return true; } } diff --git a/sources/appl/Gui/BufferView.h b/sources/appl/Gui/BufferView.h index e3c3a3b..485e627 100644 --- a/sources/appl/Gui/BufferView.h +++ b/sources/appl/Gui/BufferView.h @@ -42,12 +42,12 @@ class BufferView : public ewol::widget::List { private: int32_t m_selectedIdRequested; int32_t m_selectedID; - std::vector m_list; + std::vector m_list; /** * @brief Insert the element in the alphabetic order. * @param[in] _dataStruct element to add. */ - void insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition = false); + void insertAlphabetic(const appl::dataBufferStruct& _dataStruct, bool _selectNewPosition = false); protected: // Constructeur BufferView(); @@ -55,8 +55,6 @@ class BufferView : public ewol::widget::List { public: DECLARE_FACTORY(BufferView); virtual ~BufferView(); - // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); private: bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order protected: @@ -69,6 +67,13 @@ class BufferView : public ewol::widget::List { virtual uint32_t getNuberOfRaw(); virtual bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg); virtual bool onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y); + private: //callback function: + void onCallbackChangeName(); + void onCallbackIsSave(); + void onCallbackIsModify(); + void onCallbackNewBuffer(const std::string& _value); + void onCallbackselectNewFile(const std::string& _value); + void onCallbackBufferRemoved(const std::shared_ptr& _buffer); }; diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index e0f0993..f3560a2 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -172,105 +172,66 @@ void MainWindows::init() { mySizerVert2->subWidgetAdd(myTextView); */ // search area : - std::shared_ptr mySearch = appl::widget::Search::create(); - mySizerVert2->subWidgetAdd(mySearch); + m_widgetSearch = appl::widget::Search::create(); + mySizerVert2->subWidgetAdd(m_widgetSearch); mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori); mySizerHori->setName("plop 555555"); mySizerVert->subWidgetAdd(mySizerHori); myMenu = ewol::widget::Menu::create(); + myMenu->setName("appl-menu-interface"); mySizerHori->subWidgetAdd(myMenu); int32_t idMenuFile = myMenu->addTitle("File"); - myMenu->add(idMenuFile, "New", "", ednMsgGuiNew); + myMenu->add(idMenuFile, "New", "", "menu:new"); myMenu->addSpacer(); - myMenu->add(idMenuFile, "Open", "THEME:GUI:Load.edf", ednMsgGuiOpen); - myMenu->add(idMenuFile, "Close", "THEME:GUI:Close.edf", ednMsgGuiClose, "current"); - myMenu->add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All"); - myMenu->add(idMenuFile, "Save", "THEME:GUI:Save.edf", ednMsgGuiSave, "current"); - myMenu->add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs); + myMenu->add(idMenuFile, "Open", "THEME:GUI:Load.edf", "menu:open"); + myMenu->add(idMenuFile, "Close", "THEME:GUI:Close.edf", "menu:close"); + myMenu->add(idMenuFile, "Close (all)", "", "menu:close-all"); + myMenu->add(idMenuFile, "Save", "THEME:GUI:Save.edf", "menu:save"); + myMenu->add(idMenuFile, "Save As ...", "", "menu:save-as"); myMenu->addSpacer(); - //myMenu->add(idMenuFile, "Exit", "", ednMsgGuiExit); - myMenu->addSpacer(); - myMenu->add(idMenuFile, "Properties", "THEME:GUI:Parameter.edf", ednMsgProperties); + myMenu->add(idMenuFile, "Properties", "THEME:GUI:Parameter.edf", "menu:property"); int32_t idMenuEdit = myMenu->addTitle("Edit"); - myMenu->add(idMenuEdit, "Undo", "THEME:GUI:Undo.edf", ednMsgGuiUndo); - myMenu->add(idMenuEdit, "Redo", "THEME:GUI:Redo.edf", ednMsgGuiRedo); - myMenu->addSpacer(); - myMenu->add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD"); - myMenu->add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD"); - myMenu->add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD"); - myMenu->add(idMenuEdit, "Remove", "", ednMsgGuiRm); - myMenu->addSpacer(); - myMenu->add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL"); - myMenu->add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE"); - myMenu->add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???"); + myMenu->add(idMenuEdit, "Goto line ...","", "menu:goto-line"); int32_t idMenuSearch = myMenu->addTitle("Search"); - myMenu->add(idMenuSearch, "Search", "THEME:GUI:Search.edf", ednMsgGuiSearch); - myMenu->add(idMenuSearch, "Replace", "THEME:GUI:Replace.edf", ednMsgGuiReplace); + myMenu->add(idMenuSearch, "Search", "THEME:GUI:Search.edf", "menu:search"); + myMenu->add(idMenuSearch, "Replace", "THEME:GUI:Replace.edf", "menu:replace"); myMenu->addSpacer(); - myMenu->add(idMenuSearch, "Find (previous)","", ednMsgGuiFind, "Previous"); - myMenu->add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next"); - myMenu->add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All"); - myMenu->add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None"); - /* ==> must be in the pluggin list control ... - int32_t idMenuCTags = myMenu->addTitle("C-tags"); - myMenu->add(idMenuCTags, "Load", "", ednMsgGuiCtags, "Load"); - myMenu->add(idMenuCTags, "ReLoad", "", ednMsgGuiCtags, "ReLoad"); - myMenu->add(idMenuCTags, "Jump", "", ednMsgGuiCtags, "Jump"); - myMenu->add(idMenuCTags, "Back", "", ednMsgGuiCtags, "Back"); - */ + myMenu->add(idMenuSearch, "Find (previous)","", "menu:find:previous"); + myMenu->add(idMenuSearch, "Find (next)", "", "menu:find:next"); + myMenu->add(idMenuSearch, "Find (all)", "", "menu:find:all"); + myMenu->add(idMenuSearch, "Un-Select", "", "menu:find:none"); int32_t idMenugDisplay = myMenu->addTitle("Display"); - myMenu->add(idMenugDisplay, "Color Black", "", appl::MsgNameGuiChangeColor, "color/black/"); - myMenu->add(idMenugDisplay, "Color White", "", appl::MsgNameGuiChangeColor, "color/white/"); - myMenu->add(idMenugDisplay, "Shape square", "", l_MsgNameGuiChangeShape, "shape/square/"); - myMenu->add(idMenugDisplay, "Shape round", "", l_MsgNameGuiChangeShape, "shape/round/"); + myMenu->add(idMenugDisplay, "Color Black", "", "menu:color:color/black/"); + myMenu->add(idMenugDisplay, "Color White", "", "menu:color:color/white/"); + myMenu->add(idMenugDisplay, "Shape square", "", "menu:shape:shape/square/"); + myMenu->add(idMenugDisplay, "Shape round", "", "menu:shape:shape/round/"); myMenu->addSpacer(); - myMenu->add(idMenugDisplay, "Reload openGl Shader", "", ednMsgGuiReloadShader); - + myMenu->add(idMenugDisplay, "Reload openGl Shader", "", "menu:reloadShape"); + myMenu->signalSelect.bind(shared_from_this(), &MainWindows::onCallbackMenuEvent); m_widgetLabelFileName = ewol::widget::Label::create("FileName"); m_widgetLabelFileName->setExpand(bvec2(true,false)); m_widgetLabelFileName->setFill(bvec2(true,false));; mySizerHori->subWidgetAdd(m_widgetLabelFileName); - // add generic shortcut ... - // (shift, control, alt, meta, char32_t unicodeValue, const char * generateEventId, std::string& data) - shortCutAdd("ctrl+o", ednMsgGuiOpen, "", true); - shortCutAdd("ctrl+n", ednMsgGuiNew, "", true); + shortCutAdd("ctrl+o", "menu:open"); + shortCutAdd("ctrl+n", "menu:new"); - shortCutAdd("ctrl+s", ednMsgGuiSave, "current", true); - shortCutAdd("ctrl+shift+s", ednMsgGuiSave, "All", true); + shortCutAdd("ctrl+s", "menu:save"); + shortCutAdd("ctrl+shift+s", "menu:save-all"); - shortCutAdd("ctrl+q", ednMsgGuiClose, "current", true); - shortCutAdd("ctrl+shift+q", ednMsgGuiClose, "All", true); + shortCutAdd("ctrl+q", "menu:close"); + shortCutAdd("ctrl+shift+q", "menu:close-all"); - shortCutAdd("ctrl+z", ednMsgGuiUndo, "", true); - shortCutAdd("ctrl+shift+z", ednMsgGuiRedo, "", true); + shortCutAdd("ctrl+l", "menu:goto-line"); - shortCutAdd("ctrl+l", ednMsgGuiGotoLine, "???", true); - - shortCutAdd("ctrl+f", ednMsgGuiSearch, "", true); - shortCutAdd("F12", ednMsgGuiReloadShader, "", true); - - //shortCutAdd("ctrl+d", ednMsgGuiCtags, "Jump", true); - - - - // Generic event ... - registerMultiCast(ednMsgGuiSave); - registerMultiCast(ednMsgGuiSaveAs); - registerMultiCast(ednMsgProperties); - registerMultiCast(ednMsgGuiNew); - registerMultiCast(ednMsgGuiOpen); - registerMultiCast(ednMsgGuiClose); - // to update the title ... - registerMultiCast(ednMsgBufferState); - registerMultiCast(ednMsgBufferId); - registerMultiCast(ednMsgGuiReloadShader); - registerMultiCast(appl::MsgNameGuiChangeColor); - registerMultiCast(l_MsgNameGuiChangeShape); - registerMultiCast(appl::MsgSelectNewFile); + shortCutAdd("ctrl+f", "menu:search"); + shortCutAdd("F12", "menu:reloade-shader"); + // TODO : auto-bind on shortcut event ==> maybe do beter later ... + signalShortcut.bind(shared_from_this(), &MainWindows::onCallbackShortCut); + m_bufferManager->signalSelectFile.bind(shared_from_this(), &MainWindows::onCallbackShortCut); } @@ -279,154 +240,79 @@ MainWindows::~MainWindows() { } -const char *const ednEventPopUpFileSelected = "edn-mainWindows-openSelected"; -const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected"; +void MainWindows::onCallbackShortCut(const std::string& _value) { + APPL_WARNING("Event from ShortCut : " << _value); + onCallbackMenuEvent(_value); +} -void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { - ewol::widget::Windows::onReceiveMessage(_msg); - - APPL_VERBOSE("Receive Event from the main windows: " << _msg ); - // open file Section ... - if (_msg.getMessage() == ednMsgGuiOpen) { - std::shared_ptr tmpWidget = ewol::widget::FileChooser::create(); - if (tmpWidget == nullptr) { - APPL_ERROR("Can not open File chooser !!! "); - return; +void MainWindows::onCallbackMenuEvent(const std::string& _value) { + APPL_WARNING("Event from Menu : " << _value); + if (_value == "menu:new") { + if (m_bufferManager != nullptr) { + m_bufferManager->createNewBuffer(); } - tmpWidget->setTitle("Open files ..."); - tmpWidget->setValidateLabel("Open"); - if (m_bufferManager == nullptr) { - APPL_ERROR("can not call unexistant buffer manager ... "); - return; - } - // Get a ref on the buffer selected (if null, no buffer was selected ...) - std::shared_ptr tmpBuffer = m_bufferManager->getBufferSelected(); - if (tmpBuffer != nullptr) { - etk::FSNode tmpFile = tmpBuffer->getFileName(); - tmpWidget->setFolder(tmpFile.getNameFolder()); - } - // apply widget pop-up ... - popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(shared_from_this(), "validate", ednEventPopUpFileSelected); - } else if (_msg.getMessage() == ednMsgProperties) { - // Request the parameter GUI - std::shared_ptr tmpWidget = ewol::widget::Parameter::create(); - if (nullptr == tmpWidget) { - APPL_ERROR("Can not allocate widget == > display might be in error"); - } else { - #ifdef SDGSDFGSDFGSDFGSDFGSTERGDHFGHFDS - std::string menuDescription = "Properties\n"; - menuDescription += "\n"; - menuDescription += " Editor\n"; - menuDescription += " \n"; - menuDescription += " Editor Interface\n"; - menuDescription += " Editor\n"; - menuDescription += " appl-text-viewer\n"; - menuDescription += " \n"; - menuDescription += "\n"; - menuDescription += "\n"; - menuDescription += " Gui\n"; - menuDescription += " \n"; - menuDescription += " Font selection\n"; - menuDescription += " Font\n"; - menuDescription += " \n"; - menuDescription += " \n"; - menuDescription += " \n"; - menuDescription += " Color selection\n"; - menuDescription += " Color\n"; - menuDescription += " \n"; - menuDescription += " \n"; - menuDescription += " \n"; - menuDescription += " Theme selection\n"; - menuDescription += " Theme\n"; - menuDescription += " \n"; - menuDescription += " \n"; - menuDescription += "\n"; - - tmpWidget->setMenu(menuDescription); - #endif - tmpWidget->setTitle("Properties"); - popUpWidgetPush(tmpWidget); - tmpWidget->menuAddGroup("Editor"); - std::shared_ptr tmpSubWidget = globals::ParameterGlobalsGui::create(); - tmpWidget->menuAdd("Editor", "", tmpSubWidget); - tmpWidget->menuAdd("Font & Color", "", nullptr); - tmpWidget->menuAdd("Highlight", "", nullptr); - tmpWidget->menuAddGroup("General"); - tmpWidget->menuAdd("Display", "", nullptr); - tmpSubWidget = ParameterAboutGui::create(); - tmpWidget->menuAdd("About", "", tmpSubWidget); - } - } else if (_msg.getMessage() == appl::MsgNameGuiChangeColor) { - etk::theme::setName("COLOR", _msg.getData()); - ewol::getContext().getResourcesManager().reLoadResources(); - ewol::getContext().forceRedrawAll(); - } else if (_msg.getMessage() == l_MsgNameGuiChangeShape) { - etk::theme::setName("GUI", _msg.getData()); - ewol::getContext().getResourcesManager().reLoadResources(); - ewol::getContext().forceRedrawAll(); - } else if (_msg.getMessage() == ednMsgGuiReloadShader) { - ewol::getContext().getResourcesManager().reLoadResources(); - ewol::getContext().forceRedrawAll(); - } else if (_msg.getMessage() == ednMsgGuiExit) { - // TODO : ... - } - // Note : Fore all next message we need to acces to the buffer manager ==> just check one time ... - if (m_bufferManager == nullptr) { - APPL_ERROR("can not call unexistant buffer manager ... "); - return; - } - if ( _msg.getMessage() == appl::MsgSelectNewFile - || _msg.getMessage() == appl::Buffer::eventIsModify - || _msg.getMessage() == appl::Buffer::eventIsSave - || _msg.getMessage() == appl::Buffer::eventChangeName) { - // select a new Buffer ==> change title: - std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); - if (tmpp == nullptr) { - setTitle("Edn"); - if (m_widgetLabelFileName != nullptr) { - m_widgetLabelFileName->setLabel(""); - } - } else { - if (_msg.getMessage() == appl::MsgSelectNewFile) { - tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify); - tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventIsSave); - tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventChangeName); - } - std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); - setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem); - if (m_widgetLabelFileName != nullptr) { - m_widgetLabelFileName->setLabel(nameFileSystem + (tmpp->isModify()==true?" *":"")); - } - } - - - } else if (_msg.getMessage() == ednMsgGuiNew) { - m_bufferManager->createNewBuffer(); - } else if (_msg.getMessage() == ednEventPopUpFileSelected) { - APPL_DEBUG("Request opening the file : " << _msg.getData()); - m_bufferManager->open(_msg.getData()); - } else if (_msg.getMessage() == ednMsgGuiSave) { - APPL_DEBUG("Request saving the file : " << _msg.getData()); - if (etk::tolower(_msg.getData()) == "current") { - appl::WorkerSaveFile::create("", false); - return; - } else if (etk::tolower(_msg.getData()) == "all") { - appl::WorkerSaveAllFile::create(); - return; - } else { - APPL_ERROR("UNKNOW request : " << _msg); - } - } else if (_msg.getMessage() == ednMsgGuiSaveAs) { + } else if (_value == "menu:open") { + displayOpen(); + } else if (_value == "menu:close") { + std::shared_ptr worker = appl::WorkerCloseFile::create(); + worker->startAction(""); + } else if (_value == "menu:close-all") { + appl::WorkerCloseAllFile::create(); + } else if (_value == "menu:save") { + appl::WorkerSaveFile::create("", false); + } else if (_value == "menu:save-all") { + appl::WorkerSaveAllFile::create(); + } else if (_value == "menu:save-as") { appl::WorkerSaveFile::create("", true); - } else if (_msg.getMessage() == ednMsgGuiClose) { - // Get a ref on the buffer selected (if null, no buffer was selected ...) - if (_msg.getData() == "current") { - appl::WorkerCloseFile::create(""); - } else { - appl::WorkerCloseAllFile::create(); + } else if (_value == "menu:property") { + displayProperty(); + } else if (_value == "menu:search") { + if (m_widgetSearch == nullptr) { + return; } + if (m_widgetSearch->isHide()) { + m_widgetSearch->show(); + m_widgetSearch->selectSearch(); + } else { + m_widgetSearch->hide(); + } + } else if (_value == "menu:replace") { + if (m_widgetSearch == nullptr) { + return; + } + if (m_widgetSearch->isHide()) { + m_widgetSearch->show(); + m_widgetSearch->selectReplace(); + } else { + m_widgetSearch->hide(); + } + } else if (_value == "menu:find:previous") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:find:next") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:find:all") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:find:none") { + APPL_TODO("Event from Menu : " << _value); + } else if ( _value == "menu:color:color/black/" + || _value == "menu:color:color/white/") { + etk::theme::setName("COLOR", std::string(_value, 12)); + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); + } else if ( _value == "menu:shape:shape/square/" + || _value == "menu:shape:shape/round/") { + etk::theme::setName("GUI", std::string(_value, 12)); + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); + } else if (_value == "menu:reloadShape") { + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); + } else { + APPL_ERROR("Event from Menu UNKNOW : '" << _value << "'"); + } +} +/* TODO : } else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close... if (m_bufferManager->exist(_msg.getData()) == false) { APPL_ERROR("Try to save an non-existant file :" << _msg.getData()); @@ -471,7 +357,124 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { //tmpBuffer->removeObject(); EWOL_TODO("call remove buffer ..."); } - return; +*/ + +void MainWindows::displayOpen() { + std::shared_ptr tmpWidget = ewol::widget::FileChooser::create(); + if (tmpWidget == nullptr) { + APPL_ERROR("Can not open File chooser !!! "); + return; + } + tmpWidget->setTitle("Open files ..."); + tmpWidget->setValidateLabel("Open"); + if (m_bufferManager == nullptr) { + APPL_ERROR("can not call unexistant buffer manager ... "); + return; + } + // Get a ref on the buffer selected (if null, no buffer was selected ...) + std::shared_ptr tmpBuffer = m_bufferManager->getBufferSelected(); + if (tmpBuffer != nullptr) { + etk::FSNode tmpFile = tmpBuffer->getFileName(); + tmpWidget->setFolder(tmpFile.getNameFolder()); + } + // apply widget pop-up ... + popUpWidgetPush(tmpWidget); + tmpWidget->signalValidate.bind(shared_from_this(), &MainWindows::onCallbackPopUpFileSelected); +} + +void MainWindows::displayProperty() { + // Request the parameter GUI + std::shared_ptr tmpWidget = ewol::widget::Parameter::create(); + if (nullptr == tmpWidget) { + APPL_ERROR("Can not allocate widget == > display might be in error"); + } else { + #ifdef SDGSDFGSDFGSDFGSDFGSTERGDHFGHFDS + std::string menuDescription = "Properties\n"; + menuDescription += "\n"; + menuDescription += " Editor\n"; + menuDescription += " \n"; + menuDescription += " Editor Interface\n"; + menuDescription += " Editor\n"; + menuDescription += " appl-text-viewer\n"; + menuDescription += " \n"; + menuDescription += "\n"; + menuDescription += "\n"; + menuDescription += " Gui\n"; + menuDescription += " \n"; + menuDescription += " Font selection\n"; + menuDescription += " Font\n"; + menuDescription += " \n"; + menuDescription += " \n"; + menuDescription += " \n"; + menuDescription += " Color selection\n"; + menuDescription += " Color\n"; + menuDescription += " \n"; + menuDescription += " \n"; + menuDescription += " \n"; + menuDescription += " Theme selection\n"; + menuDescription += " Theme\n"; + menuDescription += " \n"; + menuDescription += " \n"; + menuDescription += "\n"; + + tmpWidget->setMenu(menuDescription); + #endif + tmpWidget->setTitle("Properties"); + popUpWidgetPush(tmpWidget); + tmpWidget->menuAddGroup("Editor"); + std::shared_ptr tmpSubWidget = globals::ParameterGlobalsGui::create(); + tmpWidget->menuAdd("Editor", "", tmpSubWidget); + tmpWidget->menuAdd("Font & Color", "", nullptr); + tmpWidget->menuAdd("Highlight", "", nullptr); + tmpWidget->menuAddGroup("General"); + tmpWidget->menuAdd("Display", "", nullptr); + tmpSubWidget = ParameterAboutGui::create(); + tmpWidget->menuAdd("About", "", tmpSubWidget); + } +} + +void MainWindows::onCallbackselectNewFile(const std::string& _value) { + APPL_INFO("onCallbackselectNewFile(" << _value << ")"); + if (m_bufferManager == nullptr) { + APPL_ERROR("can not call unexistant buffer manager ... "); + return; + } + // TODO : Remove all previous binding from the old buffer ... + onCallbackTitleUpdate(); + std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); + if (tmpp != nullptr) { + tmpp->signalIsSave.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate); + tmpp->signalIsModify.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate); + tmpp->signalChangeName.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate); + } +} + +void MainWindows::onCallbackPopUpFileSelected(const std::string& _value) { + APPL_INFO("onCallbackPopUpFileSelected(" << _value << ")"); + APPL_DEBUG("Request opening the file : " << _value); + m_bufferManager->open(_value); +} + +void MainWindows::onCallbackTitleUpdate() { + APPL_INFO("onCallbackTitleUpdate()"); + if (m_bufferManager == nullptr) { + APPL_ERROR("can not call unexistant buffer manager ... "); + return; + } + // select a new Buffer ==> change title: + std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); + if (tmpp == nullptr) { + setTitle("Edn"); + if (m_widgetLabelFileName != nullptr) { + m_widgetLabelFileName->setLabel(""); + } + } else { + std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); + setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem); + if (m_widgetLabelFileName != nullptr) { + m_widgetLabelFileName->setLabel(nameFileSystem + (tmpp->isModify()==true?" *":"")); + } + } } void MainWindows::saveAsPopUp(const std::shared_ptr& _buffer) { @@ -494,24 +497,24 @@ void MainWindows::closeNotSavedFile(const std::shared_ptr& _buffer } tmpPopUp->setTitle("Close un-saved file:"); tmpPopUp->setComment("The file named : \"" + _buffer->getFileName() + "\" is curently modify.
If you don't saves these modifications,
they will be definitly lost..."); - std::shared_ptr bt = nullptr; + std::shared_ptr bt = nullptr; if (_buffer->hasFileName() == true) { bt = tmpPopUp->addButton("Save", true); if (bt != nullptr) { // TODO : The element is removed before beeing pressed - bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestSaveFile, _buffer->getFileName()); - bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); + // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestSaveFile, _buffer->getFileName()); + // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); } } bt = tmpPopUp->addButton("Save As", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestSaveFileAs, _buffer->getFileName()); - //bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); + // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestSaveFileAs, _buffer->getFileName()); + //bt->signalPressed.bind(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); // TODO : Request the close when saved ... } bt = tmpPopUp->addButton("Close", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); + // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); } tmpPopUp->addButton("Cancel", true); tmpPopUp->setRemoveOnExternClick(true); diff --git a/sources/appl/Gui/MainWindows.h b/sources/appl/Gui/MainWindows.h index 0156616..5646529 100644 --- a/sources/appl/Gui/MainWindows.h +++ b/sources/appl/Gui/MainWindows.h @@ -16,10 +16,12 @@ #include #include #include +#include class MainWindows : public ewol::widget::Windows { private: std::shared_ptr m_widgetLabelFileName; + std::shared_ptr m_widgetSearch; protected: // Constructeur MainWindows(); @@ -39,8 +41,14 @@ class MainWindows : public ewol::widget::Windows { * @param[in] _buffer Buffer that might be close. */ void closeNotSavedFile(const std::shared_ptr& _buffer); - public: // Derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + void displayOpen(); + void displayProperty(); + private: + void onCallbackPopUpFileSelected(const std::string& _value); + void onCallbackTitleUpdate(); + void onCallbackMenuEvent(const std::string& _value); + void onCallbackShortCut(const std::string& _value); + void onCallbackselectNewFile(const std::string& _value); }; diff --git a/sources/appl/Gui/Search.cpp b/sources/appl/Gui/Search.cpp index cbbb118..b06f3fa 100644 --- a/sources/appl/Gui/Search.cpp +++ b/sources/appl/Gui/Search.cpp @@ -12,6 +12,8 @@ #include "appl/Gui/TextViewer.h" #include "appl/Gui/MainWindows.h" #include "appl/globalMsg.h" +#include +#include #undef __class__ @@ -38,25 +40,23 @@ void appl::widget::Search::init() { ewol::widget::Composer::init(ewol::widget::Composer::file, "DATA:GUI-Search.xml"); m_viewerManager = appl::ViewerManager::create(); // link event - registerOnEventNameWidget(shared_from_this(), "SEARCH:close", "pressed", l_eventHideBt); - registerOnEventNameWidget(shared_from_this(), "SEARCH:search-entry", "modify", l_eventSearchEntry); - registerOnEventNameWidget(shared_from_this(), "SEARCH:search-entry", "enter", l_eventSearchEntryEnter); - registerOnEventNameWidget(shared_from_this(), "SEARCH:search", "pressed", l_eventSearchBt); - registerOnEventNameWidget(shared_from_this(), "SEARCH:replace-entry", "modify", l_eventReplaceEntry); - registerOnEventNameWidget(shared_from_this(), "SEARCH:replace-entry", "enter", l_eventReplaceEntryEnter); - registerOnEventNameWidget(shared_from_this(), "SEARCH:replace", "pressed", l_eventReplaceBt); - registerOnEventNameWidget(shared_from_this(), "SEARCH:case", "value", l_eventCaseCb); - registerOnEventNameWidget(shared_from_this(), "SEARCH:wrap", "value", l_eventWrapCb); - registerOnEventNameWidget(shared_from_this(), "SEARCH:up-down", "value", l_eventForwardCb); + subBind(ewol::widget::Button, "SEARCH:close", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackHide); + subBind(ewol::widget::Entry, "SEARCH:search-entry", signalModify, shared_from_this(), &appl::widget::Search::OnCallbackSearchValue); + subBind(ewol::widget::Entry, "SEARCH:search-entry", signalEnter, shared_from_this(), &appl::widget::Search::OnCallbackSearchEntryValidate); + subBind(ewol::widget::Button, "SEARCH:search", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackSearch); + subBind(ewol::widget::Entry, "SEARCH:replace-entry", signalModify, shared_from_this(), &appl::widget::Search::OnCallbackReplaceValue); + subBind(ewol::widget::Entry, "SEARCH:replace-entry", signalEnter, shared_from_this(), &appl::widget::Search::OnCallbackReplaceEntryValidate); + subBind(ewol::widget::Button, "SEARCH:replace", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackReplace); + subBind(ewol::widget::Button, "SEARCH:case", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackCase); + subBind(ewol::widget::Button, "SEARCH:wrap", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackWrap); + subBind(ewol::widget::Button, "SEARCH:up-down", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackForward); // set default properties parameterSetOnWidgetNamed("SEARCH:case", "value", etk::to_string(m_caseSensitive)); parameterSetOnWidgetNamed("SEARCH:wrap", "value", etk::to_string(m_wrap)); parameterSetOnWidgetNamed("SEARCH:up-down", "value", etk::to_string(m_forward)); // get widget - m_searchEntry = std::dynamic_pointer_cast(getWidgetNamed("SEARCH:search-entry")); - m_replaceEntry = std::dynamic_pointer_cast(getWidgetNamed("SEARCH:replace-entry")); - // Display and hide event: - registerMultiCast(ednMsgGuiSearch); + m_searchEntry = std::dynamic_pointer_cast(getSubObjectNamed("SEARCH:search-entry")); + m_replaceEntry = std::dynamic_pointer_cast(getSubObjectNamed("SEARCH:replace-entry")); // basicly hiden ... hide(); } @@ -118,45 +118,50 @@ void appl::widget::Search::replace() { viewer->replace(m_replaceData); } +void appl::widget::Search::OnCallbackHide() { + hide(); +} +void appl::widget::Search::OnCallbackSearchValue(const std::string& _value) { + m_searchData = etk::to_u32string(_value); +} +void appl::widget::Search::OnCallbackSearch() { + find(); +} +void appl::widget::Search::OnCallbackSearchEntryValidate(const std::string& _value) { + m_searchData = etk::to_u32string(_value); + find(); +} +void appl::widget::Search::OnCallbackReplaceValue(const std::string& _value) { + m_replaceData = etk::to_u32string(_value); +} +void appl::widget::Search::OnCallbackReplace() { + replace(); + find(); +} +void appl::widget::Search::OnCallbackReplaceEntryValidate(const std::string& _value) { + m_replaceData = etk::to_u32string(_value); + replace(); + find(); +} +void appl::widget::Search::OnCallbackCase(const bool& _value) { + m_caseSensitive = _value; +} +void appl::widget::Search::OnCallbackWrap(const bool& _value) { + m_wrap = _value; +} +void appl::widget::Search::OnCallbackForward(const bool& _value) { + m_forward = _value; +} -void appl::widget::Search::onReceiveMessage(const ewol::object::Message& _msg) { - ewol::widget::Composer::onReceiveMessage(_msg); - APPL_INFO("Search receive message : " << _msg); - if ( _msg.getMessage() == l_eventSearchEntry) { - m_searchData = etk::to_u32string(_msg.getData()); - } else if ( _msg.getMessage() == l_eventSearchEntryEnter - || _msg.getMessage() == l_eventSearchBt) { - find(); - } else if ( _msg.getMessage() == l_eventReplaceEntry) { - m_replaceData = etk::to_u32string(_msg.getData()); - } else if ( _msg.getMessage() == l_eventReplaceEntryEnter - || _msg.getMessage() == l_eventReplaceBt) { - replace(); - find(); - } else if ( _msg.getMessage() == l_eventCaseCb) { - m_caseSensitive = etk::string_to_bool(_msg.getData()); - } else if ( _msg.getMessage() == l_eventWrapCb) { - m_wrap = etk::string_to_bool(_msg.getData()); - } else if ( _msg.getMessage() == l_eventForwardCb) { - m_forward = etk::string_to_bool(_msg.getData()); - } else if ( _msg.getMessage() == l_eventHideBt) { - hide(); - } else if ( _msg.getMessage() == ednMsgGuiSearch) { - if (true == isHide()) { - show(); - if (m_searchEntry!= nullptr) { - m_searchEntry->keepFocus(); - } - } else { - if( (m_searchEntry!=nullptr && true == m_searchEntry->getFocus()) - || (m_replaceEntry!=nullptr && true == m_replaceEntry->getFocus()) ) { - hide(); - } else if (m_searchEntry!= nullptr) { - m_searchEntry->keepFocus(); - } else { - hide(); - } - } +void appl::widget::Search::selectSearch() { + if (m_searchEntry!= nullptr) { + m_searchEntry->keepFocus(); + } +} + +void appl::widget::Search::selectReplace() { + if (m_replaceEntry!= nullptr) { + m_replaceEntry->keepFocus(); } } diff --git a/sources/appl/Gui/Search.h b/sources/appl/Gui/Search.h index 3a34150..eb2c8dc 100644 --- a/sources/appl/Gui/Search.h +++ b/sources/appl/Gui/Search.h @@ -42,8 +42,20 @@ namespace appl { * @brief Replace the current selected text. */ void replace(); - public: // derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + public: + void selectSearch(); + void selectReplace(); + private: // callback functions + void OnCallbackHide(); + void OnCallbackSearchValue(const std::string& _value); + void OnCallbackSearch(); + void OnCallbackSearchEntryValidate(const std::string& _value); + void OnCallbackReplaceValue(const std::string& _value); + void OnCallbackReplace(); + void OnCallbackReplaceEntryValidate(const std::string& _value); + void OnCallbackCase(const bool& _value); + void OnCallbackWrap(const bool& _value); + void OnCallbackForward(const bool& _value); }; }; }; diff --git a/sources/appl/Gui/TagFileList.cpp b/sources/appl/Gui/TagFileList.cpp index be19a79..9b3131f 100644 --- a/sources/appl/Gui/TagFileList.cpp +++ b/sources/appl/Gui/TagFileList.cpp @@ -12,15 +12,12 @@ #undef __class__ #define __class__ "TagFileList" -extern const char * const applEventCtagsListSelect = "appl-event-ctags-list-select"; -extern const char * const applEventCtagsListUnSelect = "appl-event-ctags-list-un-select"; -extern const char * const applEventCtagsListValidate = "appl-event-ctags-list-validate"; - -appl::TagFileList::TagFileList() { +appl::TagFileList::TagFileList() : + signalSelect(*this, "select"), + signalValidate(*this, "validate"), + signalUnSelect(*this, "unselect") { addObjectType("appl::TagFileList"); m_selectedLine = -1; - addEventId(applEventCtagsListSelect); - addEventId(applEventCtagsListValidate); setMouseLimit(1); // Load color properties: (use file list to be generic ...) m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:ListFileSystem.json"); @@ -92,16 +89,16 @@ bool appl::TagFileList::onItemEvent(int32_t _IdInput, enum ewol::key::status _ty } else { m_selectedLine = _raw; } - const char * event = applEventCtagsListValidate; - if (previousRaw != m_selectedLine) { - event = applEventCtagsListSelect; - } if( m_selectedLine >= 0 && m_selectedLine < (int64_t)m_list.size() && nullptr != m_list[m_selectedLine] ) { - generateEventId(event, etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); + if (previousRaw != m_selectedLine) { + signalSelect.emit(etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); + } else { + signalValidate.emit(etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); + } } else { - generateEventId(applEventCtagsListUnSelect); + signalUnSelect.emit(); } // need to regenerate the display of the list : markToRedraw(); diff --git a/sources/appl/Gui/TagFileList.h b/sources/appl/Gui/TagFileList.h index e7b0909..abef110 100644 --- a/sources/appl/Gui/TagFileList.h +++ b/sources/appl/Gui/TagFileList.h @@ -13,11 +13,6 @@ #include #include - -extern const char * const applEventCtagsListSelect; -extern const char * const applEventCtagsListValidate; -extern const char * const applEventCtagsListUnSelect; - namespace appl { class TagListElement { public: @@ -33,6 +28,10 @@ namespace appl { }; }; class TagFileList : public ewol::widget::List { + public: + ewol::object::Signal signalSelect; + ewol::object::Signal signalValidate; + ewol::object::Signal signalUnSelect; private: int32_t m_selectedLine; std::vector m_list; diff --git a/sources/appl/Gui/TagFileSelection.cpp b/sources/appl/Gui/TagFileSelection.cpp index de5f36b..6a90622 100644 --- a/sources/appl/Gui/TagFileSelection.cpp +++ b/sources/appl/Gui/TagFileSelection.cpp @@ -26,14 +26,18 @@ #define __class__ "TagFileSelection" -extern const char * const applEventctagsSelection = "appl-event-ctags-validate"; -extern const char * const applEventctagsCancel = "appl-event-ctags-cancel"; +static const char * const applEventctagsSelection = "appl-event-ctags-validate"; +static const char * const applEventctagsCancel = "appl-event-ctags-cancel"; +static const char * const applEventCtagsListValidate = "appl-event-ctags-list-validate"; +static const char * const applEventCtagsListSelect = "appl-event-ctags-list-selected"; +static const char * const applEventCtagsListUnSelect = "appl-event-ctags-list-un-selected"; -appl::TagFileSelection::TagFileSelection() { + +appl::TagFileSelection::TagFileSelection() : + signalSelect(*this, "select"), + signalCancel(*this, "cancel") { addObjectType("appl::TagFileSelection"); - addEventId(applEventctagsSelection); - addEventId(applEventctagsCancel); } void appl::TagFileSelection::init() { @@ -74,16 +78,16 @@ void appl::TagFileSelection::init() { compose->setExpand(bvec2(true,false)); compose->setFill(bvec2(true,true)); mySizerVert->subWidgetAdd(compose); - compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection); - compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-cancel", "pressed", applEventctagsCancel); + externSubBind(compose, ewol::widget::Button, "PLUGIN-CTAGS-jump", signalPressed, shared_from_this(), &appl::TagFileSelection::onCallbackCtagsSelection); + externSubBind(compose, ewol::widget::Button, "PLUGIN-CTAGS-cancel", signalPressed, shared_from_this(), &appl::TagFileSelection::onCallbackCtagsCancel); m_listTag = appl::TagFileList::create(); if (nullptr == m_listTag) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { - m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListValidate); - m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListSelect); - m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListUnSelect); + m_listTag->signalValidate.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListValidate); + m_listTag->signalSelect.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListSelect); + m_listTag->signalUnSelect.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListUnSelect); m_listTag->setExpand(bvec2(true,true)); m_listTag->setFill(bvec2(true,true)); mySizerVert->subWidgetAdd(m_listTag); @@ -104,30 +108,34 @@ appl::TagFileSelection::~TagFileSelection() { } -void appl::TagFileSelection::onReceiveMessage(const ewol::object::Message& _msg) { - EWOL_INFO("ctags LIST ... : " << _msg ); - if (_msg.getMessage() == applEventctagsSelection) { - if (m_eventNamed!="") { - generateEventId(applEventctagsSelection, m_eventNamed); - // == > Auto remove ... - autoDestroy(); - } - } else if (_msg.getMessage() == applEventCtagsListSelect) { - m_eventNamed = _msg.getData(); - - } else if (_msg.getMessage() == applEventCtagsListUnSelect) { - m_eventNamed = ""; - } else if (_msg.getMessage() == applEventCtagsListValidate) { - generateEventId(applEventctagsSelection, _msg.getData()); - // == > Auto remove ... - autoDestroy(); - } else if (_msg.getMessage() == applEventctagsCancel) { - generateEventId(applEventctagsCancel, ""); +void appl::TagFileSelection::onCallbackCtagsSelection() { + if (m_eventNamed!="") { + signalSelect.emit(m_eventNamed); // == > Auto remove ... autoDestroy(); } - return; -}; +} + +void appl::TagFileSelection::onCallbackCtagsCancel() { + signalCancel.emit(); + // == > Auto remove ... + autoDestroy(); +} + +void appl::TagFileSelection::onCallbackCtagsListValidate(const std::string& _value) { + signalSelect.emit(_value); + // == > Auto remove ... + autoDestroy(); +} + +void appl::TagFileSelection::onCallbackCtagsListSelect(const std::string& _value) { + m_eventNamed = _value; +} + +void appl::TagFileSelection::onCallbackCtagsListUnSelect() { + m_eventNamed = ""; +} + /** diff --git a/sources/appl/Gui/TagFileSelection.h b/sources/appl/Gui/TagFileSelection.h index 2d4ba0e..cb90203 100644 --- a/sources/appl/Gui/TagFileSelection.h +++ b/sources/appl/Gui/TagFileSelection.h @@ -13,11 +13,11 @@ #include #include -extern const char * const applEventctagsSelection; -extern const char * const applEventctagsCancel; - namespace appl { class TagFileSelection : public ewol::widget::PopUp { + public: + ewol::object::Signal signalSelect; + ewol::object::Signal signalCancel; private: std::shared_ptr m_listTag; std::string m_eventNamed; @@ -33,8 +33,12 @@ namespace appl { * @param[in] jump line id */ void addCtagsNewItem(std::string file, int32_t line); - public: // herited function - void onReceiveMessage(const ewol::object::Message& _msg); + public: // callback function + void onCallbackCtagsSelection(); + void onCallbackCtagsCancel(); + void onCallbackCtagsListValidate(const std::string& _value); + void onCallbackCtagsListSelect(const std::string& _value); + void onCallbackCtagsListUnSelect(); }; }; diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index c147aa3..2f0f07d 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -28,6 +28,10 @@ int64_t processTimeLocal = (endTime - startTime); \ APPL_DEBUG(comment << (float)((float)processTimeLocal / 1000.0) << "ms"); +static const char* const appl_Buffer_eventIsModify = "buffer-is-modify"; +static const char* const appl_Buffer_eventSelectChange = "buffer-select-change"; + + appl::TextViewer::TextViewer() : m_insertMode(false) { addObjectType("appl::TextViewer"); @@ -37,6 +41,7 @@ appl::TextViewer::TextViewer() : // load buffer manager: m_bufferManager = appl::BufferManager::create(); + m_pluginManager = appl::textPluginManager::create(); m_viewerManager = appl::ViewerManager::create(); // load color properties @@ -54,21 +59,78 @@ appl::TextViewer::TextViewer() : void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) { ewol::widget::WidgetScrolled::init(); m_displayText.setFont(_fontName, _fontSize); - appl::textPluginManager::connect(*this); + m_pluginManager->connect(*this); // last created has focus ... setCurrentSelect(); + signalShortcut.bind(shared_from_this(), &appl::TextViewer::onCallbackShortCut); + /* registerMultiCast(ednMsgBufferId); registerMultiCast(ednMsgGuiFind); registerMultiCast(ednMsgGuiReplace); registerMultiCast(appl::MsgSelectGotoLine); - registerMultiCast(appl::MsgSelectNewFile); registerMultiCast(appl::MsgSelectGotoLineSelect); + */ + if (m_bufferManager != nullptr) { + m_bufferManager->signalSelectFile.bind(shared_from_this(), &appl::TextViewer::onCallbackselectNewFile); + } +} + +appl::TextViewer::~TextViewer() { + m_pluginManager->disconnect(*this); +} + +void appl::TextViewer::onCallbackShortCut(const std::string& _value) { + if (m_pluginManager->onReceiveShortCut(*this, _value) == true) { + return; + } } -appl::TextViewer::~TextViewer() { - appl::textPluginManager::disconnect(*this); +void appl::TextViewer::onCallbackselectNewFile(const std::string& _value) { + // reset scroll: + if (m_buffer != nullptr) { + m_buffer->unBindAll(shared_from_this()); + bool needAdd = true; + auto it = m_drawingRemenber.begin(); + while (it != m_drawingRemenber.end()) { + std::shared_ptr tmpBuff = it->first.lock(); + if (tmpBuff == nullptr) { + it = m_drawingRemenber.erase(it); + continue; + } + if (tmpBuff == m_buffer) { + it->second = m_originScrooled; + APPL_VERBOSE("store origin : " << m_originScrooled); + needAdd = false; + break; + } + ++it; + } + if (needAdd == true) { + m_drawingRemenber.push_back(std::make_pair(std::weak_ptr(m_buffer), m_originScrooled)); + APPL_VERBOSE("Push origin : " << m_originScrooled); + } + } + m_originScrooled = vec2(0,0); + if (m_bufferManager != nullptr) { + m_buffer = m_bufferManager->get(_value); + m_bufferManager->setBufferSelected(m_buffer); + if (m_buffer != nullptr) { + m_buffer->signalIsModify.bind(shared_from_this(), &appl::TextViewer::onCallbackIsModify); + m_buffer->signalSelectChange.bind(shared_from_this(), &appl::TextViewer::onCallbackSelectChange); + for (auto element : m_drawingRemenber) { + if (element.first.lock() == m_buffer) { + m_originScrooled = element.second; + APPL_VERBOSE("retrive origin : " << m_originScrooled); + // TODO : Check if this element is not out of the display text ... + break; + } + } + } + } + markToRedraw(); + return; } std::string appl::TextViewer::getBufferPath() { @@ -322,7 +384,7 @@ bool appl::TextViewer::onEventEntry(const ewol::event::Entry& _event) { return false; } // First call plugin - if (appl::textPluginManager::onEventEntry(*this, _event) == true) { + if (m_pluginManager->onEventEntry(*this, _event) == true) { markToRedraw(); return true; } @@ -444,7 +506,7 @@ bool appl::TextViewer::onEventInput(const ewol::event::Input& _event) { } APPL_VERBOSE("event : " << _event); // Second call plugin - if (appl::textPluginManager::onEventInput(*this, _event) == true) { + if (m_pluginManager->onEventInput(*this, _event) == true) { markToRedraw(); return true; } @@ -461,9 +523,9 @@ bool appl::TextViewer::onEventInput(const ewol::event::Input& _event) { } if ( _event.getId() == 12 && _event.getStatus() == ewol::key::statusSingle) { - APPL_DEBUG("kjhkjhkjh"); + APPL_TODO("RAT5 SAVE button ==> TODO implement"); // Rat5 save event - sendMultiCast(ednMsgGuiSave, "current"); + //sendMultiCast(ednMsgGuiSave, "current"); return true; } // just forward event == > manage directly in the buffer @@ -625,84 +687,13 @@ void appl::TextViewer::onEventClipboard(enum ewol::context::clipBoard::clipboard markToRedraw(); } -void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { - ewol::widget::WidgetScrolled::onReceiveMessage(_msg); - APPL_VERBOSE("receive msg: " << _msg); - // First call plugin - if (appl::textPluginManager::onReceiveMessageViewer(*this, _msg) == true) { - markToRedraw(); - return; - } - // event needed even if selection of buffer is not done ... - if (_msg.getMessage() == appl::Buffer::eventIsModify) { - markToRedraw(); - return; - } - if (_msg.getMessage() == appl::Buffer::eventSelectChange) { - markToRedraw(); - return; - } - // If not the last buffer selected, then no event parsing ... - if (isSelectedLast() == false) { - return; - } - if (_msg.getMessage() == appl::MsgSelectGotoLineSelect) { - if (m_buffer == nullptr) { - return; - } - appl::Buffer::Iterator it = m_buffer->countForwardNLines(m_buffer->begin(), etk::string_to_int32_t(_msg.getData())); - select(it, m_buffer->getEndLine(it)); - markToRedraw(); - return; - } - if (_msg.getMessage() == appl::MsgSelectGotoLine) { - if (m_buffer == nullptr) { - return; - } - appl::Buffer::Iterator it = m_buffer->countForwardNLines(m_buffer->begin(), etk::string_to_int32_t(_msg.getData())); - moveCursor(it); - markToRedraw(); - return; - } - if (_msg.getMessage() == appl::MsgSelectNewFile) { - // reset scroll: - if (m_buffer != nullptr) { - m_buffer->unRegisterOnEvent(shared_from_this()); - bool needAdd = true; - for (size_t iii=0; iiiget(_msg.getData()); - m_bufferManager->setBufferSelected(m_buffer); - if (m_buffer != nullptr) { - m_buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify); - m_buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventSelectChange); - for (auto element : m_drawingRemenber) { - if (element.first == m_buffer) { - m_originScrooled = element.second; - APPL_VERBOSE("retrive origin : " << m_originScrooled); - // TODO : Check if this element is not out of the display text ... - break; - } - } - } - } - markToRedraw(); - return; - } +void appl::TextViewer::onCallbackIsModify() { + markToRedraw(); } +void appl::TextViewer::onCallbackSelectChange() { + markToRedraw(); +} + void appl::TextViewer::onGetFocus() { showKeyboard(); @@ -761,7 +752,7 @@ bool appl::TextViewer::moveCursor(const appl::Buffer::Iterator& _pos) { return false; } markToRedraw(); - if (appl::textPluginManager::onCursorMove(*this, _pos) == true) { + if (m_pluginManager->onCursorMove(*this, _pos) == true) { updateScrolling(); return true; } @@ -785,13 +776,13 @@ bool appl::TextViewer::write(const std::string& _data, const appl::Buffer::Itera return false; } 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... updateScrolling(); return true; } bool ret = m_buffer->write(_data, _pos); - appl::textPluginManager::onCursorMove(*this, m_buffer->cursor()); + m_pluginManager->onCursorMove(*this, m_buffer->cursor()); updateScrolling(); return ret; } @@ -801,13 +792,13 @@ bool appl::TextViewer::replace(const std::string& _data, const appl::Buffer::Ite return false; } 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... updateScrolling(); return true; } bool ret = m_buffer->replace(_data, _pos, _posEnd); - appl::textPluginManager::onCursorMove(*this, m_buffer->cursor()); + m_pluginManager->onCursorMove(*this, m_buffer->cursor()); updateScrolling(); return ret; } @@ -831,11 +822,11 @@ void appl::TextViewer::remove() { return; } 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; } m_buffer->removeSelection(); - appl::textPluginManager::onCursorMove(*this, m_buffer->cursor()); + m_pluginManager->onCursorMove(*this, m_buffer->cursor()); } diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index 5d2f676..e77fabc 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -22,6 +22,7 @@ #include namespace appl { + class textPluginManager; class TextViewer : public ewol::widget::WidgetScrolled { private: std::shared_ptr m_paintingProperties; //!< element painting property @@ -34,6 +35,7 @@ namespace appl { int32_t m_colorNormal; private: std::shared_ptr m_bufferManager; //!< handle on the buffer manager + std::shared_ptr m_pluginManager; //!< Plugin manager interface std::shared_ptr m_viewerManager; //!< handle on the buffer manager protected: TextViewer(); @@ -54,7 +56,7 @@ namespace appl { private: ewol::compositing::Text m_displayText; //!< Text display properties. ewol::compositing::Drawing m_displayDrawing; //!< Other diaplay requested. - std::vector, vec2>> m_drawingRemenber; + std::vector, vec2>> m_drawingRemenber; public: void setFontSize(int32_t _size); void setFontName(const std::string& _fontName); @@ -63,7 +65,6 @@ namespace appl { public: // Derived function virtual bool calculateMinSize(); virtual void onRegenerateDisplay(); - virtual void onReceiveMessage(const ewol::object::Message& _msg); virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventEntry(const ewol::event::Entry& _event); virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID); @@ -391,21 +392,31 @@ namespace appl { * @brief Register of the arrival of a Multicast message * @param[in] _messageId Event Id waiting for... */ + // TODO : Remove void ext_registerMultiCast(const char* const _messageId) { - registerMultiCast(_messageId); + //registerMultiCast(_messageId); } /** * @brief add a specific shortcut with his description * @param[in] _descriptiveString Description string of the shortcut - * @param[in] _generateEventId Event generic of the element - * @param[in] _data Associate data wit the event + * @param[in] _generateEventName Event generic of the element */ - virtual void ext_shortCutAdd(const char * _descriptiveString, - const char * _generateEventId, - std::string _data="", - bool _broadcast=false) { - shortCutAdd(_descriptiveString, _generateEventId, _data, _broadcast); + virtual void ext_shortCutAdd(const std::string& _descriptiveString, + const std::string& _generateEventName) { + shortCutAdd(_descriptiveString, _generateEventName); } + /** + * @brief Remove a specific shortcut with his event name + * @param[in] _generateEventName Event of the element shortcut + */ + virtual void ext_shortCutRm(const std::string& _generateEventName) { + shortCutRemove(_generateEventName); + } + private: // callback fundtions + void onCallbackIsModify(); + void onCallbackShortCut(const std::string& _value); + void onCallbackSelectChange(); + void onCallbackselectNewFile(const std::string& _value); }; }; diff --git a/sources/appl/Gui/ViewerManager.cpp b/sources/appl/Gui/ViewerManager.cpp index 54e404c..9c2aecf 100644 --- a/sources/appl/Gui/ViewerManager.cpp +++ b/sources/appl/Gui/ViewerManager.cpp @@ -41,6 +41,6 @@ void appl::ViewerManager::setViewerSelected(const std::shared_ptrsetBufferSelected(_buffer); + //m_bufferManager->setBufferSelected(_buffer); } } diff --git a/sources/appl/Gui/WorkerCloseAllFile.cpp b/sources/appl/Gui/WorkerCloseAllFile.cpp index aada838..f799fc2 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.cpp +++ b/sources/appl/Gui/WorkerCloseAllFile.cpp @@ -13,8 +13,6 @@ #undef __class__ #define __class__ "WorkerCloseAllFile" -static const char* s_closeDone = "close-done"; - appl::WorkerCloseAllFile::WorkerCloseAllFile() { addObjectType("appl::WorkerCloseAllFile"); // load buffer manager: @@ -22,10 +20,10 @@ appl::WorkerCloseAllFile::WorkerCloseAllFile() { } void appl::WorkerCloseAllFile::init() { - ewol::Object::init(); + ewol::object::Worker::init(); if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); - autoDestroy(); + destroy(); return; } // List all current open file : @@ -43,43 +41,43 @@ void appl::WorkerCloseAllFile::init() { } // checkif an element has something to do in the queue if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } // create the worker : - m_worker = appl::WorkerCloseFile::create(m_bufferNameList.front()); + m_worker = appl::WorkerCloseFile::create(); + m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); + m_worker->startAction(m_bufferNameList.front()); // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } - m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone); } appl::WorkerCloseAllFile::~WorkerCloseAllFile() { - + APPL_ERROR("Remove Worker"); } -void appl::WorkerCloseAllFile::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::WorkerCloseAllFile::onCallbackCloseDone() { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... return; } - if (_msg.getMessage() == s_closeDone) { - if (m_bufferNameList.size() == 0) { - autoDestroy(); - return; - } - // create the worker : - m_worker = appl::WorkerCloseFile::create(m_bufferNameList.front()); - // remove first element : - m_bufferNameList.erase(m_bufferNameList.begin()); - if (m_bufferNameList.size() == 0) { - autoDestroy(); - return; - } - m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone); + if (m_bufferNameList.size() == 0) { + destroy(); + return; + } + // create the worker : + m_worker = appl::WorkerCloseFile::create(); + m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); + m_worker->startAction(m_bufferNameList.front()); + // remove first element : + m_bufferNameList.erase(m_bufferNameList.begin()); + if (m_bufferNameList.size() == 0) { + destroy(); + return; } } diff --git a/sources/appl/Gui/WorkerCloseAllFile.h b/sources/appl/Gui/WorkerCloseAllFile.h index 5615fca..9c2e4a2 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.h +++ b/sources/appl/Gui/WorkerCloseAllFile.h @@ -9,11 +9,12 @@ #ifndef __WORKER_CLOSE_ALL_FILE_H__ #define __WORKER_CLOSE_ALL_FILE_H__ +#include #include #include namespace appl { - class WorkerCloseAllFile : public ewol::Object { + class WorkerCloseAllFile : public ewol::object::Worker { protected: WorkerCloseAllFile(); void init(); @@ -24,8 +25,8 @@ namespace appl { std::vector m_bufferNameList; std::shared_ptr m_worker; //! pop-up element that is open... std::shared_ptr m_bufferManager; //!< handle on the buffer manager - public: // derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + public: // callback function + void onCallbackCloseDone(); }; }; diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index c5f4a11..a4e5a2b 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -14,29 +14,26 @@ #undef __class__ #define __class__ "WorkerCloseFile" -const char* appl::WorkerCloseFile::eventCloseDone = "close-file-done"; - -static const char* s_saveAsValidate = "save-as-validate"; -static const char* s_saveValidate = "save-validate"; -static const char* s_closeValidate = "close-validate"; -static const char* s_saveAsDone = "save-as-done"; - appl::WorkerCloseFile::WorkerCloseFile() : + signalCloseDone(*this, "close-file-done"), + signalAbort(*this, "close-file-abort"), m_buffer(nullptr), m_worker(nullptr), m_bufferManager(nullptr) { addObjectType("appl::WorkerCloseFile"); - addEventId(eventCloseDone); // load buffer manager: m_bufferManager = appl::BufferManager::create(); } -void appl::WorkerCloseFile::init(const std::string& _bufferName) { - ewol::Object::init(); +void appl::WorkerCloseFile::init() { + ewol::object::Worker::init(); +} + +void appl::WorkerCloseFile::startAction(const std::string& _bufferName) { m_bufferName = _bufferName; if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); - autoDestroy(); + destroy(); return; } if (m_bufferName == "") { @@ -44,101 +41,132 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) { std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); if (tmpp == nullptr) { APPL_ERROR("No selected buffer now ..."); - autoDestroy(); + destroy(); return; } m_bufferName = tmpp->getFileName(); } if (m_bufferManager->exist(m_bufferName) == false) { APPL_ERROR("Try to close an non-existant file :" << m_bufferName); - autoDestroy(); + destroy(); return; } m_buffer = m_bufferManager->get(m_bufferName); if (m_buffer == nullptr) { APPL_ERROR("Error to get the buffer : " << m_bufferName); - autoDestroy(); + destroy(); return; } if (m_buffer->isModify() == false) { - generateEventId(eventCloseDone); + signalCloseDone.emit(); m_buffer->destroy(); + destroy(); return; } std::shared_ptr tmpPopUp = ewol::widget::StdPopUp::create(); if (tmpPopUp == nullptr) { APPL_ERROR("Can not create a simple pop-up"); + destroy(); return; } tmpPopUp->setTitle("Close un-saved file:"); tmpPopUp->setComment("The file named : \"" + m_buffer->getFileName() + "\" is curently modify.
If you don't saves these modifications,
they will be definitly lost..."); - std::shared_ptr bt = nullptr; + std::shared_ptr bt = nullptr; if (m_buffer->hasFileName() == true) { bt = tmpPopUp->addButton("Save", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", s_saveValidate); + bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackSaveValidate); } } bt = tmpPopUp->addButton("Save As", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", s_saveAsValidate); + bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackSaveAsValidate); } bt = tmpPopUp->addButton("Close", true); if (bt != nullptr) { - bt->registerOnEvent(shared_from_this(), "pressed", s_closeValidate); + bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackClose); + } + bt = tmpPopUp->addButton("Cancel", true); + if (bt != nullptr) { + bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackCancel); } - tmpPopUp->addButton("Cancel", true); tmpPopUp->setRemoveOnExternClick(true); std::shared_ptr tmpWindows = ewol::getContext().getWindows(); if (tmpWindows == nullptr) { APPL_ERROR("Error to get the windows."); - autoDestroy(); + destroy(); return; } tmpWindows->popUpWidgetPush(tmpPopUp); } appl::WorkerCloseFile::~WorkerCloseFile() { - + APPL_ERROR("Remove Worker"); } -void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::WorkerCloseFile::onCallbackCancel() { + APPL_VERBOSE("Cancel signal ..."); + signalAbort.emit(); + destroy(); +} + +void appl::WorkerCloseFile::onCallbackSaveAsValidate() { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... return; } - APPL_DEBUG("have message : " << _msg); - if (_msg.getMessage() == s_saveAsValidate) { - m_worker = appl::WorkerSaveFile::create(m_bufferName); - if (m_worker != nullptr) { - m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); - } - } else if (_msg.getMessage() == s_saveValidate) { - if (m_buffer == nullptr) { - APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName); - autoDestroy(); - return; - } - if (m_buffer->storeFile() == false) { - std::shared_ptr tmpWindows = ewol::getContext().getWindows(); - if (tmpWindows == nullptr) { - return; - } - tmpWindows->displayWarningMessage("We can not save the file :
" + m_buffer->getFileName() + ""); - } else { - generateEventId(eventCloseDone); - } - } else if ( _msg.getMessage() == s_closeValidate - || _msg.getMessage() == s_saveAsDone) { - if (m_buffer == nullptr) { - APPL_ERROR("Error to get the buffer : " << m_bufferName); - autoDestroy(); - return; - } - generateEventId(eventCloseDone); - m_buffer->destroy(); - m_buffer.reset(); + m_worker = appl::WorkerSaveFile::create(m_bufferName); + if (m_worker != nullptr) { + m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackClose); + m_worker->signalAbort.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackCancel); } } +void appl::WorkerCloseFile::onCallbackSaveValidate() { + if (m_bufferManager == nullptr) { + // nothing to do in this case ==> can do nothing ... + signalAbort.emit(); + destroy(); + return; + } + if (m_buffer == nullptr) { + APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName); + signalAbort.emit(); + destroy(); + return; + } + if (m_buffer->storeFile() == false) { + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); + if (tmpWindows == nullptr) { + return; + } + tmpWindows->displayWarningMessage("We can not save the file :
" + m_buffer->getFileName() + ""); + signalAbort.emit(); + } else { + m_buffer->destroy(); + m_buffer.reset(); + signalCloseDone.emit(); + } + destroy(); +} + +void appl::WorkerCloseFile::onCallbackClose() { + if (m_bufferManager == nullptr) { + // nothing to do in this case ==> can do nothing ... + signalAbort.emit(); + destroy(); + return; + } + if (m_buffer == nullptr) { + APPL_ERROR("Error to get the buffer : " << m_bufferName); + signalAbort.emit(); + destroy(); + return; + } + m_buffer->destroy(); + m_buffer.reset(); + signalCloseDone.emit(); + destroy(); +} + diff --git a/sources/appl/Gui/WorkerCloseFile.h b/sources/appl/Gui/WorkerCloseFile.h index 31354c4..b962138 100644 --- a/sources/appl/Gui/WorkerCloseFile.h +++ b/sources/appl/Gui/WorkerCloseFile.h @@ -9,28 +9,38 @@ #ifndef __WORKER_CLOSE_FILE_H__ #define __WORKER_CLOSE_FILE_H__ +#include #include #include #include namespace appl { - class WorkerCloseFile : public ewol::Object { + class WorkerCloseFile : public ewol::object::Worker { public: - static const char* eventCloseDone; + ewol::object::Signal signalCloseDone; + ewol::object::Signal signalAbort; protected: // note : if == "" ==> current ... WorkerCloseFile(); - void init(const std::string& _bufferName); + void init(); public: DECLARE_FACTORY(WorkerCloseFile); virtual ~WorkerCloseFile(); + public: + /** + * @brief Action to do + */ + void startAction(const std::string& _bufferName); private: std::string m_bufferName; std::shared_ptr m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer std::shared_ptr m_worker; //! sub-worker element... std::shared_ptr m_bufferManager; //!< handle on the buffer manager - public: // derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + public: // callback Functions + void onCallbackSaveAsValidate(); + void onCallbackSaveValidate(); + void onCallbackClose(); + void onCallbackCancel(); }; }; diff --git a/sources/appl/Gui/WorkerSaveAllFile.cpp b/sources/appl/Gui/WorkerSaveAllFile.cpp index 68a9381..44007c9 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.cpp +++ b/sources/appl/Gui/WorkerSaveAllFile.cpp @@ -13,8 +13,6 @@ #undef __class__ #define __class__ "WorkerSaveAllFile" -static const char* s_saveAsDone = "save-as-done"; - appl::WorkerSaveAllFile::WorkerSaveAllFile() { addObjectType("appl::WorkerSaveAllFile"); // load buffer manager: @@ -22,10 +20,10 @@ appl::WorkerSaveAllFile::WorkerSaveAllFile() { } void appl::WorkerSaveAllFile::init() { - ewol::Object::init(); + ewol::object::Worker::init(); if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); - autoDestroy(); + destroy(); return; } // List all current open file : @@ -45,7 +43,7 @@ void appl::WorkerSaveAllFile::init() { } // checkif an element has something to do in the queue if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } // create the worker : @@ -53,35 +51,33 @@ void appl::WorkerSaveAllFile::init() { // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } - m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); + m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone); } appl::WorkerSaveAllFile::~WorkerSaveAllFile() { - + APPL_ERROR("Remove Worker"); } -void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::WorkerSaveAllFile::onCallbackSaveAsDone() { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... return; } - if (_msg.getMessage() == s_saveAsDone) { - if (m_bufferNameList.size() == 0) { - autoDestroy(); - return; - } - // create the worker : - m_worker = appl::WorkerSaveFile::create(m_bufferNameList.front()); - // remove first element : - m_bufferNameList.erase(m_bufferNameList.begin()); - if (m_bufferNameList.size() == 0) { - autoDestroy(); - return; - } - m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); + if (m_bufferNameList.size() == 0) { + destroy(); + return; } + // create the worker : + m_worker = appl::WorkerSaveFile::create(m_bufferNameList.front()); + // remove first element : + m_bufferNameList.erase(m_bufferNameList.begin()); + if (m_bufferNameList.size() == 0) { + destroy(); + return; + } + m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone); } diff --git a/sources/appl/Gui/WorkerSaveAllFile.h b/sources/appl/Gui/WorkerSaveAllFile.h index 8909655..c3f1192 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.h +++ b/sources/appl/Gui/WorkerSaveAllFile.h @@ -9,11 +9,12 @@ #ifndef __WORKER_SAVE_ALL_FILE_H__ #define __WORKER_SAVE_ALL_FILE_H__ +#include #include #include namespace appl { - class WorkerSaveAllFile : public ewol::Object { + class WorkerSaveAllFile : public ewol::object::Worker { protected: WorkerSaveAllFile(); void init(); @@ -24,8 +25,8 @@ namespace appl { std::vector m_bufferNameList; std::shared_ptr m_worker; //! pop-up element that is open... std::shared_ptr m_bufferManager; //!< handle on the buffer manager - public: // derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + public: // callback function + void onCallbackSaveAsDone(); }; }; diff --git a/sources/appl/Gui/WorkerSaveFile.cpp b/sources/appl/Gui/WorkerSaveFile.cpp index dde1524..351a2c0 100644 --- a/sources/appl/Gui/WorkerSaveFile.cpp +++ b/sources/appl/Gui/WorkerSaveFile.cpp @@ -13,23 +13,21 @@ #undef __class__ #define __class__ "WorkerSaveFile" -const char* appl::WorkerSaveFile::eventSaveDone = "save-file-done"; -static const char* s_saveAsValidate = "save-as-validate"; - -appl::WorkerSaveFile::WorkerSaveFile() { +appl::WorkerSaveFile::WorkerSaveFile() : + signalSaveDone(*this, "save-file-done"), + signalAbort(*this, "save-file-abort") { addObjectType("appl::WorkerSaveFile"); - addEventId(eventSaveDone); // load buffer manager: m_bufferManager = appl::BufferManager::create(); } void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveAs) { - ewol::Object::init(); + ewol::object::Worker::init(); m_bufferName = _bufferName; if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); - autoDestroy(); + destroy(); return; } if (m_bufferName == "") { @@ -37,34 +35,34 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); if (tmpp == nullptr) { APPL_ERROR("No selected buffer now ..."); - autoDestroy(); + destroy(); return; } m_bufferName = tmpp->getFileName(); } if (m_bufferManager->exist(m_bufferName) == false) { APPL_ERROR("Try to save an non-existant file :" << m_bufferName); - autoDestroy(); + destroy(); return; } std::shared_ptr tmpBuffer = m_bufferManager->get(m_bufferName); if (tmpBuffer == nullptr) { APPL_ERROR("Error to get the buffer : " << m_bufferName); - autoDestroy(); + destroy(); return; } if (_forceSaveAs == false) { if (tmpBuffer->hasFileName() == true) { tmpBuffer->storeFile(); - generateEventId(eventSaveDone); - autoDestroy(); + signalSaveDone.emit(); + destroy(); return; } } m_chooser = ewol::widget::FileChooser::create(); if (nullptr == m_chooser) { APPL_ERROR("Can not allocate widget == > display might be in error"); - autoDestroy(); + destroy(); return; } m_chooser->setTitle("Save files As..."); @@ -75,46 +73,56 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA std::shared_ptr tmpWindows = ewol::getContext().getWindows(); if (tmpWindows == nullptr) { APPL_ERROR("Error to get the windows."); - autoDestroy(); + destroy(); return; } tmpWindows->popUpWidgetPush(m_chooser); - m_chooser->registerOnEvent(shared_from_this(), ewol::widget::FileChooser::eventValidate, s_saveAsValidate); + m_chooser->signalValidate.bind(shared_from_this(), &appl::WorkerSaveFile::onCallbackSaveAsValidate); + m_chooser->signalCancel.bind(shared_from_this(), &appl::WorkerSaveFile::onCallbackCancel); } appl::WorkerSaveFile::~WorkerSaveFile() { - + APPL_ERROR("Remove Worker"); } -void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::WorkerSaveFile::onCallbackCancel() { + signalAbort.emit(); + destroy(); +} + +void appl::WorkerSaveFile::onCallbackSaveAsValidate(const std::string& _value) { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... + destroy(); return; } - if (_msg.getMessage() == s_saveAsValidate) { - if (_msg.getData() == "") { - APPL_ERROR(" might be an error of the File chooser system..."); - return; - } - if (m_bufferManager->exist(m_bufferName) == false) { - APPL_ERROR("Try to save an non-existant file :" << m_bufferName); - return; - } - std::shared_ptr tmpBuffer = m_bufferManager->get(m_bufferName); - if (tmpBuffer == nullptr) { - APPL_ERROR("Error to get the buffer : " << m_bufferName); - return; - } - tmpBuffer->setFileName(_msg.getData()); - if (tmpBuffer->storeFile() == false) { - std::shared_ptr tmpWindows = ewol::getContext().getWindows(); - if (tmpWindows == nullptr) { - return; - } - tmpWindows->displayWarningMessage("We can not save the file :
" + tmpBuffer->getFileName() + ""); - } else { - generateEventId(eventSaveDone); - } + if (_value == "") { + APPL_ERROR(" might be an error of the File chooser system..."); + destroy(); + return; } + if (m_bufferManager->exist(m_bufferName) == false) { + APPL_ERROR("Try to save an non-existant file :" << m_bufferName); + destroy(); + return; + } + std::shared_ptr tmpBuffer = m_bufferManager->get(m_bufferName); + if (tmpBuffer == nullptr) { + APPL_ERROR("Error to get the buffer : " << m_bufferName); + destroy(); + return; + } + tmpBuffer->setFileName(_value); + if (tmpBuffer->storeFile() == false) { + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); + if (tmpWindows == nullptr) { + destroy(); + return; + } + tmpWindows->displayWarningMessage("We can not save the file :
" + tmpBuffer->getFileName() + ""); + } else { + signalSaveDone.emit(); + } + destroy(); } diff --git a/sources/appl/Gui/WorkerSaveFile.h b/sources/appl/Gui/WorkerSaveFile.h index 3fbf3b6..690491b 100644 --- a/sources/appl/Gui/WorkerSaveFile.h +++ b/sources/appl/Gui/WorkerSaveFile.h @@ -10,12 +10,14 @@ #define __WORKER_SAVE_FILE_H__ #include +#include #include namespace appl { - class WorkerSaveFile : public ewol::Object { + class WorkerSaveFile : public ewol::object::Worker { public: - static const char* eventSaveDone; + ewol::object::Signal signalSaveDone; + ewol::object::Signal signalAbort; protected: WorkerSaveFile(); void init(const std::string& _bufferName, bool _forceSaveAs=true); @@ -26,8 +28,9 @@ namespace appl { std::string m_bufferName; std::shared_ptr m_chooser; //! pop-up element that is open... std::shared_ptr m_bufferManager; //!< handle on the buffer manager - public: // derived function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + public: // callback function + void onCallbackSaveAsValidate(const std::string& _value); + void onCallbackCancel(); }; }; diff --git a/sources/appl/Highlight.cpp b/sources/appl/Highlight.cpp index 0fc9a11..600dc53 100644 --- a/sources/appl/Highlight.cpp +++ b/sources/appl/Highlight.cpp @@ -25,12 +25,13 @@ #define HL2_DEBUG APPL_VERBOSE void appl::Highlight::parseRules(exml::Element* _child, - std::vector>& _mListPatern, - int32_t _level) { + std::vector>& _mListPatern, + int32_t _level, + bool forceMaximize) { // Create the patern ... HighlightPattern *myPattern = new HighlightPattern(m_paintingProperties); // parse under Element - myPattern->parseRules(_child, _level); + myPattern->parseRules(_child, _level, forceMaximize); // add element in the list _mListPatern.push_back(std::unique_ptr(myPattern)); } @@ -95,7 +96,7 @@ void appl::Highlight::init(const std::string& _xmlFilename, const std::string& _ APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" ); continue; } - parseRules(passChild, m_listHighlightPass2, level2++); + parseRules(passChild, m_listHighlightPass2, level2++, true); } } else { APPL_ERROR("(l "<< child->getPos() << ") node not suported : \""<< child->getValue() << "\" must be [ext,pass1,pass2]" ); diff --git a/sources/appl/Highlight.h b/sources/appl/Highlight.h index 87508c7..ec49138 100644 --- a/sources/appl/Highlight.h +++ b/sources/appl/Highlight.h @@ -63,7 +63,8 @@ namespace appl { private: void parseRules(exml::Element* _child, std::vector> &_mListPatern, - int32_t _level); + int32_t _level, + bool forceMaximize=false); std::string m_styleName; //!< curent style name (like "c++" or "c" or "script Bash") std::vector m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" std::vector> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer) diff --git a/sources/appl/HighlightPattern.cpp b/sources/appl/HighlightPattern.cpp index ade0386..d4c73a5 100644 --- a/sources/appl/HighlightPattern.cpp +++ b/sources/appl/HighlightPattern.cpp @@ -26,11 +26,12 @@ appl::HighlightPattern::~HighlightPattern() { } -void appl::HighlightPattern::setPatern(std::string& _regExp) { +void appl::HighlightPattern::setPatern(std::string& _regExp, bool forceMaximize) { if (m_regExp == nullptr) { return; } m_regExp->compile(_regExp); + m_regExp->setMaximize(forceMaximize); } std::string appl::HighlightPattern::getPaternString() { return m_regExp->getRegExDecorated(); @@ -48,12 +49,13 @@ void appl::HighlightPattern::display() { APPL_INFO(" == > regExp '" << m_regExp->getRegExp() << "'"); } -void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) { +void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level, bool forceMaximize) { //-------------------------------------------------------------------------------------------- /* preprocesseur # + false */ //-------------------------------------------------------------------------------------------- @@ -75,13 +77,17 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) { setColorGlyph(myEdnData); } } + xChild = _child->getNamed("max"); + if (nullptr != xChild) { + forceMaximize = etk::string_to_bool(xChild->getText()); + } xChild = _child->getNamed("regex"); if (nullptr != xChild) { std::string myData = xChild->getText(); if (myData.size() != 0) { //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); std::string myEdnData = myData; - setPatern(myEdnData); + setPatern(myEdnData, forceMaximize); } } } diff --git a/sources/appl/HighlightPattern.h b/sources/appl/HighlightPattern.h index 4b4069b..e013ccf 100644 --- a/sources/appl/HighlightPattern.h +++ b/sources/appl/HighlightPattern.h @@ -46,7 +46,7 @@ namespace appl { private: std::unique_ptr> m_regExp; //!< Start of Regular expression public: - void setPatern(std::string& _regExp); + void setPatern(std::string& _regExp, bool forceMaximize=false); std::string getPaternString(); private: std::string m_colorName; //!< Current color name @@ -84,7 +84,7 @@ namespace appl { appl::HighlightInfo& _resultat, etk::Buffer& _buffer); - void parseRules(exml::Element* _child, int32_t _level); + void parseRules(exml::Element* _child, int32_t _level, bool forceMaximize=false); }; }; diff --git a/sources/appl/TextPlugin.cpp b/sources/appl/TextPlugin.cpp index 6a9089a..7dc280b 100644 --- a/sources/appl/TextPlugin.cpp +++ b/sources/appl/TextPlugin.cpp @@ -8,6 +8,7 @@ #include +#include #include #undef __class__ @@ -21,21 +22,31 @@ appl::TextViewerPlugin::TextViewerPlugin() : m_activateOnWrite(false), m_activateOnReplace(false), m_activateOnRemove(false), - m_activateOnReceiveMessage(false), + m_activateOnReceiveShortCut(false), m_activateOnCursorMove(false) { addObjectType("appl::TextViewerPlugin"); + m_menuInterface = std::dynamic_pointer_cast(getObjectNamed("appl-menu-interface")); + if (m_menuInterface.expired() == true) { + 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() { ewol::Object::init(); } +void appl::TextViewerPlugin::init(const std::string& _name) { + ewol::Object::init(_name); +} + appl::TextViewerPlugin::~TextViewerPlugin() { if (m_isEnable == false) { return; } m_isEnable = false; - onPluginDisable(); + onPluginGlobalDisable(); } void appl::TextViewerPlugin::setEnableStatus(bool _status) { @@ -44,9 +55,9 @@ void appl::TextViewerPlugin::setEnableStatus(bool _status) { } m_isEnable = _status; if (m_isEnable == true) { - onPluginEnable(); + onPluginGlobalEnable(); } else { - onPluginDisable(); + onPluginGlobalDisable(); } } diff --git a/sources/appl/TextPlugin.h b/sources/appl/TextPlugin.h index 1cc3bf9..b68b76c 100644 --- a/sources/appl/TextPlugin.h +++ b/sources/appl/TextPlugin.h @@ -13,16 +13,23 @@ #include #include #include +#include namespace appl { + class textPluginManager; class TextViewerPlugin : public ewol::Object { friend class appl::TextViewer; + protected: + std::weak_ptr m_pluginManager; protected: TextViewerPlugin(); void init(); + void init(const std::string& _name); public: DECLARE_FACTORY(TextViewerPlugin); virtual ~TextViewerPlugin(); + protected: + std::weak_ptr m_menuInterface; private: bool m_isEnable; //!< The plugin is enable or not (for all viewer). public: @@ -42,13 +49,13 @@ namespace appl { /** * @brief On plugin global enable. */ - virtual void onPluginEnable() { + virtual void onPluginGlobalEnable() { // nothing to do here ... }; /** * @brief On plugin global disable. */ - virtual void onPluginDisable() { + virtual void onPluginGlobalDisable() { // nothing to do here ... }; /** @@ -174,23 +181,22 @@ namespace appl { return false; }; protected: - bool m_activateOnReceiveMessage; //!< onReceiveMessage is availlable for this plugin. + bool m_activateOnReceiveShortCut; //!< onReceiveShortCut is availlable for this plugin. public: /** * @brief Get the availlability of a callback * @return true if availlable */ - bool isAvaillableOnReceiveMessage() { - return m_activateOnReceiveMessage; + bool isAvaillableOnReceiveShortCut() { + return m_activateOnReceiveShortCut; } /** * @brief Called when a message arrive. * @param[in] _widget Reference on the widget caller. - * @param[in] _msg Generic message. + * @param[in] _shortCutName Generic message requested. * @return true if the event might not propagate anymore */ - virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg) { + virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer, const std::string& _shortCutName) { return false; } protected: diff --git a/sources/appl/TextPluginCopy.cpp b/sources/appl/TextPluginCopy.cpp index 5a0c933..55b9e5f 100644 --- a/sources/appl/TextPluginCopy.cpp +++ b/sources/appl/TextPluginCopy.cpp @@ -15,8 +15,13 @@ #define __class__ "TextPluginCopy" -appl::TextPluginCopy::TextPluginCopy() { - m_activateOnReceiveMessage = true; +appl::TextPluginCopy::TextPluginCopy() : + m_menuIdTitle(-1), + m_menuIdCopy(-1), + m_menuIdCut(-1), + m_menuIdPast(-1), + m_menuIdRemove(-1) { + m_activateOnReceiveShortCut = true; addObjectType("appl::TextPluginCopy"); } @@ -26,25 +31,47 @@ void appl::TextPluginCopy::init() { void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) { // add event : - _textDrawer.ext_registerMultiCast(ednMsgGuiCopy); - _textDrawer.ext_registerMultiCast(ednMsgGuiPaste); - _textDrawer.ext_registerMultiCast(ednMsgGuiCut); - _textDrawer.ext_shortCutAdd("ctrl+x", ednMsgGuiCut, "STD"); - _textDrawer.ext_shortCutAdd("ctrl+c", ednMsgGuiCopy, "STD"); - _textDrawer.ext_shortCutAdd("ctrl+v", ednMsgGuiPaste, "STD"); + std::shared_ptr menu = m_menuInterface.lock(); + if (menu != nullptr) { + m_menuIdTitle = menu->addTitle("Edit"); + if (m_menuIdTitle != -1) { + m_menuIdCopy = menu->add(m_menuIdTitle, "Copy", "", "appl::TextPluginCopy::menu:copy"); + m_menuIdCut = menu->add(m_menuIdTitle, "Cut", "", "appl::TextPluginCopy::menu:cut"); + m_menuIdPast = menu->add(m_menuIdTitle, "Paste", "", "appl::TextPluginCopy::menu:past"); + m_menuIdRemove = menu->add(m_menuIdTitle, "Remove", "", "appl::TextPluginCopy::menu:remove"); + } + } + _textDrawer.ext_shortCutAdd("ctrl+x", "appl::TextPluginCopy::cut"); + _textDrawer.ext_shortCutAdd("ctrl+c", "appl::TextPluginCopy::copy"); + _textDrawer.ext_shortCutAdd("ctrl+v", "appl::TextPluginCopy::Paste"); } void appl::TextPluginCopy::onPluginDisable(appl::TextViewer& _textDrawer) { - // TODO : unknow function ... + _textDrawer.ext_shortCutRm("appl::TextPluginCopy::cut"); + _textDrawer.ext_shortCutRm("appl::TextPluginCopy::copy"); + _textDrawer.ext_shortCutRm("appl::TextPluginCopy::Paste"); + std::shared_ptr menu = m_menuInterface.lock(); + if (menu != nullptr) { + menu->remove(m_menuIdRemove); + menu->remove(m_menuIdPast); + menu->remove(m_menuIdCut); + menu->remove(m_menuIdCopy); + menu->remove(m_menuIdTitle); + } + m_menuIdTitle = -1; + m_menuIdCopy = -1; + m_menuIdCut = -1; + m_menuIdPast = -1; + m_menuIdRemove = -1; } -bool appl::TextPluginCopy::onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg) { +bool appl::TextPluginCopy::onReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName) { if (isEnable() == false) { return false; } - if ( _msg.getMessage() == ednMsgGuiCopy - || _msg.getMessage() == ednMsgGuiCut) { + if ( _shortCutName == "appl::TextPluginCopy::copy" + || _shortCutName == "appl::TextPluginCopy::cut") { if (_textDrawer.hasBuffer() == true) { std::string value; _textDrawer.copy(value); @@ -52,11 +79,11 @@ bool appl::TextPluginCopy::onReceiveMessageViewer(appl::TextViewer& _textDrawer, ewol::context::clipBoard::set(ewol::context::clipBoard::clipboardStd, value); } } - if (_msg.getMessage() == ednMsgGuiCut) { + if (_shortCutName == "appl::TextPluginCopy::cut") { _textDrawer.remove(); } return true; - } else if (_msg.getMessage() == ednMsgGuiPaste) { + } else if (_shortCutName == "appl::TextPluginCopy::Paste") { if (_textDrawer.hasBuffer() == true) { ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd); } diff --git a/sources/appl/TextPluginCopy.h b/sources/appl/TextPluginCopy.h index e64bbc3..27b0d9b 100644 --- a/sources/appl/TextPluginCopy.h +++ b/sources/appl/TextPluginCopy.h @@ -17,6 +17,12 @@ namespace appl { class TextPluginCopy : public appl::TextViewerPlugin { + private: + int32_t m_menuIdTitle; + int32_t m_menuIdCopy; + int32_t m_menuIdCut; + int32_t m_menuIdPast; + int32_t m_menuIdRemove; protected: TextPluginCopy(); void init(); @@ -28,7 +34,7 @@ namespace appl { public: virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginDisable(appl::TextViewer& _textDrawer); - virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg); + virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer, const std::string& _shortCutName); }; }; diff --git a/sources/appl/TextPluginCtags.cpp b/sources/appl/TextPluginCtags.cpp index 2630871..3a4ea11 100644 --- a/sources/appl/TextPluginCtags.cpp +++ b/sources/appl/TextPluginCtags.cpp @@ -22,7 +22,7 @@ appl::TextPluginCtags::TextPluginCtags() : m_tagFolderBase(""), m_tagFilename(""), m_ctagFile(nullptr) { - m_activateOnReceiveMessage = true; + m_activateOnReceiveShortCut = true; // load buffer manager: m_bufferManager = appl::BufferManager::create(); addObjectType("appl::TextPluginCtags"); @@ -37,30 +37,17 @@ appl::TextPluginCtags::~TextPluginCtags() { } -const char* eventJumpDestination = "event-plugin-ctags-jump-destination"; -const char* eventJumpBack = "event-plugin-ctags-jump-back"; -const char* eventOpenCtagsFile = "event-plugin-ctags-open"; -const char* eventOpenCtagsOpenFileReturn = "event-plugin-ctags-open-file-return"; -const char* eventOpenCtagsSelectReturn = "event-plugin-ctags-select-file-return"; - void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) { - // Add local event of this object (no dependency with the viewer ... - /* - registerMultiCast(ednMsgGuiCtags); - registerMultiCast(ednMsgBufferId); - registerMultiCast(ednMsgCtagsLoadFile); - */ // add event : - _textDrawer.ext_registerMultiCast(eventJumpDestination); - _textDrawer.ext_registerMultiCast(eventJumpBack); - _textDrawer.ext_registerMultiCast(eventOpenCtagsFile); - _textDrawer.ext_shortCutAdd("ctrl+d", eventJumpDestination); - _textDrawer.ext_shortCutAdd("ctrl+shift+d", eventJumpBack); - _textDrawer.ext_shortCutAdd("ctrl+alt+d", eventOpenCtagsFile); + _textDrawer.ext_shortCutAdd("ctrl+d", "appl::TextPluginCtags::JumpDestination"); + _textDrawer.ext_shortCutAdd("ctrl+shift+d", "appl::TextPluginCtags::JumpBack"); + _textDrawer.ext_shortCutAdd("ctrl+alt+d", "appl::TextPluginCtags::OpenCtagsFile"); } void appl::TextPluginCtags::onPluginDisable(appl::TextViewer& _textDrawer) { - // TODO : unknow function ... + _textDrawer.ext_shortCutRm("appl::TextPluginCtags::JumpDestination"); + _textDrawer.ext_shortCutRm("appl::TextPluginCtags::JumpBack"); + _textDrawer.ext_shortCutRm("appl::TextPluginCtags::OpenCtagsFile"); } void appl::TextPluginCtags::jumpTo(const std::string& _name) { @@ -98,7 +85,7 @@ void appl::TextPluginCtags::jumpTo(const std::string& _name) { tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID); } while (tagsFindNext (m_ctagFile, &entry) == TagSuccess); ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(shared_from_this(), applEventctagsSelection, eventOpenCtagsSelectReturn); + tmpWidget->signalSelect.bind(shared_from_this(), &appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn); } } else { jumpFile(myfile.getName(), lineID - 1); @@ -111,8 +98,8 @@ void appl::TextPluginCtags::jumpFile(const std::string& _filename, int64_t _line if (m_bufferManager != nullptr) { m_bufferManager->open(_filename); } - sendMultiCast(appl::MsgSelectChange, _filename); - sendMultiCast(appl::MsgSelectGotoLineSelect, etk::to_string(_lineId)); + //sendMultiCast(appl::MsgSelectGotoLineSelect, etk::to_string(_lineId)); + APPL_TODO("request jup at line ..."); } void appl::TextPluginCtags::loadTagFile() { @@ -157,29 +144,30 @@ void appl::TextPluginCtags::printTag(const tagEntry *_entry) { #endif } -void appl::TextPluginCtags::onReceiveMessage(const ewol::object::Message& _msg) { - if (_msg.getMessage() == eventOpenCtagsOpenFileReturn) { - // open the new one : - etk::FSNode tmpFilename = _msg.getData(); - m_tagFilename = tmpFilename.getNameFile(); - m_tagFolderBase = tmpFilename.getNameFolder(); - APPL_INFO("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " "); - loadTagFile(); - } else if (_msg.getMessage() == eventOpenCtagsSelectReturn) { - // parse the input data - char tmp[4096]; - int32_t lineID; - // TODO : Review this ... - sscanf(_msg.getData().c_str(), "%d:%s", &lineID, tmp); - jumpFile(tmp, lineID - 1); - } +void appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn(const std::string& _value) { + // open the new one : + etk::FSNode tmpFilename = _value; + m_tagFilename = tmpFilename.getNameFile(); + m_tagFolderBase = tmpFilename.getNameFolder(); + APPL_INFO("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " "); + loadTagFile(); } -bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg) { + +void appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn(const std::string& _value) { + // parse the input data + char tmp[4096]; + int32_t lineID; + // TODO : Review this ... + sscanf(_value.c_str(), "%d:%s", &lineID, tmp); + jumpFile(tmp, lineID - 1); +} + +bool appl::TextPluginCtags::onReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName) { if (isEnable() == false) { return false; } - if (_msg.getMessage() == eventOpenCtagsFile) { + if (_shortCutName == "appl::TextPluginCtags::OpenCtagsFile") { APPL_INFO("Request opening ctag file"); std::shared_ptr tmpWidget = ewol::widget::FileChooser::create(); if (nullptr == tmpWidget) { @@ -195,9 +183,9 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer tmpWidget->setFolder(path); } ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(shared_from_this(), "validate", eventOpenCtagsOpenFileReturn); + tmpWidget->signalValidate.bind(shared_from_this(), &appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn); return true; - } else if (_msg.getMessage() == eventJumpDestination) { + } else if (_shortCutName == "appl::TextPluginCtags::JumpDestination") { if (_textDrawer.hasBuffer() == false) { return false; } @@ -215,7 +203,7 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer } jumpTo(textToSearch); return true; - } else if (_msg.getMessage() == eventJumpBack) { + } else if (_shortCutName == "appl::TextPluginCtags::JumpBack") { if (_textDrawer.hasBuffer() == false) { return false; } diff --git a/sources/appl/TextPluginCtags.h b/sources/appl/TextPluginCtags.h index cb8e64e..27447b6 100644 --- a/sources/appl/TextPluginCtags.h +++ b/sources/appl/TextPluginCtags.h @@ -43,10 +43,11 @@ namespace appl { public: virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginDisable(appl::TextViewer& _textDrawer); - virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg); - // internal message : - virtual void onReceiveMessage(const ewol::object::Message& _msg); + virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName); + // callback function: + void onCallbackOpenCtagsOpenFileReturn(const std::string& _value); + void onCallbackOpenCtagsSelectReturn(const std::string& _value); }; }; diff --git a/sources/appl/TextPluginData.h b/sources/appl/TextPluginData.h index 389c0e9..033b667 100644 --- a/sources/appl/TextPluginData.h +++ b/sources/appl/TextPluginData.h @@ -25,6 +25,9 @@ namespace appl { void init() { appl::TextViewerPlugin::init(); } + void init(const std::string& _name) { + appl::TextViewerPlugin::init(_name); + } public: DECLARE_FACTORY(TextViewerPluginData); virtual ~TextViewerPluginData() { @@ -38,13 +41,21 @@ namespace appl { m_specificData.clear(); } private: - std::vector ,TYPE* >> m_specificData; + std::vector ,TYPE* >> m_specificData; protected: TYPE* getDataRef(appl::TextViewer& _textDrawer) { - for (size_t iii = 0; iii < m_specificData.size() ; ++iii) { - if (m_specificData[iii].first == _textDrawer.internalGetBuffer()) { - return m_specificData[iii].second; + auto it = m_specificData.begin(); + while(it != m_specificData.end()) { + std::shared_ptr buf = it->first.lock(); + if (buf == nullptr) { + delete(it->second); + it->second = nullptr; + it = m_specificData.erase(it); } + if (buf == _textDrawer.internalGetBuffer()) { + return it->second; + } + ++it; } TYPE* data = new TYPE(); if (data == nullptr) { @@ -55,13 +66,13 @@ namespace appl { return data; } protected: // Wrap all element with their internal data: (do not use theses function) - bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg) { + bool onReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName) { TYPE* data = getDataRef(_textDrawer); if (data == nullptr) { return false; } - return onReceiveMessageViewer(_textDrawer, _msg, *data); + return onDataReceiveShortCut(_textDrawer, _shortCutName, *data); } bool onWrite(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, @@ -70,7 +81,7 @@ namespace appl { if (data == nullptr) { return false; } - return onWrite(_textDrawer, _pos, _data, *data); + return onDataWrite(_textDrawer, _pos, _data, *data); } bool onReplace(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, @@ -80,7 +91,7 @@ namespace appl { if (data == nullptr) { return false; } - return onReplace(_textDrawer, _pos, _data, _posEnd, *data); + return onDataReplace(_textDrawer, _pos, _data, _posEnd, *data); } bool onRemove(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, @@ -89,32 +100,32 @@ namespace appl { if (data == nullptr) { return false; } - return onRemove(_textDrawer, _pos, _posEnd, *data); + return onDataRemove(_textDrawer, _pos, _posEnd, *data); } public: - virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg, - TYPE& _data) { + virtual bool onDataReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName, + TYPE& _data) { return false; } - virtual bool onWrite(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const std::string& _strData, - TYPE& _data) { + virtual bool onDataWrite(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const std::string& _strData, + TYPE& _data) { return false; } - virtual bool onReplace(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const std::string& _strData, - const appl::Buffer::Iterator& _posEnd, - TYPE& _data) { + virtual bool onDataReplace(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const std::string& _strData, + const appl::Buffer::Iterator& _posEnd, + TYPE& _data) { return false; } - virtual bool onRemove(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const appl::Buffer::Iterator& _posEnd, - TYPE& _data) { + virtual bool onDataRemove(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const appl::Buffer::Iterator& _posEnd, + TYPE& _data) { return false; } virtual void remove(TYPE& _data) { diff --git a/sources/appl/TextPluginHistory.cpp b/sources/appl/TextPluginHistory.cpp index 46f4a9b..59a4b89 100644 --- a/sources/appl/TextPluginHistory.cpp +++ b/sources/appl/TextPluginHistory.cpp @@ -15,8 +15,11 @@ #undef __class__ #define __class__ "TextPluginHistory" -appl::TextPluginHistory::TextPluginHistory() { - m_activateOnReceiveMessage = true; +appl::TextPluginHistory::TextPluginHistory() : + m_menuIdTitle(-1), + m_menuIdUndo(-1), + m_menuIdRedo(-1) { + m_activateOnReceiveShortCut = true; m_activateOnWrite = true; m_activateOnReplace = true; m_activateOnRemove = true; @@ -29,24 +32,40 @@ void appl::TextPluginHistory::init() { void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) { + std::shared_ptr menu = m_menuInterface.lock(); + if (menu != nullptr) { + m_menuIdTitle = menu->addTitle("Edit"); + if (m_menuIdTitle != -1) { + m_menuIdUndo = menu->add(m_menuIdTitle, "Undo", "THEME:GUI:Undo.edf", "appl::TextPluginHistory::menu:undo"); + m_menuIdRedo = menu->add(m_menuIdTitle, "Redo", "THEME:GUI:Redo.edf", "appl::TextPluginHistory::menu:redo"); + } + } // add event : - _textDrawer.ext_registerMultiCast(ednMsgGuiRedo); - _textDrawer.ext_registerMultiCast(ednMsgGuiUndo); - _textDrawer.ext_shortCutAdd("ctrl+z", ednMsgGuiUndo); - _textDrawer.ext_shortCutAdd("ctrl+shift+z", ednMsgGuiRedo); + _textDrawer.ext_shortCutAdd("ctrl+z", "appl::TextPluginHistory::Undo"); + _textDrawer.ext_shortCutAdd("ctrl+shift+z", "appl::TextPluginHistory::Redo"); } void appl::TextPluginHistory::onPluginDisable(appl::TextViewer& _textDrawer) { - // TODO : unknow function ... + _textDrawer.ext_shortCutRm("appl::TextPluginHistory::Undo"); + _textDrawer.ext_shortCutRm("appl::TextPluginHistory::Redo"); + std::shared_ptr menu = m_menuInterface.lock(); + if (menu != nullptr) { + menu->remove(m_menuIdRedo); + menu->remove(m_menuIdUndo); + menu->remove(m_menuIdTitle); + } + m_menuIdTitle = -1; + m_menuIdUndo = -1; + m_menuIdRedo = -1; } -bool appl::TextPluginHistory::onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg, - appl::PluginHistoryData& _data) { +bool appl::TextPluginHistory::onDataReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName, + appl::PluginHistoryData& _data) { if (isEnable() == false) { return false; } - if (_msg.getMessage() == ednMsgGuiRedo) { + if (_shortCutName == "appl::TextPluginHistory::Redo") { if (_data.m_redo.size() == 0) { return true; } @@ -62,7 +81,7 @@ bool appl::TextPluginHistory::onReceiveMessageViewer(appl::TextViewer& _textDraw _textDrawer.position(tmpElement->m_endPosRemoved) ); return true; - } else if (_msg.getMessage() == ednMsgGuiUndo) { + } else if (_shortCutName == "appl::TextPluginHistory::Undo") { if (_data.m_undo.size() == 0) { return true; } @@ -111,10 +130,10 @@ void appl::TextPluginHistory::clearUndo(appl::PluginHistoryData& _data) { } -bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const std::string& _strData, - appl::PluginHistoryData& _data) { +bool appl::TextPluginHistory::onDataWrite(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const std::string& _strData, + appl::PluginHistoryData& _data) { if (isEnable() == false) { return false; } @@ -130,15 +149,18 @@ bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer, clearRedo(_data); _data.m_undo.push_back(tmpElement); } - appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor()); + std::shared_ptr mng = m_pluginManager.lock(); + if (mng!=nullptr) { + mng->onCursorMove(_textDrawer, _textDrawer.cursor()); + } return true; } -bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const std::string& _strData, - const appl::Buffer::Iterator& _posEnd, - appl::PluginHistoryData& _data) { +bool appl::TextPluginHistory::onDataReplace(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const std::string& _strData, + const appl::Buffer::Iterator& _posEnd, + appl::PluginHistoryData& _data) { if (isEnable() == false) { return false; } @@ -155,14 +177,17 @@ bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer, clearRedo(_data); _data.m_undo.push_back(tmpElement); } - appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor()); + std::shared_ptr mng = m_pluginManager.lock(); + if (mng!=nullptr) { + mng->onCursorMove(_textDrawer, _textDrawer.cursor()); + } return true; } -bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const appl::Buffer::Iterator& _posEnd, - appl::PluginHistoryData& _data) { +bool appl::TextPluginHistory::onDataRemove(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const appl::Buffer::Iterator& _posEnd, + appl::PluginHistoryData& _data) { if (isEnable() == false) { return false; } @@ -177,7 +202,10 @@ bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer, _data.m_undo.push_back(tmpElement); } _textDrawer.removeDirect(); - appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor()); + std::shared_ptr mng = m_pluginManager.lock(); + if (mng!=nullptr) { + mng->onCursorMove(_textDrawer, _textDrawer.cursor()); + } return true; } diff --git a/sources/appl/TextPluginHistory.h b/sources/appl/TextPluginHistory.h index 787d916..0278356 100644 --- a/sources/appl/TextPluginHistory.h +++ b/sources/appl/TextPluginHistory.h @@ -36,6 +36,10 @@ namespace appl { std::vector m_redo; //!< History storing data }; class TextPluginHistory : public appl::TextViewerPluginData { + private: + int32_t m_menuIdTitle; + int32_t m_menuIdUndo; + int32_t m_menuIdRedo; protected: TextPluginHistory(); void init(); @@ -46,22 +50,22 @@ namespace appl { public: virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginDisable(appl::TextViewer& _textDrawer); - virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg, - appl::PluginHistoryData& _data); - virtual bool onWrite(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const std::string& _strData, - appl::PluginHistoryData& _data); - virtual bool onReplace(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const std::string& _strData, - const appl::Buffer::Iterator& _posEnd, - appl::PluginHistoryData& _data); - virtual bool onRemove(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const appl::Buffer::Iterator& _posEnd, - appl::PluginHistoryData& _data); + virtual bool onDataReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName, + appl::PluginHistoryData& _data); + virtual bool onDataWrite(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const std::string& _strData, + appl::PluginHistoryData& _data); + virtual bool onDataReplace(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const std::string& _strData, + const appl::Buffer::Iterator& _posEnd, + appl::PluginHistoryData& _data); + virtual bool onDataRemove(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const appl::Buffer::Iterator& _posEnd, + appl::PluginHistoryData& _data); virtual void remove(appl::PluginHistoryData& _data) { clearRedo(_data); clearUndo(_data); diff --git a/sources/appl/TextPluginManager.cpp b/sources/appl/TextPluginManager.cpp index 5d444b5..2326595 100644 --- a/sources/appl/TextPluginManager.cpp +++ b/sources/appl/TextPluginManager.cpp @@ -19,53 +19,11 @@ #undef __class__ #define __class__ "textPluginManager" -static std::list>& getList() { - static std::list> s_list; - return s_list; -} -static std::vector>& getListOnEventEntry() { - static std::vector> s_list; - return s_list; -} -static std::vector>& getListOnEventInput() { - static std::vector> s_list; - return s_list; -} -static std::vector>& getListOnWrite() { - static std::vector> s_list; - return s_list; -} -static std::vector>& getListOnReplace() { - static std::vector> s_list; - return s_list; -} -static std::vector>& getListOnRemove() { - static std::vector> s_list; - return s_list; -} -static std::vector>& getListonReceiveMessageViewer() { - static std::vector> s_list; - return s_list; -} -static std::vector>& getListOnCursorMove() { - static std::vector> s_list; - return s_list; -} - -void appl::textPluginManager::init() { +appl::textPluginManager::textPluginManager() { } - -void appl::textPluginManager::unInit() { - // remove all sub plugin class: - getListOnEventEntry().clear(); - getListOnEventInput().clear(); - getListOnWrite().clear(); - getListOnReplace().clear(); - getListOnRemove().clear(); - getListonReceiveMessageViewer().clear(); - getListOnCursorMove().clear(); - getList().clear(); +void appl::textPluginManager::init(const std::string& _name) { + ewol::Resource::init(_name); } void appl::textPluginManager::addDefaultPlugin() { @@ -82,32 +40,38 @@ void appl::textPluginManager::addPlugin(const std::shared_ptrgetObjectType()); + m_list.push_back(_plugin); if (_plugin->isAvaillableOnEventEntry() == true) { - getListOnEventEntry().push_back(_plugin); + m_listOnEventEntry.push_back(_plugin); } if (_plugin->isAvaillableOnEventInput() == true) { - getListOnEventInput().push_back(_plugin); + m_listOnEventInput.push_back(_plugin); } if (_plugin->isAvaillableOnWrite() == true) { - getListOnWrite().push_back(_plugin); + m_listOnWrite.push_back(_plugin); } if (_plugin->isAvaillableOnReplace() == true) { - getListOnReplace().push_back(_plugin); + m_listOnReplace.push_back(_plugin); } if (_plugin->isAvaillableOnRemove() == true) { - getListOnRemove().push_back(_plugin); + m_listOnRemove.push_back(_plugin); } - if (_plugin->isAvaillableOnReceiveMessage() == true) { - getListonReceiveMessageViewer().push_back(_plugin); + if (_plugin->isAvaillableOnReceiveShortCut() == true) { + m_listOnReceiveShortCutViewer.push_back(_plugin); } if (_plugin->isAvaillableOnCursorMove() == true) { - getListOnCursorMove().push_back(_plugin); + m_listOnCursorMove.push_back(_plugin); + } + std::shared_ptr viewer = m_currentViewer.lock(); + if (viewer != nullptr) { + _plugin->onPluginEnable(*viewer); } } void appl::textPluginManager::connect(appl::TextViewer& _widget) { - for (auto &it : getList()) { + m_currentViewer = std::dynamic_pointer_cast(_widget.shared_from_this()); + for (auto &it : m_list) { if (it == nullptr) { continue; } @@ -116,7 +80,8 @@ void appl::textPluginManager::connect(appl::TextViewer& _widget) { } void appl::textPluginManager::disconnect(appl::TextViewer& _widget) { - for (auto &it : getList()) { + m_currentViewer.reset(); + for (auto &it : m_list) { if (it == nullptr) { continue; } @@ -126,7 +91,7 @@ void appl::textPluginManager::disconnect(appl::TextViewer& _widget) { bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer, const ewol::event::Entry& _event) { - for (auto &it : getListOnEventEntry()) { + for (auto &it : m_listOnEventEntry) { if (it == nullptr) { continue; } @@ -139,7 +104,7 @@ bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer, const ewol::event::Input& _event) { - for (auto &it : getListOnEventInput()) { + for (auto &it : m_listOnEventInput) { if (it == nullptr) { continue; } @@ -153,7 +118,7 @@ bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onWrite(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, const std::string& _data) { - for (auto &it : getListOnWrite()) { + for (auto &it : m_listOnWrite) { if (it == nullptr) { continue; } @@ -168,7 +133,7 @@ bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, const std::string& _data, const appl::Buffer::Iterator& _posEnd) { - for (auto &it : getListOnReplace()) { + for (auto &it : m_listOnReplace) { if (it == nullptr) { continue; } @@ -182,7 +147,7 @@ bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd) { - for (auto &it : getListOnRemove()) { + for (auto &it : m_listOnRemove) { if (it == nullptr) { continue; } @@ -193,13 +158,13 @@ bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer, return false; } -bool appl::textPluginManager::onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg) { - for (auto &it : getListonReceiveMessageViewer()) { +bool appl::textPluginManager::onReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName) { + for (auto &it : m_listOnReceiveShortCutViewer) { if (it == nullptr) { continue; } - if (it->onReceiveMessageViewer(_textDrawer, _msg) == true ) { + if (it->onReceiveShortCut(_textDrawer, _shortCutName) == true ) { return true; } } @@ -208,7 +173,7 @@ bool appl::textPluginManager::onReceiveMessageViewer(appl::TextViewer& _textDraw bool appl::textPluginManager::onCursorMove(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos) { - for (auto &it : getListOnCursorMove()) { + for (auto &it : m_listOnCursorMove) { if (it == nullptr) { continue; } diff --git a/sources/appl/TextPluginManager.h b/sources/appl/TextPluginManager.h index b9c557d..d0ffc58 100644 --- a/sources/appl/TextPluginManager.h +++ b/sources/appl/TextPluginManager.h @@ -16,98 +16,106 @@ #include namespace appl { - namespace textPluginManager { - /** - * @brief Init the plugin manager for writer. - */ - void init(); - /** - * @brief UnInit the plugin manager for writer. - */ - void unInit(); - /** - * @brief Add default plugin list - */ - void addDefaultPlugin(); - /** - * @brief Add a plugin. - * @param[in] _plugin Plugin pointer to add. - */ - void addPlugin(const std::shared_ptr& _plugin); - /** - * @brief connect a new widget to the plugin. - * @param[in] _widget Reference on the widget caller. - */ - void connect(appl::TextViewer& _widget); - /** - * @brief dis-connect a new widget to the plugin. - * @param[in] _widget Reference on the widget caller. - */ - void disconnect(appl::TextViewer& _widget); - /** - * @brief On entry event call. - * @param[in] _widget Reference on the widget caller. - * @param[in] _event Generic event. - * @return true if the event might not propagate anymore. - */ - bool onEventEntry(appl::TextViewer& _widget, - const ewol::event::Entry& _event); - /** - * @brief On Input event call. - * @param[in] _widget Reference on the widget caller. - * @param[in] _event Generic event. - * @return true if the event might not propagate anymore - */ - bool onEventInput(appl::TextViewer& _textDrawer, - const ewol::event::Input& _event); - /** - * @brief Called when data is written in the buffer. - * @param[in] _widget Reference on the widget caller. - * @param[in] _pos Position in the buffer where data might be witten. - * @param[in] _data Input stream written. - * @return true if the event might not propagate anymore - */ - bool onWrite(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const std::string& _data); - /** - * @brief Called when data is written in the buffer, and some are removed. - * @param[in] _widget Reference on the widget caller. - * @param[in] _pos Position in the buffer where data might be witten. - * @param[in] _data Input stream written. - * @param[in] _posEnd end replace position. - * @return true if the event might not propagate anymore - */ - bool onReplace(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const std::string& _data, - const appl::Buffer::Iterator& _posEnd); - /** - * @brief Called when data is removed. - * @param[in] _widget Reference on the widget caller. - * @param[in] _pos Position in the buffer where data might be witten. - * @param[in] _posEnd end replace position. - * @return true if the event might not propagate anymore - */ - bool onRemove(appl::TextViewer& _textDrawer, - const appl::Buffer::Iterator& _pos, - const appl::Buffer::Iterator& _posEnd); - /** - * @brief Called when a message arrive. - * @param[in] _widget Reference on the widget caller. - * @param[in] _msg Generic message. - * @return true if the event might not propagate anymore - */ - bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg); - /** - * @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); + class textPluginManager : public ewol::Resource { + private: + std::weak_ptr m_currentViewer; + std::list> m_list; + std::vector> m_listOnEventEntry; + std::vector> m_listOnEventInput; + std::vector> m_listOnWrite; + std::vector> m_listOnReplace; + std::vector> m_listOnRemove; + std::vector> m_listOnReceiveShortCutViewer; + std::vector> m_listOnCursorMove; + protected: + textPluginManager(); + void init(const std::string& _name); + public: + DECLARE_RESOURCE_SINGLE_FACTORY(textPluginManager, "plugin-Manager"); + virtual ~textPluginManager() {}; + /** + * @brief Add default plugin list + */ + void addDefaultPlugin(); + /** + * @brief Add a plugin. + * @param[in] _plugin Plugin pointer to add. + */ + void addPlugin(const std::shared_ptr& _plugin); + /** + * @brief connect a new widget to the plugin. + * @param[in] _widget Reference on the widget caller. + */ + void connect(appl::TextViewer& _widget); + /** + * @brief dis-connect a new widget to the plugin. + * @param[in] _widget Reference on the widget caller. + */ + void disconnect(appl::TextViewer& _widget); + /** + * @brief On entry event call. + * @param[in] _widget Reference on the widget caller. + * @param[in] _event Generic event. + * @return true if the event might not propagate anymore. + */ + bool onEventEntry(appl::TextViewer& _widget, + const ewol::event::Entry& _event); + /** + * @brief On Input event call. + * @param[in] _widget Reference on the widget caller. + * @param[in] _event Generic event. + * @return true if the event might not propagate anymore + */ + bool onEventInput(appl::TextViewer& _textDrawer, + const ewol::event::Input& _event); + /** + * @brief Called when data is written in the buffer. + * @param[in] _widget Reference on the widget caller. + * @param[in] _pos Position in the buffer where data might be witten. + * @param[in] _data Input stream written. + * @return true if the event might not propagate anymore + */ + bool onWrite(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const std::string& _data); + /** + * @brief Called when data is written in the buffer, and some are removed. + * @param[in] _widget Reference on the widget caller. + * @param[in] _pos Position in the buffer where data might be witten. + * @param[in] _data Input stream written. + * @param[in] _posEnd end replace position. + * @return true if the event might not propagate anymore + */ + bool onReplace(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const std::string& _data, + const appl::Buffer::Iterator& _posEnd); + /** + * @brief Called when data is removed. + * @param[in] _widget Reference on the widget caller. + * @param[in] _pos Position in the buffer where data might be witten. + * @param[in] _posEnd end replace position. + * @return true if the event might not propagate anymore + */ + bool onRemove(appl::TextViewer& _textDrawer, + const appl::Buffer::Iterator& _pos, + const appl::Buffer::Iterator& _posEnd); + /** + * @brief Called when a message arrive. + * @param[in] _widget Reference on the widget caller. + * @param[in] _shortCutName shortcut properties. + * @return true if the event might not propagate anymore + */ + bool onReceiveShortCut(appl::TextViewer& _textDrawer, + 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); }; }; diff --git a/sources/appl/TextPluginRmLine.cpp b/sources/appl/TextPluginRmLine.cpp index 802aad2..a0504c9 100644 --- a/sources/appl/TextPluginRmLine.cpp +++ b/sources/appl/TextPluginRmLine.cpp @@ -16,7 +16,7 @@ appl::TextPluginRmLine::TextPluginRmLine() { - m_activateOnReceiveMessage = true; + m_activateOnReceiveShortCut = true; addObjectType("appl::TextPluginRmLine"); } @@ -26,20 +26,19 @@ void appl::TextPluginRmLine::init() { void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) { // add event : - _textDrawer.ext_registerMultiCast(ednMsgGuiRm); - _textDrawer.ext_shortCutAdd("ctrl+w", ednMsgGuiRm); + _textDrawer.ext_shortCutAdd("ctrl+w", "appl::TextPluginRmLine::Rm"); } void appl::TextPluginRmLine::onPluginDisable(appl::TextViewer& _textDrawer) { - // TODO : unknow function ... + _textDrawer.ext_shortCutRm("appl::TextPluginRmLine::Rm"); } -bool appl::TextPluginRmLine::onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg) { +bool appl::TextPluginRmLine::onReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName) { if (isEnable() == false) { return false; } - if (_msg.getMessage() == ednMsgGuiRm) { + if (_shortCutName == "appl::TextPluginRmLine::Rm") { if (_textDrawer.hasBuffer() == false) { return false; } diff --git a/sources/appl/TextPluginRmLine.h b/sources/appl/TextPluginRmLine.h index 3cca37d..bfba1e2 100644 --- a/sources/appl/TextPluginRmLine.h +++ b/sources/appl/TextPluginRmLine.h @@ -28,7 +28,7 @@ namespace appl { public: virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginDisable(appl::TextViewer& _textDrawer); - virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg); + virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer, const std::string& _shortCutName); }; }; diff --git a/sources/appl/TextPluginSelectAll.cpp b/sources/appl/TextPluginSelectAll.cpp index 0eb6c75..4689a75 100644 --- a/sources/appl/TextPluginSelectAll.cpp +++ b/sources/appl/TextPluginSelectAll.cpp @@ -15,8 +15,11 @@ #define __class__ "TextPluginSelectAll" -appl::TextPluginSelectAll::TextPluginSelectAll() { - m_activateOnReceiveMessage = true; +appl::TextPluginSelectAll::TextPluginSelectAll() : + m_menuIdTitle(-1), + m_menuIdSelectAll(-1), + m_menuIdSelectNone(-1) { + m_activateOnReceiveShortCut = true; addObjectType("appl::TextPluginSelectAll"); } @@ -24,29 +27,53 @@ void appl::TextPluginSelectAll::init() { appl::TextViewerPlugin::init(); } -static const char* eventSelectAll = "plugin-select-all"; - void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) { + std::shared_ptr menu = m_menuInterface.lock(); + if (menu != nullptr) { + m_menuIdTitle = menu->addTitle("Edit"); + if (m_menuIdTitle != -1) { + m_menuIdSelectAll = menu->add(m_menuIdTitle, "Select All","", "appl::TextPluginSelectAll::menu:select-all"); + m_menuIdSelectNone = menu->add(m_menuIdTitle, "Un-Select","", "appl::TextPluginSelectAll::menu:select-none"); + } + } // add event : - _textDrawer.ext_registerMultiCast(eventSelectAll); - _textDrawer.ext_shortCutAdd("ctrl+a", eventSelectAll); + _textDrawer.ext_shortCutAdd("ctrl+a", "appl::TextPluginSelectAll::All"); + _textDrawer.ext_shortCutAdd("ctrl+shift+a", "appl::TextPluginSelectAll::None"); } void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) { - // TODO : unknow function ... + _textDrawer.ext_shortCutRm("appl::TextPluginSelectAll::All"); + _textDrawer.ext_shortCutRm("appl::TextPluginSelectAll::None"); + std::shared_ptr menu = m_menuInterface.lock(); + if (menu != nullptr) { + menu->remove(m_menuIdSelectNone); + menu->remove(m_menuIdSelectAll); + menu->remove(m_menuIdTitle); + } + m_menuIdTitle = -1; + m_menuIdSelectAll = -1; + m_menuIdSelectNone = -1; } -bool appl::TextPluginSelectAll::onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg) { + +bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName) { if (isEnable() == false) { return false; } - if (_msg.getMessage() == eventSelectAll) { + if (_shortCutName == "appl::TextPluginSelectAll::All") { if (_textDrawer.hasBuffer() == false) { return false; } _textDrawer.select(_textDrawer.begin(), _textDrawer.end()); return true; } + if (_shortCutName == "appl::TextPluginSelectAll::None") { + if (_textDrawer.hasBuffer() == false) { + return false; + } + _textDrawer.unSelect(); + return true; + } return false; } diff --git a/sources/appl/TextPluginSelectAll.h b/sources/appl/TextPluginSelectAll.h index 8b41a1e..c4b3fb7 100644 --- a/sources/appl/TextPluginSelectAll.h +++ b/sources/appl/TextPluginSelectAll.h @@ -20,6 +20,9 @@ namespace appl { protected: TextPluginSelectAll(); void init(); + int32_t m_menuIdTitle; + int32_t m_menuIdSelectAll; + int32_t m_menuIdSelectNone; public: DECLARE_FACTORY(TextPluginSelectAll); virtual ~TextPluginSelectAll() { @@ -28,7 +31,7 @@ namespace appl { public: virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginDisable(appl::TextViewer& _textDrawer); - virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg); + virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer, const std::string& _shortCutName); }; }; diff --git a/sources/appl/global.cpp b/sources/appl/global.cpp index 3824cd0..3cef25c 100644 --- a/sources/appl/global.cpp +++ b/sources/appl/global.cpp @@ -31,64 +31,6 @@ class myParamGlobal : public ewol::Object { m_static = true; // Note : set the object static notification( Must be set or assert at the end of process) setName("edn_global_param"); } - /* - bool onSetConfig(const ewol::object::Config& _conf) { - // Not set the EObject node parameter (name == > not change ...) - if (_conf.getConfig() == configEOL) { - m_displayEOL = etk::string_to_bool(_conf.getData()); - return true; - } - if (_conf.getConfig() == configAutoIndent) { - m_AutoIndent = etk::string_to_bool(_conf.getData()); - return true; - } - if (_conf.getConfig() == configShowTabChar) { - m_displayTabChar = etk::string_to_bool(_conf.getData()); - return true; - } - if (_conf.getConfig() == configShowSpaceChar) { - m_displaySpaceChar = etk::string_to_bool(_conf.getData()); - return true; - } - return false; - } - bool onGetConfig(const char* _config, std::string& _result) const { - // Not set the EObject node parameter (name == > not change ...) - if (_config == configEOL) { - if (true == m_displayEOL) { - _result = "true"; - } else { - _result = "false"; - } - return true; - } - if (_config == configAutoIndent) { - if (true == m_AutoIndent) { - _result = "true"; - } else { - _result = "false"; - } - return true; - } - if (_config == configShowTabChar) { - if (true == m_displayTabChar) { - _result = "true"; - } else { - _result = "false"; - } - return true; - } - if (_config == configShowSpaceChar) { - if (true == m_displaySpaceChar) { - _result = "true"; - } else { - _result = "false"; - } - return true; - } - return false; - } - */ }; @@ -161,11 +103,6 @@ int32_t globals::getNbLineBorder() { #include #include -static const char * const l_changeIndentation = "edn-event-change-indentation"; -static const char * const l_changeSpace = "edn-event-change-spaces"; -static const char * const l_changeTabulation = "edn-event-change-tabulation"; -static const char * const l_changeEndOfLine = "edn-event-change-endOfLine"; -static const char * const l_changeRounded = "edn-event-change-rounded"; globals::ParameterGlobalsGui::ParameterGlobalsGui() { addObjectType("globals::ParameterGlobalsGui"); @@ -189,7 +126,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetAutoIndent()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeIndentation); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackIndentation); subWidgetAdd(myCheckbox); } myCheckbox = ewol::widget::CheckBox::create("Display space char (' ')"); @@ -198,7 +135,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplaySpaceChar()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeSpace); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackSpace); subWidgetAdd(myCheckbox); } myCheckbox = ewol::widget::CheckBox::create("Display tabulation char ('\\t')"); @@ -207,7 +144,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayTabChar()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeTabulation); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackTabulation); subWidgetAdd(myCheckbox); } myCheckbox = ewol::widget::CheckBox::create("Display end of line ('\\n')"); @@ -216,7 +153,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayEndOfLine()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeEndOfLine); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackEndOfLine); subWidgetAdd(myCheckbox); } myCheckbox = ewol::widget::CheckBox::create("switch Rounded/default"); @@ -225,7 +162,7 @@ void globals::ParameterGlobalsGui::init() { } else { myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setValue(isSetDisplayEndOfLine()); - myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeRounded); + myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackRounded); subWidgetAdd(myCheckbox); } } @@ -235,43 +172,28 @@ globals::ParameterGlobalsGui::~ParameterGlobalsGui() { } -void globals::ParameterGlobalsGui::onReceiveMessage(const ewol::object::Message& _msg) { - ewol::widget::Sizer::onReceiveMessage(_msg); - - if (_msg.getMessage() == l_changeEndOfLine) { - if (_msg.getData() == "true") { - setDisplayEndOfLine(true); - } else { - setDisplayEndOfLine(false); - } - } else if (_msg.getMessage() == l_changeIndentation) { - if (_msg.getData() == "true") { - setAutoIndent(true); - } else { - setAutoIndent(false); - } - } else if (_msg.getMessage() == l_changeSpace) { - if (_msg.getData() == "true") { - setDisplaySpaceChar(true); - } else { - setDisplaySpaceChar(false); - } - } else if (_msg.getMessage() == l_changeTabulation) { - if (_msg.getData() == "true") { - setDisplayTabChar(true); - } else { - setDisplayTabChar(false); - } - } else if (_msg.getMessage() == l_changeRounded) { - if (_msg.getData() == "true") { - etk::theme::setName("GUI", "rounded");; - } else { - etk::theme::setName("GUI", "default");; - } - // Reload shaders and graphic system ... - ewol::getContext().getResourcesManager().reLoadResources(); - ewol::getContext().forceRedrawAll(); - } - +void globals::ParameterGlobalsGui::onCallbackEndOfLine(const bool& _value) { + setDisplayEndOfLine(_value); +} + +void globals::ParameterGlobalsGui::onCallbackIndentation(const bool& _value) { + setAutoIndent(_value); +} + +void globals::ParameterGlobalsGui::onCallbackSpace(const bool& _value) { + setDisplaySpaceChar(_value); +} +void globals::ParameterGlobalsGui::onCallbackTabulation(const bool& _value) { + setDisplayTabChar(_value); +} +void globals::ParameterGlobalsGui::onCallbackRounded(const bool& _value) { + if (_value == true) { + etk::theme::setName("GUI", "rounded");; + } else { + etk::theme::setName("GUI", "default");; + } + // Reload shaders and graphic system ... + ewol::getContext().getResourcesManager().reLoadResources(); + ewol::getContext().forceRedrawAll(); } diff --git a/sources/appl/global.h b/sources/appl/global.h index 60e6009..5c6d1b0 100644 --- a/sources/appl/global.h +++ b/sources/appl/global.h @@ -43,8 +43,11 @@ namespace globals public: DECLARE_FACTORY(ParameterGlobalsGui); virtual ~ParameterGlobalsGui(); - // herited function - virtual void onReceiveMessage(const ewol::object::Message& _msg); + void onCallbackEndOfLine(const bool& _value); + void onCallbackIndentation(const bool& _value); + void onCallbackSpace(const bool& _value); + void onCallbackTabulation(const bool& _value); + void onCallbackRounded(const bool& _value); }; } diff --git a/sources/appl/globalMsg.cpp b/sources/appl/globalMsg.cpp index 9c873e2..e69de29 100644 --- a/sources/appl/globalMsg.cpp +++ b/sources/appl/globalMsg.cpp @@ -1,66 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license GPL v3 (see license file) - */ - -#include - - -//////////////////////////////////////////////////////////////////////// -// Event of the gui request something : -//////////////////////////////////////////////////////////////////////// -extern const char* const ednMsgGuiNew = "edn-Msg-Gui-New"; -extern const char* const ednMsgGuiOpen = "edn-Msg-Gui-Open"; -extern const char* const ednMsgGuiClose = "edn-Msg-Gui-Close"; -extern const char* const ednMsgGuiSave = "edn-Msg-Gui-Save"; -extern const char* const ednMsgGuiSaveAs = "edn-Msg-Gui-SaveAs"; -extern const char* const ednMsgProperties = "edn-Msg-Gui-Properties"; -extern const char* const ednMsgGuiExit = "edn-Msg-Gui-quit"; - -extern const char* const ednMsgGuiUndo = "edn-Msg-Gui-Undo"; -extern const char* const ednMsgGuiRedo = "edn-Msg-Gui-Redo"; -extern const char* const ednMsgGuiCopy = "edn-Msg-Gui-Copy"; -extern const char* const ednMsgGuiCut = "edn-Msg-Gui-Cut"; -extern const char* const ednMsgGuiPaste = "edn-Msg-Gui-Paste"; -extern const char* const ednMsgGuiRm = "edn-Msg-Gui-Rm"; -extern const char* const ednMsgGuiSelect = "edn-Msg-Gui-Select"; -extern const char* const ednMsgGuiGotoLine = "edn-Msg-Gui-GotoLine"; - -extern const char* const ednMsgGuiSearch = "edn-Msg-Gui-Search"; -extern const char* const ednMsgGuiReplace = "edn-Msg-Gui-Replace"; -extern const char* const ednMsgGuiFind = "edn-Msg-Gui-Find"; - -extern const char* const ednMsgGuiShowSpaces = "edn-Msg-Gui-ShowSpaces"; -extern const char* const ednMsgGuiShowEndOfLine = "edn-Msg-Gui-ShowEndOfLine"; - -extern const char* const ednMsgGuiCtags = "edn-Msg-Gui-CTags"; -extern const char* const ednMsgCtagsLoadFile = "edn-Msg-CTags-direct-load"; - -extern const char* const ednMsgGuiReloadShader = "edn-Msg-Gui-ReloadOpenGlShader"; - - -//////////////////////////////////////////////////////////////////////// -// Event internal : -//////////////////////////////////////////////////////////////////////// -extern const char* const ednMsgBufferState = "edn-Msg-Buffer-State"; -extern const char* const ednMsgBufferName = "edn-Msg-Buffer-Name"; -extern const char* const ednMsgBufferId = "edn-Msg-Buffer-Id"; -extern const char* const ednMsgCodeViewSelectedId = "edn-Msg-CodeView-Select-Id"; -extern const char* const ednMsgOpenFile = "edn-Msg-OpenFile"; - -extern const char* const ednMsgBufferListChange = "edn-Msg-BufferListChange"; - -extern const char* const ednMsgBufferColor = "edn-Msg-Buffer-Color"; - - -extern const char* const appl::MsgSelectNewFile = "edn-msg-select-new-file"; -extern const char* const appl::MsgSelectChange = "edn-msg-select-change"; -extern const char* const appl::MsgNameChange = "edn-msg-buffer-name-change"; -extern const char* const appl::MsgNameGuiChangeColor = "edn-Msg-Gui-Change-color"; -extern const char* const appl::MsgSelectGotoLine = "edn-Msg-Gui-goto-line"; -extern const char* const appl::MsgSelectGotoLineSelect = "edn-Msg-Gui-goto-line-select"; - - diff --git a/sources/appl/globalMsg.h b/sources/appl/globalMsg.h index 6d3d58f..e69de29 100644 --- a/sources/appl/globalMsg.h +++ b/sources/appl/globalMsg.h @@ -1,68 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license GPL v3 (see license file) - */ - -#ifndef __MSG_BROADCAST_H__ -#define __MSG_BROADCAST_H__ - -//////////////////////////////////////////////////////////////////////// -// Event of the gui request something : -//////////////////////////////////////////////////////////////////////// - extern const char* const ednMsgGuiNew; // data : "" - extern const char* const ednMsgGuiOpen; // data : "" - extern const char* const ednMsgGuiClose; // data : "current" "All" - extern const char* const ednMsgGuiSave; // data : "" - extern const char* const ednMsgGuiSaveAs; // data : "" - extern const char* const ednMsgProperties; // data : "" - extern const char* const ednMsgGuiExit; // data : "" - - extern const char* const ednMsgGuiUndo; // data : "" - extern const char* const ednMsgGuiRedo; // data : "" - extern const char* const ednMsgGuiCopy; // data : "STD" "Middle" "1" ... "9" - extern const char* const ednMsgGuiCut; // data : "STD" "Middle" "1" ... "9" - extern const char* const ednMsgGuiPaste; // data : "STD" "Middle" "1" ... "9" - extern const char* const ednMsgGuiRm; // data : "Word" "Line" "Paragraph" - extern const char* const ednMsgGuiSelect; // data : "ALL" "NONE" - extern const char* const ednMsgGuiGotoLine; // data : "???" / "1" ... "999999999999" - - extern const char* const ednMsgGuiSearch; // data : "" - extern const char* const ednMsgGuiReplace; // data : "Normal" "All" - extern const char* const ednMsgGuiFind; // data : "Next" "Previous" "All" "None" - - extern const char* const ednMsgGuiShowSpaces; // data : "enable" "disable" - extern const char* const ednMsgGuiShowEndOfLine; // data : "enable" "disable" - - extern const char* const ednMsgGuiCtags; // data : "Load" "ReLoad" "Jump" "Back" - extern const char* const ednMsgCtagsLoadFile; // data : "filename of the ctags file" - - extern const char* const ednMsgGuiReloadShader; // data : "" - - -//////////////////////////////////////////////////////////////////////// -// Event internal : -//////////////////////////////////////////////////////////////////////// - extern const char* const ednMsgBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory" - extern const char* const ednMsgBufferName; // data : "filename" - extern const char* const ednMsgBufferId; // data : "0" ... "99999999999" - extern const char* const ednMsgCodeViewSelectedId; // data : "0" ... "99999999999" - extern const char* const ednMsgOpenFile; // data : "/Compleate/file/name.xx" - - extern const char* const ednMsgBufferListChange; // data : "" - - extern const char* const ednMsgBufferColor; // data : "new" - -namespace appl { - extern const char* const MsgSelectNewFile; // data : "buffer/name" - extern const char* const MsgSelectChange; // data : "" - extern const char* const MsgNameChange; // data : "" - extern const char* const MsgNameGuiChangeColor; // data : "Black" "White" - extern const char* const MsgSelectGotoLine; // data : "75822" - extern const char* const MsgSelectGotoLineSelect; // data : "75822" -}; - -#endif - diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 7b442b1..0882ced 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -32,6 +32,7 @@ class MainApplication : public ewol::context::Application { private: std::shared_ptr m_bufferManager; + std::shared_ptr m_pluginManager; public: bool init(ewol::Context& _context, size_t _initId) { APPL_INFO(" == > init APPL v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")"); @@ -58,10 +59,9 @@ class MainApplication : public ewol::context::Application { // init ALL Singleton : //()CTagsManager::getInstance(); m_bufferManager = appl::BufferManager::create(); + m_pluginManager = appl::textPluginManager::create(); appl::highlightManager::init(); - appl::textPluginManager::init(); - appl::textPluginManager::addDefaultPlugin(); // Request load of the user configuration ... //ewol::userConfig::load(); @@ -84,6 +84,8 @@ class MainApplication : public ewol::context::Application { // create the specific windows _context.setWindows(basicWindows); + // need to add default plugin, because they depend on the Menu widget wich might be named : "appl-menu-interface" + m_pluginManager->addDefaultPlugin(); // add files APPL_INFO("show list of files : "); @@ -97,7 +99,7 @@ class MainApplication : public ewol::context::Application { std::string name = file.getName(); APPL_INFO("Load ctag file : \"" << name << "\"" ); ctagDetected = false; - _context.getEObjectManager().multiCast().anonymousSend(ednMsgCtagsLoadFile, name); + //_context.getEObjectManager().multiCast().anonymousSend(ednMsgCtagsLoadFile, name); } else { etk::FSNode file(tmpppp); std::string name = file.getName(); @@ -111,10 +113,10 @@ class MainApplication : public ewol::context::Application { } void unInit(ewol::Context& _context) { APPL_INFO(" == > Un-Init " PROJECT_NAME " (START)"); - appl::textPluginManager::unInit(); APPL_INFO("Stop Hightlight"); appl::highlightManager::unInit(); //Kill all singleton + m_pluginManager.reset(); m_bufferManager.reset(); APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)"); } diff --git a/sources/lutin_edn.py b/sources/lutin_edn.py index 33c41ed..9106f5b 100755 --- a/sources/lutin_edn.py +++ b/sources/lutin_edn.py @@ -102,9 +102,12 @@ def create(target): myModule.compile_flags_CC([ "-DAPPL_VERSION=\"\\\"" + versionID + "\\\"\"" ]) + tagFile = tools.get_current_path(__file__) + "/tagCode" + versionIDCode = tools.file_read_data(tagFile) # set the package properties : myModule.pkg_set("VERSION", versionID) + myModule.pkg_set("VERSION_CODE", versionIDCode) myModule.pkg_set("COMPAGNY_TYPE", "org") myModule.pkg_set("COMPAGNY_NAME", "Edouard DUPIN") myModule.pkg_set("MAINTAINER", ["Mr DUPIN Edouard "]) diff --git a/sources/tag b/sources/tag index cb174d5..d2d61a7 100644 --- a/sources/tag +++ b/sources/tag @@ -1 +1 @@ -1.2.1 \ No newline at end of file +1.2.2 \ No newline at end of file diff --git a/sources/tagCode b/sources/tagCode new file mode 100644 index 0000000..62f9457 --- /dev/null +++ b/sources/tagCode @@ -0,0 +1 @@ +6 \ No newline at end of file