Merge branch 'dev'

This commit is contained in:
Edouard DUPIN 2014-10-17 09:05:23 +02:00
commit fbf774174f
62 changed files with 1418 additions and 1373 deletions

39
.travis.yml Normal file
View File

@ -0,0 +1,39 @@
# language type:
language: cpp
# compilator system:
compiler:
- clang
- gcc
# build branch requested
branches:
only:
- master
- dev
# previous actions:
before_script:
- git clone https://github.com/HeeroYui/ewol.git
- cd ewol; git checkout origin/dev -b dev; cd ..
- cd ewol; git submodule init; cd ..
- cd ewol; git submodule update; cd ..
install:
- if [ "$CXX" == "g++" ]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y; fi
- if [ "$CXX" == "g++" ]; then sudo apt-get update -qq; fi
- if [ "$CXX" == "g++" ]; then sudo apt-get install -qq g++-4.8; fi
- if [ "$CXX" == "g++" ]; then sudo rm /usr/bin/gcc /usr/bin/g++; fi
- if [ "$CXX" == "g++" ]; then sudo ln -s /usr/bin/gcc-4.8 /usr/bin/gcc; fi
- if [ "$CXX" == "g++" ]; then sudo ln -s /usr/bin/g++-4.8 /usr/bin/g++; fi
# build sequence with Lutin :
script:
- if [ "$CXX" == "clang++" ]; then ./ewol/build/lutin.py -cclang -mdebug -p edn; fi
- if [ "$CXX" == "g++" ]; then ./ewol/build/lutin.py -cgcc -mdebug -p edn; fi
#send e-mail on compilation result:
notifications:
email:
- yui.heero@gmail.com

View File

@ -28,10 +28,12 @@
<color>keyword</color> <color>keyword</color>
<regex>[\$]+[a-zA-Z_][a-zA-Z0-9_]*</regex> <regex>[\$]+[a-zA-Z_][a-zA-Z0-9_]*</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>function (\w|_)+[ \t]*\(</regex> <regex>function (\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex>

View File

@ -44,7 +44,7 @@
</rule> </rule>
<rule name="doubleQuteText"> <rule name="doubleQuteText">
<color>doubleQuoteText</color> <color>doubleQuoteText</color>
<regex>"(\\[\\"]|.)*"</regex> <regex>"(\\[\\"]|.)*"</regex><!-- " -->
</rule> </rule>
<rule name="simpleQuteText"> <rule name="simpleQuteText">
<color>doubleQuoteText</color> <color>doubleQuoteText</color>
@ -99,11 +99,14 @@
<rule name="function input"> <rule name="function input">
<color>inputFunction</color> <color>inputFunction</color>
<regex>\@_[A-Za-z_0-9]*\@</regex> <regex>\@_[A-Za-z_0-9]*\@</regex>
<max>false</max>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex>

View File

@ -41,10 +41,11 @@
<color>macro</color> <color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex> <regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
</pass2> </pass2>
</EdnLang> </EdnLang>

View File

@ -64,10 +64,12 @@
<color>macro</color> <color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex> <regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex>

View File

@ -40,10 +40,12 @@
<color>macro</color> <color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex> <regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|~=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|~=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex>

View File

@ -33,10 +33,12 @@
<color>boolean</color> <color>boolean</color>
<regex>\@true|false\@</regex> <regex>\@true|false\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex>

View File

@ -55,10 +55,12 @@
<color>boolean</color> <color>boolean</color>
<regex>\@true|TRUE|false|FALSE\@</regex> <regex>\@true|TRUE|false|FALSE\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;|&gt;|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|!=|&lt;|&gt;|&amp;&amp;|\{|\}|</regex>

View File

@ -56,10 +56,12 @@
<color>macro</color> <color>macro</color>
<regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex> <regex>\@[A-Z_][A-Z_0-9]{3,500}\@</regex>
</rule> </rule>
<!--
<rule name="Function name"> <rule name="Function name">
<color>functionName</color> <color>functionName</color>
<regex>\@(\w|_)+[ \t]*\(</regex> <regex>\@(\w|_)+[ \t]*\(</regex>
</rule> </rule>
-->
<rule name="condition"> <rule name="condition">
<color>boolean</color> <color>boolean</color>
<regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex> <regex>==|&lt;=|&gt;=|!=|&lt;{1,2}|&gt;{1,2}|&amp;&amp;|\{|\}|</regex>

View File

@ -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/")

View File

@ -17,11 +17,6 @@
#undef __class__ #undef __class__
#define __class__ "Buffer" #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++ () { appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ () {
m_value = u32char::Null; m_value = u32char::Null;
if (m_current < 0) { if (m_current < 0) {
@ -119,8 +114,11 @@ appl::Buffer::Iterator appl::Buffer::selectStop() {
return position( getStopSelectionPos() ); return position( getStopSelectionPos() );
} }
appl::Buffer::Buffer() : appl::Buffer::Buffer() :
signalIsModify(*this, "is-modify"),
signalIsSave(*this, "is-save"),
signalSelectChange(*this, "select-change"),
signalChangeName(*this, "change-name"),
m_hasFileName(false), m_hasFileName(false),
m_fileName(""), m_fileName(""),
m_isModify(false), m_isModify(false),
@ -133,10 +131,6 @@ appl::Buffer::Buffer() :
static int32_t bufferBaseId = 0; static int32_t bufferBaseId = 0;
m_fileName = "No Name " + etk::to_string(bufferBaseId); m_fileName = "No Name " + etk::to_string(bufferBaseId);
bufferBaseId++; bufferBaseId++;
addEventId(eventIsModify);
addEventId(eventIsSave);
addEventId(eventSelectChange);
addEventId(eventChangeName);
} }
void appl::Buffer::init() { void appl::Buffer::init() {
@ -144,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) {
@ -176,7 +170,7 @@ void appl::Buffer::setFileName(const std::string& _name) {
} }
m_fileName = name; m_fileName = name;
m_hasFileName = true; m_hasFileName = true;
generateEventId(eventChangeName); signalChangeName.emit();
setModification(true); setModification(true);
} }
@ -195,9 +189,9 @@ void appl::Buffer::setModification(bool _status) {
} }
m_isModify = _status; m_isModify = _status;
if (m_isModify == true) { if (m_isModify == true) {
generateEventId(eventIsModify); signalIsModify.emit();
} else { } else {
generateEventId(eventIsSave); signalIsSave.emit();
} }
} }
@ -420,13 +414,13 @@ void appl::Buffer::moveCursor(int64_t _pos) {
if (m_cursorPos == m_cursorSelectPos) { if (m_cursorPos == m_cursorSelectPos) {
m_cursorSelectPos = -1; m_cursorSelectPos = -1;
} }
generateEventId(eventSelectChange); signalSelectChange.emit();
return; return;
} }
// move mode // move mode
m_cursorPos = _pos; m_cursorPos = _pos;
m_cursorSelectPos = -1; m_cursorSelectPos = -1;
generateEventId(eventSelectChange); signalSelectChange.emit();
} }
bool appl::Buffer::getPosAround(const appl::Buffer::Iterator& _startPos, 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) { void appl::Buffer::setSelectionPos(const appl::Buffer::Iterator& _pos) {
m_cursorSelectPos = _pos; m_cursorSelectPos = _pos;
generateEventId(eventSelectChange); signalSelectChange.emit();
} }
void appl::Buffer::unSelect() { void appl::Buffer::unSelect() {
m_cursorSelectPos = -1; m_cursorSelectPos = -1;
generateEventId(eventSelectChange); signalSelectChange.emit();
} }
static const char *ControlCodeTable[32] = { static const char *ControlCodeTable[32] = {
@ -993,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));
}
};

View File

