parent
0a054c209f
commit
05ac6a9210
@ -138,7 +138,7 @@ void appl::Buffer::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
appl::Buffer::~Buffer() {
|
appl::Buffer::~Buffer() {
|
||||||
|
APPL_ERROR("REAL remove buffer : '" << m_name << "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool appl::Buffer::loadFile(const std::string& _name) {
|
bool appl::Buffer::loadFile(const std::string& _name) {
|
||||||
@ -987,3 +987,41 @@ uint32_t appl::Buffer::getCursorLinesId() {
|
|||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace etk {
|
||||||
|
template<> std::string to_string<std::shared_ptr<appl::Buffer>>(const std::shared_ptr<appl::Buffer>& _obj) {
|
||||||
|
if (_obj != nullptr) {
|
||||||
|
return _obj->getFileName();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
template<> std::u32string to_u32string<std::shared_ptr<appl::Buffer>>(const std::shared_ptr<appl::Buffer>& _obj) {
|
||||||
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> bool from_string<std::shared_ptr<appl::Buffer>>(std::shared_ptr<appl::Buffer>& _variableRet, const std::string& _value) {
|
||||||
|
if (_variableRet != nullptr) {
|
||||||
|
_variableRet->loadFile(_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
template<> bool from_string<std::shared_ptr<appl::Buffer>>(std::shared_ptr<appl::Buffer>& _variableRet, const std::u32string& _value) {
|
||||||
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
template<> std::string to_string<appl::Buffer>(const appl::Buffer& _obj) {
|
||||||
|
return _obj.getFileName();
|
||||||
|
}
|
||||||
|
template<> std::u32string to_u32string<appl::Buffer>(const appl::Buffer& _obj) {
|
||||||
|
return etk::to_u32string(etk::to_string(_obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> bool from_string<appl::Buffer>(appl::Buffer& _variableRet, const std::string& _value) {
|
||||||
|
_variableRet.loadFile(_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
template<> bool from_string<appl::Buffer>(appl::Buffer& _variableRet, const std::u32string& _value) {
|
||||||
|
return from_string(_variableRet, etk::to_string(_value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@ -306,14 +306,14 @@ namespace appl {
|
|||||||
/**
|
/**
|
||||||
* @brief get the curent filename of the Buffer
|
* @brief get the curent filename of the Buffer
|
||||||
*/
|
*/
|
||||||
const std::string& getFileName() {
|
const std::string& getFileName() const {
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Check if the buffer has a real filename.
|
* @brief Check if the buffer has a real filename.
|
||||||
* @return the status of the existance of a name.
|
* @return the status of the existance of a name.
|
||||||
*/
|
*/
|
||||||
bool hasFileName() {
|
bool hasFileName() const {
|
||||||
return m_hasFileName;
|
return m_hasFileName;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
appl::BufferManager::BufferManager() :
|
appl::BufferManager::BufferManager() :
|
||||||
signalNewBuffer(*this, "new-buffer"),
|
signalNewBuffer(*this, "new-buffer"),
|
||||||
signalSelectFile(*this, "select-buffer"),
|
signalSelectFile(*this, "select-buffer"),
|
||||||
signalTextSelectionChange(*this, "text-selection-change") {
|
signalTextSelectionChange(*this, "text-selection-change"),
|
||||||
|
signalRemoveBuffer(*this, "remove-buffer") {
|
||||||
addObjectType("appl::BufferManager");
|
addObjectType("appl::BufferManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ std::shared_ptr<appl::Buffer> appl::BufferManager::createNewBuffer() {
|
|||||||
APPL_ERROR("Can not allocate the Buffer (empty).");
|
APPL_ERROR("Can not allocate the Buffer (empty).");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
tmp->setParent(shared_from_this());
|
||||||
m_list.push_back(tmp);
|
m_list.push_back(tmp);
|
||||||
APPL_INFO("Create a new Buffer");
|
APPL_INFO("Create a new Buffer");
|
||||||
signalNewBuffer.emit(tmp->getFileName());
|
signalNewBuffer.emit(tmp->getFileName());
|
||||||
@ -132,6 +134,8 @@ void appl::BufferManager::open(const std::string& _fileName) {
|
|||||||
|
|
||||||
void appl::BufferManager::requestDestroyFromChild(const std::shared_ptr<Object>& _child) {
|
void appl::BufferManager::requestDestroyFromChild(const std::shared_ptr<Object>& _child) {
|
||||||
APPL_WARNING("Buffer request a close...");
|
APPL_WARNING("Buffer request a close...");
|
||||||
|
bool find = false;
|
||||||
|
int32_t newValue = -1;
|
||||||
auto it = m_list.begin();
|
auto it = m_list.begin();
|
||||||
while(it != m_list.end()) {
|
while(it != m_list.end()) {
|
||||||
if (*it == nullptr) {
|
if (*it == nullptr) {
|
||||||
@ -140,8 +144,18 @@ void appl::BufferManager::requestDestroyFromChild(const std::shared_ptr<Object>&
|
|||||||
}
|
}
|
||||||
if (*it == _child) {
|
if (*it == _child) {
|
||||||
it = m_list.erase(it);
|
it = m_list.erase(it);
|
||||||
return;
|
find = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
newValue++;
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
if (find == true) {
|
||||||
|
signalRemoveBuffer.emit(std::dynamic_pointer_cast<appl::Buffer>(_child));
|
||||||
|
}
|
||||||
|
if (m_bufferSelected == _child) {
|
||||||
|
APPL_ERROR("is selected");
|
||||||
|
signalSelectFile.emit("");
|
||||||
|
m_bufferSelected = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ namespace appl {
|
|||||||
ewol::object::Signal<std::string> signalNewBuffer;
|
ewol::object::Signal<std::string> signalNewBuffer;
|
||||||
ewol::object::Signal<std::string> signalSelectFile;
|
ewol::object::Signal<std::string> signalSelectFile;
|
||||||
ewol::object::Signal<void> signalTextSelectionChange;
|
ewol::object::Signal<void> signalTextSelectionChange;
|
||||||
|
ewol::object::Signal<std::shared_ptr<appl::Buffer>> signalRemoveBuffer;
|
||||||
protected:
|
protected:
|
||||||
BufferManager();
|
BufferManager();
|
||||||
void init(const std::string& _uniqueName);
|
void init(const std::string& _uniqueName);
|
||||||
|
@ -17,20 +17,15 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "BufferView"
|
#define __class__ "BufferView"
|
||||||
|
|
||||||
static void SortElementList(std::vector<appl::dataBufferStruct*>& _list) {
|
// TODO : write it better
|
||||||
std::vector<appl::dataBufferStruct *> tmpList = _list;
|
static void SortElementList(std::vector<appl::dataBufferStruct>& _list) {
|
||||||
|
std::vector<appl::dataBufferStruct> tmpList = _list;
|
||||||
_list.clear();
|
_list.clear();
|
||||||
for(size_t iii=0; iii<tmpList.size(); iii++) {
|
for(size_t iii=0; iii<tmpList.size(); iii++) {
|
||||||
if (nullptr == tmpList[iii]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
size_t findPos = 0;
|
size_t findPos = 0;
|
||||||
for(size_t jjj=0; jjj<_list.size(); jjj++) {
|
for(size_t jjj=0; jjj<_list.size(); jjj++) {
|
||||||
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
//EWOL_DEBUG("compare : \""<<*tmpList[iii] << "\" and \"" << *m_listDirectory[jjj] << "\"");
|
||||||
if (_list[jjj] == nullptr) {
|
if (tmpList[iii].m_bufferName.getNameFile() > _list[jjj].m_bufferName.getNameFile()) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (tmpList[iii]->m_bufferName.getNameFile() > _list[jjj]->m_bufferName.getNameFile()) {
|
|
||||||
findPos = jjj+1;
|
findPos = jjj+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,6 +57,7 @@ void BufferView::init() {
|
|||||||
if (m_bufferManager != nullptr) {
|
if (m_bufferManager != nullptr) {
|
||||||
m_bufferManager->signalNewBuffer.bind(shared_from_this(), &BufferView::onCallbackNewBuffer);
|
m_bufferManager->signalNewBuffer.bind(shared_from_this(), &BufferView::onCallbackNewBuffer);
|
||||||
m_bufferManager->signalSelectFile.bind(shared_from_this(), &BufferView::onCallbackselectNewFile);
|
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() {
|
void BufferView::removeAllElement() {
|
||||||
for(auto &it : m_list) {
|
|
||||||
delete(it);
|
|
||||||
it = nullptr;
|
|
||||||
}
|
|
||||||
m_list.clear();
|
m_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferView::insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition) {
|
void BufferView::insertAlphabetic(const appl::dataBufferStruct& _dataStruct, bool _selectNewPosition) {
|
||||||
if (_dataStruct == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// alphabetical order:
|
// alphabetical order:
|
||||||
for (size_t iii = 0; iii < m_list.size(); ++iii) {
|
for (size_t iii = 0; iii < m_list.size(); ++iii) {
|
||||||
if (m_list[iii] == nullptr) {
|
if (etk::tolower(m_list[iii].m_bufferName.getNameFile()) > etk::tolower(_dataStruct.m_bufferName.getNameFile())) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (etk::tolower(m_list[iii]->m_bufferName.getNameFile()) > etk::tolower(_dataStruct->m_bufferName.getNameFile())) {
|
|
||||||
m_list.insert(m_list.begin() + iii, _dataStruct);
|
m_list.insert(m_list.begin() + iii, _dataStruct);
|
||||||
_dataStruct = nullptr;
|
|
||||||
if (_selectNewPosition == true) {
|
if (_selectNewPosition == true) {
|
||||||
m_selectedID = iii;
|
m_selectedID = iii;
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_dataStruct != nullptr) {
|
m_list.push_back(_dataStruct);
|
||||||
m_list.push_back(_dataStruct);
|
if (_selectNewPosition == true) {
|
||||||
if (_selectNewPosition == true) {
|
m_selectedID = m_list.size()-1;
|
||||||
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->signalIsSave.bind(shared_from_this(), &BufferView::onCallbackIsSave);
|
||||||
buffer->signalIsModify.bind(shared_from_this(), &BufferView::onCallbackIsModify);
|
buffer->signalIsModify.bind(shared_from_this(), &BufferView::onCallbackIsModify);
|
||||||
buffer->signalChangeName.bind(shared_from_this(), &BufferView::onCallbackChangeName);
|
buffer->signalChangeName.bind(shared_from_this(), &BufferView::onCallbackChangeName);
|
||||||
appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_value, buffer);
|
appl::dataBufferStruct tmp(_value, buffer);
|
||||||
if (tmp == nullptr) {
|
|
||||||
APPL_ERROR("Allocation error of the tmp buffer list element");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_openOrderMode == true) {
|
if (m_openOrderMode == true) {
|
||||||
m_list.push_back(tmp);
|
m_list.push_back(tmp);
|
||||||
} else {
|
} else {
|
||||||
@ -129,13 +108,10 @@ void BufferView::onCallbackNewBuffer(const std::string& _value) {
|
|||||||
void BufferView::onCallbackselectNewFile(const std::string& _value) {
|
void BufferView::onCallbackselectNewFile(const std::string& _value) {
|
||||||
m_selectedID = -1;
|
m_selectedID = -1;
|
||||||
for (size_t iii=0; iii<m_list.size(); iii++) {
|
for (size_t iii=0; iii<m_list.size(); iii++) {
|
||||||
if (m_list[iii] == nullptr) {
|
if (m_list[iii].m_buffer == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (m_list[iii]->m_buffer == nullptr) {
|
if (m_list[iii].m_buffer->getFileName() != _value) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (m_list[iii]->m_buffer->getFileName() != _value) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_selectedID = iii;
|
m_selectedID = iii;
|
||||||
@ -146,15 +122,11 @@ void BufferView::onCallbackselectNewFile(const std::string& _value) {
|
|||||||
|
|
||||||
void BufferView::onCallbackChangeName() {
|
void BufferView::onCallbackChangeName() {
|
||||||
for (size_t iii = 0; iii < m_list.size(); ++iii) {
|
for (size_t iii = 0; iii < m_list.size(); ++iii) {
|
||||||
if (m_list[iii] == nullptr) {
|
if (m_list[iii].m_bufferName != m_list[iii].m_buffer->getFileName()) {
|
||||||
continue;
|
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) {
|
if (m_openOrderMode == false) {
|
||||||
// re-order the fine in the correct position
|
// re-order the fine in the correct position
|
||||||
appl::dataBufferStruct* tmp = m_list[iii];
|
appl::dataBufferStruct tmp = m_list[iii];
|
||||||
m_list[iii] = nullptr;
|
|
||||||
m_list.erase(m_list.begin() + iii);
|
m_list.erase(m_list.begin() + iii);
|
||||||
insertAlphabetic(tmp, ((int64_t)iii == m_selectedID));
|
insertAlphabetic(tmp, ((int64_t)iii == m_selectedID));
|
||||||
break;
|
break;
|
||||||
@ -164,6 +136,19 @@ void BufferView::onCallbackChangeName() {
|
|||||||
markToRedraw();
|
markToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BufferView::onCallbackBufferRemoved(const std::shared_ptr<appl::Buffer>& _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() {
|
void BufferView::onCallbackIsSave() {
|
||||||
markToRedraw();
|
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) {
|
bool BufferView::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
|
||||||
if( _raw >= 0
|
if( _raw >= 0
|
||||||
&& _raw<(int64_t)m_list.size()
|
&& _raw<(int64_t)m_list.size() ) {
|
||||||
&& m_list[_raw] != nullptr) {
|
_myTextToWrite = m_list[_raw].m_bufferName.getNameFile();
|
||||||
_myTextToWrite = m_list[_raw]->m_bufferName.getNameFile();
|
|
||||||
|
|
||||||
if ( m_list[_raw]->m_buffer != nullptr
|
if ( m_list[_raw].m_buffer != nullptr
|
||||||
&& m_list[_raw]->m_buffer->isModify() == false) {
|
&& m_list[_raw].m_buffer->isModify() == false) {
|
||||||
_fg = (*m_paintingProperties)[m_colorTextNormal].getForeground();
|
_fg = (*m_paintingProperties)[m_colorTextNormal].getForeground();
|
||||||
} else {
|
} else {
|
||||||
_fg = (*m_paintingProperties)[m_colorTextModify].getForeground();
|
_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) {
|
if (1 == _IdInput && _typeEvent == ewol::key::statusSingle) {
|
||||||
APPL_INFO("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
|
APPL_INFO("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw );
|
||||||
if( _raw >= 0
|
if( _raw >= 0
|
||||||
&& _raw<(int64_t)m_list.size()
|
&& _raw<(int64_t)m_list.size()) {
|
||||||
&& nullptr != m_list[_raw]) {
|
if (m_list[_raw].m_buffer != nullptr) {
|
||||||
if (m_list[_raw]->m_buffer != nullptr) {
|
|
||||||
if (m_bufferManager != nullptr) {
|
if (m_bufferManager != nullptr) {
|
||||||
APPL_INFO("Select file :" << m_list[_raw]->m_buffer->getFileName() << " in list");
|
APPL_INFO("Select file :" << m_list[_raw].m_buffer->getFileName() << " in list");
|
||||||
m_bufferManager->open(m_list[_raw]->m_buffer->getFileName());
|
m_bufferManager->open(m_list[_raw].m_buffer->getFileName());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,12 @@ class BufferView : public ewol::widget::List {
|
|||||||
private:
|
private:
|
||||||
int32_t m_selectedIdRequested;
|
int32_t m_selectedIdRequested;
|
||||||
int32_t m_selectedID;
|
int32_t m_selectedID;
|
||||||
std::vector<appl::dataBufferStruct*> m_list;
|
std::vector<appl::dataBufferStruct> m_list;
|
||||||
/**
|
/**
|
||||||
* @brief Insert the element in the alphabetic order.
|
* @brief Insert the element in the alphabetic order.
|
||||||
* @param[in] _dataStruct element to add.
|
* @param[in] _dataStruct element to add.
|
||||||
*/
|
*/
|
||||||
void insertAlphabetic(appl::dataBufferStruct* _dataStruct, bool _selectNewPosition = false);
|
void insertAlphabetic(const appl::dataBufferStruct& _dataStruct, bool _selectNewPosition = false);
|
||||||
protected:
|
protected:
|
||||||
// Constructeur
|
// Constructeur
|
||||||
BufferView();
|
BufferView();
|
||||||
@ -73,6 +73,7 @@ class BufferView : public ewol::widget::List {
|
|||||||
void onCallbackIsModify();
|
void onCallbackIsModify();
|
||||||
void onCallbackNewBuffer(const std::string& _value);
|
void onCallbackNewBuffer(const std::string& _value);
|
||||||
void onCallbackselectNewFile(const std::string& _value);
|
void onCallbackselectNewFile(const std::string& _value);
|
||||||
|
void onCallbackBufferRemoved(const std::shared_ptr<appl::Buffer>& _buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -255,7 +255,8 @@ void MainWindows::onCallbackMenuEvent(const std::string& _value) {
|
|||||||
} else if (_value == "menu:open") {
|
} else if (_value == "menu:open") {
|
||||||
displayOpen();
|
displayOpen();
|
||||||
} else if (_value == "menu:close") {
|
} else if (_value == "menu:close") {
|
||||||
appl::WorkerCloseFile::create("");
|
std::shared_ptr<appl::WorkerCloseFile> worker = appl::WorkerCloseFile::create();
|
||||||
|
worker->startAction("");
|
||||||
} else if (_value == "menu:close-all") {
|
} else if (_value == "menu:close-all") {
|
||||||
appl::WorkerCloseAllFile::create();
|
appl::WorkerCloseAllFile::create();
|
||||||
} else if (_value == "menu:save") {
|
} else if (_value == "menu:save") {
|
||||||
|
@ -91,16 +91,23 @@ void appl::TextViewer::onCallbackselectNewFile(const std::string& _value) {
|
|||||||
if (m_buffer != nullptr) {
|
if (m_buffer != nullptr) {
|
||||||
m_buffer->unBindAll(shared_from_this());
|
m_buffer->unBindAll(shared_from_this());
|
||||||
bool needAdd = true;
|
bool needAdd = true;
|
||||||
for (size_t iii=0; iii<m_drawingRemenber.size(); ++iii) {
|
auto it = m_drawingRemenber.begin();
|
||||||
if (m_drawingRemenber[iii].first == m_buffer) {
|
while (it != m_drawingRemenber.end()) {
|
||||||
m_drawingRemenber[iii].second = m_originScrooled;
|
std::shared_ptr<appl::Buffer> 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);
|
APPL_VERBOSE("store origin : " << m_originScrooled);
|
||||||
needAdd = false;
|
needAdd = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
if (needAdd == true) {
|
if (needAdd == true) {
|
||||||
m_drawingRemenber.push_back(std::make_pair(m_buffer, m_originScrooled));
|
m_drawingRemenber.push_back(std::make_pair(std::weak_ptr<appl::Buffer>(m_buffer), m_originScrooled));
|
||||||
APPL_VERBOSE("Push origin : " << 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->signalIsModify.bind(shared_from_this(), &appl::TextViewer::onCallbackIsModify);
|
||||||
m_buffer->signalSelectChange.bind(shared_from_this(), &appl::TextViewer::onCallbackSelectChange);
|
m_buffer->signalSelectChange.bind(shared_from_this(), &appl::TextViewer::onCallbackSelectChange);
|
||||||
for (auto element : m_drawingRemenber) {
|
for (auto element : m_drawingRemenber) {
|
||||||
if (element.first == m_buffer) {
|
if (element.first.lock() == m_buffer) {
|
||||||
m_originScrooled = element.second;
|
m_originScrooled = element.second;
|
||||||
APPL_VERBOSE("retrive origin : " << m_originScrooled);
|
APPL_VERBOSE("retrive origin : " << m_originScrooled);
|
||||||
// TODO : Check if this element is not out of the display text ...
|
// TODO : Check if this element is not out of the display text ...
|
||||||
|
@ -54,7 +54,7 @@ namespace appl {
|
|||||||
private:
|
private:
|
||||||
ewol::compositing::Text m_displayText; //!< Text display properties.
|
ewol::compositing::Text m_displayText; //!< Text display properties.
|
||||||
ewol::compositing::Drawing m_displayDrawing; //!< Other diaplay requested.
|
ewol::compositing::Drawing m_displayDrawing; //!< Other diaplay requested.
|
||||||
std::vector<std::pair<std::shared_ptr<appl::Buffer>, vec2>> m_drawingRemenber;
|
std::vector<std::pair<std::weak_ptr<appl::Buffer>, vec2>> m_drawingRemenber;
|
||||||
public:
|
public:
|
||||||
void setFontSize(int32_t _size);
|
void setFontSize(int32_t _size);
|
||||||
void setFontName(const std::string& _fontName);
|
void setFontName(const std::string& _fontName);
|
||||||
|
@ -45,14 +45,15 @@ void appl::WorkerCloseAllFile::init() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// create the worker :
|
// 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 :
|
// remove first element :
|
||||||
m_bufferNameList.erase(m_bufferNameList.begin());
|
m_bufferNameList.erase(m_bufferNameList.begin());
|
||||||
if (m_bufferNameList.size() == 0) {
|
if (m_bufferNameList.size() == 0) {
|
||||||
destroy();
|
destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
appl::WorkerCloseAllFile::~WorkerCloseAllFile() {
|
appl::WorkerCloseAllFile::~WorkerCloseAllFile() {
|
||||||
@ -69,13 +70,14 @@ void appl::WorkerCloseAllFile::onCallbackCloseDone() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// create the worker :
|
// 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 :
|
// remove first element :
|
||||||
m_bufferNameList.erase(m_bufferNameList.begin());
|
m_bufferNameList.erase(m_bufferNameList.begin());
|
||||||
if (m_bufferNameList.size() == 0) {
|
if (m_bufferNameList.size() == 0) {
|
||||||
destroy();
|
destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_worker->signalCloseDone.bind(shared_from_this(), &appl::WorkerCloseAllFile::onCallbackCloseDone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,11 @@ appl::WorkerCloseFile::WorkerCloseFile() :
|
|||||||
m_bufferManager = appl::BufferManager::create();
|
m_bufferManager = appl::BufferManager::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
void appl::WorkerCloseFile::init(const std::string& _bufferName) {
|
void appl::WorkerCloseFile::init() {
|
||||||
ewol::object::Worker::init();
|
ewol::object::Worker::init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void appl::WorkerCloseFile::startAction(const std::string& _bufferName) {
|
||||||
m_bufferName = _bufferName;
|
m_bufferName = _bufferName;
|
||||||
if (m_bufferManager == nullptr) {
|
if (m_bufferManager == nullptr) {
|
||||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||||
@ -38,7 +41,7 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) {
|
|||||||
std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
|
std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
|
||||||
if (tmpp == nullptr) {
|
if (tmpp == nullptr) {
|
||||||
APPL_ERROR("No selected buffer now ...");
|
APPL_ERROR("No selected buffer now ...");
|
||||||
autoDestroy();
|
destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_bufferName = tmpp->getFileName();
|
m_bufferName = tmpp->getFileName();
|
||||||
@ -57,12 +60,14 @@ void appl::WorkerCloseFile::init(const std::string& _bufferName) {
|
|||||||
if (m_buffer->isModify() == false) {
|
if (m_buffer->isModify() == false) {
|
||||||
signalCloseDone.emit();
|
signalCloseDone.emit();
|
||||||
m_buffer->destroy();
|
m_buffer->destroy();
|
||||||
|
destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ewol::widget::StdPopUp> tmpPopUp = ewol::widget::StdPopUp::create();
|
std::shared_ptr<ewol::widget::StdPopUp> tmpPopUp = ewol::widget::StdPopUp::create();
|
||||||
if (tmpPopUp == nullptr) {
|
if (tmpPopUp == nullptr) {
|
||||||
APPL_ERROR("Can not create a simple pop-up");
|
APPL_ERROR("Can not create a simple pop-up");
|
||||||
|
destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
|
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
|
||||||
|
@ -22,10 +22,15 @@ namespace appl {
|
|||||||
protected:
|
protected:
|
||||||
// note : if == "" ==> current ...
|
// note : if == "" ==> current ...
|
||||||
WorkerCloseFile();
|
WorkerCloseFile();
|
||||||
void init(const std::string& _bufferName);
|
void init();
|
||||||
public:
|
public:
|
||||||
DECLARE_FACTORY(WorkerCloseFile);
|
DECLARE_FACTORY(WorkerCloseFile);
|
||||||
virtual ~WorkerCloseFile();
|
virtual ~WorkerCloseFile();
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Action to do
|
||||||
|
*/
|
||||||
|
void startAction(const std::string& _bufferName);
|
||||||
private:
|
private:
|
||||||
std::string m_bufferName;
|
std::string m_bufferName;
|
||||||
std::shared_ptr<appl::Buffer> m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer
|
std::shared_ptr<appl::Buffer> m_buffer; //!< reference on the buffer (when rename, we have no more reference on the buffer
|
||||||
|
@ -41,12 +41,19 @@ namespace appl {
|
|||||||
m_specificData.clear();
|
m_specificData.clear();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::vector<std::pair<std::shared_ptr<appl::Buffer> ,TYPE* >> m_specificData;
|
std::vector<std::pair<std::weak_ptr<appl::Buffer> ,TYPE* >> m_specificData;
|
||||||
protected:
|
protected:
|
||||||
TYPE* getDataRef(appl::TextViewer& _textDrawer) {
|
TYPE* getDataRef(appl::TextViewer& _textDrawer) {
|
||||||
for (size_t iii = 0; iii < m_specificData.size() ; ++iii) {
|
auto it = m_specificData.begin();
|
||||||
if (m_specificData[iii].first == _textDrawer.internalGetBuffer()) {
|
while(it != m_specificData.end()) {
|
||||||
return m_specificData[iii].second;
|
std::shared_ptr<appl::Buffer> 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();
|
TYPE* data = new TYPE();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user