From 03fa46bbcd719a0c5c22bcc1a22458069ce77ef2 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 20 Aug 2014 22:34:31 +0200 Subject: [PATCH 01/20] [DEV] rework signal interface (step 1 normalisation) --- sources/appl/Buffer.cpp | 28 ++++++++++--------------- sources/appl/Buffer.h | 9 ++++---- sources/appl/Gui/BufferView.cpp | 16 +++++++------- sources/appl/Gui/MainWindows.cpp | 20 ++++++++++-------- sources/appl/Gui/TagFileList.cpp | 23 +++++++++----------- sources/appl/Gui/TagFileList.h | 9 ++++---- sources/appl/Gui/TagFileSelection.cpp | 27 +++++++++++++----------- sources/appl/Gui/TagFileSelection.h | 6 +++--- sources/appl/Gui/TextViewer.cpp | 12 +++++++---- sources/appl/Gui/WorkerCloseAllFile.cpp | 4 ++-- sources/appl/Gui/WorkerCloseFile.cpp | 12 +++++------ sources/appl/Gui/WorkerCloseFile.h | 2 +- sources/appl/Gui/WorkerSaveAllFile.cpp | 4 ++-- sources/appl/Gui/WorkerSaveFile.cpp | 12 +++++------ sources/appl/Gui/WorkerSaveFile.h | 2 +- sources/appl/TextPluginCtags.cpp | 2 +- 16 files changed, 93 insertions(+), 95 deletions(-) diff --git a/sources/appl/Buffer.cpp b/sources/appl/Buffer.cpp index edeaa2c..a68a35d 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() { @@ -176,7 +170,7 @@ void appl::Buffer::setFileName(const std::string& _name) { } m_fileName = name; m_hasFileName = true; - generateEventId(eventChangeName); + signalChangeName.emit(shared_from_this()); setModification(true); } @@ -195,9 +189,9 @@ void appl::Buffer::setModification(bool _status) { } m_isModify = _status; if (m_isModify == true) { - generateEventId(eventIsModify); + signalIsModify.emit(shared_from_this()); } else { - generateEventId(eventIsSave); + signalIsSave.emit(shared_from_this()); } } @@ -420,13 +414,13 @@ void appl::Buffer::moveCursor(int64_t _pos) { if (m_cursorPos == m_cursorSelectPos) { m_cursorSelectPos = -1; } - generateEventId(eventSelectChange); + signalSelectChange.emit(shared_from_this()); return; } // move mode m_cursorPos = _pos; m_cursorSelectPos = -1; - generateEventId(eventSelectChange); + signalSelectChange.emit(shared_from_this()); } 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(shared_from_this()); } void appl::Buffer::unSelect() { m_cursorSelectPos = -1; - generateEventId(eventSelectChange); + signalSelectChange.emit(shared_from_this()); } static const char *ControlCodeTable[32] = { diff --git a/sources/appl/Buffer.h b/sources/appl/Buffer.h index 9891212..3f98895 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(); diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index b3d9c5f..8288f56 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -104,7 +104,9 @@ void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _sel } } } - +static const char* const ednEventIsSave = "edn-buffer-is-saved"; +static const char* const ednEventIsModify = "edn-buffer-is-modify"; +static const char* const ednEventChangeName = "edn-buffer-change-name"; void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { APPL_VERBOSE("message : " << _msg); @@ -115,9 +117,9 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { APPL_ERROR("event on element nor exist : " << _msg.getData()); return; } - buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsSave); - buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify); - buffer->registerOnEvent(shared_from_this(), appl::Buffer::eventChangeName); + buffer->registerOnEvent(shared_from_this(), "is-save", ednEventIsSave); + buffer->registerOnEvent(shared_from_this(), "is-modify", ednEventIsModify); + buffer->registerOnEvent(shared_from_this(), "change-name", ednEventChangeName); appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer); if (tmp == nullptr) { APPL_ERROR("Allocation error of the tmp buffer list element"); @@ -131,7 +133,7 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { markToRedraw(); return; } - if (_msg.getMessage() == appl::Buffer::eventChangeName) { + if (_msg.getMessage() == ednEventChangeName) { for (size_t iii = 0; iii < m_list.size(); ++iii) { if (m_list[iii] == nullptr) { continue; @@ -151,11 +153,11 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { markToRedraw(); return; } - if (_msg.getMessage() == appl::Buffer::eventIsSave) { + if (_msg.getMessage() == ednEventIsSave) { markToRedraw(); return; } - if (_msg.getMessage() == appl::Buffer::eventIsModify) { + if (_msg.getMessage() == ednEventIsModify) { markToRedraw(); return; } diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index e0f0993..79448d2 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -279,9 +279,11 @@ MainWindows::~MainWindows() { } -const char *const ednEventPopUpFileSelected = "edn-mainWindows-openSelected"; -const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected"; - +static const char* const ednEventPopUpFileSelected = "edn-mainWindows-openSelected"; +static const char* const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected"; +static const char* const ednEventIsSave = "edn-buffer-is-saved"; +static const char* const ednEventIsModify = "edn-buffer-is-modify"; +static const char* const ednEventChangeName = "edn-buffer-change-name"; void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { ewol::widget::Windows::onReceiveMessage(_msg); @@ -378,9 +380,9 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { return; } if ( _msg.getMessage() == appl::MsgSelectNewFile - || _msg.getMessage() == appl::Buffer::eventIsModify - || _msg.getMessage() == appl::Buffer::eventIsSave - || _msg.getMessage() == appl::Buffer::eventChangeName) { + || _msg.getMessage() == ednEventIsModify + || _msg.getMessage() == ednEventIsSave + || _msg.getMessage() == ednEventChangeName) { // select a new Buffer ==> change title: std::shared_ptr tmpp = m_bufferManager->getBufferSelected(); if (tmpp == nullptr) { @@ -390,9 +392,9 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } } 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); + tmpp->registerOnEvent(shared_from_this(), "is-save", ednEventIsSave); + tmpp->registerOnEvent(shared_from_this(), "is-modify", ednEventIsModify); + tmpp->registerOnEvent(shared_from_this(), "change-name", ednEventChangeName); } std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem); diff --git a/sources/appl/Gui/TagFileList.cpp b/sources/appl/Gui/TagFileList.cpp index be19a79..6216f25 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(shared_from_this(), etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); + } else { + signalValidate.emit(shared_from_this(), etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); + } } else { - generateEventId(applEventCtagsListUnSelect); + signalUnSelect.emit(shared_from_this()); } // 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..8a36cf1 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() { @@ -81,9 +85,9 @@ void appl::TagFileSelection::init() { 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->registerOnEvent(shared_from_this(), "validate", applEventCtagsListValidate); + m_listTag->registerOnEvent(shared_from_this(), "select", applEventCtagsListSelect); + m_listTag->registerOnEvent(shared_from_this(), "unselect", applEventCtagsListUnSelect); m_listTag->setExpand(bvec2(true,true)); m_listTag->setFill(bvec2(true,true)); mySizerVert->subWidgetAdd(m_listTag); @@ -108,21 +112,20 @@ 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); + signalSelect.emit(shared_from_this(), 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()); + signalSelect.emit(shared_from_this(), _msg.getData()); // == > Auto remove ... autoDestroy(); } else if (_msg.getMessage() == applEventctagsCancel) { - generateEventId(applEventctagsCancel, ""); + signalCancel.emit(shared_from_this()); // == > Auto remove ... autoDestroy(); } diff --git a/sources/appl/Gui/TagFileSelection.h b/sources/appl/Gui/TagFileSelection.h index 2d4ba0e..a08174f 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; diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index c147aa3..93a6335 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"); @@ -634,11 +638,11 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { return; } // event needed even if selection of buffer is not done ... - if (_msg.getMessage() == appl::Buffer::eventIsModify) { + if (_msg.getMessage() == appl_Buffer_eventIsModify) { markToRedraw(); return; } - if (_msg.getMessage() == appl::Buffer::eventSelectChange) { + if (_msg.getMessage() == appl_Buffer_eventSelectChange) { markToRedraw(); return; } @@ -687,8 +691,8 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { m_buffer = m_bufferManager->get(_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); + m_buffer->registerOnEvent(shared_from_this(), "is-modify", appl_Buffer_eventIsModify); + m_buffer->registerOnEvent(shared_from_this(), "select-change", appl_Buffer_eventSelectChange); for (auto element : m_drawingRemenber) { if (element.first == m_buffer) { m_originScrooled = element.second; diff --git a/sources/appl/Gui/WorkerCloseAllFile.cpp b/sources/appl/Gui/WorkerCloseAllFile.cpp index aada838..0ee9ef0 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.cpp +++ b/sources/appl/Gui/WorkerCloseAllFile.cpp @@ -54,7 +54,7 @@ void appl::WorkerCloseAllFile::init() { autoDestroy(); return; } - m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone); + m_worker->registerOnEvent(shared_from_this(), "close-file-done", s_closeDone); } appl::WorkerCloseAllFile::~WorkerCloseAllFile() { @@ -79,7 +79,7 @@ void appl::WorkerCloseAllFile::onReceiveMessage(const ewol::object::Message& _ms autoDestroy(); return; } - m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone); + m_worker->registerOnEvent(shared_from_this(), "close-file-done", s_closeDone); } } diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index c5f4a11..1a7ceb3 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -14,19 +14,17 @@ #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"), m_buffer(nullptr), m_worker(nullptr), m_bufferManager(nullptr) { addObjectType("appl::WorkerCloseFile"); - addEventId(eventCloseDone); // load buffer manager: m_bufferManager = appl::BufferManager::create(); } @@ -61,7 +59,7 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) { return; } if (m_buffer->isModify() == false) { - generateEventId(eventCloseDone); + signalCloseDone.emit(shared_from_this()); m_buffer->destroy(); return; } @@ -112,7 +110,7 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::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); + m_worker->registerOnEvent(shared_from_this(), "save-file-done", s_saveAsDone); } } else if (_msg.getMessage() == s_saveValidate) { if (m_buffer == nullptr) { @@ -127,7 +125,7 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) } tmpWindows->displayWarningMessage("We can not save the file :
" + m_buffer->getFileName() + ""); } else { - generateEventId(eventCloseDone); + signalCloseDone.emit(shared_from_this()); } } else if ( _msg.getMessage() == s_closeValidate || _msg.getMessage() == s_saveAsDone) { @@ -136,7 +134,7 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) autoDestroy(); return; } - generateEventId(eventCloseDone); + signalCloseDone.emit(shared_from_this()); m_buffer->destroy(); m_buffer.reset(); } diff --git a/sources/appl/Gui/WorkerCloseFile.h b/sources/appl/Gui/WorkerCloseFile.h index 31354c4..c405928 100644 --- a/sources/appl/Gui/WorkerCloseFile.h +++ b/sources/appl/Gui/WorkerCloseFile.h @@ -16,7 +16,7 @@ namespace appl { class WorkerCloseFile : public ewol::Object { public: - static const char* eventCloseDone; + ewol::object::Signal signalCloseDone; protected: // note : if == "" ==> current ... WorkerCloseFile(); diff --git a/sources/appl/Gui/WorkerSaveAllFile.cpp b/sources/appl/Gui/WorkerSaveAllFile.cpp index 68a9381..0e2fb80 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.cpp +++ b/sources/appl/Gui/WorkerSaveAllFile.cpp @@ -56,7 +56,7 @@ void appl::WorkerSaveAllFile::init() { autoDestroy(); return; } - m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); + m_worker->registerOnEvent(shared_from_this(), "save-file-done", s_saveAsDone); } appl::WorkerSaveAllFile::~WorkerSaveAllFile() { @@ -81,7 +81,7 @@ void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::object::Message& _msg autoDestroy(); return; } - m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); + m_worker->registerOnEvent(shared_from_this(), "save-file-done", s_saveAsDone); } } diff --git a/sources/appl/Gui/WorkerSaveFile.cpp b/sources/appl/Gui/WorkerSaveFile.cpp index dde1524..8f13fd5 100644 --- a/sources/appl/Gui/WorkerSaveFile.cpp +++ b/sources/appl/Gui/WorkerSaveFile.cpp @@ -13,13 +13,11 @@ #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") { addObjectType("appl::WorkerSaveFile"); - addEventId(eventSaveDone); // load buffer manager: m_bufferManager = appl::BufferManager::create(); } @@ -56,7 +54,7 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA if (_forceSaveAs == false) { if (tmpBuffer->hasFileName() == true) { tmpBuffer->storeFile(); - generateEventId(eventSaveDone); + signalSaveDone.emit(shared_from_this()); autoDestroy(); return; } @@ -79,7 +77,7 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA return; } tmpWindows->popUpWidgetPush(m_chooser); - m_chooser->registerOnEvent(shared_from_this(), ewol::widget::FileChooser::eventValidate, s_saveAsValidate); + m_chooser->registerOnEvent(shared_from_this(), "validate", s_saveAsValidate); } appl::WorkerSaveFile::~WorkerSaveFile() { @@ -113,7 +111,7 @@ void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) { } tmpWindows->displayWarningMessage("We can not save the file :
" + tmpBuffer->getFileName() + ""); } else { - generateEventId(eventSaveDone); + signalSaveDone.emit(shared_from_this()); } } } diff --git a/sources/appl/Gui/WorkerSaveFile.h b/sources/appl/Gui/WorkerSaveFile.h index 3fbf3b6..61d76ca 100644 --- a/sources/appl/Gui/WorkerSaveFile.h +++ b/sources/appl/Gui/WorkerSaveFile.h @@ -15,7 +15,7 @@ namespace appl { class WorkerSaveFile : public ewol::Object { public: - static const char* eventSaveDone; + ewol::object::Signal signalSaveDone; protected: WorkerSaveFile(); void init(const std::string& _bufferName, bool _forceSaveAs=true); diff --git a/sources/appl/TextPluginCtags.cpp b/sources/appl/TextPluginCtags.cpp index 2630871..5d65681 100644 --- a/sources/appl/TextPluginCtags.cpp +++ b/sources/appl/TextPluginCtags.cpp @@ -98,7 +98,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->registerOnEvent(shared_from_this(), "select", eventOpenCtagsSelectReturn); } } else { jumpFile(myfile.getName(), lineID - 1); From d31137e1a3c360d07d14543cd2e6751a635f67d4 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 21 Aug 2014 21:00:13 +0200 Subject: [PATCH 02/20] [DEBUG] gcc compilation warning --- sources/appl/TextPlugin.cpp | 6 ++--- sources/appl/TextPlugin.h | 4 +-- sources/appl/TextPluginData.h | 40 +++++++++++++++--------------- sources/appl/TextPluginHistory.cpp | 32 ++++++++++++------------ sources/appl/TextPluginHistory.h | 32 ++++++++++++------------ 5 files changed, 57 insertions(+), 57 deletions(-) diff --git a/sources/appl/TextPlugin.cpp b/sources/appl/TextPlugin.cpp index 6a9089a..ea4b751 100644 --- a/sources/appl/TextPlugin.cpp +++ b/sources/appl/TextPlugin.cpp @@ -35,7 +35,7 @@ appl::TextViewerPlugin::~TextViewerPlugin() { return; } m_isEnable = false; - onPluginDisable(); + onPluginGlobalDisable(); } void appl::TextViewerPlugin::setEnableStatus(bool _status) { @@ -44,9 +44,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..e8584f1 100644 --- a/sources/appl/TextPlugin.h +++ b/sources/appl/TextPlugin.h @@ -42,13 +42,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 ... }; /** diff --git a/sources/appl/TextPluginData.h b/sources/appl/TextPluginData.h index 389c0e9..9081d12 100644 --- a/sources/appl/TextPluginData.h +++ b/sources/appl/TextPluginData.h @@ -61,7 +61,7 @@ namespace appl { if (data == nullptr) { return false; } - return onReceiveMessageViewer(_textDrawer, _msg, *data); + return onDataReceiveMessageViewer(_textDrawer, _msg, *data); } bool onWrite(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, @@ -70,7 +70,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 +80,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 +89,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 onDataReceiveMessageViewer(appl::TextViewer& _textDrawer, + const ewol::object::Message& _msg, + 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..0793f8b 100644 --- a/sources/appl/TextPluginHistory.cpp +++ b/sources/appl/TextPluginHistory.cpp @@ -40,9 +40,9 @@ void appl::TextPluginHistory::onPluginDisable(appl::TextViewer& _textDrawer) { // TODO : unknow function ... } -bool appl::TextPluginHistory::onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg, - appl::PluginHistoryData& _data) { +bool appl::TextPluginHistory::onDataReceiveMessageViewer(appl::TextViewer& _textDrawer, + const ewol::object::Message& _msg, + appl::PluginHistoryData& _data) { if (isEnable() == false) { return false; } @@ -111,10 +111,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; } @@ -134,11 +134,11 @@ bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer, 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; } @@ -159,10 +159,10 @@ bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer, 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; } diff --git a/sources/appl/TextPluginHistory.h b/sources/appl/TextPluginHistory.h index 787d916..3d66d86 100644 --- a/sources/appl/TextPluginHistory.h +++ b/sources/appl/TextPluginHistory.h @@ -46,22 +46,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 onDataReceiveMessageViewer(appl::TextViewer& _textDrawer, + const ewol::object::Message& _msg, + 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); From 686ec6d8bd2082f3c7358e11a6b989148fa15c60 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 22 Aug 2014 05:21:10 +0200 Subject: [PATCH 03/20] [DEV] remove caller in signal emit --- sources/appl/Buffer.cpp | 14 +++++++------- sources/appl/Gui/TagFileList.cpp | 6 +++--- sources/appl/Gui/TagFileSelection.cpp | 6 +++--- sources/appl/Gui/WorkerCloseFile.cpp | 6 +++--- sources/appl/Gui/WorkerSaveFile.cpp | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sources/appl/Buffer.cpp b/sources/appl/Buffer.cpp index a68a35d..42c7f65 100644 --- a/sources/appl/Buffer.cpp +++ b/sources/appl/Buffer.cpp @@ -170,7 +170,7 @@ void appl::Buffer::setFileName(const std::string& _name) { } m_fileName = name; m_hasFileName = true; - signalChangeName.emit(shared_from_this()); + signalChangeName.emit(); setModification(true); } @@ -189,9 +189,9 @@ void appl::Buffer::setModification(bool _status) { } m_isModify = _status; if (m_isModify == true) { - signalIsModify.emit(shared_from_this()); + signalIsModify.emit(); } else { - signalIsSave.emit(shared_from_this()); + signalIsSave.emit(); } } @@ -414,13 +414,13 @@ void appl::Buffer::moveCursor(int64_t _pos) { if (m_cursorPos == m_cursorSelectPos) { m_cursorSelectPos = -1; } - signalSelectChange.emit(shared_from_this()); + signalSelectChange.emit(); return; } // move mode m_cursorPos = _pos; m_cursorSelectPos = -1; - signalSelectChange.emit(shared_from_this()); + signalSelectChange.emit(); } bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos, @@ -513,12 +513,12 @@ bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos, void appl::Buffer::setSelectionPos(const appl::Buffer::Iterator& _pos) { m_cursorSelectPos = _pos; - signalSelectChange.emit(shared_from_this()); + signalSelectChange.emit(); } void appl::Buffer::unSelect() { m_cursorSelectPos = -1; - signalSelectChange.emit(shared_from_this()); + signalSelectChange.emit(); } static const char *ControlCodeTable[32] = { diff --git a/sources/appl/Gui/TagFileList.cpp b/sources/appl/Gui/TagFileList.cpp index 6216f25..9b3131f 100644 --- a/sources/appl/Gui/TagFileList.cpp +++ b/sources/appl/Gui/TagFileList.cpp @@ -93,12 +93,12 @@ bool appl::TagFileList::onItemEvent(int32_t _IdInput, enum ewol::key::status _ty && m_selectedLine < (int64_t)m_list.size() && nullptr != m_list[m_selectedLine] ) { if (previousRaw != m_selectedLine) { - signalSelect.emit(shared_from_this(), etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); + signalSelect.emit(etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); } else { - signalValidate.emit(shared_from_this(), etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); + signalValidate.emit(etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); } } else { - signalUnSelect.emit(shared_from_this()); + signalUnSelect.emit(); } // need to regenerate the display of the list : markToRedraw(); diff --git a/sources/appl/Gui/TagFileSelection.cpp b/sources/appl/Gui/TagFileSelection.cpp index 8a36cf1..82e19d6 100644 --- a/sources/appl/Gui/TagFileSelection.cpp +++ b/sources/appl/Gui/TagFileSelection.cpp @@ -112,7 +112,7 @@ void appl::TagFileSelection::onReceiveMessage(const ewol::object::Message& _msg) EWOL_INFO("ctags LIST ... : " << _msg ); if (_msg.getMessage() == applEventctagsSelection) { if (m_eventNamed!="") { - signalSelect.emit(shared_from_this(), m_eventNamed); + signalSelect.emit(m_eventNamed); // == > Auto remove ... autoDestroy(); } @@ -121,11 +121,11 @@ void appl::TagFileSelection::onReceiveMessage(const ewol::object::Message& _msg) } else if (_msg.getMessage() == applEventCtagsListUnSelect) { m_eventNamed = ""; } else if (_msg.getMessage() == applEventCtagsListValidate) { - signalSelect.emit(shared_from_this(), _msg.getData()); + signalSelect.emit(_msg.getData()); // == > Auto remove ... autoDestroy(); } else if (_msg.getMessage() == applEventctagsCancel) { - signalCancel.emit(shared_from_this()); + signalCancel.emit(); // == > Auto remove ... autoDestroy(); } diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index 1a7ceb3..2287b26 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -59,7 +59,7 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) { return; } if (m_buffer->isModify() == false) { - signalCloseDone.emit(shared_from_this()); + signalCloseDone.emit(); m_buffer->destroy(); return; } @@ -125,7 +125,7 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) } tmpWindows->displayWarningMessage("We can not save the file :
" + m_buffer->getFileName() + ""); } else { - signalCloseDone.emit(shared_from_this()); + signalCloseDone.emit(); } } else if ( _msg.getMessage() == s_closeValidate || _msg.getMessage() == s_saveAsDone) { @@ -134,7 +134,7 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) autoDestroy(); return; } - signalCloseDone.emit(shared_from_this()); + signalCloseDone.emit(); m_buffer->destroy(); m_buffer.reset(); } diff --git a/sources/appl/Gui/WorkerSaveFile.cpp b/sources/appl/Gui/WorkerSaveFile.cpp index 8f13fd5..e81dafe 100644 --- a/sources/appl/Gui/WorkerSaveFile.cpp +++ b/sources/appl/Gui/WorkerSaveFile.cpp @@ -54,7 +54,7 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA if (_forceSaveAs == false) { if (tmpBuffer->hasFileName() == true) { tmpBuffer->storeFile(); - signalSaveDone.emit(shared_from_this()); + signalSaveDone.emit(); autoDestroy(); return; } @@ -111,7 +111,7 @@ void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) { } tmpWindows->displayWarningMessage("We can not save the file :
" + tmpBuffer->getFileName() + ""); } else { - signalSaveDone.emit(shared_from_this()); + signalSaveDone.emit(); } } } From cd3c5ff2d408a48ac6d91085ddf912dc0370f5b5 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 25 Aug 2014 05:55:06 +0200 Subject: [PATCH 04/20] [DEV] update new object interface & rework global message (start) --- sources/appl/Gui/BufferView.cpp | 63 +++++------ sources/appl/Gui/BufferView.h | 4 + sources/appl/Gui/MainWindows.cpp | 72 +++++++------ sources/appl/Gui/MainWindows.h | 3 + sources/appl/Gui/Search.cpp | 81 ++++++++------ sources/appl/Gui/Search.h | 11 ++ sources/appl/Gui/TagFileSelection.cpp | 55 +++++----- sources/appl/Gui/TagFileSelection.h | 8 +- sources/appl/Gui/TextViewer.cpp | 23 ++-- sources/appl/Gui/TextViewer.h | 3 + sources/appl/Gui/WorkerCloseAllFile.cpp | 32 +++--- sources/appl/Gui/WorkerCloseAllFile.h | 4 +- sources/appl/Gui/WorkerCloseFile.cpp | 86 +++++++-------- sources/appl/Gui/WorkerCloseFile.h | 6 +- sources/appl/Gui/WorkerSaveAllFile.cpp | 32 +++--- sources/appl/Gui/WorkerSaveAllFile.h | 4 +- sources/appl/Gui/WorkerSaveFile.cpp | 47 ++++----- sources/appl/Gui/WorkerSaveFile.h | 4 +- sources/appl/TextPluginCtags.cpp | 43 ++++---- sources/appl/TextPluginCtags.h | 5 +- sources/appl/global.cpp | 134 +++++------------------- sources/appl/global.h | 7 +- sources/appl/globalMsg.cpp | 41 ++++---- sources/appl/globalMsg.h | 106 ++++++++++--------- sources/appl/init.cpp | 2 +- 25 files changed, 423 insertions(+), 453 deletions(-) diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index 8288f56..e965838 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -104,10 +104,6 @@ void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _sel } } } -static const char* const ednEventIsSave = "edn-buffer-is-saved"; -static const char* const ednEventIsModify = "edn-buffer-is-modify"; -static const char* const ednEventChangeName = "edn-buffer-change-name"; - void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { APPL_VERBOSE("message : " << _msg); ewol::widget::List::onReceiveMessage(_msg); @@ -117,9 +113,9 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { APPL_ERROR("event on element nor exist : " << _msg.getData()); return; } - buffer->registerOnEvent(shared_from_this(), "is-save", ednEventIsSave); - buffer->registerOnEvent(shared_from_this(), "is-modify", ednEventIsModify); - buffer->registerOnEvent(shared_from_this(), "change-name", ednEventChangeName); + 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 = new appl::dataBufferStruct(_msg.getData(), buffer); if (tmp == nullptr) { APPL_ERROR("Allocation error of the tmp buffer list element"); @@ -133,34 +129,6 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { markToRedraw(); return; } - if (_msg.getMessage() == ednEventChangeName) { - 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() == ednEventIsSave) { - markToRedraw(); - return; - } - if (_msg.getMessage() == ednEventIsModify) { - markToRedraw(); - return; - } if (_msg.getMessage() == appl::MsgSelectChange) { m_selectedID = -1; std::shared_ptr tmpBuffer; @@ -222,6 +190,31 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { } } +void BufferView::onCallbackChangeName() { + 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(); +} +void BufferView::onCallbackIsSave() { + markToRedraw(); +} +void BufferView::onCallbackIsModify() { + markToRedraw(); +} etk::Color<> BufferView::getBasicBG() { return (*m_paintingProperties)[m_colorBackground1].getForeground(); diff --git a/sources/appl/Gui/BufferView.h b/sources/appl/Gui/BufferView.h index e3c3a3b..8f29819 100644 --- a/sources/appl/Gui/BufferView.h +++ b/sources/appl/Gui/BufferView.h @@ -69,6 +69,10 @@ 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(); }; diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 79448d2..00809a4 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -279,7 +279,6 @@ MainWindows::~MainWindows() { } -static const char* const ednEventPopUpFileSelected = "edn-mainWindows-openSelected"; static const char* const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected"; static const char* const ednEventIsSave = "edn-buffer-is-saved"; static const char* const ednEventIsModify = "edn-buffer-is-modify"; @@ -310,7 +309,7 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } // apply widget pop-up ... popUpWidgetPush(tmpWidget); - tmpWidget->registerOnEvent(shared_from_this(), "validate", ednEventPopUpFileSelected); + tmpWidget->signalValidate.bind(shared_from_this(), &MainWindows::onCallbackPopUpFileSelected); } else if (_msg.getMessage() == ednMsgProperties) { // Request the parameter GUI std::shared_ptr tmpWidget = ewol::widget::Parameter::create(); @@ -379,36 +378,16 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { APPL_ERROR("can not call unexistant buffer manager ... "); return; } - if ( _msg.getMessage() == appl::MsgSelectNewFile - || _msg.getMessage() == ednEventIsModify - || _msg.getMessage() == ednEventIsSave - || _msg.getMessage() == ednEventChangeName) { - // select a new Buffer ==> change title: + if (_msg.getMessage() == appl::MsgSelectNewFile) { + onCallbackTitleUpdate(); 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(), "is-save", ednEventIsSave); - tmpp->registerOnEvent(shared_from_this(), "is-modify", ednEventIsModify); - tmpp->registerOnEvent(shared_from_this(), "change-name", ednEventChangeName); - } - 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?" *":"")); - } + 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); } - - } 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") { @@ -475,6 +454,31 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { } return; } +void MainWindows::onCallbackPopUpFileSelected(const std::string& _value) { + APPL_DEBUG("Request opening the file : " << _value); + m_bufferManager->open(_value); +} + +void MainWindows::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) { if (_buffer == nullptr) { @@ -496,24 +500,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..cf3ab67 100644 --- a/sources/appl/Gui/MainWindows.h +++ b/sources/appl/Gui/MainWindows.h @@ -41,6 +41,9 @@ class MainWindows : public ewol::widget::Windows { void closeNotSavedFile(const std::shared_ptr& _buffer); public: // Derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); + private: + void onCallbackPopUpFileSelected(const std::string& _value); + void onCallbackTitleUpdate(); }; diff --git a/sources/appl/Gui/Search.cpp b/sources/appl/Gui/Search.cpp index cbbb118..c07333a 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,23 +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")); + m_searchEntry = std::dynamic_pointer_cast(getSubObjectNamed("SEARCH:search-entry")); + m_replaceEntry = std::dynamic_pointer_cast(getSubObjectNamed("SEARCH:replace-entry")); // Display and hide event: registerMultiCast(ednMsgGuiSearch); // basicly hiden ... @@ -118,30 +120,45 @@ 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 ( _msg.getMessage() == ednMsgGuiSearch) { if (true == isHide()) { show(); if (m_searchEntry!= nullptr) { diff --git a/sources/appl/Gui/Search.h b/sources/appl/Gui/Search.h index 3a34150..acdc7e4 100644 --- a/sources/appl/Gui/Search.h +++ b/sources/appl/Gui/Search.h @@ -44,6 +44,17 @@ namespace appl { void replace(); public: // derived function virtual void onReceiveMessage(const ewol::object::Message& _msg); + 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/TagFileSelection.cpp b/sources/appl/Gui/TagFileSelection.cpp index 82e19d6..6a90622 100644 --- a/sources/appl/Gui/TagFileSelection.cpp +++ b/sources/appl/Gui/TagFileSelection.cpp @@ -78,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(), "validate", applEventCtagsListValidate); - m_listTag->registerOnEvent(shared_from_this(), "select", applEventCtagsListSelect); - m_listTag->registerOnEvent(shared_from_this(), "unselect", 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); @@ -108,29 +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!="") { - signalSelect.emit(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) { - signalSelect.emit(_msg.getData()); - // == > Auto remove ... - autoDestroy(); - } else if (_msg.getMessage() == applEventctagsCancel) { - signalCancel.emit(); +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 a08174f..cb90203 100644 --- a/sources/appl/Gui/TagFileSelection.h +++ b/sources/appl/Gui/TagFileSelection.h @@ -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 93a6335..b81925d 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -637,15 +637,6 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { 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; @@ -671,7 +662,7 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { if (_msg.getMessage() == appl::MsgSelectNewFile) { // reset scroll: if (m_buffer != nullptr) { - m_buffer->unRegisterOnEvent(shared_from_this()); + m_buffer->unBindAll(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(), "is-modify", appl_Buffer_eventIsModify); - m_buffer->registerOnEvent(shared_from_this(), "select-change", appl_Buffer_eventSelectChange); + 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 == m_buffer) { m_originScrooled = element.second; @@ -708,6 +699,14 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { } } +void appl::TextViewer::onCallbackIsModify() { + markToRedraw(); +} +void appl::TextViewer::onCallbackSelectChange() { + markToRedraw(); +} + + void appl::TextViewer::onGetFocus() { showKeyboard(); APPL_INFO("Focus - In"); diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index 5d2f676..e3b5588 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -406,6 +406,9 @@ namespace appl { bool _broadcast=false) { shortCutAdd(_descriptiveString, _generateEventId, _data, _broadcast); } + private: // callback fundtions + void onCallbackIsModify(); + void onCallbackSelectChange(); }; }; diff --git a/sources/appl/Gui/WorkerCloseAllFile.cpp b/sources/appl/Gui/WorkerCloseAllFile.cpp index 0ee9ef0..cfcca88 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: @@ -54,32 +52,30 @@ void appl::WorkerCloseAllFile::init() { autoDestroy(); return; } - m_worker->registerOnEvent(shared_from_this(), "close-file-done", s_closeDone); + m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); } appl::WorkerCloseAllFile::~WorkerCloseAllFile() { } -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(), "close-file-done", 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->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); } diff --git a/sources/appl/Gui/WorkerCloseAllFile.h b/sources/appl/Gui/WorkerCloseAllFile.h index 5615fca..dfb3885 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.h +++ b/sources/appl/Gui/WorkerCloseAllFile.h @@ -24,8 +24,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 2287b26..45869f1 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -14,11 +14,6 @@ #undef __class__ #define __class__ "WorkerCloseFile" -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"), m_buffer(nullptr), @@ -71,20 +66,20 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) { } 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); } tmpPopUp->addButton("Cancel", true); tmpPopUp->setRemoveOnExternClick(true); @@ -101,42 +96,51 @@ appl::WorkerCloseFile::~WorkerCloseFile() { } -void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) { + +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(), "save-file-done", 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 { - signalCloseDone.emit(); - } - } 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; - } - signalCloseDone.emit(); - 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); } } +void appl::WorkerCloseFile::onCallbackSaveValidate() { + if (m_bufferManager == nullptr) { + // nothing to do in this case ==> can do nothing ... + return; + } + 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 { + signalCloseDone.emit(); + } +} + +void appl::WorkerCloseFile::onCallbackClose() { + if (m_bufferManager == nullptr) { + // nothing to do in this case ==> can do nothing ... + return; + } + if (m_buffer == nullptr) { + APPL_ERROR("Error to get the buffer : " << m_bufferName); + autoDestroy(); + return; + } + signalCloseDone.emit(); + m_buffer->destroy(); + m_buffer.reset(); +} + diff --git a/sources/appl/Gui/WorkerCloseFile.h b/sources/appl/Gui/WorkerCloseFile.h index c405928..2096a22 100644 --- a/sources/appl/Gui/WorkerCloseFile.h +++ b/sources/appl/Gui/WorkerCloseFile.h @@ -29,8 +29,10 @@ namespace appl { 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(); }; }; diff --git a/sources/appl/Gui/WorkerSaveAllFile.cpp b/sources/appl/Gui/WorkerSaveAllFile.cpp index 0e2fb80..5afe912 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: @@ -56,32 +54,30 @@ void appl::WorkerSaveAllFile::init() { autoDestroy(); return; } - m_worker->registerOnEvent(shared_from_this(), "save-file-done", s_saveAsDone); + m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone); } appl::WorkerSaveAllFile::~WorkerSaveAllFile() { } -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(), "save-file-done", 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->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone); } diff --git a/sources/appl/Gui/WorkerSaveAllFile.h b/sources/appl/Gui/WorkerSaveAllFile.h index 8909655..f40bb75 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.h +++ b/sources/appl/Gui/WorkerSaveAllFile.h @@ -24,8 +24,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 e81dafe..427eb63 100644 --- a/sources/appl/Gui/WorkerSaveFile.cpp +++ b/sources/appl/Gui/WorkerSaveFile.cpp @@ -13,7 +13,6 @@ #undef __class__ #define __class__ "WorkerSaveFile" -static const char* s_saveAsValidate = "save-as-validate"; appl::WorkerSaveFile::WorkerSaveFile() : signalSaveDone(*this, "save-file-done") { @@ -77,42 +76,40 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA return; } tmpWindows->popUpWidgetPush(m_chooser); - m_chooser->registerOnEvent(shared_from_this(), "validate", s_saveAsValidate); + m_chooser->signalValidate.bind(shared_from_this(), &appl::WorkerSaveFile::onCallbackSaveAsValidate); } appl::WorkerSaveFile::~WorkerSaveFile() { } -void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) { +void appl::WorkerSaveFile::onCallbackSaveAsValidate(const std::string& _value) { if (m_bufferManager == nullptr) { // nothing to do in this case ==> can do nothing ... return; } - if (_msg.getMessage() == s_saveAsValidate) { - if (_msg.getData() == "") { - APPL_ERROR(" might be an error of the File chooser system..."); + if (_value == "") { + 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(_value); + if (tmpBuffer->storeFile() == false) { + std::shared_ptr tmpWindows = ewol::getContext().getWindows(); + if (tmpWindows == nullptr) { 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 { - signalSaveDone.emit(); - } + tmpWindows->displayWarningMessage("We can not save the file :
" + tmpBuffer->getFileName() + ""); + } else { + signalSaveDone.emit(); } } diff --git a/sources/appl/Gui/WorkerSaveFile.h b/sources/appl/Gui/WorkerSaveFile.h index 61d76ca..3734c0f 100644 --- a/sources/appl/Gui/WorkerSaveFile.h +++ b/sources/appl/Gui/WorkerSaveFile.h @@ -26,8 +26,8 @@ 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); }; }; diff --git a/sources/appl/TextPluginCtags.cpp b/sources/appl/TextPluginCtags.cpp index 5d65681..2b1d6de 100644 --- a/sources/appl/TextPluginCtags.cpp +++ b/sources/appl/TextPluginCtags.cpp @@ -44,12 +44,6 @@ 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); @@ -98,7 +92,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(), "select", eventOpenCtagsSelectReturn); + tmpWidget->signalSelect.bind(shared_from_this(), &appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn); } } else { jumpFile(myfile.getName(), lineID - 1); @@ -157,23 +151,24 @@ 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(); } + +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::onReceiveMessageViewer(appl::TextViewer& _textDrawer, const ewol::object::Message& _msg) { if (isEnable() == false) { @@ -195,7 +190,7 @@ 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) { if (_textDrawer.hasBuffer() == false) { diff --git a/sources/appl/TextPluginCtags.h b/sources/appl/TextPluginCtags.h index cb8e64e..2633f36 100644 --- a/sources/appl/TextPluginCtags.h +++ b/sources/appl/TextPluginCtags.h @@ -45,8 +45,9 @@ namespace appl { 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); + // callback function: + void onCallbackOpenCtagsOpenFileReturn(const std::string& _value); + void onCallbackOpenCtagsSelectReturn(const std::string& _value); }; }; 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..80f37a9 100644 --- a/sources/appl/globalMsg.cpp +++ b/sources/appl/globalMsg.cpp @@ -8,10 +8,32 @@ #include +appl::Broadcast::Broadcast() : + signalBufferState(*this, "buffer-state"), + signalBufferName(*this, "buffer-name"), + signalBufferId(*this, "buffer-id"), + signalCodeViewSelectedId(*this, "code-view-select-id"), + signalOpenFile(*this, "open-file"), + signalBufferListChange(*this, "buffer-list-change"), + signalBufferColor(*this, "buffer-color"), + signalSelectNewFile(*this, "select-new-file"), + signalSelectChange(*this, "select-change"), + signalNameChange(*this, "buffer-name-change"), + signalNameGuiChangeColor(*this, "gui-Change-color"), + signalSelectGotoLine(*this, "gui-goto-line"), + signalSelectGotoLineSelect(*this, "gui-goto-line-select") +{ + +} + +void appl::Broadcast::init(const std::string& _uniqueName) { + ewol::Resource::init(_uniqueName); +} //////////////////////////////////////////////////////////////////////// // 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"; @@ -40,27 +62,10 @@ 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..8d7f27f 100644 --- a/sources/appl/globalMsg.h +++ b/sources/appl/globalMsg.h @@ -8,60 +8,66 @@ #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 : "" - +namespace appl { + class Broadcast : public ewol::Resource { + public: + Broadcast(); + void init(const std::string& _uniqueName); + public: + DECLARE_RESOURCE_SINGLE_FACTORY(Broadcast, "???Broadcast???"); + virtual ~Broadcast() {}; + public: + /* + ewol::object::Signal<> signalGuiNew; // data : "" + ewol::object::Signal<> signalGuiOpen; // data : "" + ewol::object::Signal<> signalGuiClose; // data : "current" "All" + ewol::object::Signal<> signalGuiSave; // data : "" + ewol::object::Signal<> signalSaveAs; // data : "" + ewol::object::Signal<> signalProperties; // data : "" + ewol::object::Signal<> signalGuiExit; // data : "" + + ewol::object::Signal<> signalGuiUndo; // data : "" + ewol::object::Signal<> signalGuiRedo; // data : "" + ewol::object::Signal<> signalGuiCopy; // data : "STD" "Middle" "1" ... "9" + ewol::object::Signal<> signalGuiCut; // data : "STD" "Middle" "1" ... "9" + ewol::object::Signal<> signalGuiPaste; // data : "STD" "Middle" "1" ... "9" + ewol::object::Signal<> signalGuiRm; // data : "Word" "Line" "Paragraph" + ewol::object::Signal<> signalGuiSelect; // data : "ALL" "NONE" + ewol::object::Signal<> signalGuiGotoLine; // data : "???" / "1" ... "999999999999" + + ewol::object::Signal<> signalGuiSearch; // data : "" + ewol::object::Signal<> signalGuiReplace; // data : "Normal" "All" + ewol::object::Signal<> signalGuiFind; // data : "Next" "Previous" "All" "None" + + ewol::object::Signal<> signalShowSpaces; // data : "enable" "disable" + ewol::object::Signal<> signalShowEndOfLine; // data : "enable" "disable" + + ewol::object::Signal<> signalGuiCtags; // data : "Load" "ReLoad" "Jump" "Back" + ewol::object::Signal<> signalCtagsLoadFile; // data : "filename of the ctags file" + + ewol::object::Signal<> signalGuiReloadShader; // 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" + ewol::object::Signal signalBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory" + ewol::object::Signal signalBufferName; // data : "filename" + ewol::object::Signal signalBufferId; // data : "0" ... "99999999999" + ewol::object::Signal signalCodeViewSelectedId; // data : "0" ... "99999999999" + ewol::object::Signal signalOpenFile; // data : "/Compleate/file/name.xx" + + ewol::object::Signal signalBufferListChange; // data : "" + + ewol::object::Signal signalBufferColor; // data : "new" + + ewol::object::Signal signalSelectNewFile; // data : "buffer/name" + ewol::object::Signal signalSelectChange; // data : "" + ewol::object::Signal signalNameChange; // data : "" + ewol::object::Signal signalNameGuiChangeColor; // data : "Black" "White" + ewol::object::Signal signalSelectGotoLine; // data : "75822" + ewol::object::Signal signalSelectGotoLineSelect; // data : "75822" + }; }; #endif diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 7b442b1..622faf0 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -97,7 +97,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(); From a371c09e2262928fa6f3784001f79cb83fc3d7a1 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 25 Aug 2014 22:44:42 +0200 Subject: [PATCH 05/20] [DEV] update new signal system ==> run but not have many capabilities --- sources/appl/BufferManager.cpp | 35 ++- sources/appl/BufferManager.h | 6 +- sources/appl/Gui/BufferView.cpp | 129 +++------ sources/appl/Gui/BufferView.h | 4 +- sources/appl/Gui/MainWindows.cpp | 422 ++++++++++++++++------------- sources/appl/Gui/MainWindows.h | 9 +- sources/appl/Gui/Search.cpp | 30 +- sources/appl/Gui/Search.h | 5 +- sources/appl/Gui/TextViewer.cpp | 89 +++--- sources/appl/Gui/TextViewer.h | 5 +- sources/appl/Gui/ViewerManager.cpp | 2 +- sources/appl/TextPluginCopy.cpp | 4 + sources/appl/TextPluginCtags.cpp | 4 +- sources/appl/TextPluginHistory.cpp | 4 + sources/appl/TextPluginRmLine.cpp | 4 + sources/appl/globalMsg.cpp | 71 ----- sources/appl/globalMsg.h | 74 ----- 17 files changed, 387 insertions(+), 510 deletions(-) diff --git a/sources/appl/BufferManager.cpp b/sources/appl/BufferManager.cpp index 591a08f..772709d 100644 --- a/sources/appl/BufferManager.cpp +++ b/sources/appl/BufferManager.cpp @@ -18,7 +18,10 @@ #undef __class__ #define __class__ "BufferManager" -appl::BufferManager::BufferManager() { +appl::BufferManager::BufferManager() : + signalNewBuffer(*this, "new-buffer"), + signalSelectFile(*this, "select-buffer"), + signalTextSelectionChange(*this, "text-selection-change") { addObjectType("appl::BufferManager"); } @@ -38,12 +41,17 @@ std::shared_ptr appl::BufferManager::createNewBuffer() { return nullptr; } 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; @@ -65,13 +73,23 @@ std::shared_ptr appl::BufferManager::get(const std::string& _fileN } 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 +117,14 @@ bool appl::BufferManager::exist(const std::string& _fileName) { void appl::BufferManager::open(const std::string& _fileName) { if (exist(_fileName) == true) { + // TODO : Create a pop-up ... return; } if (get(_fileName, true) == nullptr) { return; } - sendMultiCast(appl::MsgSelectNewFile, _fileName); -} - -void appl::BufferManager::onReceiveMessage(const ewol::object::Message& _msg) { - APPL_DEBUG("receive message !!! " << _msg); + APPL_INFO("Open buffer:" << _fileName); + signalSelectFile.emit(_fileName); + APPL_INFO("Open buffer (done)"); } diff --git a/sources/appl/BufferManager.h b/sources/appl/BufferManager.h index af749de..812dd4c 100644 --- a/sources/appl/BufferManager.h +++ b/sources/appl/BufferManager.h @@ -18,6 +18,10 @@ namespace appl { class BufferManager : public ewol::Resource { public: + ewol::object::Signal signalNewBuffer; + ewol::object::Signal signalSelectFile; + ewol::object::Signal signalTextSelectionChange; + protected: BufferManager(); void init(const std::string& _uniqueName); public: @@ -77,8 +81,6 @@ namespace appl { std::shared_ptr getBufferSelected() { return m_bufferSelected; }; - public: // herited function - void onReceiveMessage(const ewol::object::Message& _msg); }; }; diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index e965838..b76f30d 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -59,12 +59,10 @@ 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); + } } BufferView::~BufferView() { @@ -104,90 +102,47 @@ void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _sel } } } -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; - } - 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 = new appl::dataBufferStruct(_msg.getData(), buffer); - if (tmp == nullptr) { - APPL_ERROR("Allocation error of the tmp buffer list element"); - return; - } - if (m_openOrderMode == true) { - m_list.push_back(tmp); - } else { - insertAlphabetic(tmp); - } - markToRedraw(); + +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; } - 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; - break; - } - } - markToRedraw(); + 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 = new appl::dataBufferStruct(_value, buffer); + if (tmp == nullptr) { + APPL_ERROR("Allocation error of the tmp buffer list element"); 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(); + if (m_openOrderMode == true) { + m_list.push_back(tmp); + } else { + insertAlphabetic(tmp); } + markToRedraw(); +} +void BufferView::onCallbackselectNewFile(const std::string& _value) { + 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; + break; + } + } + markToRedraw(); } void BufferView::onCallbackChangeName() { @@ -268,7 +223,9 @@ bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent && _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()); + if (m_bufferManager != nullptr) { + m_bufferManager->open(m_list[_raw]->m_buffer->getFileName()); + } m_selectedID = _raw; markToRedraw(); return true; diff --git a/sources/appl/Gui/BufferView.h b/sources/appl/Gui/BufferView.h index 8f29819..107d7b4 100644 --- a/sources/appl/Gui/BufferView.h +++ b/sources/appl/Gui/BufferView.h @@ -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: @@ -73,6 +71,8 @@ class BufferView : public ewol::widget::List { void onCallbackChangeName(); void onCallbackIsSave(); void onCallbackIsModify(); + void onCallbackNewBuffer(const std::string& _value); + void onCallbackselectNewFile(const std::string& _value); }; diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 00809a4..49061b5 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -172,8 +172,8 @@ 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"); @@ -182,95 +182,70 @@ void MainWindows::init() { myMenu = ewol::widget::Menu::create(); 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->add(idMenuEdit, "Undo", "THEME:GUI:Undo.edf", "menu:undo"); + myMenu->add(idMenuEdit, "Redo", "THEME:GUI:Redo.edf", "menu:redo"); 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->add(idMenuEdit, "Copy", "", "menu:copy"); + myMenu->add(idMenuEdit, "Cut", "", "menu:cut"); + myMenu->add(idMenuEdit, "Paste", "", "menu:past"); + myMenu->add(idMenuEdit, "Remove", "", "menu:remove"); 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, "Select All","", "menu:select-all"); + myMenu->add(idMenuEdit, "Un-Select","", "menu:select-none"); + 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+z", "menu:undo"); + shortCutAdd("ctrl+shift+z", "menu:redo"); - shortCutAdd("ctrl+l", ednMsgGuiGotoLine, "???", true); + shortCutAdd("ctrl+l", "menu:goto-line"); - 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,135 +254,96 @@ MainWindows::~MainWindows() { } -static const char* const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected"; -static const char* const ednEventIsSave = "edn-buffer-is-saved"; -static const char* const ednEventIsModify = "edn-buffer-is-modify"; -static const char* const ednEventChangeName = "edn-buffer-change-name"; -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::onCallbackShortCut(const std::string& _value) { + APPL_WARNING("Event from ShortCut : " << _value); + onCallbackMenuEvent(_value); +} + +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->signalValidate.bind(shared_from_this(), &MainWindows::onCallbackPopUpFileSelected); - } 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) { - 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); - } - } else if (_msg.getMessage() == ednMsgGuiNew) { - m_bufferManager->createNewBuffer(); - } 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") { + appl::WorkerCloseFile::create(""); + } 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:undo") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:redo") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:copy") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:cut") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:past") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:remove") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:select-all") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:select-none") { + APPL_TODO("Event from Menu : " << _value); + } else if (_value == "menu:goto-line") { + APPL_TODO("Event from Menu : " << _value); + } 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()); @@ -452,8 +388,104 @@ 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) { + 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); + } +} + +static const char* const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected"; +static const char* const ednEventIsSave = "edn-buffer-is-saved"; +static const char* const ednEventIsModify = "edn-buffer-is-modify"; +static const char* const ednEventChangeName = "edn-buffer-change-name"; + + + void MainWindows::onCallbackPopUpFileSelected(const std::string& _value) { APPL_DEBUG("Request opening the file : " << _value); m_bufferManager->open(_value); diff --git a/sources/appl/Gui/MainWindows.h b/sources/appl/Gui/MainWindows.h index cf3ab67..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,11 +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 c07333a..b06f3fa 100644 --- a/sources/appl/Gui/Search.cpp +++ b/sources/appl/Gui/Search.cpp @@ -57,8 +57,6 @@ void appl::widget::Search::init() { // get widget m_searchEntry = std::dynamic_pointer_cast(getSubObjectNamed("SEARCH:search-entry")); m_replaceEntry = std::dynamic_pointer_cast(getSubObjectNamed("SEARCH:replace-entry")); - // Display and hide event: - registerMultiCast(ednMsgGuiSearch); // basicly hiden ... hide(); } @@ -155,25 +153,15 @@ 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() == 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 acdc7e4..eb2c8dc 100644 --- a/sources/appl/Gui/Search.h +++ b/sources/appl/Gui/Search.h @@ -42,8 +42,9 @@ 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); diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index b81925d..9636f18 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -62,12 +62,16 @@ void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) { // last created has focus ... setCurrentSelect(); + /* 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); + } } @@ -75,6 +79,45 @@ 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; + for (size_t iii=0; iiiget(_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 == 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() { if (m_buffer == nullptr) { return ""; @@ -465,9 +508,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 @@ -633,6 +676,7 @@ 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; @@ -659,44 +703,7 @@ void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { markToRedraw(); return; } - if (_msg.getMessage() == appl::MsgSelectNewFile) { - // reset scroll: - if (m_buffer != nullptr) { - m_buffer->unBindAll(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->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 == 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() { diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index e3b5588..64aa8f8 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -392,7 +392,7 @@ namespace appl { * @param[in] _messageId Event Id waiting for... */ void ext_registerMultiCast(const char* const _messageId) { - registerMultiCast(_messageId); + //registerMultiCast(_messageId); } /** * @brief add a specific shortcut with his description @@ -404,11 +404,12 @@ namespace appl { const char * _generateEventId, std::string _data="", bool _broadcast=false) { - shortCutAdd(_descriptiveString, _generateEventId, _data, _broadcast); + //shortCutAdd(_descriptiveString, _generateEventId, _data, _broadcast); } private: // callback fundtions void onCallbackIsModify(); 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/TextPluginCopy.cpp b/sources/appl/TextPluginCopy.cpp index 5a0c933..6fa19c4 100644 --- a/sources/appl/TextPluginCopy.cpp +++ b/sources/appl/TextPluginCopy.cpp @@ -26,12 +26,14 @@ 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"); + */ } void appl::TextPluginCopy::onPluginDisable(appl::TextViewer& _textDrawer) { @@ -43,6 +45,7 @@ bool appl::TextPluginCopy::onReceiveMessageViewer(appl::TextViewer& _textDrawer, if (isEnable() == false) { return false; } + /* if ( _msg.getMessage() == ednMsgGuiCopy || _msg.getMessage() == ednMsgGuiCut) { if (_textDrawer.hasBuffer() == true) { @@ -62,5 +65,6 @@ bool appl::TextPluginCopy::onReceiveMessageViewer(appl::TextViewer& _textDrawer, } return true; } + */ return false; } diff --git a/sources/appl/TextPluginCtags.cpp b/sources/appl/TextPluginCtags.cpp index 2b1d6de..447e879 100644 --- a/sources/appl/TextPluginCtags.cpp +++ b/sources/appl/TextPluginCtags.cpp @@ -105,8 +105,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() { diff --git a/sources/appl/TextPluginHistory.cpp b/sources/appl/TextPluginHistory.cpp index 0793f8b..28aaecc 100644 --- a/sources/appl/TextPluginHistory.cpp +++ b/sources/appl/TextPluginHistory.cpp @@ -30,10 +30,12 @@ void appl::TextPluginHistory::init() { void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) { // add event : + /* _textDrawer.ext_registerMultiCast(ednMsgGuiRedo); _textDrawer.ext_registerMultiCast(ednMsgGuiUndo); _textDrawer.ext_shortCutAdd("ctrl+z", ednMsgGuiUndo); _textDrawer.ext_shortCutAdd("ctrl+shift+z", ednMsgGuiRedo); + */ } void appl::TextPluginHistory::onPluginDisable(appl::TextViewer& _textDrawer) { @@ -46,6 +48,7 @@ bool appl::TextPluginHistory::onDataReceiveMessageViewer(appl::TextViewer& _text if (isEnable() == false) { return false; } + /* if (_msg.getMessage() == ednMsgGuiRedo) { if (_data.m_redo.size() == 0) { return true; @@ -79,6 +82,7 @@ bool appl::TextPluginHistory::onDataReceiveMessageViewer(appl::TextViewer& _text return true; } + */ return false; } diff --git a/sources/appl/TextPluginRmLine.cpp b/sources/appl/TextPluginRmLine.cpp index 802aad2..5dd3e60 100644 --- a/sources/appl/TextPluginRmLine.cpp +++ b/sources/appl/TextPluginRmLine.cpp @@ -26,8 +26,10 @@ void appl::TextPluginRmLine::init() { void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) { // add event : + /* _textDrawer.ext_registerMultiCast(ednMsgGuiRm); _textDrawer.ext_shortCutAdd("ctrl+w", ednMsgGuiRm); + */ } void appl::TextPluginRmLine::onPluginDisable(appl::TextViewer& _textDrawer) { @@ -39,6 +41,7 @@ bool appl::TextPluginRmLine::onReceiveMessageViewer(appl::TextViewer& _textDrawe if (isEnable() == false) { return false; } + /* if (_msg.getMessage() == ednMsgGuiRm) { if (_textDrawer.hasBuffer() == false) { return false; @@ -54,5 +57,6 @@ bool appl::TextPluginRmLine::onReceiveMessageViewer(appl::TextViewer& _textDrawe } return true; } + */ return false; } diff --git a/sources/appl/globalMsg.cpp b/sources/appl/globalMsg.cpp index 80f37a9..e69de29 100644 --- a/sources/appl/globalMsg.cpp +++ b/sources/appl/globalMsg.cpp @@ -1,71 +0,0 @@ -/** - * @author Edouard DUPIN - * - * @copyright 2010, Edouard DUPIN, all right reserved - * - * @license GPL v3 (see license file) - */ - -#include - -appl::Broadcast::Broadcast() : - signalBufferState(*this, "buffer-state"), - signalBufferName(*this, "buffer-name"), - signalBufferId(*this, "buffer-id"), - signalCodeViewSelectedId(*this, "code-view-select-id"), - signalOpenFile(*this, "open-file"), - signalBufferListChange(*this, "buffer-list-change"), - signalBufferColor(*this, "buffer-color"), - signalSelectNewFile(*this, "select-new-file"), - signalSelectChange(*this, "select-change"), - signalNameChange(*this, "buffer-name-change"), - signalNameGuiChangeColor(*this, "gui-Change-color"), - signalSelectGotoLine(*this, "gui-goto-line"), - signalSelectGotoLineSelect(*this, "gui-goto-line-select") -{ - -} - -void appl::Broadcast::init(const std::string& _uniqueName) { - ewol::Resource::init(_uniqueName); -} - -//////////////////////////////////////////////////////////////////////// -// 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 : -//////////////////////////////////////////////////////////////////////// - - diff --git a/sources/appl/globalMsg.h b/sources/appl/globalMsg.h index 8d7f27f..e69de29 100644 --- a/sources/appl/globalMsg.h +++ b/sources/appl/globalMsg.h @@ -1,74 +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__ -namespace appl { - class Broadcast : public ewol::Resource { - public: - Broadcast(); - void init(const std::string& _uniqueName); - public: - DECLARE_RESOURCE_SINGLE_FACTORY(Broadcast, "???Broadcast???"); - virtual ~Broadcast() {}; - public: - /* - ewol::object::Signal<> signalGuiNew; // data : "" - ewol::object::Signal<> signalGuiOpen; // data : "" - ewol::object::Signal<> signalGuiClose; // data : "current" "All" - ewol::object::Signal<> signalGuiSave; // data : "" - ewol::object::Signal<> signalSaveAs; // data : "" - ewol::object::Signal<> signalProperties; // data : "" - ewol::object::Signal<> signalGuiExit; // data : "" - - ewol::object::Signal<> signalGuiUndo; // data : "" - ewol::object::Signal<> signalGuiRedo; // data : "" - ewol::object::Signal<> signalGuiCopy; // data : "STD" "Middle" "1" ... "9" - ewol::object::Signal<> signalGuiCut; // data : "STD" "Middle" "1" ... "9" - ewol::object::Signal<> signalGuiPaste; // data : "STD" "Middle" "1" ... "9" - ewol::object::Signal<> signalGuiRm; // data : "Word" "Line" "Paragraph" - ewol::object::Signal<> signalGuiSelect; // data : "ALL" "NONE" - ewol::object::Signal<> signalGuiGotoLine; // data : "???" / "1" ... "999999999999" - - ewol::object::Signal<> signalGuiSearch; // data : "" - ewol::object::Signal<> signalGuiReplace; // data : "Normal" "All" - ewol::object::Signal<> signalGuiFind; // data : "Next" "Previous" "All" "None" - - ewol::object::Signal<> signalShowSpaces; // data : "enable" "disable" - ewol::object::Signal<> signalShowEndOfLine; // data : "enable" "disable" - - ewol::object::Signal<> signalGuiCtags; // data : "Load" "ReLoad" "Jump" "Back" - ewol::object::Signal<> signalCtagsLoadFile; // data : "filename of the ctags file" - - ewol::object::Signal<> signalGuiReloadShader; // data : "" - */ - -//////////////////////////////////////////////////////////////////////// -// Event internal : -//////////////////////////////////////////////////////////////////////// - ewol::object::Signal signalBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory" - ewol::object::Signal signalBufferName; // data : "filename" - ewol::object::Signal signalBufferId; // data : "0" ... "99999999999" - ewol::object::Signal signalCodeViewSelectedId; // data : "0" ... "99999999999" - ewol::object::Signal signalOpenFile; // data : "/Compleate/file/name.xx" - - ewol::object::Signal signalBufferListChange; // data : "" - - ewol::object::Signal signalBufferColor; // data : "new" - - ewol::object::Signal signalSelectNewFile; // data : "buffer/name" - ewol::object::Signal signalSelectChange; // data : "" - ewol::object::Signal signalNameChange; // data : "" - ewol::object::Signal signalNameGuiChangeColor; // data : "Black" "White" - ewol::object::Signal signalSelectGotoLine; // data : "75822" - ewol::object::Signal signalSelectGotoLineSelect; // data : "75822" - }; -}; - -#endif - From 7e6f56a1cd715dee66600e4b80e9179aa78c8ec9 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 27 Aug 2014 22:58:21 +0200 Subject: [PATCH 06/20] [DEV] this plugin to the new ewol interface --- sources/appl/Gui/MainWindows.cpp | 21 -------------- sources/appl/Gui/TextViewer.cpp | 43 ++++++---------------------- sources/appl/Gui/TextViewer.h | 11 ++++--- sources/appl/TextPlugin.cpp | 2 +- sources/appl/TextPlugin.h | 11 ++++--- sources/appl/TextPluginCopy.cpp | 27 +++++++---------- sources/appl/TextPluginCopy.h | 2 +- sources/appl/TextPluginCtags.cpp | 27 ++++++----------- sources/appl/TextPluginCtags.h | 4 +-- sources/appl/TextPluginData.h | 12 ++++---- sources/appl/TextPluginHistory.cpp | 22 ++++++-------- sources/appl/TextPluginHistory.h | 6 ++-- sources/appl/TextPluginManager.cpp | 16 +++++------ sources/appl/TextPluginManager.h | 6 ++-- sources/appl/TextPluginRmLine.cpp | 15 ++++------ sources/appl/TextPluginRmLine.h | 2 +- sources/appl/TextPluginSelectAll.cpp | 13 ++++----- sources/appl/TextPluginSelectAll.h | 2 +- sources/tagCode | 1 + 19 files changed, 82 insertions(+), 161 deletions(-) create mode 100644 sources/tagCode diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 49061b5..93de025 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -236,9 +236,6 @@ void MainWindows::init() { shortCutAdd("ctrl+q", "menu:close"); shortCutAdd("ctrl+shift+q", "menu:close-all"); - shortCutAdd("ctrl+z", "menu:undo"); - shortCutAdd("ctrl+shift+z", "menu:redo"); - shortCutAdd("ctrl+l", "menu:goto-line"); shortCutAdd("ctrl+f", "menu:search"); @@ -280,24 +277,6 @@ void MainWindows::onCallbackMenuEvent(const std::string& _value) { appl::WorkerSaveFile::create("", true); } else if (_value == "menu:property") { displayProperty(); - } else if (_value == "menu:undo") { - APPL_TODO("Event from Menu : " << _value); - } else if (_value == "menu:redo") { - APPL_TODO("Event from Menu : " << _value); - } else if (_value == "menu:copy") { - APPL_TODO("Event from Menu : " << _value); - } else if (_value == "menu:cut") { - APPL_TODO("Event from Menu : " << _value); - } else if (_value == "menu:past") { - APPL_TODO("Event from Menu : " << _value); - } else if (_value == "menu:remove") { - APPL_TODO("Event from Menu : " << _value); - } else if (_value == "menu:select-all") { - APPL_TODO("Event from Menu : " << _value); - } else if (_value == "menu:select-none") { - APPL_TODO("Event from Menu : " << _value); - } else if (_value == "menu:goto-line") { - APPL_TODO("Event from Menu : " << _value); } else if (_value == "menu:search") { if (m_widgetSearch == nullptr) { return; diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index 9636f18..2c03784 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -61,6 +61,7 @@ void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) { appl::textPluginManager::connect(*this); // last created has focus ... setCurrentSelect(); + signalShortcut.bind(shared_from_this(), &appl::TextViewer::onCallbackShortCut); /* registerMultiCast(ednMsgBufferId); @@ -74,11 +75,17 @@ void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) { } } - appl::TextViewer::~TextViewer() { appl::textPluginManager::disconnect(*this); } +void appl::TextViewer::onCallbackShortCut(const std::string& _value) { + if (appl::textPluginManager::onReceiveShortCut(*this, _value) == true) { + return; + } +} + + void appl::TextViewer::onCallbackselectNewFile(const std::string& _value) { // reset scroll: if (m_buffer != nullptr) { @@ -672,40 +679,6 @@ 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; - } - // 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; - } - */ -} - void appl::TextViewer::onCallbackIsModify() { markToRedraw(); } diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index 64aa8f8..65a9b54 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -63,7 +63,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,6 +390,7 @@ 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); } @@ -400,14 +400,13 @@ namespace appl { * @param[in] _generateEventId Event generic of the element * @param[in] _data Associate data wit the event */ - 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); } private: // callback fundtions void onCallbackIsModify(); + void onCallbackShortCut(const std::string& _value); void onCallbackSelectChange(); void onCallbackselectNewFile(const std::string& _value); }; diff --git a/sources/appl/TextPlugin.cpp b/sources/appl/TextPlugin.cpp index ea4b751..7dfb33e 100644 --- a/sources/appl/TextPlugin.cpp +++ b/sources/appl/TextPlugin.cpp @@ -21,7 +21,7 @@ appl::TextViewerPlugin::TextViewerPlugin() : m_activateOnWrite(false), m_activateOnReplace(false), m_activateOnRemove(false), - m_activateOnReceiveMessage(false), + m_activateOnReceiveShortCut(false), m_activateOnCursorMove(false) { addObjectType("appl::TextViewerPlugin"); } diff --git a/sources/appl/TextPlugin.h b/sources/appl/TextPlugin.h index e8584f1..dc4b8e6 100644 --- a/sources/appl/TextPlugin.h +++ b/sources/appl/TextPlugin.h @@ -174,23 +174,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 6fa19c4..b439828 100644 --- a/sources/appl/TextPluginCopy.cpp +++ b/sources/appl/TextPluginCopy.cpp @@ -16,7 +16,7 @@ appl::TextPluginCopy::TextPluginCopy() { - m_activateOnReceiveMessage = true; + m_activateOnReceiveShortCut = true; addObjectType("appl::TextPluginCopy"); } @@ -26,28 +26,22 @@ 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"); - */ + _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 ... } -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); @@ -55,16 +49,15 @@ 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); } return true; } - */ return false; } diff --git a/sources/appl/TextPluginCopy.h b/sources/appl/TextPluginCopy.h index e64bbc3..a8d0e3e 100644 --- a/sources/appl/TextPluginCopy.h +++ b/sources/appl/TextPluginCopy.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/TextPluginCtags.cpp b/sources/appl/TextPluginCtags.cpp index 447e879..3e4e0b5 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,20 +37,11 @@ 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 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) { @@ -169,12 +160,12 @@ void appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn(const std::string& _ jumpFile(tmp, lineID - 1); } -bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg) { +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) { @@ -192,7 +183,7 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); 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; } @@ -210,7 +201,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 2633f36..27447b6 100644 --- a/sources/appl/TextPluginCtags.h +++ b/sources/appl/TextPluginCtags.h @@ -43,8 +43,8 @@ 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); // 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 9081d12..df5b623 100644 --- a/sources/appl/TextPluginData.h +++ b/sources/appl/TextPluginData.h @@ -55,13 +55,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 onDataReceiveMessageViewer(_textDrawer, _msg, *data); + return onDataReceiveShortCut(_textDrawer, _shortCutName, *data); } bool onWrite(appl::TextViewer& _textDrawer, const appl::Buffer::Iterator& _pos, @@ -93,9 +93,9 @@ namespace appl { } public: - virtual bool onDataReceiveMessageViewer(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 onDataWrite(appl::TextViewer& _textDrawer, diff --git a/sources/appl/TextPluginHistory.cpp b/sources/appl/TextPluginHistory.cpp index 28aaecc..bc04d2d 100644 --- a/sources/appl/TextPluginHistory.cpp +++ b/sources/appl/TextPluginHistory.cpp @@ -16,7 +16,7 @@ #define __class__ "TextPluginHistory" appl::TextPluginHistory::TextPluginHistory() { - m_activateOnReceiveMessage = true; + m_activateOnReceiveShortCut = true; m_activateOnWrite = true; m_activateOnReplace = true; m_activateOnRemove = true; @@ -30,26 +30,21 @@ void appl::TextPluginHistory::init() { void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) { // 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 ... } -bool appl::TextPluginHistory::onDataReceiveMessageViewer(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; } @@ -65,7 +60,7 @@ bool appl::TextPluginHistory::onDataReceiveMessageViewer(appl::TextViewer& _text _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; } @@ -82,7 +77,6 @@ bool appl::TextPluginHistory::onDataReceiveMessageViewer(appl::TextViewer& _text return true; } - */ return false; } diff --git a/sources/appl/TextPluginHistory.h b/sources/appl/TextPluginHistory.h index 3d66d86..be22856 100644 --- a/sources/appl/TextPluginHistory.h +++ b/sources/appl/TextPluginHistory.h @@ -46,9 +46,9 @@ namespace appl { public: virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginDisable(appl::TextViewer& _textDrawer); - virtual bool onDataReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg, - 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, diff --git a/sources/appl/TextPluginManager.cpp b/sources/appl/TextPluginManager.cpp index 5d444b5..f4441d8 100644 --- a/sources/appl/TextPluginManager.cpp +++ b/sources/appl/TextPluginManager.cpp @@ -43,7 +43,7 @@ static std::vector>& getListOnRemove() { static std::vector> s_list; return s_list; } -static std::vector>& getListonReceiveMessageViewer() { +static std::vector>& getListonReceiveShortCutViewer() { static std::vector> s_list; return s_list; } @@ -63,7 +63,7 @@ void appl::textPluginManager::unInit() { getListOnWrite().clear(); getListOnReplace().clear(); getListOnRemove().clear(); - getListonReceiveMessageViewer().clear(); + getListonReceiveShortCutViewer().clear(); getListOnCursorMove().clear(); getList().clear(); } @@ -98,8 +98,8 @@ void appl::textPluginManager::addPlugin(const std::shared_ptrisAvaillableOnRemove() == true) { getListOnRemove().push_back(_plugin); } - if (_plugin->isAvaillableOnReceiveMessage() == true) { - getListonReceiveMessageViewer().push_back(_plugin); + if (_plugin->isAvaillableOnReceiveShortCut() == true) { + getListonReceiveShortCutViewer().push_back(_plugin); } if (_plugin->isAvaillableOnCursorMove() == true) { getListOnCursorMove().push_back(_plugin); @@ -193,13 +193,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 : getListonReceiveShortCutViewer()) { if (it == nullptr) { continue; } - if (it->onReceiveMessageViewer(_textDrawer, _msg) == true ) { + if (it->onReceiveShortCut(_textDrawer, _shortCutName) == true ) { return true; } } diff --git a/sources/appl/TextPluginManager.h b/sources/appl/TextPluginManager.h index b9c557d..9d03703 100644 --- a/sources/appl/TextPluginManager.h +++ b/sources/appl/TextPluginManager.h @@ -95,11 +95,11 @@ namespace appl { /** * @brief Called when a message arrive. * @param[in] _widget Reference on the widget caller. - * @param[in] _msg Generic message. + * @param[in] _shortCutName shortcut properties. * @return true if the event might not propagate anymore */ - bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, - const ewol::object::Message& _msg); + bool onReceiveShortCut(appl::TextViewer& _textDrawer, + const std::string& _shortCutName); /** * @brief Called when Cursor move of position. * @param[in] _widget Reference on the widget caller. diff --git a/sources/appl/TextPluginRmLine.cpp b/sources/appl/TextPluginRmLine.cpp index 5dd3e60..e39810d 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,23 +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 ... } -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; } @@ -57,6 +53,5 @@ bool appl::TextPluginRmLine::onReceiveMessageViewer(appl::TextViewer& _textDrawe } return true; } - */ 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..dd7f534 100644 --- a/sources/appl/TextPluginSelectAll.cpp +++ b/sources/appl/TextPluginSelectAll.cpp @@ -16,7 +16,7 @@ appl::TextPluginSelectAll::TextPluginSelectAll() { - m_activateOnReceiveMessage = true; + m_activateOnReceiveShortCut = true; addObjectType("appl::TextPluginSelectAll"); } @@ -24,24 +24,21 @@ void appl::TextPluginSelectAll::init() { appl::TextViewerPlugin::init(); } -static const char* eventSelectAll = "plugin-select-all"; - void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) { // add event : - _textDrawer.ext_registerMultiCast(eventSelectAll); - _textDrawer.ext_shortCutAdd("ctrl+a", eventSelectAll); + _textDrawer.ext_shortCutAdd("ctrl+a", "appl::TextPluginSelectAll::All"); } void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) { // TODO : unknow function ... } -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; } diff --git a/sources/appl/TextPluginSelectAll.h b/sources/appl/TextPluginSelectAll.h index 8b41a1e..6fefec7 100644 --- a/sources/appl/TextPluginSelectAll.h +++ b/sources/appl/TextPluginSelectAll.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/tagCode b/sources/tagCode new file mode 100644 index 0000000..7813681 --- /dev/null +++ b/sources/tagCode @@ -0,0 +1 @@ +5 \ No newline at end of file From 668570cdc7d0ca88eef868f9a60d29453da3038c Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 28 Aug 2014 22:31:00 +0200 Subject: [PATCH 07/20] [DEV] start correct plugin interface --- sources/appl/Gui/MainWindows.cpp | 6 +----- sources/appl/TextPlugin.cpp | 4 ++++ sources/appl/TextPlugin.h | 3 +++ sources/appl/TextPluginCopy.cpp | 13 +++++++++++++ sources/appl/init.cpp | 4 +++- sources/lutin_edn.py | 3 +++ 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 93de025..a991d5c 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -180,6 +180,7 @@ void MainWindows::init() { 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", "", "menu:new"); @@ -197,11 +198,6 @@ void MainWindows::init() { myMenu->add(idMenuEdit, "Undo", "THEME:GUI:Undo.edf", "menu:undo"); myMenu->add(idMenuEdit, "Redo", "THEME:GUI:Redo.edf", "menu:redo"); myMenu->addSpacer(); - myMenu->add(idMenuEdit, "Copy", "", "menu:copy"); - myMenu->add(idMenuEdit, "Cut", "", "menu:cut"); - myMenu->add(idMenuEdit, "Paste", "", "menu:past"); - myMenu->add(idMenuEdit, "Remove", "", "menu:remove"); - myMenu->addSpacer(); myMenu->add(idMenuEdit, "Select All","", "menu:select-all"); myMenu->add(idMenuEdit, "Un-Select","", "menu:select-none"); myMenu->add(idMenuEdit, "Goto line ...","", "menu:goto-line"); diff --git a/sources/appl/TextPlugin.cpp b/sources/appl/TextPlugin.cpp index 7dfb33e..2b0ca26 100644 --- a/sources/appl/TextPlugin.cpp +++ b/sources/appl/TextPlugin.cpp @@ -24,6 +24,10 @@ appl::TextViewerPlugin::TextViewerPlugin() : 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"); + } } void appl::TextViewerPlugin::init() { diff --git a/sources/appl/TextPlugin.h b/sources/appl/TextPlugin.h index dc4b8e6..d4bed7c 100644 --- a/sources/appl/TextPlugin.h +++ b/sources/appl/TextPlugin.h @@ -13,6 +13,7 @@ #include #include #include +#include namespace appl { class TextViewerPlugin : public ewol::Object { @@ -23,6 +24,8 @@ namespace appl { 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: diff --git a/sources/appl/TextPluginCopy.cpp b/sources/appl/TextPluginCopy.cpp index b439828..bf88356 100644 --- a/sources/appl/TextPluginCopy.cpp +++ b/sources/appl/TextPluginCopy.cpp @@ -25,7 +25,20 @@ void appl::TextPluginCopy::init() { } void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) { + APPL_ERROR("plop"); // add event : + std::shared_ptr menu = m_menuInterface.lock(); + if (menu != nullptr) { + APPL_ERROR("plop 1"); + int32_t idMenuEdit = menu->addTitle("Edit"); + if (idMenuEdit != -1) { + APPL_ERROR("plop 2 "); + menu->add(idMenuEdit, "Copy", "", "appl::TextPluginCopy::menu:copy"); + menu->add(idMenuEdit, "Cut", "", "appl::TextPluginCopy::menu:cut"); + menu->add(idMenuEdit, "Paste", "", "appl::TextPluginCopy::menu:past"); + menu->add(idMenuEdit, "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"); diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index 622faf0..c1755c3 100644 --- a/sources/appl/init.cpp +++ b/sources/appl/init.cpp @@ -61,7 +61,6 @@ class MainApplication : public ewol::context::Application { appl::highlightManager::init(); appl::textPluginManager::init(); - appl::textPluginManager::addDefaultPlugin(); // Request load of the user configuration ... //ewol::userConfig::load(); @@ -84,6 +83,9 @@ 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" + appl::textPluginManager::addDefaultPlugin(); + // add files APPL_INFO("show list of files : "); 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 "]) From b889b4aa5af4dcecf9e273e21c587c76f6066e8f Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 29 Aug 2014 22:52:21 +0200 Subject: [PATCH 08/20] [DEV] update plugin --- sources/appl/Gui/MainWindows.cpp | 7 ----- sources/appl/Gui/TextViewer.h | 10 +++++-- sources/appl/TextPlugin.cpp | 4 +++ sources/appl/TextPlugin.h | 1 + sources/appl/TextPluginCopy.cpp | 39 ++++++++++++++++++++-------- sources/appl/TextPluginCopy.h | 6 +++++ sources/appl/TextPluginCtags.cpp | 4 ++- sources/appl/TextPluginData.h | 3 +++ sources/appl/TextPluginHistory.cpp | 25 ++++++++++++++++-- sources/appl/TextPluginHistory.h | 4 +++ sources/appl/TextPluginManager.cpp | 12 +++++++++ sources/appl/TextPluginRmLine.cpp | 2 +- sources/appl/TextPluginSelectAll.cpp | 33 +++++++++++++++++++++-- sources/appl/TextPluginSelectAll.h | 3 +++ 14 files changed, 127 insertions(+), 26 deletions(-) diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index a991d5c..1a5e9c1 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -191,15 +191,8 @@ void MainWindows::init() { 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", "menu:property"); int32_t idMenuEdit = myMenu->addTitle("Edit"); - myMenu->add(idMenuEdit, "Undo", "THEME:GUI:Undo.edf", "menu:undo"); - myMenu->add(idMenuEdit, "Redo", "THEME:GUI:Redo.edf", "menu:redo"); - myMenu->addSpacer(); - myMenu->add(idMenuEdit, "Select All","", "menu:select-all"); - myMenu->add(idMenuEdit, "Un-Select","", "menu:select-none"); myMenu->add(idMenuEdit, "Goto line ...","", "menu:goto-line"); int32_t idMenuSearch = myMenu->addTitle("Search"); myMenu->add(idMenuSearch, "Search", "THEME:GUI:Search.edf", "menu:search"); diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index 65a9b54..9b5c55a 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -397,13 +397,19 @@ namespace appl { /** * @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 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); diff --git a/sources/appl/TextPlugin.cpp b/sources/appl/TextPlugin.cpp index 2b0ca26..7160c8b 100644 --- a/sources/appl/TextPlugin.cpp +++ b/sources/appl/TextPlugin.cpp @@ -34,6 +34,10 @@ 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; diff --git a/sources/appl/TextPlugin.h b/sources/appl/TextPlugin.h index d4bed7c..1609345 100644 --- a/sources/appl/TextPlugin.h +++ b/sources/appl/TextPlugin.h @@ -21,6 +21,7 @@ namespace appl { protected: TextViewerPlugin(); void init(); + void init(const std::string& _name); public: DECLARE_FACTORY(TextViewerPlugin); virtual ~TextViewerPlugin(); diff --git a/sources/appl/TextPluginCopy.cpp b/sources/appl/TextPluginCopy.cpp index bf88356..55b9e5f 100644 --- a/sources/appl/TextPluginCopy.cpp +++ b/sources/appl/TextPluginCopy.cpp @@ -15,7 +15,12 @@ #define __class__ "TextPluginCopy" -appl::TextPluginCopy::TextPluginCopy() { +appl::TextPluginCopy::TextPluginCopy() : + m_menuIdTitle(-1), + m_menuIdCopy(-1), + m_menuIdCut(-1), + m_menuIdPast(-1), + m_menuIdRemove(-1) { m_activateOnReceiveShortCut = true; addObjectType("appl::TextPluginCopy"); } @@ -25,18 +30,15 @@ void appl::TextPluginCopy::init() { } void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) { - APPL_ERROR("plop"); // add event : std::shared_ptr menu = m_menuInterface.lock(); if (menu != nullptr) { - APPL_ERROR("plop 1"); - int32_t idMenuEdit = menu->addTitle("Edit"); - if (idMenuEdit != -1) { - APPL_ERROR("plop 2 "); - menu->add(idMenuEdit, "Copy", "", "appl::TextPluginCopy::menu:copy"); - menu->add(idMenuEdit, "Cut", "", "appl::TextPluginCopy::menu:cut"); - menu->add(idMenuEdit, "Paste", "", "appl::TextPluginCopy::menu:past"); - menu->add(idMenuEdit, "Remove", "", "appl::TextPluginCopy::menu:remove"); + 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"); @@ -45,7 +47,22 @@ void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) { } 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::onReceiveShortCut(appl::TextViewer& _textDrawer, diff --git a/sources/appl/TextPluginCopy.h b/sources/appl/TextPluginCopy.h index a8d0e3e..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(); diff --git a/sources/appl/TextPluginCtags.cpp b/sources/appl/TextPluginCtags.cpp index 3e4e0b5..3a4ea11 100644 --- a/sources/appl/TextPluginCtags.cpp +++ b/sources/appl/TextPluginCtags.cpp @@ -45,7 +45,9 @@ void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) { } 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) { diff --git a/sources/appl/TextPluginData.h b/sources/appl/TextPluginData.h index df5b623..83cff7b 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() { diff --git a/sources/appl/TextPluginHistory.cpp b/sources/appl/TextPluginHistory.cpp index bc04d2d..816df06 100644 --- a/sources/appl/TextPluginHistory.cpp +++ b/sources/appl/TextPluginHistory.cpp @@ -15,7 +15,10 @@ #undef __class__ #define __class__ "TextPluginHistory" -appl::TextPluginHistory::TextPluginHistory() { +appl::TextPluginHistory::TextPluginHistory() : + m_menuIdTitle(-1), + m_menuIdUndo(-1), + m_menuIdRedo(-1) { m_activateOnReceiveShortCut = true; m_activateOnWrite = true; m_activateOnReplace = true; @@ -29,13 +32,31 @@ 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_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::onDataReceiveShortCut(appl::TextViewer& _textDrawer, diff --git a/sources/appl/TextPluginHistory.h b/sources/appl/TextPluginHistory.h index be22856..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(); diff --git a/sources/appl/TextPluginManager.cpp b/sources/appl/TextPluginManager.cpp index f4441d8..225c997 100644 --- a/sources/appl/TextPluginManager.cpp +++ b/sources/appl/TextPluginManager.cpp @@ -52,6 +52,11 @@ static std::vector>& getListOnCursorMove return s_list; } +static std::weak_ptr& getViewerConnected() { + static std::weak_ptr s_widget; + return s_widget; +} + void appl::textPluginManager::init() { } @@ -82,6 +87,7 @@ void appl::textPluginManager::addPlugin(const std::shared_ptrgetObjectType()); getList().push_back(_plugin); if (_plugin->isAvaillableOnEventEntry() == true) { getListOnEventEntry().push_back(_plugin); @@ -104,9 +110,14 @@ void appl::textPluginManager::addPlugin(const std::shared_ptrisAvaillableOnCursorMove() == true) { getListOnCursorMove().push_back(_plugin); } + std::shared_ptr viewer = getViewerConnected().lock(); + if (viewer != nullptr) { + _plugin->onPluginEnable(*viewer); + } } void appl::textPluginManager::connect(appl::TextViewer& _widget) { + getViewerConnected() = std::dynamic_pointer_cast(_widget.shared_from_this()); for (auto &it : getList()) { if (it == nullptr) { continue; @@ -116,6 +127,7 @@ void appl::textPluginManager::connect(appl::TextViewer& _widget) { } void appl::textPluginManager::disconnect(appl::TextViewer& _widget) { + getViewerConnected().reset(); for (auto &it : getList()) { if (it == nullptr) { continue; diff --git a/sources/appl/TextPluginRmLine.cpp b/sources/appl/TextPluginRmLine.cpp index e39810d..a0504c9 100644 --- a/sources/appl/TextPluginRmLine.cpp +++ b/sources/appl/TextPluginRmLine.cpp @@ -30,7 +30,7 @@ void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) { } void appl::TextPluginRmLine::onPluginDisable(appl::TextViewer& _textDrawer) { - // TODO : unknow function ... + _textDrawer.ext_shortCutRm("appl::TextPluginRmLine::Rm"); } bool appl::TextPluginRmLine::onReceiveShortCut(appl::TextViewer& _textDrawer, diff --git a/sources/appl/TextPluginSelectAll.cpp b/sources/appl/TextPluginSelectAll.cpp index dd7f534..40b1d7d 100644 --- a/sources/appl/TextPluginSelectAll.cpp +++ b/sources/appl/TextPluginSelectAll.cpp @@ -15,7 +15,10 @@ #define __class__ "TextPluginSelectAll" -appl::TextPluginSelectAll::TextPluginSelectAll() { +appl::TextPluginSelectAll::TextPluginSelectAll() : + m_menuIdTitle(-1), + m_menuIdSelectAll(-1), + m_menuIdSelectNone(-1) { m_activateOnReceiveShortCut = true; addObjectType("appl::TextPluginSelectAll"); } @@ -25,12 +28,31 @@ void appl::TextPluginSelectAll::init() { } 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_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::onReceiveShortCut(appl::TextViewer& _textDrawer, @@ -45,5 +67,12 @@ bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer, _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 6fefec7..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() { From 3574fd917c2141d00ed0141188b944d131318887 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 12 Sep 2014 21:36:20 +0200 Subject: [PATCH 09/20] [DEBUG #5] correct file selection --- sources/appl/BufferManager.cpp | 6 +++--- sources/appl/Gui/BufferView.cpp | 34 +++++++++++++++----------------- sources/appl/Gui/MainWindows.cpp | 10 +++------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/sources/appl/BufferManager.cpp b/sources/appl/BufferManager.cpp index 772709d..9eb152b 100644 --- a/sources/appl/BufferManager.cpp +++ b/sources/appl/BufferManager.cpp @@ -117,14 +117,14 @@ bool appl::BufferManager::exist(const std::string& _fileName) { void appl::BufferManager::open(const std::string& _fileName) { if (exist(_fileName) == true) { - // TODO : Create a pop-up ... + 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; } - APPL_INFO("Open buffer:" << _fileName); signalSelectFile.emit(_fileName); - APPL_INFO("Open buffer (done)"); } diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index b76f30d..782a33a 100644 --- a/sources/appl/Gui/BufferView.cpp +++ b/sources/appl/Gui/BufferView.cpp @@ -124,23 +124,22 @@ void BufferView::onCallbackNewBuffer(const std::string& _value) { } markToRedraw(); } + +// TODO : Review this callback with the real shared_ptr on the buffer ... void BufferView::onCallbackselectNewFile(const std::string& _value) { 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; - break; + for (size_t iii=0; iiim_buffer == nullptr) { + continue; + } + if (m_list[iii]->m_buffer->getFileName() != _value) { + continue; + } + m_selectedID = iii; + break; } markToRedraw(); } @@ -164,6 +163,7 @@ void BufferView::onCallbackChangeName() { } markToRedraw(); } + void BufferView::onCallbackIsSave() { markToRedraw(); } @@ -215,8 +215,7 @@ 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 @@ -224,10 +223,9 @@ bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent && nullptr != m_list[_raw]) { 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()); } - m_selectedID = _raw; - markToRedraw(); return true; } } diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp index 1a5e9c1..e22ed07 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -433,6 +433,7 @@ void MainWindows::displayProperty() { } void MainWindows::onCallbackselectNewFile(const std::string& _value) { + APPL_INFO("onCallbackselectNewFile(" << _value << ")"); if (m_bufferManager == nullptr) { APPL_ERROR("can not call unexistant buffer manager ... "); return; @@ -447,19 +448,14 @@ void MainWindows::onCallbackselectNewFile(const std::string& _value) { } } -static const char* const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected"; -static const char* const ednEventIsSave = "edn-buffer-is-saved"; -static const char* const ednEventIsModify = "edn-buffer-is-modify"; -static const char* const ednEventChangeName = "edn-buffer-change-name"; - - - 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; From 996fd5837044cdbbb9924ca5de095a2a2a4c8ac7 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 12 Sep 2014 21:52:03 +0200 Subject: [PATCH 10/20] [DEBUG #1] Save file done --- sources/appl/Gui/WorkerCloseAllFile.cpp | 14 ++++----- sources/appl/Gui/WorkerCloseAllFile.h | 3 +- sources/appl/Gui/WorkerCloseFile.cpp | 39 ++++++++++++++++++------- sources/appl/Gui/WorkerCloseFile.h | 5 +++- sources/appl/Gui/WorkerSaveAllFile.cpp | 14 ++++----- sources/appl/Gui/WorkerSaveAllFile.h | 3 +- sources/appl/Gui/WorkerSaveFile.cpp | 33 ++++++++++++++------- sources/appl/Gui/WorkerSaveFile.h | 5 +++- 8 files changed, 78 insertions(+), 38 deletions(-) diff --git a/sources/appl/Gui/WorkerCloseAllFile.cpp b/sources/appl/Gui/WorkerCloseAllFile.cpp index cfcca88..03b9313 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.cpp +++ b/sources/appl/Gui/WorkerCloseAllFile.cpp @@ -20,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 : @@ -41,7 +41,7 @@ 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 : @@ -49,14 +49,14 @@ void appl::WorkerCloseAllFile::init() { // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); } appl::WorkerCloseAllFile::~WorkerCloseAllFile() { - + APPL_ERROR("Remove Worker"); } void appl::WorkerCloseAllFile::onCallbackCloseDone() { @@ -65,7 +65,7 @@ void appl::WorkerCloseAllFile::onCallbackCloseDone() { return; } if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } // create the worker : @@ -73,7 +73,7 @@ void appl::WorkerCloseAllFile::onCallbackCloseDone() { // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); diff --git a/sources/appl/Gui/WorkerCloseAllFile.h b/sources/appl/Gui/WorkerCloseAllFile.h index dfb3885..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(); diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index 45869f1..285dcec 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -16,6 +16,7 @@ appl::WorkerCloseFile::WorkerCloseFile() : signalCloseDone(*this, "close-file-done"), + signalAbort(*this, "close-file-abort"), m_buffer(nullptr), m_worker(nullptr), m_bufferManager(nullptr) { @@ -25,11 +26,11 @@ appl::WorkerCloseFile::WorkerCloseFile() : } void appl::WorkerCloseFile::init(const std::string& _bufferName) { - 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 == "") { @@ -44,13 +45,13 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) { } 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) { @@ -81,21 +82,29 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) { if (bt != nullptr) { bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackClose); } - tmpPopUp->addButton("Cancel", true); + bt = tmpPopUp->addButton("Cancel", true); + if (bt != nullptr) { + bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackCancel); + } 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::onCallbackCancel() { + APPL_VERBOSE("Cancel signal ..."); + signalAbort.emit(); + destroy(); +} void appl::WorkerCloseFile::onCallbackSaveAsValidate() { if (m_bufferManager == nullptr) { @@ -105,17 +114,21 @@ void appl::WorkerCloseFile::onCallbackSaveAsValidate() { 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); - autoDestroy(); + signalAbort.emit(); + destroy(); return; } if (m_buffer->storeFile() == false) { @@ -124,23 +137,29 @@ void appl::WorkerCloseFile::onCallbackSaveValidate() { return; } tmpWindows->displayWarningMessage("We can not save the file :
" + m_buffer->getFileName() + ""); + signalAbort.emit(); } else { 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); - autoDestroy(); + signalAbort.emit(); + destroy(); return; } - signalCloseDone.emit(); m_buffer->destroy(); m_buffer.reset(); + signalCloseDone.emit(); + destroy(); } diff --git a/sources/appl/Gui/WorkerCloseFile.h b/sources/appl/Gui/WorkerCloseFile.h index 2096a22..ef261d7 100644 --- a/sources/appl/Gui/WorkerCloseFile.h +++ b/sources/appl/Gui/WorkerCloseFile.h @@ -9,14 +9,16 @@ #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: ewol::object::Signal signalCloseDone; + ewol::object::Signal signalAbort; protected: // note : if == "" ==> current ... WorkerCloseFile(); @@ -33,6 +35,7 @@ namespace appl { void onCallbackSaveAsValidate(); void onCallbackSaveValidate(); void onCallbackClose(); + void onCallbackCancel(); }; }; diff --git a/sources/appl/Gui/WorkerSaveAllFile.cpp b/sources/appl/Gui/WorkerSaveAllFile.cpp index 5afe912..44007c9 100644 --- a/sources/appl/Gui/WorkerSaveAllFile.cpp +++ b/sources/appl/Gui/WorkerSaveAllFile.cpp @@ -20,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 : @@ -43,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 : @@ -51,14 +51,14 @@ void appl::WorkerSaveAllFile::init() { // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone); } appl::WorkerSaveAllFile::~WorkerSaveAllFile() { - + APPL_ERROR("Remove Worker"); } void appl::WorkerSaveAllFile::onCallbackSaveAsDone() { @@ -67,7 +67,7 @@ void appl::WorkerSaveAllFile::onCallbackSaveAsDone() { return; } if (m_bufferNameList.size() == 0) { - autoDestroy(); + destroy(); return; } // create the worker : @@ -75,7 +75,7 @@ void appl::WorkerSaveAllFile::onCallbackSaveAsDone() { // remove first element : m_bufferNameList.erase(m_bufferNameList.begin()); if (m_bufferNameList.size() == 0) { - autoDestroy(); + 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 f40bb75..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(); diff --git a/sources/appl/Gui/WorkerSaveFile.cpp b/sources/appl/Gui/WorkerSaveFile.cpp index 427eb63..351a2c0 100644 --- a/sources/appl/Gui/WorkerSaveFile.cpp +++ b/sources/appl/Gui/WorkerSaveFile.cpp @@ -15,18 +15,19 @@ appl::WorkerSaveFile::WorkerSaveFile() : - signalSaveDone(*this, "save-file-done") { + signalSaveDone(*this, "save-file-done"), + signalAbort(*this, "save-file-abort") { addObjectType("appl::WorkerSaveFile"); // 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 == "") { @@ -34,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(); signalSaveDone.emit(); - autoDestroy(); + 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..."); @@ -72,44 +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->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::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 (_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 3734c0f..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: ewol::object::Signal signalSaveDone; + ewol::object::Signal signalAbort; protected: WorkerSaveFile(); void init(const std::string& _bufferName, bool _forceSaveAs=true); @@ -28,6 +30,7 @@ namespace appl { std::shared_ptr m_bufferManager; //!< handle on the buffer manager public: // callback function void onCallbackSaveAsValidate(const std::string& _value); + void onCallbackCancel(); }; }; From 0a054c209f3a7f63e9e22f7ccdfcbd8164205fa0 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 12 Sep 2014 22:10:32 +0200 Subject: [PATCH 11/20] [DEV] add parenting between bufferManager and Buffer --- sources/appl/BufferManager.cpp | 17 +++++++++++++++++ sources/appl/BufferManager.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/sources/appl/BufferManager.cpp b/sources/appl/BufferManager.cpp index 9eb152b..bbb4a56 100644 --- a/sources/appl/BufferManager.cpp +++ b/sources/appl/BufferManager.cpp @@ -71,6 +71,7 @@ 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"); @@ -128,3 +129,19 @@ void appl::BufferManager::open(const std::string& _fileName) { signalSelectFile.emit(_fileName); } + +void appl::BufferManager::requestDestroyFromChild(const std::shared_ptr& _child) { + APPL_WARNING("Buffer request a close..."); + 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); + return; + } + ++it; + } +} diff --git a/sources/appl/BufferManager.h b/sources/appl/BufferManager.h index 812dd4c..4437a52 100644 --- a/sources/appl/BufferManager.h +++ b/sources/appl/BufferManager.h @@ -81,6 +81,8 @@ namespace appl { std::shared_ptr getBufferSelected() { return m_bufferSelected; }; + private: + void requestDestroyFromChild(const std::shared_ptr& _child); }; }; From 05ac6a9210bba7e761958e876aa64d1d321c025e Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 15 Sep 2014 07:21:22 +0200 Subject: [PATCH 12/20] [DEBUG #2 #7] close file and save it whan needed --- sources/appl/Buffer.cpp | 40 ++++++++++- sources/appl/Buffer.h | 4 +- sources/appl/BufferManager.cpp | 18 ++++- sources/appl/BufferManager.h | 1 + sources/appl/Gui/BufferView.cpp | 93 ++++++++++--------------- sources/appl/Gui/BufferView.h | 5 +- sources/appl/Gui/MainWindows.cpp | 3 +- sources/appl/Gui/TextViewer.cpp | 17 +++-- sources/appl/Gui/TextViewer.h | 2 +- sources/appl/Gui/WorkerCloseAllFile.cpp | 10 +-- sources/appl/Gui/WorkerCloseFile.cpp | 9 ++- sources/appl/Gui/WorkerCloseFile.h | 7 +- sources/appl/TextPluginData.h | 15 ++-- 13 files changed, 144 insertions(+), 80 deletions(-) diff --git a/sources/appl/Buffer.cpp b/sources/appl/Buffer.cpp index 42c7f65..182593e 100644 --- a/sources/appl/Buffer.cpp +++ b/sources/appl/Buffer.cpp @@ -138,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) { @@ -987,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 3f98895..d413227 100644 --- a/sources/appl/Buffer.h +++ b/sources/appl/Buffer.h @@ -306,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 bbb4a56..0a71571 100644 --- a/sources/appl/BufferManager.cpp +++ b/sources/appl/BufferManager.cpp @@ -21,7 +21,8 @@ appl::BufferManager::BufferManager() : signalNewBuffer(*this, "new-buffer"), signalSelectFile(*this, "select-buffer"), - signalTextSelectionChange(*this, "text-selection-change") { + signalTextSelectionChange(*this, "text-selection-change"), + signalRemoveBuffer(*this, "remove-buffer") { addObjectType("appl::BufferManager"); } @@ -40,6 +41,7 @@ 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); APPL_INFO("Create a new Buffer"); signalNewBuffer.emit(tmp->getFileName()); @@ -132,6 +134,8 @@ void appl::BufferManager::open(const std::string& _fileName) { 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) { @@ -140,8 +144,18 @@ void appl::BufferManager::requestDestroyFromChild(const std::shared_ptr& } if (*it == _child) { it = m_list.erase(it); - return; + 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 4437a52..c27fe89 100644 --- a/sources/appl/BufferManager.h +++ b/sources/appl/BufferManager.h @@ -21,6 +21,7 @@ namespace appl { ewol::object::Signal signalNewBuffer; ewol::object::Signal signalSelectFile; ewol::object::Signal signalTextSelectionChange; + ewol::object::Signal> signalRemoveBuffer; protected: BufferManager(); void init(const std::string& _uniqueName); diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp index 782a33a..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; } } @@ -62,6 +57,7 @@ void BufferView::init() { 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); } } @@ -70,36 +66,23 @@ 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; } } @@ -112,11 +95,7 @@ void BufferView::onCallbackNewBuffer(const std::string& _value) { 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 = new appl::dataBufferStruct(_value, buffer); - if (tmp == nullptr) { - APPL_ERROR("Allocation error of the tmp buffer list element"); - return; - } + appl::dataBufferStruct tmp(_value, buffer); if (m_openOrderMode == true) { m_list.push_back(tmp); } else { @@ -129,13 +108,10 @@ void BufferView::onCallbackNewBuffer(const std::string& _value) { void BufferView::onCallbackselectNewFile(const std::string& _value) { m_selectedID = -1; for (size_t iii=0; iiim_buffer == nullptr) { - continue; - } - if (m_list[iii]->m_buffer->getFileName() != _value) { + if (m_list[iii].m_buffer->getFileName() != _value) { continue; } m_selectedID = iii; @@ -146,15 +122,11 @@ void BufferView::onCallbackselectNewFile(const std::string& _value) { void BufferView::onCallbackChangeName() { 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_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; + appl::dataBufferStruct tmp = m_list[iii]; m_list.erase(m_list.begin() + iii); insertAlphabetic(tmp, ((int64_t)iii == m_selectedID)); break; @@ -164,6 +136,19 @@ void BufferView::onCallbackChangeName() { 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(); } @@ -190,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(); @@ -219,12 +203,11 @@ bool BufferView::onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent 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) { + && _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()); + 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 107d7b4..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(); @@ -73,6 +73,7 @@ class BufferView : public ewol::widget::List { 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 e22ed07..f3560a2 100644 --- a/sources/appl/Gui/MainWindows.cpp +++ b/sources/appl/Gui/MainWindows.cpp @@ -255,7 +255,8 @@ void MainWindows::onCallbackMenuEvent(const std::string& _value) { } else if (_value == "menu:open") { displayOpen(); } else if (_value == "menu:close") { - appl::WorkerCloseFile::create(""); + std::shared_ptr worker = appl::WorkerCloseFile::create(); + worker->startAction(""); } else if (_value == "menu:close-all") { appl::WorkerCloseAllFile::create(); } else if (_value == "menu:save") { diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index 2c03784..b50fbd3 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -91,16 +91,23 @@ void appl::TextViewer::onCallbackselectNewFile(const std::string& _value) { if (m_buffer != nullptr) { m_buffer->unBindAll(shared_from_this()); bool needAdd = true; - for (size_t iii=0; iii 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(m_buffer, m_originScrooled)); + m_drawingRemenber.push_back(std::make_pair(std::weak_ptr(m_buffer), m_originScrooled)); APPL_VERBOSE("Push origin : " << m_originScrooled); } } @@ -112,7 +119,7 @@ void appl::TextViewer::onCallbackselectNewFile(const std::string& _value) { 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 == m_buffer) { + 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 ... diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index 9b5c55a..1f2248c 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -54,7 +54,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); diff --git a/sources/appl/Gui/WorkerCloseAllFile.cpp b/sources/appl/Gui/WorkerCloseAllFile.cpp index 03b9313..f799fc2 100644 --- a/sources/appl/Gui/WorkerCloseAllFile.cpp +++ b/sources/appl/Gui/WorkerCloseAllFile.cpp @@ -45,14 +45,15 @@ void appl::WorkerCloseAllFile::init() { 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) { destroy(); return; } - m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); } appl::WorkerCloseAllFile::~WorkerCloseAllFile() { @@ -69,13 +70,14 @@ void appl::WorkerCloseAllFile::onCallbackCloseDone() { 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) { destroy(); return; } - m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone); } diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index 285dcec..e60f996 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -25,8 +25,11 @@ appl::WorkerCloseFile::WorkerCloseFile() : m_bufferManager = appl::BufferManager::create(); } -void appl::WorkerCloseFile::init(const std::string& _bufferName) { +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 ... "); @@ -38,7 +41,7 @@ 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(); @@ -57,12 +60,14 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) { if (m_buffer->isModify() == false) { 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:"); diff --git a/sources/appl/Gui/WorkerCloseFile.h b/sources/appl/Gui/WorkerCloseFile.h index ef261d7..b962138 100644 --- a/sources/appl/Gui/WorkerCloseFile.h +++ b/sources/appl/Gui/WorkerCloseFile.h @@ -22,10 +22,15 @@ namespace appl { 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 diff --git a/sources/appl/TextPluginData.h b/sources/appl/TextPluginData.h index 83cff7b..4cbbf88 100644 --- a/sources/appl/TextPluginData.h +++ b/sources/appl/TextPluginData.h @@ -41,12 +41,19 @@ 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; } } TYPE* data = new TYPE(); From e29aa94cc5c87606d28d449b8c0c2e4d28daeceb Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 15 Sep 2014 07:27:51 +0200 Subject: [PATCH 13/20] [DEBUG #8] CLose the file after saving it when request close --- sources/appl/Gui/WorkerCloseFile.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/appl/Gui/WorkerCloseFile.cpp b/sources/appl/Gui/WorkerCloseFile.cpp index e60f996..a4e5a2b 100644 --- a/sources/appl/Gui/WorkerCloseFile.cpp +++ b/sources/appl/Gui/WorkerCloseFile.cpp @@ -144,6 +144,8 @@ void appl::WorkerCloseFile::onCallbackSaveValidate() { tmpWindows->displayWarningMessage("We can not save the file :
" + m_buffer->getFileName() + ""); signalAbort.emit(); } else { + m_buffer->destroy(); + m_buffer.reset(); signalCloseDone.emit(); } destroy(); From c12ed9e7fa5f132dc8bf8d2eb20620d5204b9760 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 18 Sep 2014 21:01:41 +0200 Subject: [PATCH 14/20] [DEBUG #9] freez correction ==> plugin data missing iterator --- sources/appl/TextPluginData.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/appl/TextPluginData.h b/sources/appl/TextPluginData.h index 4cbbf88..033b667 100644 --- a/sources/appl/TextPluginData.h +++ b/sources/appl/TextPluginData.h @@ -55,6 +55,7 @@ namespace appl { if (buf == _textDrawer.internalGetBuffer()) { return it->second; } + ++it; } TYPE* data = new TYPE(); if (data == nullptr) { From 60766982011ca340441d514669e1720e22109ca1 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 17 Sep 2014 08:38:34 +0200 Subject: [PATCH 15/20] Create .travis.yml --- .travis.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e562905 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,38 @@ +# 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 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 ./build/lutin.py -cclang -mdebug -p edn; fi + - if [ "$CXX" == "g++" ]; then ./build/lutin.py -cgcc -mdebug -p edn; fi + +#send e-mail on compilation result: +notifications: + email: + - yui.heero@gmail.com From f971c4fdfe2554676e22679e16b48a2147fb0c39 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 18 Sep 2014 21:05:48 +0200 Subject: [PATCH 16/20] [DEBUG]travis file error --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e562905..2dadfb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,8 +29,8 @@ install: # build sequence with Lutin : script: - - if [ "$CXX" == "clang++" ]; then ./build/lutin.py -cclang -mdebug -p edn; fi - - if [ "$CXX" == "g++" ]; then ./build/lutin.py -cgcc -mdebug -p edn; fi + - 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: From f9ff0b8899ece29e55ec497a2b36e8cdad8468fd Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 18 Sep 2014 21:07:32 +0200 Subject: [PATCH 17/20] [DEBUG] remove lutinBase.py that is deprecated --- lutinBase.py | 6 ------ 1 file changed, 6 deletions(-) delete mode 100755 lutinBase.py 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/") From b8962cc3b9bb29321a1eaa9f9514439ddf796352 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 18 Sep 2014 21:32:25 +0200 Subject: [PATCH 18/20] [DEV] set travis depend on dev branch of ewol --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2dadfb9..fa6ae6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ branches: # 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 .. From 2c3a64933df0802fc8b5592c225520460d1d8334 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 18 Sep 2014 22:27:54 +0200 Subject: [PATCH 19/20] [DEV] transform plugin manager in unique resource --- sources/appl/Gui/TextViewer.cpp | 25 ++-- sources/appl/Gui/TextViewer.h | 2 + sources/appl/TextPlugin.cpp | 3 + sources/appl/TextPlugin.h | 3 + sources/appl/TextPluginHistory.cpp | 15 ++- sources/appl/TextPluginManager.cpp | 93 ++++--------- sources/appl/TextPluginManager.h | 192 ++++++++++++++------------- sources/appl/TextPluginSelectAll.cpp | 1 + sources/appl/init.cpp | 8 +- 9 files changed, 161 insertions(+), 181 deletions(-) diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index b50fbd3..2f0f07d 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -41,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 @@ -58,7 +59,7 @@ 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); @@ -76,11 +77,11 @@ void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) { } appl::TextViewer::~TextViewer() { - appl::textPluginManager::disconnect(*this); + m_pluginManager->disconnect(*this); } void appl::TextViewer::onCallbackShortCut(const std::string& _value) { - if (appl::textPluginManager::onReceiveShortCut(*this, _value) == true) { + if (m_pluginManager->onReceiveShortCut(*this, _value) == true) { return; } } @@ -383,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; } @@ -505,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; } @@ -751,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; } @@ -775,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; } @@ -791,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; } @@ -821,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 1f2248c..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(); diff --git a/sources/appl/TextPlugin.cpp b/sources/appl/TextPlugin.cpp index 7160c8b..7dc280b 100644 --- a/sources/appl/TextPlugin.cpp +++ b/sources/appl/TextPlugin.cpp @@ -8,6 +8,7 @@ #include +#include #include #undef __class__ @@ -28,6 +29,8 @@ appl::TextViewerPlugin::TextViewerPlugin() : 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() { diff --git a/sources/appl/TextPlugin.h b/sources/appl/TextPlugin.h index 1609345..b68b76c 100644 --- a/sources/appl/TextPlugin.h +++ b/sources/appl/TextPlugin.h @@ -16,8 +16,11 @@ #include namespace appl { + class textPluginManager; class TextViewerPlugin : public ewol::Object { friend class appl::TextViewer; + protected: + std::weak_ptr m_pluginManager; protected: TextViewerPlugin(); void init(); diff --git a/sources/appl/TextPluginHistory.cpp b/sources/appl/TextPluginHistory.cpp index 816df06..59a4b89 100644 --- a/sources/appl/TextPluginHistory.cpp +++ b/sources/appl/TextPluginHistory.cpp @@ -149,7 +149,10 @@ bool appl::TextPluginHistory::onDataWrite(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; } @@ -174,7 +177,10 @@ bool appl::TextPluginHistory::onDataReplace(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; } @@ -196,7 +202,10 @@ bool appl::TextPluginHistory::onDataRemove(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/TextPluginManager.cpp b/sources/appl/TextPluginManager.cpp index 225c997..2326595 100644 --- a/sources/appl/TextPluginManager.cpp +++ b/sources/appl/TextPluginManager.cpp @@ -19,58 +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>& getListonReceiveShortCutViewer() { - static std::vector> s_list; - return s_list; -} -static std::vector>& getListOnCursorMove() { - static std::vector> s_list; - return s_list; -} - -static std::weak_ptr& getViewerConnected() { - static std::weak_ptr s_widget; - return s_widget; -} - -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(); - getListonReceiveShortCutViewer().clear(); - getListOnCursorMove().clear(); - getList().clear(); +void appl::textPluginManager::init(const std::string& _name) { + ewol::Resource::init(_name); } void appl::textPluginManager::addDefaultPlugin() { @@ -88,37 +41,37 @@ void appl::textPluginManager::addPlugin(const std::shared_ptrgetObjectType()); - getList().push_back(_plugin); + 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->isAvaillableOnReceiveShortCut() == true) { - getListonReceiveShortCutViewer().push_back(_plugin); + m_listOnReceiveShortCutViewer.push_back(_plugin); } if (_plugin->isAvaillableOnCursorMove() == true) { - getListOnCursorMove().push_back(_plugin); + m_listOnCursorMove.push_back(_plugin); } - std::shared_ptr viewer = getViewerConnected().lock(); + std::shared_ptr viewer = m_currentViewer.lock(); if (viewer != nullptr) { _plugin->onPluginEnable(*viewer); } } void appl::textPluginManager::connect(appl::TextViewer& _widget) { - getViewerConnected() = std::dynamic_pointer_cast(_widget.shared_from_this()); - for (auto &it : getList()) { + m_currentViewer = std::dynamic_pointer_cast(_widget.shared_from_this()); + for (auto &it : m_list) { if (it == nullptr) { continue; } @@ -127,8 +80,8 @@ void appl::textPluginManager::connect(appl::TextViewer& _widget) { } void appl::textPluginManager::disconnect(appl::TextViewer& _widget) { - getViewerConnected().reset(); - for (auto &it : getList()) { + m_currentViewer.reset(); + for (auto &it : m_list) { if (it == nullptr) { continue; } @@ -138,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; } @@ -151,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; } @@ -165,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; } @@ -180,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; } @@ -194,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; } @@ -207,7 +160,7 @@ bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onReceiveShortCut(appl::TextViewer& _textDrawer, const std::string& _shortCutName) { - for (auto &it : getListonReceiveShortCutViewer()) { + for (auto &it : m_listOnReceiveShortCutViewer) { if (it == nullptr) { continue; } @@ -220,7 +173,7 @@ bool appl::textPluginManager::onReceiveShortCut(appl::TextViewer& _textDrawer, 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 9d03703..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] _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); + 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/TextPluginSelectAll.cpp b/sources/appl/TextPluginSelectAll.cpp index 40b1d7d..4689a75 100644 --- a/sources/appl/TextPluginSelectAll.cpp +++ b/sources/appl/TextPluginSelectAll.cpp @@ -55,6 +55,7 @@ void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) { m_menuIdSelectNone = -1; } + bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer, const std::string& _shortCutName) { if (isEnable() == false) { diff --git a/sources/appl/init.cpp b/sources/appl/init.cpp index c1755c3..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,9 +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(); // Request load of the user configuration ... //ewol::userConfig::load(); @@ -84,8 +85,7 @@ class MainApplication : public ewol::context::Application { _context.setWindows(basicWindows); // need to add default plugin, because they depend on the Menu widget wich might be named : "appl-menu-interface" - appl::textPluginManager::addDefaultPlugin(); - + m_pluginManager->addDefaultPlugin(); // add files APPL_INFO("show list of files : "); @@ -113,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)"); } From b890f931ca10aed9ce6c42e28ef305f29c04f51a Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 2 Oct 2014 22:40:40 +0200 Subject: [PATCH 20/20] [DEV] remove problematic function parsing --- data/languages/bash/highlight.xml | 2 ++ data/languages/c/highlight.xml | 5 ++++- data/languages/cmake/highlight.xml | 3 ++- data/languages/java/highlight.xml | 2 ++ data/languages/lua/highlight.xml | 2 ++ data/languages/matlab/highlight.xml | 2 ++ data/languages/php/highlight.xml | 2 ++ data/languages/python/highlight.xml | 2 ++ sources/appl/Highlight.cpp | 9 +++++---- sources/appl/Highlight.h | 3 ++- sources/appl/HighlightPattern.cpp | 12 +++++++++--- sources/appl/HighlightPattern.h | 4 ++-- 12 files changed, 36 insertions(+), 12 deletions(-) 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/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); }; };