@ -17,6 +17,7 @@
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#include <ewol/compositing/Text.h> #include <ewol/compositing/Text.h>
#include <appl/Highlight.h> #include <appl/Highlight.h>
#include <ewol/object/Signal.h>
namespace appl { namespace appl {
@ -288,10 +289,10 @@ namespace appl {
friend class Buffer; friend class Buffer;
}; };
public: public:
static const char* const eventIsModify; ewol::object::Signal<void> signalIsModify;
static const char* const eventIsSave; ewol::object::Signal<void> signalIsSave;
static const char* const eventSelectChange; ewol::object::Signal<void> signalSelectChange;
static const char* const eventChangeName; ewol::object::Signal<void> signalChangeName;
protected: protected:
Buffer(); Buffer();
void init(); void init();
@ -305,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;
} }
/** /**

View File

@ -18,7 +18,11 @@
#undef __class__ #undef __class__
#define __class__ "BufferManager" #define __class__ "BufferManager"
appl::BufferManager::BufferManager() { appl::BufferManager::BufferManager() :
signalNewBuffer(*this, "new-buffer"),
signalSelectFile(*this, "select-buffer"),
signalTextSelectionChange(*this, "text-selection-change"),
signalRemoveBuffer(*this, "remove-buffer") {
addObjectType("appl::BufferManager"); addObjectType("appl::BufferManager");
} }
@ -37,13 +41,19 @@ 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);
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; return tmp;
} }
std::shared_ptr<appl::Buffer> appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) { std::shared_ptr<appl::Buffer> appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) {
APPL_INFO("get(" << _fileName << "," << _createIfNeeded << ")"); APPL_INFO("get('" << _fileName << "'," << _createIfNeeded << ")");
for (auto &it : m_list) { for (auto &it : m_list) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
@ -63,15 +73,26 @@ std::shared_ptr<appl::Buffer> appl::BufferManager::get(const std::string& _fileN
APPL_ERROR("Can not allocate the Buffer class : " << _fileName); APPL_ERROR("Can not allocate the Buffer class : " << _fileName);
return nullptr; return nullptr;
} }
tmp->setParent(shared_from_this());
tmp->loadFile(_fileName); tmp->loadFile(_fileName);
m_list.push_back(tmp); 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 tmp;
} }
return nullptr; return nullptr;
} }
void appl::BufferManager::setBufferSelected(std::shared_ptr<appl::Buffer> _bufferSelected) { void appl::BufferManager::setBufferSelected(std::shared_ptr<appl::Buffer> _bufferSelected) {
m_bufferSelected = _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::Buffer> appl::BufferManager::get(int32_t _id) { std::shared_ptr<appl::Buffer> appl::BufferManager::get(int32_t _id) {
@ -99,15 +120,42 @@ bool appl::BufferManager::exist(const std::string& _fileName) {
void appl::BufferManager::open(const std::string& _fileName) { void appl::BufferManager::open(const std::string& _fileName) {
if (exist(_fileName) == true) { if (exist(_fileName) == true) {
APPL_WARNING(" the element '" << _fileName << "' already exist ... just reselect it ...");
signalSelectFile.emit(_fileName);
return; return;
} }
if (get(_fileName, true) == nullptr) { if (get(_fileName, true) == nullptr) {
APPL_ERROR("Error get '" << _fileName << "' ... ");
return; return;
} }
sendMultiCast(appl::MsgSelectNewFile, _fileName); signalSelectFile.emit(_fileName);
} }
void appl::BufferManager::onReceiveMessage(const ewol::object::Message& _msg) {
APPL_DEBUG("receive message !!! " << _msg);
}
void appl::BufferManager::requestDestroyFromChild(const std::shared_ptr<Object>& _child) {
APPL_WARNING("Buffer request a close...");
bool find = false;
int32_t newValue = -1;
auto it = m_list.begin();
while(it != m_list.end()) {
if (*it == nullptr) {
it = m_list.erase(it);
continue;
}
if (*it == _child) {
it = m_list.erase(it);
find = true;
break;
}
newValue++;
++it;
}
if (find == true) {
signalRemoveBuffer.emit(std::dynamic_pointer_cast<appl::Buffer>(_child));
}
if (m_bufferSelected == _child) {
APPL_ERROR("is selected");
signalSelectFile.emit("");
m_bufferSelected = nullptr;
}
}

View File

@ -18,6 +18,11 @@
namespace appl { namespace appl {
class BufferManager : public ewol::Resource { class BufferManager : public ewol::Resource {
public: public:
ewol::object::Signal<std::string> signalNewBuffer;
ewol::object::Signal<std::string> signalSelectFile;
ewol::object::Signal<void> signalTextSelectionChange;
ewol::object::Signal<std::shared_ptr<appl::Buffer>> signalRemoveBuffer;
protected:
BufferManager(); BufferManager();
void init(const std::string& _uniqueName); void init(const std::string& _uniqueName);
public: public:
@ -77,8 +82,8 @@ namespace appl {
std::shared_ptr<appl::Buffer> getBufferSelected() { std::shared_ptr<appl::Buffer> getBufferSelected() {
return m_bufferSelected; return m_bufferSelected;
}; };
public: // herited function private:
void onReceiveMessage(const ewol::object::Message& _msg); void requestDestroyFromChild(const std::shared_ptr<Object>& _child);
}; };
}; };

View File

@ -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;
} }
} }
@ -59,12 +54,11 @@ BufferView::BufferView() :
void BufferView::init() { void BufferView::init() {
ewol::widget::List::init(); ewol::widget::List::init();
registerMultiCast(ednMsgBufferListChange); if (m_bufferManager != nullptr) {
registerMultiCast(ednMsgBufferState); m_bufferManager->signalNewBuffer.bind(shared_from_this(), &BufferView::onCallbackNewBuffer);
registerMultiCast(ednMsgBufferId); m_bufferManager->signalSelectFile.bind(shared_from_this(), &BufferView::onCallbackselectNewFile);
registerMultiCast(appl::MsgSelectNewFile); m_bufferManager->signalRemoveBuffer.bind(shared_from_this(), &BufferView::onCallbackBufferRemoved);
registerMultiCast(appl::MsgSelectChange); }
registerMultiCast(appl::MsgNameChange);
} }
BufferView::~BufferView() { BufferView::~BufferView() {
@ -72,76 +66,67 @@ 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;
} }
}
} }
void BufferView::onCallbackNewBuffer(const std::string& _value) {
void BufferView::onReceiveMessage(const ewol::object::Message& _msg) { std::shared_ptr<appl::Buffer> buffer = m_bufferManager->get(_value);
APPL_VERBOSE("message : " << _msg);
ewol::widget::List::onReceiveMessage(_msg);
if (_msg.getMessage() == appl::MsgSelectNewFile) {
std::shared_ptr<appl::Buffer> buffer = m_bufferManager->get(_msg.getData());
if (buffer == nullptr) { if (buffer == nullptr) {
APPL_ERROR("event on element nor exist : " << _msg.getData()); APPL_ERROR("event on element nor exist : " << _value);
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);
appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer);
if (tmp == nullptr) {
APPL_ERROR("Allocation error of the tmp buffer list element");
return; return;
} }
buffer->signalIsSave.bind(shared_from_this(), &BufferView::onCallbackIsSave);
buffer->signalIsModify.bind(shared_from_this(), &BufferView::onCallbackIsModify);
buffer->signalChangeName.bind(shared_from_this(), &BufferView::onCallbackChangeName);
appl::dataBufferStruct tmp(_value, buffer);
if (m_openOrderMode == true) { if (m_openOrderMode == true) {
m_list.push_back(tmp); m_list.push_back(tmp);
} else { } else {
insertAlphabetic(tmp); insertAlphabetic(tmp);
} }
markToRedraw(); markToRedraw();
return; }
}
if (_msg.getMessage() == appl::Buffer::eventChangeName) { // TODO : Review this callback with the real shared_ptr on the buffer ...
for (size_t iii = 0; iii < m_list.size(); ++iii) { void BufferView::onCallbackselectNewFile(const std::string& _value) {
if (m_list[iii] == nullptr) { m_selectedID = -1;
for (size_t iii=0; iii<m_list.size(); iii++) {
if (m_list[iii].m_buffer == nullptr) {
continue; continue;
} }
if (m_list[iii]->m_bufferName != m_list[iii]->m_buffer->getFileName()) { if (m_list[iii].m_buffer->getFileName() != _value) {
m_list[iii]->m_bufferName = m_list[iii]->m_buffer->getFileName(); continue;
}
m_selectedID = iii;
break;
}
markToRedraw();
}
void BufferView::onCallbackChangeName() {
for (size_t iii = 0; iii < m_list.size(); ++iii) {
if (m_list[iii].m_bufferName != m_list[iii].m_buffer->getFileName()) {
m_list[iii].m_bufferName = m_list[iii].m_buffer->getFileName();
if (m_openOrderMode == false) { 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;
@ -149,77 +134,27 @@ void BufferView::onReceiveMessage(const ewol::object::Message& _msg) {
} }
} }
markToRedraw(); markToRedraw();
return;
}
if (_msg.getMessage() == appl::Buffer::eventIsSave) {
markToRedraw();
return;
}
if (_msg.getMessage() == appl::Buffer::eventIsModify) {
markToRedraw();
return;
}
if (_msg.getMessage() == appl::MsgSelectChange) {
m_selectedID = -1;
std::shared_ptr<appl::Buffer> tmpBuffer;
if (m_bufferManager != nullptr) {
tmpBuffer = m_bufferManager->getBufferSelected();
}
if (tmpBuffer != nullptr) {
for (size_t iii=0; iii<m_list.size(); iii++) {
if (m_list[iii] == nullptr) {
continue;
}
if (m_list[iii]->m_buffer != tmpBuffer) {
continue;
}
m_selectedID = iii;
break;
}
}
markToRedraw();
return;
}
if (_msg.getMessage() == ednMsgBufferListChange) {
// clean The list
removeAllElement();
// get all the buffer name and properties:
size_t nbBufferOpen = 0; // BufferManager::size();
for (size_t iii=0; iii<nbBufferOpen; iii++) {
/*
if (BufferManager::exist(iii)) {
BufferText* tmpBuffer = BufferManager::get(iii);
if (nullptr != tmpBuffer) {
bool isModify = tmpBuffer->isModify();
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();
}
} }
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() {
markToRedraw();
}
void BufferView::onCallbackIsModify() {
markToRedraw();
}
etk::Color<> BufferView::getBasicBG() { etk::Color<> BufferView::getBasicBG() {
return (*m_paintingProperties)[m_colorBackground1].getForeground(); return (*m_paintingProperties)[m_colorBackground1].getForeground();
@ -240,12 +175,11 @@ uint32_t BufferView::getNuberOfRaw() {
bool BufferView::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) { 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();
@ -265,17 +199,16 @@ bool BufferView::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextT
return true; 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) { 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) {
sendMultiCast(appl::MsgSelectNewFile, m_list[_raw]->m_buffer->getFileName()); APPL_INFO("Select file :" << m_list[_raw].m_buffer->getFileName() << " in list");
m_selectedID = _raw; m_bufferManager->open(m_list[_raw].m_buffer->getFileName());
markToRedraw(); }
return true; return true;
} }
} }

View File

@ -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();
@ -55,8 +55,6 @@ class BufferView : public ewol::widget::List {
public: public:
DECLARE_FACTORY(BufferView); DECLARE_FACTORY(BufferView);
virtual ~BufferView(); virtual ~BufferView();
// Derived function
virtual void onReceiveMessage(const ewol::object::Message& _msg);
private: private:
bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order bool m_openOrderMode; //!< true if the order is the opening order mode, otherwise, Alphabetic order
protected: protected:
@ -69,6 +67,13 @@ class BufferView : public ewol::widget::List {
virtual uint32_t getNuberOfRaw(); virtual uint32_t getNuberOfRaw();
virtual bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg); 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); virtual bool onItemEvent(int32_t _IdInput, enum ewol::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
private: //callback function:
void onCallbackChangeName();
void onCallbackIsSave();
void onCallbackIsModify();
void onCallbackNewBuffer(const std::string& _value);
void onCallbackselectNewFile(const std::string& _value);
void onCallbackBufferRemoved(const std::shared_ptr<appl::Buffer>& _buffer);
}; };

View File

@ -172,105 +172,66 @@ void MainWindows::init() {
mySizerVert2->subWidgetAdd(myTextView); mySizerVert2->subWidgetAdd(myTextView);
*/ */
// search area : // search area :
std::shared_ptr<appl::widget::Search> mySearch = appl::widget::Search::create(); m_widgetSearch = appl::widget::Search::create();
mySizerVert2->subWidgetAdd(mySearch); mySizerVert2->subWidgetAdd(m_widgetSearch);
mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori); mySizerHori = ewol::widget::Sizer::create(ewol::widget::Sizer::modeHori);
mySizerHori->setName("plop 555555"); mySizerHori->setName("plop 555555");
mySizerVert->subWidgetAdd(mySizerHori); mySizerVert->subWidgetAdd(mySizerHori);
myMenu = ewol::widget::Menu::create(); myMenu = ewol::widget::Menu::create();
myMenu->setName("appl-menu-interface");
mySizerHori->subWidgetAdd(myMenu); mySizerHori->subWidgetAdd(myMenu);
int32_t idMenuFile = myMenu->addTitle("File"); int32_t idMenuFile = myMenu->addTitle("File");
myMenu->add(idMenuFile, "New", "", ednMsgGuiNew); myMenu->add(idMenuFile, "New", "", "menu:new");
myMenu->addSpacer(); myMenu->addSpacer();
myMenu->add(idMenuFile, "Open", "THEME:GUI:Load.edf", ednMsgGuiOpen); myMenu->add(idMenuFile, "Open", "THEME:GUI:Load.edf", "menu:open");
myMenu->add(idMenuFile, "Close", "THEME:GUI:Close.edf", ednMsgGuiClose, "current"); myMenu->add(idMenuFile, "Close", "THEME:GUI:Close.edf", "menu:close");
myMenu->add(idMenuFile, "Close (all)", "", ednMsgGuiClose, "All"); myMenu->add(idMenuFile, "Close (all)", "", "menu:close-all");
myMenu->add(idMenuFile, "Save", "THEME:GUI:Save.edf", ednMsgGuiSave, "current"); myMenu->add(idMenuFile, "Save", "THEME:GUI:Save.edf", "menu:save");
myMenu->add(idMenuFile, "Save As ...", "", ednMsgGuiSaveAs); myMenu->add(idMenuFile, "Save As ...", "", "menu:save-as");
myMenu->addSpacer(); myMenu->addSpacer();
//myMenu->add(idMenuFile, "Exit", "", ednMsgGuiExit); myMenu->add(idMenuFile, "Properties", "THEME:GUI:Parameter.edf", "menu:property");
myMenu->addSpacer();
myMenu->add(idMenuFile, "Properties", "THEME:GUI:Parameter.edf", ednMsgProperties);
int32_t idMenuEdit = myMenu->addTitle("Edit"); int32_t idMenuEdit = myMenu->addTitle("Edit");
myMenu->add(idMenuEdit, "Undo", "THEME:GUI:Undo.edf", ednMsgGuiUndo); myMenu->add(idMenuEdit, "Goto line ...","", "menu:goto-line");
myMenu->add(idMenuEdit, "Redo", "THEME:GUI:Redo.edf", ednMsgGuiRedo);
myMenu->addSpacer();
myMenu->add(idMenuEdit, "Copy", "", ednMsgGuiCopy, "STD");
myMenu->add(idMenuEdit, "Cut", "", ednMsgGuiCut, "STD");
myMenu->add(idMenuEdit, "Paste", "", ednMsgGuiPaste, "STD");
myMenu->add(idMenuEdit, "Remove", "", ednMsgGuiRm);
myMenu->addSpacer();
myMenu->add(idMenuEdit, "Select All","", ednMsgGuiSelect, "ALL");
myMenu->add(idMenuEdit, "Un-Select","", ednMsgGuiSelect, "NONE");
myMenu->add(idMenuEdit, "Goto line ...","", ednMsgGuiGotoLine, "???");
int32_t idMenuSearch = myMenu->addTitle("Search"); int32_t idMenuSearch = myMenu->addTitle("Search");
myMenu->add(idMenuSearch, "Search", "THEME:GUI:Search.edf", ednMsgGuiSearch); myMenu->add(idMenuSearch, "Search", "THEME:GUI:Search.edf", "menu:search");
myMenu->add(idMenuSearch, "Replace", "THEME:GUI:Replace.edf", ednMsgGuiReplace); myMenu->add(idMenuSearch, "Replace", "THEME:GUI:Replace.edf", "menu:replace");
myMenu->addSpacer(); myMenu->addSpacer();
myMenu->add(idMenuSearch, "Find (previous)","", ednMsgGuiFind, "Previous"); myMenu->add(idMenuSearch, "Find (previous)","", "menu:find:previous");
myMenu->add(idMenuSearch, "Find (next)", "", ednMsgGuiFind, "Next"); myMenu->add(idMenuSearch, "Find (next)", "", "menu:find:next");
myMenu->add(idMenuSearch, "Find (all)", "", ednMsgGuiFind, "All"); myMenu->add(idMenuSearch, "Find (all)", "", "menu:find:all");
myMenu->add(idMenuSearch, "Un-Select", "", ednMsgGuiFind, "None"); myMenu->add(idMenuSearch, "Un-Select", "", "menu:find: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");
*/
int32_t idMenugDisplay = myMenu->addTitle("Display"); int32_t idMenugDisplay = myMenu->addTitle("Display");
myMenu->add(idMenugDisplay, "Color Black", "", appl::MsgNameGuiChangeColor, "color/black/"); myMenu->add(idMenugDisplay, "Color Black", "", "menu:color:color/black/");
myMenu->add(idMenugDisplay, "Color White", "", appl::MsgNameGuiChangeColor, "color/white/"); myMenu->add(idMenugDisplay, "Color White", "", "menu:color:color/white/");
myMenu->add(idMenugDisplay, "Shape square", "", l_MsgNameGuiChangeShape, "shape/square/"); myMenu->add(idMenugDisplay, "Shape square", "", "menu:shape:shape/square/");
myMenu->add(idMenugDisplay, "Shape round", "", l_MsgNameGuiChangeShape, "shape/round/"); myMenu->add(idMenugDisplay, "Shape round", "", "menu:shape:shape/round/");
myMenu->addSpacer(); 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 = ewol::widget::Label::create("FileName");
m_widgetLabelFileName->setExpand(bvec2(true,false)); m_widgetLabelFileName->setExpand(bvec2(true,false));
m_widgetLabelFileName->setFill(bvec2(true,false));; m_widgetLabelFileName->setFill(bvec2(true,false));;
mySizerHori->subWidgetAdd(m_widgetLabelFileName); mySizerHori->subWidgetAdd(m_widgetLabelFileName);
// add generic shortcut ... // add generic shortcut ...
// (shift, control, alt, meta, char32_t unicodeValue, const char * generateEventId, std::string& data) shortCutAdd("ctrl+o", "menu:open");
shortCutAdd("ctrl+o", ednMsgGuiOpen, "", true); shortCutAdd("ctrl+n", "menu:new");
shortCutAdd("ctrl+n", ednMsgGuiNew, "", true);
shortCutAdd("ctrl+s", ednMsgGuiSave, "current", true); shortCutAdd("ctrl+s", "menu:save");
shortCutAdd("ctrl+shift+s", ednMsgGuiSave, "All", true); shortCutAdd("ctrl+shift+s", "menu:save-all");
shortCutAdd("ctrl+q", ednMsgGuiClose, "current", true); shortCutAdd("ctrl+q", "menu:close");
shortCutAdd("ctrl+shift+q", ednMsgGuiClose, "All", true); shortCutAdd("ctrl+shift+q", "menu:close-all");
shortCutAdd("ctrl+z", ednMsgGuiUndo, "", true); shortCutAdd("ctrl+l", "menu:goto-line");
shortCutAdd("ctrl+shift+z", ednMsgGuiRedo, "", true);
shortCutAdd("ctrl+l", ednMsgGuiGotoLine, "???", true); shortCutAdd("ctrl+f", "menu:search");
shortCutAdd("F12", "menu:reloade-shader");
shortCutAdd("ctrl+f", ednMsgGuiSearch, "", true); // TODO : auto-bind on shortcut event ==> maybe do beter later ...
shortCutAdd("F12", ednMsgGuiReloadShader, "", true); signalShortcut.bind(shared_from_this(), &MainWindows::onCallbackShortCut);
m_bufferManager->signalSelectFile.bind(shared_from_this(), &MainWindows::onCallbackShortCut);
//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);
} }
@ -279,16 +240,126 @@ MainWindows::~MainWindows() {
} }
const char *const ednEventPopUpFileSelected = "edn-mainWindows-openSelected";
const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected";
void MainWindows::onCallbackShortCut(const std::string& _value) {
APPL_WARNING("Event from ShortCut : " << _value);
onCallbackMenuEvent(_value);
}
void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) { void MainWindows::onCallbackMenuEvent(const std::string& _value) {
ewol::widget::Windows::onReceiveMessage(_msg); APPL_WARNING("Event from Menu : " << _value);
if (_value == "menu:new") {
if (m_bufferManager != nullptr) {
m_bufferManager->createNewBuffer();
}
} else if (_value == "menu:open") {
displayOpen();
} else if (_value == "menu:close") {
std::shared_ptr<appl::WorkerCloseFile> worker = appl::WorkerCloseFile::create();
worker->startAction("");
} else if (_value == "menu:close-all") {
appl::WorkerCloseAllFile::create();
} else if (_value == "menu:save") {
appl::WorkerSaveFile::create("", false);
} else if (_value == "menu:save-all") {
appl::WorkerSaveAllFile::create();
} else if (_value == "menu:save-as") {
appl::WorkerSaveFile::create("", true);
} else if (_value == "menu:property") {
displayProperty();
} else if (_value == "menu:search") {
if (m_widgetSearch == nullptr) {
return;
}
if (m_widgetSearch->isHide()) {
m_widgetSearch->show();
m_widgetSearch->selectSearch();
} else {
m_widgetSearch->hide();
}
} else if (_value == "menu:replace") {
if (m_widgetSearch == nullptr) {
return;
}
if (m_widgetSearch->isHide()) {
m_widgetSearch->show();
m_widgetSearch->selectReplace();
} else {
m_widgetSearch->hide();
}
} else if (_value == "menu:find:previous") {
APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:next") {
APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:all") {
APPL_TODO("Event from Menu : " << _value);
} else if (_value == "menu:find:none") {
APPL_TODO("Event from Menu : " << _value);
} else if ( _value == "menu:color:color/black/"
|| _value == "menu:color:color/white/") {
etk::theme::setName("COLOR", std::string(_value, 12));
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if ( _value == "menu:shape:shape/square/"
|| _value == "menu:shape:shape/round/") {
etk::theme::setName("GUI", std::string(_value, 12));
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else if (_value == "menu:reloadShape") {
ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll();
} else {
APPL_ERROR("Event from Menu UNKNOW : '" << _value << "'");
}
}
/* TODO :
} else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
if (tmpBuffer->hasFileName() == false) {
APPL_ERROR("Will never arrive");
saveAsPopUp(tmpBuffer);
} else {
if (tmpBuffer->storeFile() == false) {
APPL_ERROR("Error when loading the file " << _msg.getData());
displayErrorMessage("Error when loading the file <br/><i>" + _msg.getData() + "</i>");
}
}
} else if (_msg.getMessage() == mainWindowsRequestSaveFileAs) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
saveAsPopUp(tmpBuffer);
} else if (_msg.getMessage() == mainWindowsRequestcloseFileNoCheck) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
// note: just remove ==> no check : normal case ...
//tmpBuffer->removeObject();
EWOL_TODO("call remove buffer ...");
}
*/
APPL_VERBOSE("Receive Event from the main windows: " << _msg ); void MainWindows::displayOpen() {
// open file Section ...
if (_msg.getMessage() == ednMsgGuiOpen) {
std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::widget::FileChooser::create(); std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::widget::FileChooser::create();
if (tmpWidget == nullptr) { if (tmpWidget == nullptr) {
APPL_ERROR("Can not open File chooser !!! "); APPL_ERROR("Can not open File chooser !!! ");
@ -308,8 +379,10 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
} }
// apply widget pop-up ... // apply widget pop-up ...
popUpWidgetPush(tmpWidget); popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(shared_from_this(), "validate", ednEventPopUpFileSelected); tmpWidget->signalValidate.bind(shared_from_this(), &MainWindows::onCallbackPopUpFileSelected);
} else if (_msg.getMessage() == ednMsgProperties) { }
void MainWindows::displayProperty() {
// Request the parameter GUI // Request the parameter GUI
std::shared_ptr<ewol::widget::Parameter> tmpWidget = ewol::widget::Parameter::create(); std::shared_ptr<ewol::widget::Parameter> tmpWidget = ewol::widget::Parameter::create();
if (nullptr == tmpWidget) { if (nullptr == tmpWidget) {
@ -358,29 +431,36 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
tmpSubWidget = ParameterAboutGui::create(); tmpSubWidget = ParameterAboutGui::create();
tmpWidget->menuAdd("About", "", tmpSubWidget); tmpWidget->menuAdd("About", "", tmpSubWidget);
} }
} else if (_msg.getMessage() == appl::MsgNameGuiChangeColor) { }
etk::theme::setName("COLOR", _msg.getData());
ewol::getContext().getResourcesManager().reLoadResources(); void MainWindows::onCallbackselectNewFile(const std::string& _value) {
ewol::getContext().forceRedrawAll(); APPL_INFO("onCallbackselectNewFile(" << _value << ")");
} else if (_msg.getMessage() == l_MsgNameGuiChangeShape) { if (m_bufferManager == nullptr) {
etk::theme::setName("GUI", _msg.getData()); APPL_ERROR("can not call unexistant buffer manager ... ");
ewol::getContext().getResourcesManager().reLoadResources(); return;
ewol::getContext().forceRedrawAll(); }
} else if (_msg.getMessage() == ednMsgGuiReloadShader) { // TODO : Remove all previous binding from the old buffer ...
ewol::getContext().getResourcesManager().reLoadResources(); onCallbackTitleUpdate();
ewol::getContext().forceRedrawAll(); std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
} else if (_msg.getMessage() == ednMsgGuiExit) { if (tmpp != nullptr) {
// TODO : ... tmpp->signalIsSave.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate);
} tmpp->signalIsModify.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate);
// Note : Fore all next message we need to acces to the buffer manager ==> just check one time ... tmpp->signalChangeName.bind(shared_from_this(), &MainWindows::onCallbackTitleUpdate);
}
}
void MainWindows::onCallbackPopUpFileSelected(const std::string& _value) {
APPL_INFO("onCallbackPopUpFileSelected(" << _value << ")");
APPL_DEBUG("Request opening the file : " << _value);
m_bufferManager->open(_value);
}
void MainWindows::onCallbackTitleUpdate() {
APPL_INFO("onCallbackTitleUpdate()");
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
return; return;
} }
if ( _msg.getMessage() == appl::MsgSelectNewFile
|| _msg.getMessage() == appl::Buffer::eventIsModify
|| _msg.getMessage() == appl::Buffer::eventIsSave
|| _msg.getMessage() == appl::Buffer::eventChangeName) {
// select a new Buffer ==> change title: // select a new Buffer ==> change title:
std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected(); std::shared_ptr<appl::Buffer> tmpp = m_bufferManager->getBufferSelected();
if (tmpp == nullptr) { if (tmpp == nullptr) {
@ -389,89 +469,12 @@ void MainWindows::onReceiveMessage(const ewol::object::Message& _msg) {
m_widgetLabelFileName->setLabel(""); m_widgetLabelFileName->setLabel("");
} }
} else { } else {
if (_msg.getMessage() == appl::MsgSelectNewFile) {
tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventIsModify);
tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventIsSave);
tmpp->registerOnEvent(shared_from_this(), appl::Buffer::eventChangeName);
}
std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName(); std::string nameFileSystem = etk::FSNode(tmpp->getFileName()).getFileSystemName();
setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem); setTitle(std::string("Edn : ") + (tmpp->isModify()==true?" *":"") + nameFileSystem);
if (m_widgetLabelFileName != nullptr) { if (m_widgetLabelFileName != nullptr) {
m_widgetLabelFileName->setLabel(nameFileSystem + (tmpp->isModify()==true?" *":"")); m_widgetLabelFileName->setLabel(nameFileSystem + (tmpp->isModify()==true?" *":""));
} }
} }
} else if (_msg.getMessage() == ednMsgGuiNew) {
m_bufferManager->createNewBuffer();
} else if (_msg.getMessage() == ednEventPopUpFileSelected) {
APPL_DEBUG("Request opening the file : " << _msg.getData());
m_bufferManager->open(_msg.getData());
} else if (_msg.getMessage() == ednMsgGuiSave) {
APPL_DEBUG("Request saving the file : " << _msg.getData());
if (etk::tolower(_msg.getData()) == "current") {
appl::WorkerSaveFile::create("", false);
return;
} else if (etk::tolower(_msg.getData()) == "all") {
appl::WorkerSaveAllFile::create();
return;
} else {
APPL_ERROR("UNKNOW request : " << _msg);
}
} else if (_msg.getMessage() == ednMsgGuiSaveAs) {
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 (_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());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
if (tmpBuffer->hasFileName() == false) {
APPL_ERROR("Will never arrive");
saveAsPopUp(tmpBuffer);
} else {
if (tmpBuffer->storeFile() == false) {
APPL_ERROR("Error when loading the file " << _msg.getData());
displayErrorMessage("Error when loading the file <br/><i>" + _msg.getData() + "</i>");
}
}
} else if (_msg.getMessage() == mainWindowsRequestSaveFileAs) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
saveAsPopUp(tmpBuffer);
} else if (_msg.getMessage() == mainWindowsRequestcloseFileNoCheck) { // return after a choice of close...
if (m_bufferManager->exist(_msg.getData()) == false) {
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
return;
}
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(_msg.getData());
if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << _msg.getData());
return;
}
// note: just remove ==> no check : normal case ...
//tmpBuffer->removeObject();
EWOL_TODO("call remove buffer ...");
}
return;
} }
void MainWindows::saveAsPopUp(const std::shared_ptr<appl::Buffer>& _buffer) { void MainWindows::saveAsPopUp(const std::shared_ptr<appl::Buffer>& _buffer) {
@ -494,24 +497,24 @@ void MainWindows::closeNotSavedFile(const std::shared_ptr<appl::Buffer>& _buffer
} }
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>"); tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
tmpPopUp->setComment("The file named : <i>\"" + _buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost..."); tmpPopUp->setComment("The file named : <i>\"" + _buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
std::shared_ptr<ewol::Widget> bt = nullptr; std::shared_ptr<ewol::widget::Button> bt = nullptr;
if (_buffer->hasFileName() == true) { if (_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("Save", true); bt = tmpPopUp->addButton("Save", true);
if (bt != nullptr) { if (bt != nullptr) {
// TODO : The element is removed before beeing pressed // TODO : The element is removed before beeing pressed
bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestSaveFile, _buffer->getFileName()); // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestSaveFile, _buffer->getFileName());
bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
} }
} }
bt = tmpPopUp->addButton("Save As", true); bt = tmpPopUp->addButton("Save As", true);
if (bt != nullptr) { if (bt != nullptr) {
bt->registerOnEvent(shared_from_this(), "pressed", mainWindowsRequestSaveFileAs, _buffer->getFileName()); // TODO : bt->signalPressed.bind(shared_from_this(), mainWindowsRequestSaveFileAs, _buffer->getFileName());
//bt->registerOnEvent(this, "pressed", mainWindowsRequestcloseFileNoCheck, _buffer->getFileName()); //bt->signalPressed.bind(shared_from_this(), mainWindowsRequestcloseFileNoCheck, _buffer->getFileName());
// TODO : Request the close when saved ... // TODO : Request the close when saved ...
} }
bt = tmpPopUp->addButton("Close", true); bt = tmpPopUp->addButton("Close", true);
if (bt != nullptr) { 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->addButton("Cancel", true);
tmpPopUp->setRemoveOnExternClick(true); tmpPopUp->setRemoveOnExternClick(true);

View File

@ -16,10 +16,12 @@
#include <appl/BufferManager.h> #include <appl/BufferManager.h>
#include <ewol/widget/Label.h> #include <ewol/widget/Label.h>
#include <appl/BufferManager.h> #include <appl/BufferManager.h>
#include <appl/Gui/Search.h>
class MainWindows : public ewol::widget::Windows { class MainWindows : public ewol::widget::Windows {
private: private:
std::shared_ptr<ewol::widget::Label> m_widgetLabelFileName; std::shared_ptr<ewol::widget::Label> m_widgetLabelFileName;
std::shared_ptr<appl::widget::Search> m_widgetSearch;
protected: protected:
// Constructeur // Constructeur
MainWindows(); MainWindows();
@ -39,8 +41,14 @@ class MainWindows : public ewol::widget::Windows {
* @param[in] _buffer Buffer that might be close. * @param[in] _buffer Buffer that might be close.
*/ */
void closeNotSavedFile(const std::shared_ptr<appl::Buffer>& _buffer); void closeNotSavedFile(const std::shared_ptr<appl::Buffer>& _buffer);
public: // Derived function void displayOpen();
virtual void onReceiveMessage(const ewol::object::Message& _msg); 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);
}; };

View File

@ -12,6 +12,8 @@
#include "appl/Gui/TextViewer.h" #include "appl/Gui/TextViewer.h"
#include "appl/Gui/MainWindows.h" #include "appl/Gui/MainWindows.h"
#include "appl/globalMsg.h" #include "appl/globalMsg.h"
#include <ewol/widget/Button.h>
#include <ewol/widget/Entry.h>
#undef __class__ #undef __class__
@ -38,25 +40,23 @@ void appl::widget::Search::init() {
ewol::widget::Composer::init(ewol::widget::Composer::file, "DATA:GUI-Search.xml"); ewol::widget::Composer::init(ewol::widget::Composer::file, "DATA:GUI-Search.xml");
m_viewerManager = appl::ViewerManager::create(); m_viewerManager = appl::ViewerManager::create();
// link event // link event
registerOnEventNameWidget(shared_from_this(), "SEARCH:close", "pressed", l_eventHideBt); subBind(ewol::widget::Button, "SEARCH:close", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackHide);
registerOnEventNameWidget(shared_from_this(), "SEARCH:search-entry", "modify", l_eventSearchEntry); subBind(ewol::widget::Entry, "SEARCH:search-entry", signalModify, shared_from_this(), &appl::widget::Search::OnCallbackSearchValue);
registerOnEventNameWidget(shared_from_this(), "SEARCH:search-entry", "enter", l_eventSearchEntryEnter); subBind(ewol::widget::Entry, "SEARCH:search-entry", signalEnter, shared_from_this(), &appl::widget::Search::OnCallbackSearchEntryValidate);
registerOnEventNameWidget(shared_from_this(), "SEARCH:search", "pressed", l_eventSearchBt); subBind(ewol::widget::Button, "SEARCH:search", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackSearch);
registerOnEventNameWidget(shared_from_this(), "SEARCH:replace-entry", "modify", l_eventReplaceEntry); subBind(ewol::widget::Entry, "SEARCH:replace-entry", signalModify, shared_from_this(), &appl::widget::Search::OnCallbackReplaceValue);
registerOnEventNameWidget(shared_from_this(), "SEARCH:replace-entry", "enter", l_eventReplaceEntryEnter); subBind(ewol::widget::Entry, "SEARCH:replace-entry", signalEnter, shared_from_this(), &appl::widget::Search::OnCallbackReplaceEntryValidate);
registerOnEventNameWidget(shared_from_this(), "SEARCH:replace", "pressed", l_eventReplaceBt); subBind(ewol::widget::Button, "SEARCH:replace", signalPressed, shared_from_this(), &appl::widget::Search::OnCallbackReplace);
registerOnEventNameWidget(shared_from_this(), "SEARCH:case", "value", l_eventCaseCb); subBind(ewol::widget::Button, "SEARCH:case", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackCase);
registerOnEventNameWidget(shared_from_this(), "SEARCH:wrap", "value", l_eventWrapCb); subBind(ewol::widget::Button, "SEARCH:wrap", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackWrap);
registerOnEventNameWidget(shared_from_this(), "SEARCH:up-down", "value", l_eventForwardCb); subBind(ewol::widget::Button, "SEARCH:up-down", signalValue, shared_from_this(), &appl::widget::Search::OnCallbackForward);
// set default properties // set default properties
parameterSetOnWidgetNamed("SEARCH:case", "value", etk::to_string(m_caseSensitive)); parameterSetOnWidgetNamed("SEARCH:case", "value", etk::to_string(m_caseSensitive));
parameterSetOnWidgetNamed("SEARCH:wrap", "value", etk::to_string(m_wrap)); parameterSetOnWidgetNamed("SEARCH:wrap", "value", etk::to_string(m_wrap));
parameterSetOnWidgetNamed("SEARCH:up-down", "value", etk::to_string(m_forward)); parameterSetOnWidgetNamed("SEARCH:up-down", "value", etk::to_string(m_forward));
// get widget // get widget
m_searchEntry = std::dynamic_pointer_cast<ewol::widget::Entry>(getWidgetNamed("SEARCH:search-entry")); m_searchEntry = std::dynamic_pointer_cast<ewol::widget::Entry>(getSubObjectNamed("SEARCH:search-entry"));
m_replaceEntry = std::dynamic_pointer_cast<ewol::widget::Entry>(getWidgetNamed("SEARCH:replace-entry")); m_replaceEntry = std::dynamic_pointer_cast<ewol::widget::Entry>(getSubObjectNamed("SEARCH:replace-entry"));
// Display and hide event:
registerMultiCast(ednMsgGuiSearch);
// basicly hiden ... // basicly hiden ...
hide(); hide();
} }
@ -118,45 +118,50 @@ void appl::widget::Search::replace() {
viewer->replace(m_replaceData); viewer->replace(m_replaceData);
} }
void appl::widget::Search::OnCallbackHide() {
void appl::widget::Search::onReceiveMessage(const ewol::object::Message& _msg) { hide();
ewol::widget::Composer::onReceiveMessage(_msg); }
APPL_INFO("Search receive message : " << _msg); void appl::widget::Search::OnCallbackSearchValue(const std::string& _value) {
if ( _msg.getMessage() == l_eventSearchEntry) { m_searchData = etk::to_u32string(_value);
m_searchData = etk::to_u32string(_msg.getData()); }
} else if ( _msg.getMessage() == l_eventSearchEntryEnter void appl::widget::Search::OnCallbackSearch() {
|| _msg.getMessage() == l_eventSearchBt) {
find(); find();
} else if ( _msg.getMessage() == l_eventReplaceEntry) { }
m_replaceData = etk::to_u32string(_msg.getData()); void appl::widget::Search::OnCallbackSearchEntryValidate(const std::string& _value) {
} else if ( _msg.getMessage() == l_eventReplaceEntryEnter m_searchData = etk::to_u32string(_value);
|| _msg.getMessage() == l_eventReplaceBt) { find();
}
void appl::widget::Search::OnCallbackReplaceValue(const std::string& _value) {
m_replaceData = etk::to_u32string(_value);
}
void appl::widget::Search::OnCallbackReplace() {
replace(); replace();
find(); find();
} else if ( _msg.getMessage() == l_eventCaseCb) { }
m_caseSensitive = etk::string_to_bool(_msg.getData()); void appl::widget::Search::OnCallbackReplaceEntryValidate(const std::string& _value) {
} else if ( _msg.getMessage() == l_eventWrapCb) { m_replaceData = etk::to_u32string(_value);
m_wrap = etk::string_to_bool(_msg.getData()); replace();
} else if ( _msg.getMessage() == l_eventForwardCb) { find();
m_forward = etk::string_to_bool(_msg.getData()); }
} else if ( _msg.getMessage() == l_eventHideBt) { void appl::widget::Search::OnCallbackCase(const bool& _value) {
hide(); m_caseSensitive = _value;
} else if ( _msg.getMessage() == ednMsgGuiSearch) { }
if (true == isHide()) { void appl::widget::Search::OnCallbackWrap(const bool& _value) {
show(); m_wrap = _value;
}
void appl::widget::Search::OnCallbackForward(const bool& _value) {
m_forward = _value;
}
void appl::widget::Search::selectSearch() {
if (m_searchEntry!= nullptr) { if (m_searchEntry!= nullptr) {
m_searchEntry->keepFocus(); m_searchEntry->keepFocus();
} }
} else { }
if( (m_searchEntry!=nullptr && true == m_searchEntry->getFocus())
|| (m_replaceEntry!=nullptr && true == m_replaceEntry->getFocus()) ) { void appl::widget::Search::selectReplace() {
hide(); if (m_replaceEntry!= nullptr) {
} else if (m_searchEntry!= nullptr) { m_replaceEntry->keepFocus();
m_searchEntry->keepFocus();
} else {
hide();
}
}
} }
} }

