diff --git a/sources/appl/BufferManager.cpp b/sources/appl/BufferManager.cpp index 21cf281..bbac042 100644 --- a/sources/appl/BufferManager.cpp +++ b/sources/appl/BufferManager.cpp @@ -42,12 +42,12 @@ ewol::object::Shared appl::BufferManager::createNewBuffer() { ewol::object::Shared appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) { APPL_INFO("get(" << _fileName << "," << _createIfNeeded << ")"); - for (int32_t iii = 0; iii < m_list.size(); ++iii) { - if (m_list[iii] == NULL) { + for (auto &it : m_list) { + if (it == NULL) { continue; } - if (m_list[iii]->getFileName() == _fileName) { - return m_list[iii]; + if (it->getFileName() == _fileName) { + return it; } } if (_createIfNeeded == true) { @@ -76,22 +76,32 @@ void appl::BufferManager::onObjectRemove(const ewol::object::Shared appl::BufferManager::get(int32_t _id) { + int32_t id = 0; + for (auto it : m_list) { + if (id == _id) { + return it; + } + id++; + } + return m_list.back(); +} + bool appl::BufferManager::exist(const std::string& _fileName) { - for (int32_t iii = 0; iii < m_list.size(); ++iii) { - if (m_list[iii] == NULL) { + for (auto it : m_list) { + if (it == nullptr) { continue; } - if (m_list[iii]->getFileName() == _fileName) { + if (it->getFileName() == _fileName) { return true; } } diff --git a/sources/appl/BufferManager.h b/sources/appl/BufferManager.h index 773ead8..9ddf2b1 100644 --- a/sources/appl/BufferManager.h +++ b/sources/appl/BufferManager.h @@ -9,6 +9,7 @@ #ifndef __BUFFER_MANAGER_H__ #define __BUFFER_MANAGER_H__ +#include #include #include #include @@ -21,7 +22,7 @@ namespace appl { public: ~BufferManager(); private: - std::vector> m_list; // list of all buffer curently open + std::list> m_list; // list of all buffer curently open public: /** * @brief Get a specific buffer with his name (can create a new buffer). @@ -53,9 +54,7 @@ namespace appl { * @param[in] _id Number of buffer * @return pointer on the buffer */ - ewol::object::Shared get(int32_t _id) { - return m_list[_id]; - } + ewol::object::Shared get(int32_t _id); /** * @brief Create a new buffer empty. * @return Created buffer or NULL. diff --git a/sources/appl/Gui/BufferView.h b/sources/appl/Gui/BufferView.h index 7c95366..8e308d6 100644 --- a/sources/appl/Gui/BufferView.h +++ b/sources/appl/Gui/BufferView.h @@ -15,10 +15,8 @@ #include #include -namespace appl -{ - class dataBufferStruct - { +namespace appl { + class dataBufferStruct { public: etk::FSNode m_bufferName; ewol::object::Shared m_buffer; @@ -31,8 +29,7 @@ namespace appl }; }; -class BufferView : public ewol::widget::List -{ +class BufferView : public ewol::widget::List { private: ewol::object::Shared m_bufferManager; //!< handle on the buffer manager private: diff --git a/sources/appl/TextPluginData.h b/sources/appl/TextPluginData.h index 7afbff5..9cf19ab 100644 --- a/sources/appl/TextPluginData.h +++ b/sources/appl/TextPluginData.h @@ -116,7 +116,12 @@ namespace appl { }; public: virtual void onObjectRemove(const ewol::object::Shared& _removeObject) { - // TODO : plop + for (auto it(m_specificData.begin()); it != m_specificData.end(); ++it) { + if (it->first == _removeObject) { + m_specificData.erase(it); + it = m_specificData.begin(); + } + } }; }; };