View File

@ -42,8 +42,20 @@ namespace appl {
* @brief Replace the current selected text. * @brief Replace the current selected text.
*/ */
void replace(); void replace();
public: // derived function public:
virtual void onReceiveMessage(const ewol::object::Message& _msg); void selectSearch();
void selectReplace();
private: // callback functions
void OnCallbackHide();
void OnCallbackSearchValue(const std::string& _value);
void OnCallbackSearch();
void OnCallbackSearchEntryValidate(const std::string& _value);
void OnCallbackReplaceValue(const std::string& _value);
void OnCallbackReplace();
void OnCallbackReplaceEntryValidate(const std::string& _value);
void OnCallbackCase(const bool& _value);
void OnCallbackWrap(const bool& _value);
void OnCallbackForward(const bool& _value);
}; };
}; };
}; };

View File

@ -12,15 +12,12 @@
#undef __class__ #undef __class__
#define __class__ "TagFileList" #define __class__ "TagFileList"
extern const char * const applEventCtagsListSelect = "appl-event-ctags-list-select"; appl::TagFileList::TagFileList() :
extern const char * const applEventCtagsListUnSelect = "appl-event-ctags-list-un-select"; signalSelect(*this, "select"),
extern const char * const applEventCtagsListValidate = "appl-event-ctags-list-validate"; signalValidate(*this, "validate"),
signalUnSelect(*this, "unselect") {
appl::TagFileList::TagFileList() {
addObjectType("appl::TagFileList"); addObjectType("appl::TagFileList");
m_selectedLine = -1; m_selectedLine = -1;
addEventId(applEventCtagsListSelect);
addEventId(applEventCtagsListValidate);
setMouseLimit(1); setMouseLimit(1);
// Load color properties: (use file list to be generic ...) // Load color properties: (use file list to be generic ...)
m_colorProperty = ewol::resource::ColorFile::create("THEME:COLOR:ListFileSystem.json"); 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 { } else {
m_selectedLine = _raw; m_selectedLine = _raw;
} }
const char * event = applEventCtagsListValidate;
if (previousRaw != m_selectedLine) {
event = applEventCtagsListSelect;
}
if( m_selectedLine >= 0 if( m_selectedLine >= 0
&& m_selectedLine < (int64_t)m_list.size() && m_selectedLine < (int64_t)m_list.size()
&& nullptr != m_list[m_selectedLine] ) { && nullptr != m_list[m_selectedLine] ) {
generateEventId(event, etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename); if (previousRaw != m_selectedLine) {
signalSelect.emit(etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename);
} else { } else {
generateEventId(applEventCtagsListUnSelect); signalValidate.emit(etk::to_string(m_list[_raw]->fileLine)+":"+m_list[m_selectedLine]->filename);
}
} else {
signalUnSelect.emit();
} }
// need to regenerate the display of the list : // need to regenerate the display of the list :
markToRedraw(); markToRedraw();

View File

@ -13,11 +13,6 @@
#include <ewol/widget/List.h> #include <ewol/widget/List.h>
#include <ewol/resource/ColorFile.h> #include <ewol/resource/ColorFile.h>
extern const char * const applEventCtagsListSelect;
extern const char * const applEventCtagsListValidate;
extern const char * const applEventCtagsListUnSelect;
namespace appl { namespace appl {
class TagListElement { class TagListElement {
public: public:
@ -33,6 +28,10 @@ namespace appl {
}; };
}; };
class TagFileList : public ewol::widget::List { class TagFileList : public ewol::widget::List {
public:
ewol::object::Signal<std::string> signalSelect;
ewol::object::Signal<std::string> signalValidate;
ewol::object::Signal<void> signalUnSelect;
private: private:
int32_t m_selectedLine; int32_t m_selectedLine;
std::vector<appl::TagListElement*> m_list; std::vector<appl::TagListElement*> m_list;

View File

@ -26,14 +26,18 @@
#define __class__ "TagFileSelection" #define __class__ "TagFileSelection"
extern const char * const applEventctagsSelection = "appl-event-ctags-validate"; static const char * const applEventctagsSelection = "appl-event-ctags-validate";
extern const char * const applEventctagsCancel = "appl-event-ctags-cancel"; 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"); addObjectType("appl::TagFileSelection");
addEventId(applEventctagsSelection);
addEventId(applEventctagsCancel);
} }
void appl::TagFileSelection::init() { void appl::TagFileSelection::init() {
@ -74,16 +78,16 @@ void appl::TagFileSelection::init() {
compose->setExpand(bvec2(true,false)); compose->setExpand(bvec2(true,false));
compose->setFill(bvec2(true,true)); compose->setFill(bvec2(true,true));
mySizerVert->subWidgetAdd(compose); mySizerVert->subWidgetAdd(compose);
compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-jump", "pressed", applEventctagsSelection); externSubBind(compose, ewol::widget::Button, "PLUGIN-CTAGS-jump", signalPressed, shared_from_this(), &appl::TagFileSelection::onCallbackCtagsSelection);
compose->registerOnEventNameWidget(shared_from_this(), "PLUGIN-CTAGS-cancel", "pressed", applEventctagsCancel); externSubBind(compose, ewol::widget::Button, "PLUGIN-CTAGS-cancel", signalPressed, shared_from_this(), &appl::TagFileSelection::onCallbackCtagsCancel);
m_listTag = appl::TagFileList::create(); m_listTag = appl::TagFileList::create();
if (nullptr == m_listTag) { if (nullptr == m_listTag) {
EWOL_ERROR("Can not allocate widget == > display might be in error"); EWOL_ERROR("Can not allocate widget == > display might be in error");
} else { } else {
m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListValidate); m_listTag->signalValidate.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListValidate);
m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListSelect); m_listTag->signalSelect.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListSelect);
m_listTag->registerOnEvent(shared_from_this(), applEventCtagsListUnSelect); m_listTag->signalUnSelect.bind(shared_from_this(), &appl::TagFileSelection::onCallbackCtagsListUnSelect);
m_listTag->setExpand(bvec2(true,true)); m_listTag->setExpand(bvec2(true,true));
m_listTag->setFill(bvec2(true,true)); m_listTag->setFill(bvec2(true,true));
mySizerVert->subWidgetAdd(m_listTag); mySizerVert->subWidgetAdd(m_listTag);
@ -104,30 +108,34 @@ appl::TagFileSelection::~TagFileSelection() {
} }
void appl::TagFileSelection::onReceiveMessage(const ewol::object::Message& _msg) { void appl::TagFileSelection::onCallbackCtagsSelection() {
EWOL_INFO("ctags LIST ... : " << _msg );
if (_msg.getMessage() == applEventctagsSelection) {
if (m_eventNamed!="") { if (m_eventNamed!="") {
generateEventId(applEventctagsSelection, m_eventNamed); signalSelect.emit(m_eventNamed);
// == > Auto remove ... // == > Auto remove ...
autoDestroy(); autoDestroy();
} }
} else if (_msg.getMessage() == applEventCtagsListSelect) { }
m_eventNamed = _msg.getData();
} else if (_msg.getMessage() == applEventCtagsListUnSelect) { 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 = ""; m_eventNamed = "";
} else if (_msg.getMessage() == applEventCtagsListValidate) { }
generateEventId(applEventctagsSelection, _msg.getData());
// == > Auto remove ...
autoDestroy();
} else if (_msg.getMessage() == applEventctagsCancel) {
generateEventId(applEventctagsCancel, "");
// == > Auto remove ...
autoDestroy();
}
return;
};
/** /**

View File

@ -13,11 +13,11 @@
#include <ewol/widget/PopUp.h> #include <ewol/widget/PopUp.h>
#include <appl/Gui/TagFileList.h> #include <appl/Gui/TagFileList.h>
extern const char * const applEventctagsSelection;
extern const char * const applEventctagsCancel;
namespace appl { namespace appl {
class TagFileSelection : public ewol::widget::PopUp { class TagFileSelection : public ewol::widget::PopUp {
public:
ewol::object::Signal<std::string> signalSelect;
ewol::object::Signal<void> signalCancel;
private: private:
std::shared_ptr<appl::TagFileList> m_listTag; std::shared_ptr<appl::TagFileList> m_listTag;
std::string m_eventNamed; std::string m_eventNamed;
@ -33,8 +33,12 @@ namespace appl {
* @param[in] jump line id * @param[in] jump line id
*/ */
void addCtagsNewItem(std::string file, int32_t line); void addCtagsNewItem(std::string file, int32_t line);
public: // herited function public: // callback function
void onReceiveMessage(const ewol::object::Message& _msg); void onCallbackCtagsSelection();
void onCallbackCtagsCancel();
void onCallbackCtagsListValidate(const std::string& _value);
void onCallbackCtagsListSelect(const std::string& _value);
void onCallbackCtagsListUnSelect();
}; };
}; };

View File

@ -28,6 +28,10 @@
int64_t processTimeLocal = (endTime - startTime); \ int64_t processTimeLocal = (endTime - startTime); \
APPL_DEBUG(comment << (float)((float)processTimeLocal / 1000.0) << "ms"); 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() : appl::TextViewer::TextViewer() :
m_insertMode(false) { m_insertMode(false) {
addObjectType("appl::TextViewer"); addObjectType("appl::TextViewer");
@ -37,6 +41,7 @@ appl::TextViewer::TextViewer() :
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::create(); m_bufferManager = appl::BufferManager::create();
m_pluginManager = appl::textPluginManager::create();
m_viewerManager = appl::ViewerManager::create(); m_viewerManager = appl::ViewerManager::create();
// load color properties // load color properties
@ -54,21 +59,78 @@ appl::TextViewer::TextViewer() :
void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) { void appl::TextViewer::init(const std::string& _fontName, int32_t _fontSize) {
ewol::widget::WidgetScrolled::init(); ewol::widget::WidgetScrolled::init();
m_displayText.setFont(_fontName, _fontSize); m_displayText.setFont(_fontName, _fontSize);
appl::textPluginManager::connect(*this); m_pluginManager->connect(*this);
// last created has focus ... // last created has focus ...
setCurrentSelect(); setCurrentSelect();
signalShortcut.bind(shared_from_this(), &appl::TextViewer::onCallbackShortCut);
/*
registerMultiCast(ednMsgBufferId); registerMultiCast(ednMsgBufferId);
registerMultiCast(ednMsgGuiFind); registerMultiCast(ednMsgGuiFind);
registerMultiCast(ednMsgGuiReplace); registerMultiCast(ednMsgGuiReplace);
registerMultiCast(appl::MsgSelectGotoLine); registerMultiCast(appl::MsgSelectGotoLine);
registerMultiCast(appl::MsgSelectNewFile);
registerMultiCast(appl::MsgSelectGotoLineSelect); registerMultiCast(appl::MsgSelectGotoLineSelect);
*/
if (m_bufferManager != nullptr) {
m_bufferManager->signalSelectFile.bind(shared_from_this(), &appl::TextViewer::onCallbackselectNewFile);
}
}
appl::TextViewer::~TextViewer() {
m_pluginManager->disconnect(*this);
}
void appl::TextViewer::onCallbackShortCut(const std::string& _value) {
if (m_pluginManager->onReceiveShortCut(*this, _value) == true) {
return;
}
} }
appl::TextViewer::~TextViewer() { void appl::TextViewer::onCallbackselectNewFile(const std::string& _value) {
appl::textPluginManager::disconnect(*this); // reset scroll:
if (m_buffer != nullptr) {
m_buffer->unBindAll(shared_from_this());
bool needAdd = true;
auto it = m_drawingRemenber.begin();
while (it != m_drawingRemenber.end()) {
std::shared_ptr<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);
needAdd = false;
break;
}
++it;
}
if (needAdd == true) {
m_drawingRemenber.push_back(std::make_pair(std::weak_ptr<appl::Buffer>(m_buffer), m_originScrooled));
APPL_VERBOSE("Push origin : " << m_originScrooled);
}
}
m_originScrooled = vec2(0,0);
if (m_bufferManager != nullptr) {
m_buffer = m_bufferManager->get(_value);
m_bufferManager->setBufferSelected(m_buffer);
if (m_buffer != nullptr) {
m_buffer->signalIsModify.bind(shared_from_this(), &appl::TextViewer::onCallbackIsModify);
m_buffer->signalSelectChange.bind(shared_from_this(), &appl::TextViewer::onCallbackSelectChange);
for (auto element : m_drawingRemenber) {
if (element.first.lock() == m_buffer) {
m_originScrooled = element.second;
APPL_VERBOSE("retrive origin : " << m_originScrooled);
// TODO : Check if this element is not out of the display text ...
break;
}
}
}
}
markToRedraw();
return;
} }
std::string appl::TextViewer::getBufferPath() { std::string appl::TextViewer::getBufferPath() {
@ -322,7 +384,7 @@ bool appl::TextViewer::onEventEntry(const ewol::event::Entry& _event) {
return false; return false;
} }
// First call plugin // First call plugin
if (appl::textPluginManager::onEventEntry(*this, _event) == true) { if (m_pluginManager->onEventEntry(*this, _event) == true) {
markToRedraw(); markToRedraw();
return true; return true;
} }
@ -444,7 +506,7 @@ bool appl::TextViewer::onEventInput(const ewol::event::Input& _event) {
} }
APPL_VERBOSE("event : " << _event); APPL_VERBOSE("event : " << _event);
// Second call plugin // Second call plugin
if (appl::textPluginManager::onEventInput(*this, _event) == true) { if (m_pluginManager->onEventInput(*this, _event) == true) {
markToRedraw(); markToRedraw();
return true; return true;
} }
@ -461,9 +523,9 @@ bool appl::TextViewer::onEventInput(const ewol::event::Input& _event) {
} }
if ( _event.getId() == 12 if ( _event.getId() == 12
&& _event.getStatus() == ewol::key::statusSingle) { && _event.getStatus() == ewol::key::statusSingle) {
APPL_DEBUG("kjhkjhkjh"); APPL_TODO("RAT5 SAVE button ==> TODO implement");
// Rat5 save event // Rat5 save event
sendMultiCast(ednMsgGuiSave, "current"); //sendMultiCast(ednMsgGuiSave, "current");
return true; return true;
} }
// just forward event == > manage directly in the buffer // just forward event == > manage directly in the buffer
@ -625,84 +687,13 @@ void appl::TextViewer::onEventClipboard(enum ewol::context::clipBoard::clipboard
markToRedraw(); markToRedraw();
} }
void appl::TextViewer::onReceiveMessage(const ewol::object::Message& _msg) { void appl::TextViewer::onCallbackIsModify() {
ewol::widget::WidgetScrolled::onReceiveMessage(_msg);
APPL_VERBOSE("receive msg: " << _msg);
// First call plugin
if (appl::textPluginManager::onReceiveMessageViewer(*this, _msg) == true) {
markToRedraw(); markToRedraw();
return;
}
// event needed even if selection of buffer is not done ...
if (_msg.getMessage() == appl::Buffer::eventIsModify) {
markToRedraw();
return;
}
if (_msg.getMessage() == appl::Buffer::eventSelectChange) {
markToRedraw();
return;
}
// If not the last buffer selected, then no event parsing ...
if (isSelectedLast() == false) {
return;
}
if (_msg.getMessage() == appl::MsgSelectGotoLineSelect) {
if (m_buffer == nullptr) {
return;
}
appl::Buffer::Iterator it = m_buffer->countForwardNLines(m_buffer->begin(), etk::string_to_int32_t(_msg.getData()));
select(it, m_buffer->getEndLine(it));
markToRedraw();
return;
}
if (_msg.getMessage() == appl::MsgSelectGotoLine) {
if (m_buffer == nullptr) {
return;
}
appl::Buffer::Iterator it = m_buffer->countForwardNLines(m_buffer->begin(), etk::string_to_int32_t(_msg.getData()));
moveCursor(it);
markToRedraw();
return;
}
if (_msg.getMessage() == appl::MsgSelectNewFile) {
// reset scroll:
if (m_buffer != nullptr) {
m_buffer->unRegisterOnEvent(shared_from_this());
bool needAdd = true;
for (size_t iii=0; iii<m_drawingRemenber.size(); ++iii) {
if (m_drawingRemenber[iii].first == m_buffer) {
m_drawingRemenber[iii].second = m_originScrooled;
APPL_VERBOSE("store origin : " << m_originScrooled);
needAdd = false;
break;
}
}
if (needAdd == true) {
m_drawingRemenber.push_back(std::make_pair(m_buffer, m_originScrooled));
APPL_VERBOSE("Push origin : " << m_originScrooled);
}
}
m_originScrooled = vec2(0,0);
if (m_bufferManager != nullptr) {
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);
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::onCallbackSelectChange() {
markToRedraw();
}
void appl::TextViewer::onGetFocus() { void appl::TextViewer::onGetFocus() {
showKeyboard(); showKeyboard();
@ -761,7 +752,7 @@ bool appl::TextViewer::moveCursor(const appl::Buffer::Iterator& _pos) {
return false; return false;
} }
markToRedraw(); markToRedraw();
if (appl::textPluginManager::onCursorMove(*this, _pos) == true) { if (m_pluginManager->onCursorMove(*this, _pos) == true) {
updateScrolling(); updateScrolling();
return true; return true;
} }
@ -785,13 +776,13 @@ bool appl::TextViewer::write(const std::string& _data, const appl::Buffer::Itera
return false; return false;
} }
markToRedraw(); markToRedraw();
if (appl::textPluginManager::onWrite(*this, _pos, _data) == true) { if (m_pluginManager->onWrite(*this, _pos, _data) == true) {
// no call of the move cursor, because pluging might call theses function to copy and cut data... // no call of the move cursor, because pluging might call theses function to copy and cut data...
updateScrolling(); updateScrolling();
return true; return true;
} }
bool ret = m_buffer->write(_data, _pos); bool ret = m_buffer->write(_data, _pos);
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor()); m_pluginManager->onCursorMove(*this, m_buffer->cursor());
updateScrolling(); updateScrolling();
return ret; return ret;
} }
@ -801,13 +792,13 @@ bool appl::TextViewer::replace(const std::string& _data, const appl::Buffer::Ite
return false; return false;
} }
markToRedraw(); markToRedraw();
if (appl::textPluginManager::onReplace(*this, _pos, _data, _posEnd) == true) { if (m_pluginManager->onReplace(*this, _pos, _data, _posEnd) == true) {
// no call of the move cursor, because pluging might call theses function to copy and cut data... // no call of the move cursor, because pluging might call theses function to copy and cut data...
updateScrolling(); updateScrolling();
return true; return true;
} }
bool ret = m_buffer->replace(_data, _pos, _posEnd); bool ret = m_buffer->replace(_data, _pos, _posEnd);
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor()); m_pluginManager->onCursorMove(*this, m_buffer->cursor());
updateScrolling(); updateScrolling();
return ret; return ret;
} }
@ -831,11 +822,11 @@ void appl::TextViewer::remove() {
return; return;
} }
markToRedraw(); markToRedraw();
if (appl::textPluginManager::onRemove(*this, m_buffer->selectStart(), m_buffer->selectStop()) == true) { if (m_pluginManager->onRemove(*this, m_buffer->selectStart(), m_buffer->selectStop()) == true) {
return; return;
} }
m_buffer->removeSelection(); m_buffer->removeSelection();
appl::textPluginManager::onCursorMove(*this, m_buffer->cursor()); m_pluginManager->onCursorMove(*this, m_buffer->cursor());
} }

View File

@ -22,6 +22,7 @@
#include <utility> #include <utility>
namespace appl { namespace appl {
class textPluginManager;
class TextViewer : public ewol::widget::WidgetScrolled { class TextViewer : public ewol::widget::WidgetScrolled {
private: private:
std::shared_ptr<appl::GlyphPainting> m_paintingProperties; //!< element painting property std::shared_ptr<appl::GlyphPainting> m_paintingProperties; //!< element painting property
@ -34,6 +35,7 @@ namespace appl {
int32_t m_colorNormal; int32_t m_colorNormal;
private: private:
std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
std::shared_ptr<appl::textPluginManager> m_pluginManager; //!< Plugin manager interface
std::shared_ptr<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager std::shared_ptr<appl::ViewerManager> m_viewerManager; //!< handle on the buffer manager
protected: protected:
TextViewer(); TextViewer();
@ -54,7 +56,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);
@ -63,7 +65,6 @@ namespace appl {
public: // Derived function public: // Derived function
virtual bool calculateMinSize(); virtual bool calculateMinSize();
virtual void onRegenerateDisplay(); virtual void onRegenerateDisplay();
virtual void onReceiveMessage(const ewol::object::Message& _msg);
virtual bool onEventInput(const ewol::event::Input& _event); virtual bool onEventInput(const ewol::event::Input& _event);
virtual bool onEventEntry(const ewol::event::Entry& _event); virtual bool onEventEntry(const ewol::event::Entry& _event);
virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID); virtual void onEventClipboard(enum ewol::context::clipBoard::clipboardListe _clipboardID);
@ -391,21 +392,31 @@ namespace appl {
* @brief Register of the arrival of a Multicast message * @brief Register of the arrival of a Multicast message
* @param[in] _messageId Event Id waiting for... * @param[in] _messageId Event Id waiting for...
*/ */
// TODO : Remove
void ext_registerMultiCast(const char* const _messageId) { void ext_registerMultiCast(const char* const _messageId) {
registerMultiCast(_messageId); //registerMultiCast(_messageId);
} }
/** /**
* @brief add a specific shortcut with his description * @brief add a specific shortcut with his description
* @param[in] _descriptiveString Description string of the shortcut * @param[in] _descriptiveString Description string of the shortcut
* @param[in] _generateEventId Event generic of the element * @param[in] _generateEventName Event generic of the element
* @param[in] _data Associate data wit the event
*/ */
virtual void ext_shortCutAdd(const char * _descriptiveString, virtual void ext_shortCutAdd(const std::string& _descriptiveString,
const char * _generateEventId, const std::string& _generateEventName) {
std::string _data="", shortCutAdd(_descriptiveString, _generateEventName);
bool _broadcast=false) {
shortCutAdd(_descriptiveString, _generateEventId, _data, _broadcast);
} }
/**
* @brief Remove a specific shortcut with his event name
* @param[in] _generateEventName Event of the element shortcut
*/
virtual void ext_shortCutRm(const std::string& _generateEventName) {
shortCutRemove(_generateEventName);
}
private: // callback fundtions
void onCallbackIsModify();
void onCallbackShortCut(const std::string& _value);
void onCallbackSelectChange();
void onCallbackselectNewFile(const std::string& _value);
}; };
}; };

View File

@ -41,6 +41,6 @@ void appl::ViewerManager::setViewerSelected(const std::shared_ptr<appl::TextView
} }
m_viewer = _viewer; m_viewer = _viewer;
if (m_bufferManager != nullptr) { if (m_bufferManager != nullptr) {
m_bufferManager->setBufferSelected(_buffer); //m_bufferManager->setBufferSelected(_buffer);
} }
} }

View File

@ -13,8 +13,6 @@
#undef __class__ #undef __class__
#define __class__ "WorkerCloseAllFile" #define __class__ "WorkerCloseAllFile"
static const char* s_closeDone = "close-done";
appl::WorkerCloseAllFile::WorkerCloseAllFile() { appl::WorkerCloseAllFile::WorkerCloseAllFile() {
addObjectType("appl::WorkerCloseAllFile"); addObjectType("appl::WorkerCloseAllFile");
// load buffer manager: // load buffer manager:
@ -22,10 +20,10 @@ appl::WorkerCloseAllFile::WorkerCloseAllFile() {
} }
void appl::WorkerCloseAllFile::init() { void appl::WorkerCloseAllFile::init() {
ewol::Object::init(); ewol::object::Worker::init();
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy(); destroy();
return; return;
} }
// List all current open file : // List all current open file :
@ -43,43 +41,43 @@ void appl::WorkerCloseAllFile::init() {
} }
// checkif an element has something to do in the queue // checkif an element has something to do in the queue
if (m_bufferNameList.size() == 0) { if (m_bufferNameList.size() == 0) {
autoDestroy(); destroy();
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) {
autoDestroy(); destroy();
return; return;
} }
m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone);
} }
appl::WorkerCloseAllFile::~WorkerCloseAllFile() { appl::WorkerCloseAllFile::~WorkerCloseAllFile() {
APPL_ERROR("Remove Worker");
} }
void appl::WorkerCloseAllFile::onReceiveMessage(const ewol::object::Message& _msg) { void appl::WorkerCloseAllFile::onCallbackCloseDone() {
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
// nothing to do in this case ==> can do nothing ... // nothing to do in this case ==> can do nothing ...
return; return;
} }
if (_msg.getMessage() == s_closeDone) {
if (m_bufferNameList.size() == 0) { if (m_bufferNameList.size() == 0) {
autoDestroy(); destroy();
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) {
autoDestroy(); destroy();
return; return;
} }
m_worker->registerOnEvent(shared_from_this(), appl::WorkerCloseFile::eventCloseDone, s_closeDone);
}
} }

View File

@ -9,11 +9,12 @@
#ifndef __WORKER_CLOSE_ALL_FILE_H__ #ifndef __WORKER_CLOSE_ALL_FILE_H__
#define __WORKER_CLOSE_ALL_FILE_H__ #define __WORKER_CLOSE_ALL_FILE_H__
#include <ewol/object/Worker.h>
#include <appl/BufferManager.h> #include <appl/BufferManager.h>
#include <appl/Gui/WorkerCloseFile.h> #include <appl/Gui/WorkerCloseFile.h>
namespace appl { namespace appl {
class WorkerCloseAllFile : public ewol::Object { class WorkerCloseAllFile : public ewol::object::Worker {
protected: protected:
WorkerCloseAllFile(); WorkerCloseAllFile();
void init(); void init();
@ -24,8 +25,8 @@ namespace appl {
std::vector<std::string> m_bufferNameList; std::vector<std::string> m_bufferNameList;
std::shared_ptr<appl::WorkerCloseFile> m_worker; //! pop-up element that is open... std::shared_ptr<appl::WorkerCloseFile> m_worker; //! pop-up element that is open...
std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // derived function public: // callback function
virtual void onReceiveMessage(const ewol::object::Message& _msg); void onCallbackCloseDone();
}; };
}; };

View File

@ -14,29 +14,26 @@
#undef __class__ #undef __class__
#define __class__ "WorkerCloseFile" #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() : appl::WorkerCloseFile::WorkerCloseFile() :
signalCloseDone(*this, "close-file-done"),
signalAbort(*this, "close-file-abort"),
m_buffer(nullptr), m_buffer(nullptr),
m_worker(nullptr), m_worker(nullptr),
m_bufferManager(nullptr) { m_bufferManager(nullptr) {
addObjectType("appl::WorkerCloseFile"); addObjectType("appl::WorkerCloseFile");
addEventId(eventCloseDone);
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::create(); m_bufferManager = appl::BufferManager::create();
} }
void appl::WorkerCloseFile::init(const std::string& _bufferName) { void appl::WorkerCloseFile::init() {
ewol::Object::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 ... ");
autoDestroy(); destroy();
return; return;
} }
if (m_bufferName == "") { if (m_bufferName == "") {
@ -44,80 +41,99 @@ 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();
} }
if (m_bufferManager->exist(m_bufferName) == false) { if (m_bufferManager->exist(m_bufferName) == false) {
APPL_ERROR("Try to close an non-existant file :" << m_bufferName); APPL_ERROR("Try to close an non-existant file :" << m_bufferName);
autoDestroy(); destroy();
return; return;
} }
m_buffer = m_bufferManager->get(m_bufferName); m_buffer = m_bufferManager->get(m_bufferName);
if (m_buffer == nullptr) { if (m_buffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << m_bufferName); APPL_ERROR("Error to get the buffer : " << m_bufferName);
autoDestroy(); destroy();
return; return;
} }
if (m_buffer->isModify() == false) { if (m_buffer->isModify() == false) {
generateEventId(eventCloseDone); 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>");
tmpPopUp->setComment("The file named : <i>\"" + m_buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost..."); tmpPopUp->setComment("The file named : <i>\"" + m_buffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
std::shared_ptr<ewol::Widget> bt = nullptr; std::shared_ptr<ewol::widget::Button> bt = nullptr;
if (m_buffer->hasFileName() == true) { if (m_buffer->hasFileName() == true) {
bt = tmpPopUp->addButton("Save", true); bt = tmpPopUp->addButton("Save", true);
if (bt != nullptr) { 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); bt = tmpPopUp->addButton("Save As", true);
if (bt != nullptr) { 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); bt = tmpPopUp->addButton("Close", true);
if (bt != nullptr) { if (bt != nullptr) {
bt->registerOnEvent(shared_from_this(), "pressed", s_closeValidate); bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackClose);
}
bt = tmpPopUp->addButton("Cancel", true);
if (bt != nullptr) {
bt->signalPressed.bind(shared_from_this(), &appl::WorkerCloseFile::onCallbackCancel);
} }
tmpPopUp->addButton("Cancel", true);
tmpPopUp->setRemoveOnExternClick(true); tmpPopUp->setRemoveOnExternClick(true);
std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows(); std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == nullptr) { if (tmpWindows == nullptr) {
APPL_ERROR("Error to get the windows."); APPL_ERROR("Error to get the windows.");
autoDestroy(); destroy();
return; return;
} }
tmpWindows->popUpWidgetPush(tmpPopUp); tmpWindows->popUpWidgetPush(tmpPopUp);
} }
appl::WorkerCloseFile::~WorkerCloseFile() { appl::WorkerCloseFile::~WorkerCloseFile() {
APPL_ERROR("Remove Worker");
} }
void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg) { void appl::WorkerCloseFile::onCallbackCancel() {
APPL_VERBOSE("Cancel signal ...");
signalAbort.emit();
destroy();
}
void appl::WorkerCloseFile::onCallbackSaveAsValidate() {
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
// nothing to do in this case ==> can do nothing ... // nothing to do in this case ==> can do nothing ...
return; return;
} }
APPL_DEBUG("have message : " << _msg);
if (_msg.getMessage() == s_saveAsValidate) {
m_worker = appl::WorkerSaveFile::create(m_bufferName); m_worker = appl::WorkerSaveFile::create(m_bufferName);
if (m_worker != nullptr) { if (m_worker != nullptr) {
m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); 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;
} }
} else if (_msg.getMessage() == s_saveValidate) {
if (m_buffer == nullptr) { if (m_buffer == nullptr) {
APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName); APPL_ERROR("Error to get the buffer : oldName=" << m_bufferName);
autoDestroy(); signalAbort.emit();
destroy();
return; return;
} }
if (m_buffer->storeFile() == false) { if (m_buffer->storeFile() == false) {
@ -126,19 +142,31 @@ void appl::WorkerCloseFile::onReceiveMessage(const ewol::object::Message& _msg)
return; return;
} }
tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + m_buffer->getFileName() + "</i>"); tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + m_buffer->getFileName() + "</i>");
signalAbort.emit();
} else { } else {
generateEventId(eventCloseDone);
}
} else if ( _msg.getMessage() == s_closeValidate
|| _msg.getMessage() == s_saveAsDone) {
if (m_buffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << m_bufferName);
autoDestroy();
return;
}
generateEventId(eventCloseDone);
m_buffer->destroy(); m_buffer->destroy();
m_buffer.reset(); m_buffer.reset();
signalCloseDone.emit();
} }
destroy();
}
void appl::WorkerCloseFile::onCallbackClose() {
if (m_bufferManager == nullptr) {
// nothing to do in this case ==> can do nothing ...
signalAbort.emit();
destroy();
return;
}
if (m_buffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << m_bufferName);
signalAbort.emit();
destroy();
return;
}
m_buffer->destroy();
m_buffer.reset();
signalCloseDone.emit();
destroy();
} }

View File

@ -9,28 +9,38 @@
#ifndef __WORKER_CLOSE_FILE_H__ #ifndef __WORKER_CLOSE_FILE_H__
#define __WORKER_CLOSE_FILE_H__ #define __WORKER_CLOSE_FILE_H__
#include <ewol/object/Worker.h>
#include <ewol/widget/meta/FileChooser.h> #include <ewol/widget/meta/FileChooser.h>
#include <appl/BufferManager.h> #include <appl/BufferManager.h>
#include <appl/Gui/WorkerSaveFile.h> #include <appl/Gui/WorkerSaveFile.h>
namespace appl { namespace appl {
class WorkerCloseFile : public ewol::Object { class WorkerCloseFile : public ewol::object::Worker {
public: public:
static const char* eventCloseDone; ewol::object::Signal<void> signalCloseDone;
ewol::object::Signal<void> signalAbort;
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
std::shared_ptr<appl::WorkerSaveFile> m_worker; //! sub-worker element... std::shared_ptr<appl::WorkerSaveFile> m_worker; //! sub-worker element...
std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // derived function public: // callback Functions
virtual void onReceiveMessage(const ewol::object::Message& _msg); void onCallbackSaveAsValidate();
void onCallbackSaveValidate();
void onCallbackClose();
void onCallbackCancel();
}; };
}; };

View File

@ -13,8 +13,6 @@
#undef __class__ #undef __class__
#define __class__ "WorkerSaveAllFile" #define __class__ "WorkerSaveAllFile"
static const char* s_saveAsDone = "save-as-done";
appl::WorkerSaveAllFile::WorkerSaveAllFile() { appl::WorkerSaveAllFile::WorkerSaveAllFile() {
addObjectType("appl::WorkerSaveAllFile"); addObjectType("appl::WorkerSaveAllFile");
// load buffer manager: // load buffer manager:
@ -22,10 +20,10 @@ appl::WorkerSaveAllFile::WorkerSaveAllFile() {
} }
void appl::WorkerSaveAllFile::init() { void appl::WorkerSaveAllFile::init() {
ewol::Object::init(); ewol::object::Worker::init();
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
APPL_ERROR("can not call unexistant buffer manager ... "); APPL_ERROR("can not call unexistant buffer manager ... ");
autoDestroy(); destroy();
return; return;
} }
// List all current open file : // List all current open file :
@ -45,7 +43,7 @@ void appl::WorkerSaveAllFile::init() {
} }
// checkif an element has something to do in the queue // checkif an element has something to do in the queue
if (m_bufferNameList.size() == 0) { if (m_bufferNameList.size() == 0) {
autoDestroy(); destroy();
return; return;
} }
// create the worker : // create the worker :
@ -53,24 +51,23 @@ void appl::WorkerSaveAllFile::init() {
// 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) {
autoDestroy(); destroy();
return; return;
} }
m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone);
} }
appl::WorkerSaveAllFile::~WorkerSaveAllFile() { appl::WorkerSaveAllFile::~WorkerSaveAllFile() {
APPL_ERROR("Remove Worker");
} }
void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::object::Message& _msg) { void appl::WorkerSaveAllFile::onCallbackSaveAsDone() {
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
// nothing to do in this case ==> can do nothing ... // nothing to do in this case ==> can do nothing ...
return; return;
} }
if (_msg.getMessage() == s_saveAsDone) {
if (m_bufferNameList.size() == 0) { if (m_bufferNameList.size() == 0) {
autoDestroy(); destroy();
return; return;
} }
// create the worker : // create the worker :
@ -78,10 +75,9 @@ void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::object::Message& _msg
// 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) {
autoDestroy(); destroy();
return; return;
} }
m_worker->registerOnEvent(shared_from_this(), appl::WorkerSaveFile::eventSaveDone, s_saveAsDone); m_worker->signalSaveDone.bind(shared_from_this(), &appl::WorkerSaveAllFile::onCallbackSaveAsDone);
}
} }

View File

@ -9,11 +9,12 @@
#ifndef __WORKER_SAVE_ALL_FILE_H__ #ifndef __WORKER_SAVE_ALL_FILE_H__
#define __WORKER_SAVE_ALL_FILE_H__ #define __WORKER_SAVE_ALL_FILE_H__
#include <ewol/object/Worker.h>
#include <appl/BufferManager.h> #include <appl/BufferManager.h>
#include <appl/Gui/WorkerSaveFile.h> #include <appl/Gui/WorkerSaveFile.h>
namespace appl { namespace appl {
class WorkerSaveAllFile : public ewol::Object { class WorkerSaveAllFile : public ewol::object::Worker {
protected: protected:
WorkerSaveAllFile(); WorkerSaveAllFile();
void init(); void init();
@ -24,8 +25,8 @@ namespace appl {
std::vector<std::string> m_bufferNameList; std::vector<std::string> m_bufferNameList;
std::shared_ptr<appl::WorkerSaveFile> m_worker; //! pop-up element that is open... std::shared_ptr<appl::WorkerSaveFile> m_worker; //! pop-up element that is open...
std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // derived function public: // callback function
virtual void onReceiveMessage(const ewol::object::Message& _msg); void onCallbackSaveAsDone();
}; };
}; };

View File

@ -13,23 +13,21 @@
#undef __class__ #undef __class__
#define __class__ "WorkerSaveFile" #define __class__ "WorkerSaveFile"
const char* appl::WorkerSaveFile::eventSaveDone = "save-file-done";
static const char* s_saveAsValidate = "save-as-validate"; appl::WorkerSaveFile::WorkerSaveFile() :
signalSaveDone(*this, "save-file-done"),
appl::WorkerSaveFile::WorkerSaveFile() { signalAbort(*this, "save-file-abort") {
addObjectType("appl::WorkerSaveFile"); addObjectType("appl::WorkerSaveFile");
addEventId(eventSaveDone);
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::create(); m_bufferManager = appl::BufferManager::create();
} }
void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveAs) { void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveAs) {
ewol::Object::init(); ewol::object::Worker::init();
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 ... ");
autoDestroy(); destroy();
return; return;
} }
if (m_bufferName == "") { if (m_bufferName == "") {
@ -37,34 +35,34 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA
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();
} }
if (m_bufferManager->exist(m_bufferName) == false) { if (m_bufferManager->exist(m_bufferName) == false) {
APPL_ERROR("Try to save an non-existant file :" << m_bufferName); APPL_ERROR("Try to save an non-existant file :" << m_bufferName);
autoDestroy(); destroy();
return; return;
} }
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(m_bufferName); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(m_bufferName);
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << m_bufferName); APPL_ERROR("Error to get the buffer : " << m_bufferName);
autoDestroy(); destroy();
return; return;
} }
if (_forceSaveAs == false) { if (_forceSaveAs == false) {
if (tmpBuffer->hasFileName() == true) { if (tmpBuffer->hasFileName() == true) {
tmpBuffer->storeFile(); tmpBuffer->storeFile();
generateEventId(eventSaveDone); signalSaveDone.emit();
autoDestroy(); destroy();
return; return;
} }
} }
m_chooser = ewol::widget::FileChooser::create(); m_chooser = ewol::widget::FileChooser::create();
if (nullptr == m_chooser) { if (nullptr == m_chooser) {
APPL_ERROR("Can not allocate widget == > display might be in error"); APPL_ERROR("Can not allocate widget == > display might be in error");
autoDestroy(); destroy();
return; return;
} }
m_chooser->setTitle("Save files As..."); m_chooser->setTitle("Save files As...");
@ -75,46 +73,56 @@ void appl::WorkerSaveFile::init(const std::string& _bufferName, bool _forceSaveA
std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows(); std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == nullptr) { if (tmpWindows == nullptr) {
APPL_ERROR("Error to get the windows."); APPL_ERROR("Error to get the windows.");
autoDestroy(); destroy();
return; return;
} }
tmpWindows->popUpWidgetPush(m_chooser); tmpWindows->popUpWidgetPush(m_chooser);
m_chooser->registerOnEvent(shared_from_this(), ewol::widget::FileChooser::eventValidate, s_saveAsValidate); m_chooser->signalValidate.bind(shared_from_this(), &appl::WorkerSaveFile::onCallbackSaveAsValidate);
m_chooser->signalCancel.bind(shared_from_this(), &appl::WorkerSaveFile::onCallbackCancel);
} }
appl::WorkerSaveFile::~WorkerSaveFile() { appl::WorkerSaveFile::~WorkerSaveFile() {
APPL_ERROR("Remove Worker");
} }
void appl::WorkerSaveFile::onReceiveMessage(const ewol::object::Message& _msg) { void appl::WorkerSaveFile::onCallbackCancel() {
signalAbort.emit();
destroy();
}
void appl::WorkerSaveFile::onCallbackSaveAsValidate(const std::string& _value) {
if (m_bufferManager == nullptr) { if (m_bufferManager == nullptr) {
// nothing to do in this case ==> can do nothing ... // nothing to do in this case ==> can do nothing ...
destroy();
return; return;
} }
if (_msg.getMessage() == s_saveAsValidate) { if (_value == "") {
if (_msg.getData() == "") {
APPL_ERROR(" might be an error of the File chooser system..."); APPL_ERROR(" might be an error of the File chooser system...");
destroy();
return; return;
} }
if (m_bufferManager->exist(m_bufferName) == false) { if (m_bufferManager->exist(m_bufferName) == false) {
APPL_ERROR("Try to save an non-existant file :" << m_bufferName); APPL_ERROR("Try to save an non-existant file :" << m_bufferName);
destroy();
return; return;
} }
std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(m_bufferName); std::shared_ptr<appl::Buffer> tmpBuffer = m_bufferManager->get(m_bufferName);
if (tmpBuffer == nullptr) { if (tmpBuffer == nullptr) {
APPL_ERROR("Error to get the buffer : " << m_bufferName); APPL_ERROR("Error to get the buffer : " << m_bufferName);
destroy();
return; return;
} }
tmpBuffer->setFileName(_msg.getData()); tmpBuffer->setFileName(_value);
if (tmpBuffer->storeFile() == false) { if (tmpBuffer->storeFile() == false) {
std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows(); std::shared_ptr<ewol::widget::Windows> tmpWindows = ewol::getContext().getWindows();
if (tmpWindows == nullptr) { if (tmpWindows == nullptr) {
destroy();
return; return;
} }
tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>"); tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
} else { } else {
generateEventId(eventSaveDone); signalSaveDone.emit();
}
} }
destroy();
} }

View File

@ -10,12 +10,14 @@
#define __WORKER_SAVE_FILE_H__ #define __WORKER_SAVE_FILE_H__
#include <ewol/widget/meta/FileChooser.h> #include <ewol/widget/meta/FileChooser.h>
#include <ewol/object/Worker.h>
#include <appl/BufferManager.h> #include <appl/BufferManager.h>
namespace appl { namespace appl {
class WorkerSaveFile : public ewol::Object { class WorkerSaveFile : public ewol::object::Worker {
public: public:
static const char* eventSaveDone; ewol::object::Signal<void> signalSaveDone;
ewol::object::Signal<void> signalAbort;
protected: protected:
WorkerSaveFile(); WorkerSaveFile();
void init(const std::string& _bufferName, bool _forceSaveAs=true); void init(const std::string& _bufferName, bool _forceSaveAs=true);
@ -26,8 +28,9 @@ namespace appl {
std::string m_bufferName; std::string m_bufferName;
std::shared_ptr<ewol::widget::FileChooser> m_chooser; //! pop-up element that is open... std::shared_ptr<ewol::widget::FileChooser> m_chooser; //! pop-up element that is open...
std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager std::shared_ptr<appl::BufferManager> m_bufferManager; //!< handle on the buffer manager
public: // derived function public: // callback function
virtual void onReceiveMessage(const ewol::object::Message& _msg); void onCallbackSaveAsValidate(const std::string& _value);
void onCallbackCancel();
}; };
}; };

View File

@ -26,11 +26,12 @@
void appl::Highlight::parseRules(exml::Element* _child, void appl::Highlight::parseRules(exml::Element* _child,
std::vector<std::unique_ptr<HighlightPattern>>& _mListPatern, std::vector<std::unique_ptr<HighlightPattern>>& _mListPatern,
int32_t _level) { int32_t _level,
bool forceMaximize) {
// Create the patern ... // Create the patern ...
HighlightPattern *myPattern = new HighlightPattern(m_paintingProperties); HighlightPattern *myPattern = new HighlightPattern(m_paintingProperties);
// parse under Element // parse under Element
myPattern->parseRules(_child, _level); myPattern->parseRules(_child, _level, forceMaximize);
// add element in the list // add element in the list
_mListPatern.push_back(std::unique_ptr<HighlightPattern>(myPattern)); _mListPatern.push_back(std::unique_ptr<HighlightPattern>(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]" ); APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" );
continue; continue;
} }
parseRules(passChild, m_listHighlightPass2, level2++); parseRules(passChild, m_listHighlightPass2, level2++, true);
} }
} else { } else {
APPL_ERROR("(l "<< child->getPos() << ") node not suported : \""<< child->getValue() << "\" must be [ext,pass1,pass2]" ); APPL_ERROR("(l "<< child->getPos() << ") node not suported : \""<< child->getValue() << "\" must be [ext,pass1,pass2]" );

View File

@ -63,7 +63,8 @@ namespace appl {
private: private:
void parseRules(exml::Element* _child, void parseRules(exml::Element* _child,
std::vector<std::unique_ptr<HighlightPattern>> &_mListPatern, std::vector<std::unique_ptr<HighlightPattern>> &_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::string m_styleName; //!< curent style name (like "c++" or "c" or "script Bash")
std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h" std::vector<std::string> m_listExtentions; //!< List of possible extention for this high-light, like : ".c", ".cpp", ".h"
std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer) std::vector<std::unique_ptr<HighlightPattern>> m_listHighlightPass1; //!< List of ALL hightlight modules (pass 1 == > when we load and wride data on the buffer)

View File

@ -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) { if (m_regExp == nullptr) {
return; return;
} }
m_regExp->compile(_regExp); m_regExp->compile(_regExp);
m_regExp->setMaximize(forceMaximize);
} }
std::string appl::HighlightPattern::getPaternString() { std::string appl::HighlightPattern::getPaternString() {
return m_regExp->getRegExDecorated(); return m_regExp->getRegExDecorated();
@ -48,12 +49,13 @@ void appl::HighlightPattern::display() {
APPL_INFO(" == > regExp '" << m_regExp->getRegExp() << "'"); 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) {
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
/* /*
<rule name="my preprocesseur"> <rule name="my preprocesseur">
<color>preprocesseur</color> <color>preprocesseur</color>
<regex>#</regex> <regex>#</regex>
<max>false</max>
</rule> </rule>
*/ */
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
@ -75,13 +77,17 @@ void appl::HighlightPattern::parseRules(exml::Element* _child, int32_t _level) {
setColorGlyph(myEdnData); setColorGlyph(myEdnData);
} }
} }
xChild = _child->getNamed("max");
if (nullptr != xChild) {
forceMaximize = etk::string_to_bool(xChild->getText());
}
xChild = _child->getNamed("regex"); xChild = _child->getNamed("regex");
if (nullptr != xChild) { if (nullptr != xChild) {
std::string myData = xChild->getText(); std::string myData = xChild->getText();
if (myData.size() != 0) { if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
std::string myEdnData = myData; std::string myEdnData = myData;
setPatern(myEdnData); setPatern(myEdnData, forceMaximize);
} }
} }
} }

View File

@ -46,7 +46,7 @@ namespace appl {
private: private:
std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExp; //!< Start of Regular expression std::unique_ptr<etk::RegExp<etk::Buffer>> m_regExp; //!< Start of Regular expression
public: public:
void setPatern(std::string& _regExp); void setPatern(std::string& _regExp, bool forceMaximize=false);
std::string getPaternString(); std::string getPaternString();
private: private:
std::string m_colorName; //!< Current color name std::string m_colorName; //!< Current color name
@ -84,7 +84,7 @@ namespace appl {
appl::HighlightInfo& _resultat, appl::HighlightInfo& _resultat,
etk::Buffer& _buffer); etk::Buffer& _buffer);
void parseRules(exml::Element* _child, int32_t _level); void parseRules(exml::Element* _child, int32_t _level, bool forceMaximize=false);
}; };
}; };

View File

@ -8,6 +8,7 @@
#include <appl/TextPlugin.h> #include <appl/TextPlugin.h>
#include <appl/TextPluginManager.h>
#include <appl/debug.h> #include <appl/debug.h>
#undef __class__ #undef __class__
@ -21,21 +22,31 @@ appl::TextViewerPlugin::TextViewerPlugin() :
m_activateOnWrite(false), m_activateOnWrite(false),
m_activateOnReplace(false), m_activateOnReplace(false),
m_activateOnRemove(false), m_activateOnRemove(false),
m_activateOnReceiveMessage(false), m_activateOnReceiveShortCut(false),
m_activateOnCursorMove(false) { m_activateOnCursorMove(false) {
addObjectType("appl::TextViewerPlugin"); addObjectType("appl::TextViewerPlugin");
m_menuInterface = std::dynamic_pointer_cast<ewol::widget::Menu>(getObjectNamed("appl-menu-interface"));
if (m_menuInterface.expired() == true) {
APPL_ERROR("Can not acces to the Menu interface");
}
// get a reference on the plugin manager...
m_pluginManager = appl::textPluginManager::create();
} }
void appl::TextViewerPlugin::init() { void appl::TextViewerPlugin::init() {
ewol::Object::init(); ewol::Object::init();
} }
void appl::TextViewerPlugin::init(const std::string& _name) {
ewol::Object::init(_name);
}
appl::TextViewerPlugin::~TextViewerPlugin() { appl::TextViewerPlugin::~TextViewerPlugin() {
if (m_isEnable == false) { if (m_isEnable == false) {
return; return;
} }
m_isEnable = false; m_isEnable = false;
onPluginDisable(); onPluginGlobalDisable();
} }
void appl::TextViewerPlugin::setEnableStatus(bool _status) { void appl::TextViewerPlugin::setEnableStatus(bool _status) {
@ -44,9 +55,9 @@ void appl::TextViewerPlugin::setEnableStatus(bool _status) {
} }
m_isEnable = _status; m_isEnable = _status;
if (m_isEnable == true) { if (m_isEnable == true) {
onPluginEnable(); onPluginGlobalEnable();
} else { } else {
onPluginDisable(); onPluginGlobalDisable();
} }
} }

View File

@ -13,16 +13,23 @@
#include <ewol/object/Object.h> #include <ewol/object/Object.h>
#include <appl/Gui/TextViewer.h> #include <appl/Gui/TextViewer.h>
#include <ewol/compositing/Text.h> #include <ewol/compositing/Text.h>
#include <ewol/widget/Menu.h>
namespace appl { namespace appl {
class textPluginManager;
class TextViewerPlugin : public ewol::Object { class TextViewerPlugin : public ewol::Object {
friend class appl::TextViewer; friend class appl::TextViewer;
protected:
std::weak_ptr<appl::textPluginManager> m_pluginManager;
protected: protected:
TextViewerPlugin(); TextViewerPlugin();
void init(); void init();
void init(const std::string& _name);
public: public:
DECLARE_FACTORY(TextViewerPlugin); DECLARE_FACTORY(TextViewerPlugin);
virtual ~TextViewerPlugin(); virtual ~TextViewerPlugin();
protected:
std::weak_ptr<ewol::widget::Menu> m_menuInterface;
private: private:
bool m_isEnable; //!< The plugin is enable or not (for all viewer). bool m_isEnable; //!< The plugin is enable or not (for all viewer).
public: public:
@ -42,13 +49,13 @@ namespace appl {
/** /**
* @brief On plugin global enable. * @brief On plugin global enable.
*/ */
virtual void onPluginEnable() { virtual void onPluginGlobalEnable() {
// nothing to do here ... // nothing to do here ...
}; };
/** /**
* @brief On plugin global disable. * @brief On plugin global disable.
*/ */
virtual void onPluginDisable() { virtual void onPluginGlobalDisable() {
// nothing to do here ... // nothing to do here ...
}; };
/** /**
@ -174,23 +181,22 @@ namespace appl {
return false; return false;
}; };
protected: protected:
bool m_activateOnReceiveMessage; //!< onReceiveMessage is availlable for this plugin. bool m_activateOnReceiveShortCut; //!< onReceiveShortCut is availlable for this plugin.
public: public:
/** /**
* @brief Get the availlability of a callback * @brief Get the availlability of a callback
* @return true if availlable * @return true if availlable
*/ */
bool isAvaillableOnReceiveMessage() { bool isAvaillableOnReceiveShortCut() {
return m_activateOnReceiveMessage; return m_activateOnReceiveShortCut;
} }
/** /**
* @brief Called when a message arrive. * @brief Called when a message arrive.
* @param[in] _widget Reference on the widget caller. * @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 * @return true if the event might not propagate anymore
*/ */
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer, const std::string& _shortCutName) {
const ewol::object::Message& _msg) {
return false; return false;
} }
protected: protected:

View File

@ -15,8 +15,13 @@
#define __class__ "TextPluginCopy" #define __class__ "TextPluginCopy"
appl::TextPluginCopy::TextPluginCopy() { appl::TextPluginCopy::TextPluginCopy() :
m_activateOnReceiveMessage = true; m_menuIdTitle(-1),
m_menuIdCopy(-1),
m_menuIdCut(-1),
m_menuIdPast(-1),
m_menuIdRemove(-1) {
m_activateOnReceiveShortCut = true;
addObjectType("appl::TextPluginCopy"); addObjectType("appl::TextPluginCopy");
} }
@ -26,25 +31,47 @@ void appl::TextPluginCopy::init() {
void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event : // add event :
_textDrawer.ext_registerMultiCast(ednMsgGuiCopy); std::shared_ptr<ewol::widget::Menu> menu = m_menuInterface.lock();
_textDrawer.ext_registerMultiCast(ednMsgGuiPaste); if (menu != nullptr) {
_textDrawer.ext_registerMultiCast(ednMsgGuiCut); m_menuIdTitle = menu->addTitle("Edit");
_textDrawer.ext_shortCutAdd("ctrl+x", ednMsgGuiCut, "STD"); if (m_menuIdTitle != -1) {
_textDrawer.ext_shortCutAdd("ctrl+c", ednMsgGuiCopy, "STD"); m_menuIdCopy = menu->add(m_menuIdTitle, "Copy", "", "appl::TextPluginCopy::menu:copy");
_textDrawer.ext_shortCutAdd("ctrl+v", ednMsgGuiPaste, "STD"); m_menuIdCut = menu->add(m_menuIdTitle, "Cut", "", "appl::TextPluginCopy::menu:cut");
m_menuIdPast = menu->add(m_menuIdTitle, "Paste", "", "appl::TextPluginCopy::menu:past");
m_menuIdRemove = menu->add(m_menuIdTitle, "Remove", "", "appl::TextPluginCopy::menu:remove");
}
}
_textDrawer.ext_shortCutAdd("ctrl+x", "appl::TextPluginCopy::cut");
_textDrawer.ext_shortCutAdd("ctrl+c", "appl::TextPluginCopy::copy");
_textDrawer.ext_shortCutAdd("ctrl+v", "appl::TextPluginCopy::Paste");
} }
void appl::TextPluginCopy::onPluginDisable(appl::TextViewer& _textDrawer) { 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<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
menu->remove(m_menuIdRemove);
menu->remove(m_menuIdPast);
menu->remove(m_menuIdCut);
menu->remove(m_menuIdCopy);
menu->remove(m_menuIdTitle);
}
m_menuIdTitle = -1;
m_menuIdCopy = -1;
m_menuIdCut = -1;
m_menuIdPast = -1;
m_menuIdRemove = -1;
} }
bool appl::TextPluginCopy::onReceiveMessageViewer(appl::TextViewer& _textDrawer, bool appl::TextPluginCopy::onReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) { const std::string& _shortCutName) {
if (isEnable() == false) { if (isEnable() == false) {
return false; return false;
} }
if ( _msg.getMessage() == ednMsgGuiCopy if ( _shortCutName == "appl::TextPluginCopy::copy"
|| _msg.getMessage() == ednMsgGuiCut) { || _shortCutName == "appl::TextPluginCopy::cut") {
if (_textDrawer.hasBuffer() == true) { if (_textDrawer.hasBuffer() == true) {
std::string value; std::string value;
_textDrawer.copy(value); _textDrawer.copy(value);
@ -52,11 +79,11 @@ bool appl::TextPluginCopy::onReceiveMessageViewer(appl::TextViewer& _textDrawer,
ewol::context::clipBoard::set(ewol::context::clipBoard::clipboardStd, value); ewol::context::clipBoard::set(ewol::context::clipBoard::clipboardStd, value);
} }
} }
if (_msg.getMessage() == ednMsgGuiCut) { if (_shortCutName == "appl::TextPluginCopy::cut") {
_textDrawer.remove(); _textDrawer.remove();
} }
return true; return true;
} else if (_msg.getMessage() == ednMsgGuiPaste) { } else if (_shortCutName == "appl::TextPluginCopy::Paste") {
if (_textDrawer.hasBuffer() == true) { if (_textDrawer.hasBuffer() == true) {
ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd); ewol::context::clipBoard::request(ewol::context::clipBoard::clipboardStd);
} }

View File

@ -17,6 +17,12 @@
namespace appl { namespace appl {
class TextPluginCopy : public appl::TextViewerPlugin { 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: protected:
TextPluginCopy(); TextPluginCopy();
void init(); void init();
@ -28,7 +34,7 @@ namespace appl {
public: public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(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);
}; };
}; };

View File

@ -22,7 +22,7 @@ appl::TextPluginCtags::TextPluginCtags() :
m_tagFolderBase(""), m_tagFolderBase(""),
m_tagFilename(""), m_tagFilename(""),
m_ctagFile(nullptr) { m_ctagFile(nullptr) {
m_activateOnReceiveMessage = true; m_activateOnReceiveShortCut = true;
// load buffer manager: // load buffer manager:
m_bufferManager = appl::BufferManager::create(); m_bufferManager = appl::BufferManager::create();
addObjectType("appl::TextPluginCtags"); addObjectType("appl::TextPluginCtags");
@ -37,30 +37,17 @@ appl::TextPluginCtags::~TextPluginCtags() {
} }
const char* eventJumpDestination = "event-plugin-ctags-jump-destination";
const char* eventJumpBack = "event-plugin-ctags-jump-back";
const char* eventOpenCtagsFile = "event-plugin-ctags-open";
const char* eventOpenCtagsOpenFileReturn = "event-plugin-ctags-open-file-return";
const char* eventOpenCtagsSelectReturn = "event-plugin-ctags-select-file-return";
void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) { 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 : // add event :
_textDrawer.ext_registerMultiCast(eventJumpDestination); _textDrawer.ext_shortCutAdd("ctrl+d", "appl::TextPluginCtags::JumpDestination");
_textDrawer.ext_registerMultiCast(eventJumpBack); _textDrawer.ext_shortCutAdd("ctrl+shift+d", "appl::TextPluginCtags::JumpBack");
_textDrawer.ext_registerMultiCast(eventOpenCtagsFile); _textDrawer.ext_shortCutAdd("ctrl+alt+d", "appl::TextPluginCtags::OpenCtagsFile");
_textDrawer.ext_shortCutAdd("ctrl+d", eventJumpDestination);
_textDrawer.ext_shortCutAdd("ctrl+shift+d", eventJumpBack);
_textDrawer.ext_shortCutAdd("ctrl+alt+d", eventOpenCtagsFile);
} }
void appl::TextPluginCtags::onPluginDisable(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) { void appl::TextPluginCtags::jumpTo(const std::string& _name) {
@ -98,7 +85,7 @@ void appl::TextPluginCtags::jumpTo(const std::string& _name) {
tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID); tmpWidget->addCtagsNewItem(myfile.getFileSystemName(), lineID);
} while (tagsFindNext (m_ctagFile, &entry) == TagSuccess); } while (tagsFindNext (m_ctagFile, &entry) == TagSuccess);
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(shared_from_this(), applEventctagsSelection, eventOpenCtagsSelectReturn); tmpWidget->signalSelect.bind(shared_from_this(), &appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn);
} }
} else { } else {
jumpFile(myfile.getName(), lineID - 1); jumpFile(myfile.getName(), lineID - 1);
@ -111,8 +98,8 @@ void appl::TextPluginCtags::jumpFile(const std::string& _filename, int64_t _line
if (m_bufferManager != nullptr) { if (m_bufferManager != nullptr) {
m_bufferManager->open(_filename); 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() { void appl::TextPluginCtags::loadTagFile() {
@ -157,29 +144,30 @@ void appl::TextPluginCtags::printTag(const tagEntry *_entry) {
#endif #endif
} }
void appl::TextPluginCtags::onReceiveMessage(const ewol::object::Message& _msg) { void appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn(const std::string& _value) {
if (_msg.getMessage() == eventOpenCtagsOpenFileReturn) {
// open the new one : // open the new one :
etk::FSNode tmpFilename = _msg.getData(); etk::FSNode tmpFilename = _value;
m_tagFilename = tmpFilename.getNameFile(); m_tagFilename = tmpFilename.getNameFile();
m_tagFolderBase = tmpFilename.getNameFolder(); m_tagFolderBase = tmpFilename.getNameFolder();
APPL_INFO("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " "); APPL_INFO("Receive load Ctags file : " << m_tagFolderBase << "/" << m_tagFilename << " ");
loadTagFile(); loadTagFile();
} else if (_msg.getMessage() == eventOpenCtagsSelectReturn) { }
void appl::TextPluginCtags::onCallbackOpenCtagsSelectReturn(const std::string& _value) {
// parse the input data // parse the input data
char tmp[4096]; char tmp[4096];
int32_t lineID; int32_t lineID;
// TODO : Review this ... // TODO : Review this ...
sscanf(_msg.getData().c_str(), "%d:%s", &lineID, tmp); sscanf(_value.c_str(), "%d:%s", &lineID, tmp);
jumpFile(tmp, lineID - 1); 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) { if (isEnable() == false) {
return false; return false;
} }
if (_msg.getMessage() == eventOpenCtagsFile) { if (_shortCutName == "appl::TextPluginCtags::OpenCtagsFile") {
APPL_INFO("Request opening ctag file"); APPL_INFO("Request opening ctag file");
std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::widget::FileChooser::create(); std::shared_ptr<ewol::widget::FileChooser> tmpWidget = ewol::widget::FileChooser::create();
if (nullptr == tmpWidget) { if (nullptr == tmpWidget) {
@ -195,9 +183,9 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer
tmpWidget->setFolder(path); tmpWidget->setFolder(path);
} }
ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget); ewol::getContext().getWindows()->popUpWidgetPush(tmpWidget);
tmpWidget->registerOnEvent(shared_from_this(), "validate", eventOpenCtagsOpenFileReturn); tmpWidget->signalValidate.bind(shared_from_this(), &appl::TextPluginCtags::onCallbackOpenCtagsOpenFileReturn);
return true; return true;
} else if (_msg.getMessage() == eventJumpDestination) { } else if (_shortCutName == "appl::TextPluginCtags::JumpDestination") {
if (_textDrawer.hasBuffer() == false) { if (_textDrawer.hasBuffer() == false) {
return false; return false;
} }
@ -215,7 +203,7 @@ bool appl::TextPluginCtags::onReceiveMessageViewer(appl::TextViewer& _textDrawer
} }
jumpTo(textToSearch); jumpTo(textToSearch);
return true; return true;
} else if (_msg.getMessage() == eventJumpBack) { } else if (_shortCutName == "appl::TextPluginCtags::JumpBack") {
if (_textDrawer.hasBuffer() == false) { if (_textDrawer.hasBuffer() == false) {
return false; return false;
} }

View File

@ -43,10 +43,11 @@ namespace appl {
public: public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer); virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, virtual bool onReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg); const std::string& _shortCutName);
// internal message : // callback function:
virtual void onReceiveMessage(const ewol::object::Message& _msg); void onCallbackOpenCtagsOpenFileReturn(const std::string& _value);
void onCallbackOpenCtagsSelectReturn(const std::string& _value);
}; };
}; };

View File

@ -25,6 +25,9 @@ namespace appl {
void init() { void init() {
appl::TextViewerPlugin::init(); appl::TextViewerPlugin::init();
} }
void init(const std::string& _name) {
appl::TextViewerPlugin::init(_name);
}
public: public:
DECLARE_FACTORY(TextViewerPluginData); DECLARE_FACTORY(TextViewerPluginData);
virtual ~TextViewerPluginData() { virtual ~TextViewerPluginData() {
@ -38,13 +41,21 @@ 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;
}
++it;
} }
TYPE* data = new TYPE(); TYPE* data = new TYPE();
if (data == nullptr) { if (data == nullptr) {
@ -55,13 +66,13 @@ namespace appl {
return data; return data;
} }
protected: // Wrap all element with their internal data: (do not use theses function) protected: // Wrap all element with their internal data: (do not use theses function)
bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, bool onReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) { const std::string& _shortCutName) {
TYPE* data = getDataRef(_textDrawer); TYPE* data = getDataRef(_textDrawer);
if (data == nullptr) { if (data == nullptr) {
return false; return false;
} }
return onReceiveMessageViewer(_textDrawer, _msg, *data); return onDataReceiveShortCut(_textDrawer, _shortCutName, *data);
} }
bool onWrite(appl::TextViewer& _textDrawer, bool onWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
@ -70,7 +81,7 @@ namespace appl {
if (data == nullptr) { if (data == nullptr) {
return false; return false;
} }
return onWrite(_textDrawer, _pos, _data, *data); return onDataWrite(_textDrawer, _pos, _data, *data);
} }
bool onReplace(appl::TextViewer& _textDrawer, bool onReplace(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
@ -80,7 +91,7 @@ namespace appl {
if (data == nullptr) { if (data == nullptr) {
return false; return false;
} }
return onReplace(_textDrawer, _pos, _data, _posEnd, *data); return onDataReplace(_textDrawer, _pos, _data, _posEnd, *data);
} }
bool onRemove(appl::TextViewer& _textDrawer, bool onRemove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
@ -89,29 +100,29 @@ namespace appl {
if (data == nullptr) { if (data == nullptr) {
return false; return false;
} }
return onRemove(_textDrawer, _pos, _posEnd, *data); return onDataRemove(_textDrawer, _pos, _posEnd, *data);
} }
public: public:
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, virtual bool onDataReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg, const std::string& _shortCutName,
TYPE& _data) { TYPE& _data) {
return false; return false;
} }
virtual bool onWrite(appl::TextViewer& _textDrawer, virtual bool onDataWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _strData, const std::string& _strData,
TYPE& _data) { TYPE& _data) {
return false; return false;
} }
virtual bool onReplace(appl::TextViewer& _textDrawer, virtual bool onDataReplace(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _strData, const std::string& _strData,
const appl::Buffer::Iterator& _posEnd, const appl::Buffer::Iterator& _posEnd,
TYPE& _data) { TYPE& _data) {
return false; return false;
} }
virtual bool onRemove(appl::TextViewer& _textDrawer, virtual bool onDataRemove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const appl::Buffer::Iterator& _posEnd, const appl::Buffer::Iterator& _posEnd,
TYPE& _data) { TYPE& _data) {

View File

@ -15,8 +15,11 @@
#undef __class__ #undef __class__
#define __class__ "TextPluginHistory" #define __class__ "TextPluginHistory"
appl::TextPluginHistory::TextPluginHistory() { appl::TextPluginHistory::TextPluginHistory() :
m_activateOnReceiveMessage = true; m_menuIdTitle(-1),
m_menuIdUndo(-1),
m_menuIdRedo(-1) {
m_activateOnReceiveShortCut = true;
m_activateOnWrite = true; m_activateOnWrite = true;
m_activateOnReplace = true; m_activateOnReplace = true;
m_activateOnRemove = true; m_activateOnRemove = true;
@ -29,24 +32,40 @@ void appl::TextPluginHistory::init() {
void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
std::shared_ptr<ewol::widget::Menu> 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 : // add event :
_textDrawer.ext_registerMultiCast(ednMsgGuiRedo); _textDrawer.ext_shortCutAdd("ctrl+z", "appl::TextPluginHistory::Undo");
_textDrawer.ext_registerMultiCast(ednMsgGuiUndo); _textDrawer.ext_shortCutAdd("ctrl+shift+z", "appl::TextPluginHistory::Redo");
_textDrawer.ext_shortCutAdd("ctrl+z", ednMsgGuiUndo);
_textDrawer.ext_shortCutAdd("ctrl+shift+z", ednMsgGuiRedo);
} }
void appl::TextPluginHistory::onPluginDisable(appl::TextViewer& _textDrawer) { 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<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
menu->remove(m_menuIdRedo);
menu->remove(m_menuIdUndo);
menu->remove(m_menuIdTitle);
}
m_menuIdTitle = -1;
m_menuIdUndo = -1;
m_menuIdRedo = -1;
} }
bool appl::TextPluginHistory::onReceiveMessageViewer(appl::TextViewer& _textDrawer, bool appl::TextPluginHistory::onDataReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg, const std::string& _shortCutName,
appl::PluginHistoryData& _data) { appl::PluginHistoryData& _data) {
if (isEnable() == false) { if (isEnable() == false) {
return false; return false;
} }
if (_msg.getMessage() == ednMsgGuiRedo) { if (_shortCutName == "appl::TextPluginHistory::Redo") {
if (_data.m_redo.size() == 0) { if (_data.m_redo.size() == 0) {
return true; return true;
} }
@ -62,7 +81,7 @@ bool appl::TextPluginHistory::onReceiveMessageViewer(appl::TextViewer& _textDraw
_textDrawer.position(tmpElement->m_endPosRemoved) ); _textDrawer.position(tmpElement->m_endPosRemoved) );
return true; return true;
} else if (_msg.getMessage() == ednMsgGuiUndo) { } else if (_shortCutName == "appl::TextPluginHistory::Undo") {
if (_data.m_undo.size() == 0) { if (_data.m_undo.size() == 0) {
return true; return true;
} }
@ -111,7 +130,7 @@ void appl::TextPluginHistory::clearUndo(appl::PluginHistoryData& _data) {
} }
bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer, bool appl::TextPluginHistory::onDataWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _strData, const std::string& _strData,
appl::PluginHistoryData& _data) { appl::PluginHistoryData& _data) {
@ -130,11 +149,14 @@ bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer,
clearRedo(_data); clearRedo(_data);
_data.m_undo.push_back(tmpElement); _data.m_undo.push_back(tmpElement);
} }
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor()); std::shared_ptr<appl::textPluginManager> mng = m_pluginManager.lock();
if (mng!=nullptr) {
mng->onCursorMove(_textDrawer, _textDrawer.cursor());
}
return true; return true;
} }
bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer, bool appl::TextPluginHistory::onDataReplace(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _strData, const std::string& _strData,
const appl::Buffer::Iterator& _posEnd, const appl::Buffer::Iterator& _posEnd,
@ -155,11 +177,14 @@ bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer,
clearRedo(_data); clearRedo(_data);
_data.m_undo.push_back(tmpElement); _data.m_undo.push_back(tmpElement);
} }
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor()); std::shared_ptr<appl::textPluginManager> mng = m_pluginManager.lock();
if (mng!=nullptr) {
mng->onCursorMove(_textDrawer, _textDrawer.cursor());
}
return true; return true;
} }
bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer, bool appl::TextPluginHistory::onDataRemove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const appl::Buffer::Iterator& _posEnd, const appl::Buffer::Iterator& _posEnd,
appl::PluginHistoryData& _data) { appl::PluginHistoryData& _data) {
@ -177,7 +202,10 @@ bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer,
_data.m_undo.push_back(tmpElement); _data.m_undo.push_back(tmpElement);
} }
_textDrawer.removeDirect(); _textDrawer.removeDirect();
appl::textPluginManager::onCursorMove(_textDrawer, _textDrawer.cursor()); std::shared_ptr<appl::textPluginManager> mng = m_pluginManager.lock();
if (mng!=nullptr) {
mng->onCursorMove(_textDrawer, _textDrawer.cursor());
}
return true; return true;
} }

View File

@ -36,6 +36,10 @@ namespace appl {
std::vector<History*> m_redo; //!< History storing data std::vector<History*> m_redo; //!< History storing data
}; };
class TextPluginHistory : public appl::TextViewerPluginData<appl::PluginHistoryData> { class TextPluginHistory : public appl::TextViewerPluginData<appl::PluginHistoryData> {
private:
int32_t m_menuIdTitle;
int32_t m_menuIdUndo;
int32_t m_menuIdRedo;
protected: protected:
TextPluginHistory(); TextPluginHistory();
void init(); void init();
@ -46,19 +50,19 @@ namespace appl {
public: public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(appl::TextViewer& _textDrawer); virtual void onPluginDisable(appl::TextViewer& _textDrawer);
virtual bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, virtual bool onDataReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg, const std::string& _shortCutName,
appl::PluginHistoryData& _data); appl::PluginHistoryData& _data);
virtual bool onWrite(appl::TextViewer& _textDrawer, virtual bool onDataWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _strData, const std::string& _strData,
appl::PluginHistoryData& _data); appl::PluginHistoryData& _data);
virtual bool onReplace(appl::TextViewer& _textDrawer, virtual bool onDataReplace(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _strData, const std::string& _strData,
const appl::Buffer::Iterator& _posEnd, const appl::Buffer::Iterator& _posEnd,
appl::PluginHistoryData& _data); appl::PluginHistoryData& _data);
virtual bool onRemove(appl::TextViewer& _textDrawer, virtual bool onDataRemove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const appl::Buffer::Iterator& _posEnd, const appl::Buffer::Iterator& _posEnd,
appl::PluginHistoryData& _data); appl::PluginHistoryData& _data);

View File

@ -19,53 +19,11 @@
#undef __class__ #undef __class__
#define __class__ "textPluginManager" #define __class__ "textPluginManager"
static std::list<std::shared_ptr<appl::TextViewerPlugin>>& getList() { appl::textPluginManager::textPluginManager() {
static std::list<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list;
}
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnEventEntry() {
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list;
}
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnEventInput() {
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list;
}
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnWrite() {
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list;
}
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnReplace() {
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list;
}
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnRemove() {
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list;
}
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListonReceiveMessageViewer() {
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list;
}
static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnCursorMove() {
static std::vector<std::shared_ptr<appl::TextViewerPlugin>> s_list;
return s_list;
}
void appl::textPluginManager::init() {
} }
void appl::textPluginManager::init(const std::string& _name) {
void appl::textPluginManager::unInit() { ewol::Resource::init(_name);
// remove all sub plugin class:
getListOnEventEntry().clear();
getListOnEventInput().clear();
getListOnWrite().clear();
getListOnReplace().clear();
getListOnRemove().clear();
getListonReceiveMessageViewer().clear();
getListOnCursorMove().clear();
getList().clear();
} }
void appl::textPluginManager::addDefaultPlugin() { void appl::textPluginManager::addDefaultPlugin() {
@ -82,32 +40,38 @@ void appl::textPluginManager::addPlugin(const std::shared_ptr<appl::TextViewerPl
if (_plugin == nullptr) { if (_plugin == nullptr) {
return; return;
} }
getList().push_back(_plugin); APPL_DEBUG("Add plugin : " << _plugin->getObjectType());
m_list.push_back(_plugin);
if (_plugin->isAvaillableOnEventEntry() == true) { if (_plugin->isAvaillableOnEventEntry() == true) {
getListOnEventEntry().push_back(_plugin); m_listOnEventEntry.push_back(_plugin);
} }
if (_plugin->isAvaillableOnEventInput() == true) { if (_plugin->isAvaillableOnEventInput() == true) {
getListOnEventInput().push_back(_plugin); m_listOnEventInput.push_back(_plugin);
} }
if (_plugin->isAvaillableOnWrite() == true) { if (_plugin->isAvaillableOnWrite() == true) {
getListOnWrite().push_back(_plugin); m_listOnWrite.push_back(_plugin);
} }
if (_plugin->isAvaillableOnReplace() == true) { if (_plugin->isAvaillableOnReplace() == true) {
getListOnReplace().push_back(_plugin); m_listOnReplace.push_back(_plugin);
} }
if (_plugin->isAvaillableOnRemove() == true) { if (_plugin->isAvaillableOnRemove() == true) {
getListOnRemove().push_back(_plugin); m_listOnRemove.push_back(_plugin);
} }
if (_plugin->isAvaillableOnReceiveMessage() == true) { if (_plugin->isAvaillableOnReceiveShortCut() == true) {
getListonReceiveMessageViewer().push_back(_plugin); m_listOnReceiveShortCutViewer.push_back(_plugin);
} }
if (_plugin->isAvaillableOnCursorMove() == true) { if (_plugin->isAvaillableOnCursorMove() == true) {
getListOnCursorMove().push_back(_plugin); m_listOnCursorMove.push_back(_plugin);
}
std::shared_ptr<appl::TextViewer> viewer = m_currentViewer.lock();
if (viewer != nullptr) {
_plugin->onPluginEnable(*viewer);
} }
} }
void appl::textPluginManager::connect(appl::TextViewer& _widget) { void appl::textPluginManager::connect(appl::TextViewer& _widget) {
for (auto &it : getList()) { m_currentViewer = std::dynamic_pointer_cast<appl::TextViewer>(_widget.shared_from_this());
for (auto &it : m_list) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
@ -116,7 +80,8 @@ void appl::textPluginManager::connect(appl::TextViewer& _widget) {
} }
void appl::textPluginManager::disconnect(appl::TextViewer& _widget) { void appl::textPluginManager::disconnect(appl::TextViewer& _widget) {
for (auto &it : getList()) { m_currentViewer.reset();
for (auto &it : m_list) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
@ -126,7 +91,7 @@ void appl::textPluginManager::disconnect(appl::TextViewer& _widget) {
bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer,
const ewol::event::Entry& _event) { const ewol::event::Entry& _event) {
for (auto &it : getListOnEventEntry()) { for (auto &it : m_listOnEventEntry) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
@ -139,7 +104,7 @@ bool appl::textPluginManager::onEventEntry(appl::TextViewer& _textDrawer,
bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer,
const ewol::event::Input& _event) { const ewol::event::Input& _event) {
for (auto &it : getListOnEventInput()) { for (auto &it : m_listOnEventInput) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
@ -153,7 +118,7 @@ bool appl::textPluginManager::onEventInput(appl::TextViewer& _textDrawer,
bool appl::textPluginManager::onWrite(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onWrite(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _data) { const std::string& _data) {
for (auto &it : getListOnWrite()) { for (auto &it : m_listOnWrite) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
@ -168,7 +133,7 @@ bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const std::string& _data, const std::string& _data,
const appl::Buffer::Iterator& _posEnd) { const appl::Buffer::Iterator& _posEnd) {
for (auto &it : getListOnReplace()) { for (auto &it : m_listOnReplace) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
@ -182,7 +147,7 @@ bool appl::textPluginManager::onReplace(appl::TextViewer& _textDrawer,
bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _pos,
const appl::Buffer::Iterator& _posEnd) { const appl::Buffer::Iterator& _posEnd) {
for (auto &it : getListOnRemove()) { for (auto &it : m_listOnRemove) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
@ -193,13 +158,13 @@ bool appl::textPluginManager::onRemove(appl::TextViewer& _textDrawer,
return false; return false;
} }
bool appl::textPluginManager::onReceiveMessageViewer(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) { const std::string& _shortCutName) {
for (auto &it : getListonReceiveMessageViewer()) { for (auto &it : m_listOnReceiveShortCutViewer) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
if (it->onReceiveMessageViewer(_textDrawer, _msg) == true ) { if (it->onReceiveShortCut(_textDrawer, _shortCutName) == true ) {
return true; return true;
} }
} }
@ -208,7 +173,7 @@ bool appl::textPluginManager::onReceiveMessageViewer(appl::TextViewer& _textDraw
bool appl::textPluginManager::onCursorMove(appl::TextViewer& _textDrawer, bool appl::textPluginManager::onCursorMove(appl::TextViewer& _textDrawer,
const appl::Buffer::Iterator& _pos) { const appl::Buffer::Iterator& _pos) {
for (auto &it : getListOnCursorMove()) { for (auto &it : m_listOnCursorMove) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }

View File

@ -16,15 +16,23 @@
#include <appl/TextPlugin.h> #include <appl/TextPlugin.h>
namespace appl { namespace appl {
namespace textPluginManager { class textPluginManager : public ewol::Resource {
/** private:
* @brief Init the plugin manager for writer. std::weak_ptr<appl::TextViewer> m_currentViewer;
*/ std::list<std::shared_ptr<appl::TextViewerPlugin>> m_list;
void init(); std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnEventEntry;
/** std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnEventInput;
* @brief UnInit the plugin manager for writer. std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnWrite;
*/ std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnReplace;
void unInit(); std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnRemove;
std::vector<std::shared_ptr<appl::TextViewerPlugin>> m_listOnReceiveShortCutViewer;
std::vector<std::shared_ptr<appl::TextViewerPlugin>> 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 * @brief Add default plugin list
*/ */
@ -95,11 +103,11 @@ namespace appl {
/** /**
* @brief Called when a message arrive. * @brief Called when a message arrive.
* @param[in] _widget Reference on the widget caller. * @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 * @return true if the event might not propagate anymore
*/ */
bool onReceiveMessageViewer(appl::TextViewer& _textDrawer, bool onReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg); const std::string& _shortCutName);
/** /**
* @brief Called when Cursor move of position. * @brief Called when Cursor move of position.
* @param[in] _widget Reference on the widget caller. * @param[in] _widget Reference on the widget caller.

View File

@ -16,7 +16,7 @@
appl::TextPluginRmLine::TextPluginRmLine() { appl::TextPluginRmLine::TextPluginRmLine() {
m_activateOnReceiveMessage = true; m_activateOnReceiveShortCut = true;
addObjectType("appl::TextPluginRmLine"); addObjectType("appl::TextPluginRmLine");
} }
@ -26,20 +26,19 @@ void appl::TextPluginRmLine::init() {
void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event : // add event :
_textDrawer.ext_registerMultiCast(ednMsgGuiRm); _textDrawer.ext_shortCutAdd("ctrl+w", "appl::TextPluginRmLine::Rm");
_textDrawer.ext_shortCutAdd("ctrl+w", ednMsgGuiRm);
} }
void appl::TextPluginRmLine::onPluginDisable(appl::TextViewer& _textDrawer) { void appl::TextPluginRmLine::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ... _textDrawer.ext_shortCutRm("appl::TextPluginRmLine::Rm");
} }
bool appl::TextPluginRmLine::onReceiveMessageViewer(appl::TextViewer& _textDrawer, bool appl::TextPluginRmLine::onReceiveShortCut(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) { const std::string& _shortCutName) {
if (isEnable() == false) { if (isEnable() == false) {
return false; return false;
} }
if (_msg.getMessage() == ednMsgGuiRm) { if (_shortCutName == "appl::TextPluginRmLine::Rm") {
if (_textDrawer.hasBuffer() == false) { if (_textDrawer.hasBuffer() == false) {
return false; return false;
} }

View File

@ -28,7 +28,7 @@ namespace appl {
public: public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(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);
}; };
}; };

View File

@ -15,8 +15,11 @@
#define __class__ "TextPluginSelectAll" #define __class__ "TextPluginSelectAll"
appl::TextPluginSelectAll::TextPluginSelectAll() { appl::TextPluginSelectAll::TextPluginSelectAll() :
m_activateOnReceiveMessage = true; m_menuIdTitle(-1),
m_menuIdSelectAll(-1),
m_menuIdSelectNone(-1) {
m_activateOnReceiveShortCut = true;
addObjectType("appl::TextPluginSelectAll"); addObjectType("appl::TextPluginSelectAll");
} }
@ -24,29 +27,53 @@ void appl::TextPluginSelectAll::init() {
appl::TextViewerPlugin::init(); appl::TextViewerPlugin::init();
} }
static const char* eventSelectAll = "plugin-select-all";
void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) { void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) {
std::shared_ptr<ewol::widget::Menu> 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 : // add event :
_textDrawer.ext_registerMultiCast(eventSelectAll); _textDrawer.ext_shortCutAdd("ctrl+a", "appl::TextPluginSelectAll::All");
_textDrawer.ext_shortCutAdd("ctrl+a", eventSelectAll); _textDrawer.ext_shortCutAdd("ctrl+shift+a", "appl::TextPluginSelectAll::None");
} }
void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) { 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<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
menu->remove(m_menuIdSelectNone);
menu->remove(m_menuIdSelectAll);
menu->remove(m_menuIdTitle);
}
m_menuIdTitle = -1;
m_menuIdSelectAll = -1;
m_menuIdSelectNone = -1;
} }
bool appl::TextPluginSelectAll::onReceiveMessageViewer(appl::TextViewer& _textDrawer,
const ewol::object::Message& _msg) { bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer,
const std::string& _shortCutName) {
if (isEnable() == false) { if (isEnable() == false) {
return false; return false;
} }
if (_msg.getMessage() == eventSelectAll) { if (_shortCutName == "appl::TextPluginSelectAll::All") {
if (_textDrawer.hasBuffer() == false) { if (_textDrawer.hasBuffer() == false) {
return false; return false;
} }
_textDrawer.select(_textDrawer.begin(), _textDrawer.end()); _textDrawer.select(_textDrawer.begin(), _textDrawer.end());
return true; return true;
} }
if (_shortCutName == "appl::TextPluginSelectAll::None") {
if (_textDrawer.hasBuffer() == false) {
return false;
}
_textDrawer.unSelect();
return true;
}
return false; return false;
} }

View File

@ -20,6 +20,9 @@ namespace appl {
protected: protected:
TextPluginSelectAll(); TextPluginSelectAll();
void init(); void init();
int32_t m_menuIdTitle;
int32_t m_menuIdSelectAll;
int32_t m_menuIdSelectNone;
public: public:
DECLARE_FACTORY(TextPluginSelectAll); DECLARE_FACTORY(TextPluginSelectAll);
virtual ~TextPluginSelectAll() { virtual ~TextPluginSelectAll() {
@ -28,7 +31,7 @@ namespace appl {
public: public:
virtual void onPluginEnable(appl::TextViewer& _textDrawer); virtual void onPluginEnable(appl::TextViewer& _textDrawer);
virtual void onPluginDisable(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);
}; };
}; };

View File

@ -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) m_static = true; // Note : set the object static notification( Must be set or assert at the end of process)
setName("edn_global_param"); 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 <ewol/widget/CheckBox.h> #include <ewol/widget/CheckBox.h>
#include <ewol/widget/Spacer.h> #include <ewol/widget/Spacer.h>
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() { globals::ParameterGlobalsGui::ParameterGlobalsGui() {
addObjectType("globals::ParameterGlobalsGui"); addObjectType("globals::ParameterGlobalsGui");
@ -189,7 +126,7 @@ void globals::ParameterGlobalsGui::init() {
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetAutoIndent()); myCheckbox->setValue(isSetAutoIndent());
myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeIndentation); myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackIndentation);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
myCheckbox = ewol::widget::CheckBox::create("Display space char (' ')"); myCheckbox = ewol::widget::CheckBox::create("Display space char (' ')");
@ -198,7 +135,7 @@ void globals::ParameterGlobalsGui::init() {
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplaySpaceChar()); myCheckbox->setValue(isSetDisplaySpaceChar());
myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeSpace); myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackSpace);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
myCheckbox = ewol::widget::CheckBox::create("Display tabulation char ('\\t')"); myCheckbox = ewol::widget::CheckBox::create("Display tabulation char ('\\t')");
@ -207,7 +144,7 @@ void globals::ParameterGlobalsGui::init() {
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayTabChar()); myCheckbox->setValue(isSetDisplayTabChar());
myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeTabulation); myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackTabulation);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
myCheckbox = ewol::widget::CheckBox::create("Display end of line ('\\n')"); myCheckbox = ewol::widget::CheckBox::create("Display end of line ('\\n')");
@ -216,7 +153,7 @@ void globals::ParameterGlobalsGui::init() {
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayEndOfLine()); myCheckbox->setValue(isSetDisplayEndOfLine());
myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeEndOfLine); myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackEndOfLine);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
myCheckbox = ewol::widget::CheckBox::create("switch Rounded/default"); myCheckbox = ewol::widget::CheckBox::create("switch Rounded/default");
@ -225,7 +162,7 @@ void globals::ParameterGlobalsGui::init() {
} else { } else {
myCheckbox->setExpand(bvec2(true,false)); myCheckbox->setExpand(bvec2(true,false));
myCheckbox->setValue(isSetDisplayEndOfLine()); myCheckbox->setValue(isSetDisplayEndOfLine());
myCheckbox->registerOnEvent(shared_from_this(), "clicked", l_changeRounded); myCheckbox->signalValue.bind(shared_from_this(), &globals::ParameterGlobalsGui::onCallbackRounded);
subWidgetAdd(myCheckbox); subWidgetAdd(myCheckbox);
} }
} }
@ -235,35 +172,22 @@ globals::ParameterGlobalsGui::~ParameterGlobalsGui() {
} }
void globals::ParameterGlobalsGui::onReceiveMessage(const ewol::object::Message& _msg) { void globals::ParameterGlobalsGui::onCallbackEndOfLine(const bool& _value) {
ewol::widget::Sizer::onReceiveMessage(_msg); setDisplayEndOfLine(_value);
}
if (_msg.getMessage() == l_changeEndOfLine) { void globals::ParameterGlobalsGui::onCallbackIndentation(const bool& _value) {
if (_msg.getData() == "true") { setAutoIndent(_value);
setDisplayEndOfLine(true); }
} else {
setDisplayEndOfLine(false); void globals::ParameterGlobalsGui::onCallbackSpace(const bool& _value) {
} setDisplaySpaceChar(_value);
} else if (_msg.getMessage() == l_changeIndentation) { }
if (_msg.getData() == "true") { void globals::ParameterGlobalsGui::onCallbackTabulation(const bool& _value) {
setAutoIndent(true); setDisplayTabChar(_value);
} else { }
setAutoIndent(false); void globals::ParameterGlobalsGui::onCallbackRounded(const bool& _value) {
} if (_value == true) {
} 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");; etk::theme::setName("GUI", "rounded");;
} else { } else {
etk::theme::setName("GUI", "default");; etk::theme::setName("GUI", "default");;
@ -271,7 +195,5 @@ void globals::ParameterGlobalsGui::onReceiveMessage(const ewol::object::Message&
// Reload shaders and graphic system ... // Reload shaders and graphic system ...
ewol::getContext().getResourcesManager().reLoadResources(); ewol::getContext().getResourcesManager().reLoadResources();
ewol::getContext().forceRedrawAll(); ewol::getContext().forceRedrawAll();
}
} }

View File

@ -43,8 +43,11 @@ namespace globals
public: public:
DECLARE_FACTORY(ParameterGlobalsGui); DECLARE_FACTORY(ParameterGlobalsGui);
virtual ~ParameterGlobalsGui(); virtual ~ParameterGlobalsGui();
// herited function void onCallbackEndOfLine(const bool& _value);
virtual void onReceiveMessage(const ewol::object::Message& _msg); void onCallbackIndentation(const bool& _value);
void onCallbackSpace(const bool& _value);
void onCallbackTabulation(const bool& _value);
void onCallbackRounded(const bool& _value);
}; };
} }

View File

@ -1,66 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/globalMsg.h>
////////////////////////////////////////////////////////////////////////
// Event of the gui request something :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgGuiNew = "edn-Msg-Gui-New";
extern const char* const ednMsgGuiOpen = "edn-Msg-Gui-Open";
extern const char* const ednMsgGuiClose = "edn-Msg-Gui-Close";
extern const char* const ednMsgGuiSave = "edn-Msg-Gui-Save";
extern const char* const ednMsgGuiSaveAs = "edn-Msg-Gui-SaveAs";
extern const char* const ednMsgProperties = "edn-Msg-Gui-Properties";
extern const char* const ednMsgGuiExit = "edn-Msg-Gui-quit";
extern const char* const ednMsgGuiUndo = "edn-Msg-Gui-Undo";
extern const char* const ednMsgGuiRedo = "edn-Msg-Gui-Redo";
extern const char* const ednMsgGuiCopy = "edn-Msg-Gui-Copy";
extern const char* const ednMsgGuiCut = "edn-Msg-Gui-Cut";
extern const char* const ednMsgGuiPaste = "edn-Msg-Gui-Paste";
extern const char* const ednMsgGuiRm = "edn-Msg-Gui-Rm";
extern const char* const ednMsgGuiSelect = "edn-Msg-Gui-Select";
extern const char* const ednMsgGuiGotoLine = "edn-Msg-Gui-GotoLine";
extern const char* const ednMsgGuiSearch = "edn-Msg-Gui-Search";
extern const char* const ednMsgGuiReplace = "edn-Msg-Gui-Replace";
extern const char* const ednMsgGuiFind = "edn-Msg-Gui-Find";
extern const char* const ednMsgGuiShowSpaces = "edn-Msg-Gui-ShowSpaces";
extern const char* const ednMsgGuiShowEndOfLine = "edn-Msg-Gui-ShowEndOfLine";
extern const char* const ednMsgGuiCtags = "edn-Msg-Gui-CTags";
extern const char* const ednMsgCtagsLoadFile = "edn-Msg-CTags-direct-load";
extern const char* const ednMsgGuiReloadShader = "edn-Msg-Gui-ReloadOpenGlShader";
////////////////////////////////////////////////////////////////////////
// Event internal :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgBufferState = "edn-Msg-Buffer-State";
extern const char* const ednMsgBufferName = "edn-Msg-Buffer-Name";
extern const char* const ednMsgBufferId = "edn-Msg-Buffer-Id";
extern const char* const ednMsgCodeViewSelectedId = "edn-Msg-CodeView-Select-Id";
extern const char* const ednMsgOpenFile = "edn-Msg-OpenFile";
extern const char* const ednMsgBufferListChange = "edn-Msg-BufferListChange";
extern const char* const ednMsgBufferColor = "edn-Msg-Buffer-Color";
extern const char* const appl::MsgSelectNewFile = "edn-msg-select-new-file";
extern const char* const appl::MsgSelectChange = "edn-msg-select-change";
extern const char* const appl::MsgNameChange = "edn-msg-buffer-name-change";
extern const char* const appl::MsgNameGuiChangeColor = "edn-Msg-Gui-Change-color";
extern const char* const appl::MsgSelectGotoLine = "edn-Msg-Gui-goto-line";
extern const char* const appl::MsgSelectGotoLineSelect = "edn-Msg-Gui-goto-line-select";

View File

@ -1,68 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#ifndef __MSG_BROADCAST_H__
#define __MSG_BROADCAST_H__
////////////////////////////////////////////////////////////////////////
// Event of the gui request something :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgGuiNew; // data : ""
extern const char* const ednMsgGuiOpen; // data : ""
extern const char* const ednMsgGuiClose; // data : "current" "All"
extern const char* const ednMsgGuiSave; // data : ""
extern const char* const ednMsgGuiSaveAs; // data : ""
extern const char* const ednMsgProperties; // data : ""
extern const char* const ednMsgGuiExit; // data : ""
extern const char* const ednMsgGuiUndo; // data : ""
extern const char* const ednMsgGuiRedo; // data : ""
extern const char* const ednMsgGuiCopy; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgGuiCut; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgGuiPaste; // data : "STD" "Middle" "1" ... "9"
extern const char* const ednMsgGuiRm; // data : "Word" "Line" "Paragraph"
extern const char* const ednMsgGuiSelect; // data : "ALL" "NONE"
extern const char* const ednMsgGuiGotoLine; // data : "???" / "1" ... "999999999999"
extern const char* const ednMsgGuiSearch; // data : ""
extern const char* const ednMsgGuiReplace; // data : "Normal" "All"
extern const char* const ednMsgGuiFind; // data : "Next" "Previous" "All" "None"
extern const char* const ednMsgGuiShowSpaces; // data : "enable" "disable"
extern const char* const ednMsgGuiShowEndOfLine; // data : "enable" "disable"
extern const char* const ednMsgGuiCtags; // data : "Load" "ReLoad" "Jump" "Back"
extern const char* const ednMsgCtagsLoadFile; // data : "filename of the ctags file"
extern const char* const ednMsgGuiReloadShader; // data : ""
////////////////////////////////////////////////////////////////////////
// Event internal :
////////////////////////////////////////////////////////////////////////
extern const char* const ednMsgBufferState; // data : "Saved" "Modify" "HasHistory" "HasNotHistory" "HasFutureHistory" "HasNotFutureHistory"
extern const char* const ednMsgBufferName; // data : "filename"
extern const char* const ednMsgBufferId; // data : "0" ... "99999999999"
extern const char* const ednMsgCodeViewSelectedId; // data : "0" ... "99999999999"
extern const char* const ednMsgOpenFile; // data : "/Compleate/file/name.xx"
extern const char* const ednMsgBufferListChange; // data : ""
extern const char* const ednMsgBufferColor; // data : "new"
namespace appl {
extern const char* const MsgSelectNewFile; // data : "buffer/name"
extern const char* const MsgSelectChange; // data : ""
extern const char* const MsgNameChange; // data : ""
extern const char* const MsgNameGuiChangeColor; // data : "Black" "White"
extern const char* const MsgSelectGotoLine; // data : "75822"
extern const char* const MsgSelectGotoLineSelect; // data : "75822"
};
#endif

View File

@ -32,6 +32,7 @@
class MainApplication : public ewol::context::Application { class MainApplication : public ewol::context::Application {
private: private:
std::shared_ptr<appl::BufferManager> m_bufferManager; std::shared_ptr<appl::BufferManager> m_bufferManager;
std::shared_ptr<appl::textPluginManager> m_pluginManager;
public: public:
bool init(ewol::Context& _context, size_t _initId) { bool init(ewol::Context& _context, size_t _initId) {
APPL_INFO(" == > init APPL v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")"); APPL_INFO(" == > init APPL v" << APPL_VERSION << " (START) [" << ewol::getBoardType() << "] (" << ewol::getCompilationMode() << ")");
@ -58,10 +59,9 @@ class MainApplication : public ewol::context::Application {
// init ALL Singleton : // init ALL Singleton :
//()CTagsManager::getInstance(); //()CTagsManager::getInstance();
m_bufferManager = appl::BufferManager::create(); m_bufferManager = appl::BufferManager::create();
m_pluginManager = appl::textPluginManager::create();
appl::highlightManager::init(); appl::highlightManager::init();
appl::textPluginManager::init();
appl::textPluginManager::addDefaultPlugin();
// Request load of the user configuration ... // Request load of the user configuration ...
//ewol::userConfig::load(); //ewol::userConfig::load();
@ -84,6 +84,8 @@ class MainApplication : public ewol::context::Application {
// create the specific windows // create the specific windows
_context.setWindows(basicWindows); _context.setWindows(basicWindows);
// need to add default plugin, because they depend on the Menu widget wich might be named : "appl-menu-interface"
m_pluginManager->addDefaultPlugin();
// add files // add files
APPL_INFO("show list of files : "); APPL_INFO("show list of files : ");
@ -97,7 +99,7 @@ class MainApplication : public ewol::context::Application {
std::string name = file.getName(); std::string name = file.getName();
APPL_INFO("Load ctag file : \"" << name << "\"" ); APPL_INFO("Load ctag file : \"" << name << "\"" );
ctagDetected = false; ctagDetected = false;
_context.getEObjectManager().multiCast().anonymousSend(ednMsgCtagsLoadFile, name); //_context.getEObjectManager().multiCast().anonymousSend(ednMsgCtagsLoadFile, name);
} else { } else {
etk::FSNode file(tmpppp); etk::FSNode file(tmpppp);
std::string name = file.getName(); std::string name = file.getName();
@ -111,10 +113,10 @@ class MainApplication : public ewol::context::Application {
} }
void unInit(ewol::Context& _context) { void unInit(ewol::Context& _context) {
APPL_INFO(" == > Un-Init " PROJECT_NAME " (START)"); APPL_INFO(" == > Un-Init " PROJECT_NAME " (START)");
appl::textPluginManager::unInit();
APPL_INFO("Stop Hightlight"); APPL_INFO("Stop Hightlight");
appl::highlightManager::unInit(); appl::highlightManager::unInit();
//Kill all singleton //Kill all singleton
m_pluginManager.reset();
m_bufferManager.reset(); m_bufferManager.reset();
APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)"); APPL_INFO(" == > Un-Init " PROJECT_NAME " (END)");
} }

View File

@ -102,9 +102,12 @@ def create(target):
myModule.compile_flags_CC([ myModule.compile_flags_CC([
"-DAPPL_VERSION=\"\\\"" + versionID + "\\\"\"" "-DAPPL_VERSION=\"\\\"" + versionID + "\\\"\""
]) ])
tagFile = tools.get_current_path(__file__) + "/tagCode"
versionIDCode = tools.file_read_data(tagFile)
# set the package properties : # set the package properties :
myModule.pkg_set("VERSION", versionID) myModule.pkg_set("VERSION", versionID)
myModule.pkg_set("VERSION_CODE", versionIDCode)
myModule.pkg_set("COMPAGNY_TYPE", "org") myModule.pkg_set("COMPAGNY_TYPE", "org")
myModule.pkg_set("COMPAGNY_NAME", "Edouard DUPIN") myModule.pkg_set("COMPAGNY_NAME", "Edouard DUPIN")
myModule.pkg_set("MAINTAINER", ["Mr DUPIN Edouard <yui.heero@gmail.com>"]) myModule.pkg_set("MAINTAINER", ["Mr DUPIN Edouard <yui.heero@gmail.com>"])

View File

@ -1 +1 @@
1.2.1 1.2.2

1
sources/tagCode Normal file
View File

@ -0,0 +1 @@
6