diff --git a/data/GUI-Search.xml b/data/GUI-Search.xml
new file mode 100644
index 0000000..faf2210
--- /dev/null
+++ b/data/GUI-Search.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sources/appl/Buffer.cpp b/sources/appl/Buffer.cpp
index 76afca7..0512090 100644
--- a/sources/appl/Buffer.cpp
+++ b/sources/appl/Buffer.cpp
@@ -27,7 +27,6 @@ appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ (void) {
if (m_data != NULL) {
if (m_current < m_data->m_data.size() ) {
int8_t nbChar = etk::UChar::theoricUTF8Len(m_data->m_data[m_current]);
- APPL_DEBUG("get pos=" << m_current << "len=" << nbChar);
if (nbChar != 0) {
m_current+=nbChar;
} else {
@@ -38,7 +37,6 @@ appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ (void) {
m_current = m_data->m_data.size();
}
}
- APPL_DEBUG(" ==> return " << m_current);
return *this;
}
@@ -231,7 +229,6 @@ appl::Buffer::Iterator appl::Buffer::getEndLine(const appl::Buffer::Iterator& _p
bool appl::Buffer::search(const appl::Buffer::Iterator& _pos, const char32_t& _search, appl::Buffer::Iterator& _result) {
// move in the string
- char32_t value;
for (Iterator it = _pos;
(bool)it == true;
++it) {
@@ -246,7 +243,6 @@ bool appl::Buffer::search(const appl::Buffer::Iterator& _pos, const char32_t& _s
bool appl::Buffer::searchBack(const appl::Buffer::Iterator& _pos, const char32_t& _search, appl::Buffer::Iterator& _result) {
// move in the string
- char32_t value;
for (Iterator it = _pos - 1;
(bool)it == true;
--it) {
@@ -261,9 +257,150 @@ bool appl::Buffer::searchBack(const appl::Buffer::Iterator& _pos, const char32_t
return false;
}
+bool appl::Buffer::search(const appl::Buffer::Iterator& _pos,
+ const std::u32string& _search,
+ appl::Buffer::Iterator& _result,
+ bool _caseSensitive) {
+ if (_search.size() <= 0 ) {
+ return false;
+ }
+ if (_caseSensitive == true) {
+ // move in the string
+ for (Iterator it = _pos;
+ (bool)it == true;
+ ++it) {
+ if (*it == _search[0]) {
+ // find the first char ==> check next...
+ bool find = true;
+ Iterator tmp = it;
+ for (size_t iii=0; iii<_search.size(); ++iii) {
+ if (*tmp != _search[iii]) {
+ find = false;
+ break;
+ }
+ ++tmp;
+ if ((bool)tmp == false) {
+ if (iii != _search.size()-1) {
+ find = false;
+ }
+ break;
+ }
+ }
+ if (find == true) {
+ _result = it;
+ return true;
+ }
+ }
+ }
+ } else {
+ char32_t firstElement = tolower(_search[0]);
+ // move in the string
+ for (Iterator it = _pos;
+ (bool)it == true;
+ ++it) {
+ if (tolower(*it) == firstElement) {
+ // find the first char ==> check next...
+ bool find = true;
+ Iterator tmp = it;
+ for (size_t iii=0; iii<_search.size(); ++iii) {
+ if (tolower(*tmp) != tolower(_search[iii])) {
+ find = false;
+ break;
+ }
+ ++tmp;
+ if ((bool)tmp == false) {
+ if (iii != _search.size()-1) {
+ find = false;
+ }
+ break;
+ }
+ }
+ if (find == true) {
+ _result = it;
+ return true;
+ }
+ }
+ }
+ }
+ _result = end();
+ return false;
+}
+
+bool appl::Buffer::searchBack(const appl::Buffer::Iterator& _pos,
+ const std::u32string& _search,
+ appl::Buffer::Iterator& _result,
+ bool _caseSensitive) {
+ if (_search.size() <= 0 ) {
+ return false;
+ }
+ char32_t lastElement = _search[_search.size()-1];
+ if (_caseSensitive == true) {
+ // move in the string
+ for (Iterator it = _pos - 1;
+ (bool)it == true;
+ --it) {
+ //APPL_DEBUG("compare : " << *it << " ?= " << _search);
+ if (*it == lastElement) {
+ // find the last char ==> check previous...
+ bool find = true;
+ _result = it;
+ for (int64_t iii=_search.size()-1; iii>=0; --iii) {
+ if (*_result != _search[iii]) {
+ find = false;
+ break;
+ }
+ --_result;
+ if ((bool)_result == false) {
+ if (iii != 0) {
+ find = false;
+ }
+ break;
+ }
+ }
+ if (find == true) {
+ _result++;
+ return true;
+ }
+ }
+ }
+ } else {
+ lastElement = tolower(lastElement);
+ // move in the string
+ for (Iterator it = _pos - 1;
+ (bool)it == true;
+ --it) {
+ //APPL_DEBUG("compare : " << *it << " ?= " << _search);
+ if (tolower(*it) == lastElement) {
+ // find the last char ==> check previous...
+ bool find = true;
+ _result = it;
+ for (int64_t iii=_search.size()-1; iii>=0; --iii) {
+ if (tolower(*_result) != tolower(_search[iii])) {
+ find = false;
+ break;
+ }
+ --_result;
+ if ((bool)_result == false) {
+ if (iii != 0) {
+ find = false;
+ }
+ break;
+ }
+ }
+ if (find == true) {
+ _result++;
+ return true;
+ }
+ }
+ }
+ }
+ _result = begin();
+ return false;
+}
+
void appl::Buffer::moveCursor(int64_t _pos) {
m_cursorPreferredCol = -1;
- APPL_DEBUG("move cursor : " << _pos << "/" << m_data.size());
+ APPL_VERBOSE("move cursor : " << _pos << "/" << m_data.size());
// selecting mode ...
if (m_selectMode == true) {
if (m_cursorSelectPos == -1) {
diff --git a/sources/appl/Buffer.h b/sources/appl/Buffer.h
index e63e050..c316a27 100644
--- a/sources/appl/Buffer.h
+++ b/sources/appl/Buffer.h
@@ -247,6 +247,13 @@ namespace appl {
}
return tmpp;
};
+ Iterator operator+ (const size_t _val) const {
+ Iterator tmpp(*this);
+ for (int64_t iii=0; iii<_val; ++iii) {
+ ++tmpp;
+ }
+ return tmpp;
+ };
/**
* @brief move the element position
* @return a new iterator.
@@ -265,6 +272,13 @@ namespace appl {
}
return tmpp;
};
+ Iterator operator- (const size_t _val) const {
+ Iterator tmpp(*this);
+ for (int64_t iii=0; iii<_val; ++iii) {
+ --tmpp;
+ }
+ return tmpp;
+ };
private:
Iterator(Buffer* _obj, int64_t _pos) :
m_current(_pos),
@@ -349,7 +363,7 @@ namespace appl {
*/
void setSelectionPos(const Iterator& _pos);
/**
- * @brief Un select request.
+ * @brief Remove Selection of the buffer.
*/
void unSelect(void);
/**
@@ -446,6 +460,7 @@ namespace appl {
* @param[out] _result Research position.
* @return true if pos if fined.
*/
+ // TODO : rename find
bool search(const Iterator& _pos, const char32_t& _search, Iterator& _result);
/**
* @brief Search a character in the buffer in back mode.
@@ -454,7 +469,28 @@ namespace appl {
* @param[out] _result Research position.
* @return true if pos if fined.
*/
+ // TODO : rename rfind
bool searchBack(const Iterator& _pos, const char32_t& _search, Iterator& _result);
+ /**
+ * @brief Search a string in the buffer.
+ * @param[in] _pos Position to start the search of the element.
+ * @param[in] _search String to search.
+ * @param[out] _result Research position.
+ * @param[in] _caseSensitive (optional) Search making attention of the case [default true]
+ * @return true if pos if fined.
+ */
+ // TODO : rename find
+ bool search(const Iterator& _pos, const std::u32string& _search, Iterator& _result, bool _caseSensitive = true);
+ /**
+ * @brief Search a string in the buffer in back mode.
+ * @param[in] _pos Position to start the search of the element.
+ * @param[in] _search String to search.
+ * @param[out] _result Research position.
+ * @param[in] _caseSensitive (optional) Search making attention of the case [default true]
+ * @return true if pos if fined.
+ */
+ // TODO : rename rfind
+ bool searchBack(const Iterator& _pos, const std::u32string& _search, Iterator& _result, bool _caseSensitive = true);
/**
* @brief find the first character of the line "nLines" forward
* @param[in] _startPos Start position.
diff --git a/sources/appl/BufferManager.cpp b/sources/appl/BufferManager.cpp
index 3682d7f..4ec6163 100644
--- a/sources/appl/BufferManager.cpp
+++ b/sources/appl/BufferManager.cpp
@@ -136,394 +136,3 @@ void appl::BufferManager::release(appl::BufferManager*& _object) {
getManager().release(object2);
_object = NULL;
}
-
-
-
-#ifdef QSGDQSDFGSDFGSDFGZS8DFGHD_sDFGSDFGDGT
-
-
-class classBufferManager: public ewol::EObject {
- public:
- // Constructeur
- classBufferManager(void);
- ~classBufferManager(void);
- public:
- virtual void onReceiveMessage(const ewol::EMessage& _msg);
- private:
- // return the ID of the buffer allocated
- // create a buffer with no element
- int32_t create(void);
- // open curent filename
- int32_t open(etk::FSNode &myFile);
- bool remove(int32_t BufferID);
- public:
- int32_t getSelected(void) { return m_idSelected;};
- //void setSelected(int32_t id) {m_idSelected = id;};
- BufferText* get(int32_t BufferID);
- bool exist(int32_t BufferID);
- bool exist(etk::FSNode &myFile);
- int32_t getId(etk::FSNode &myFile);
- // return the number of buffer (open in the past) if 5 buffer open and 4 close == > return 5
- uint32_t size(void);
- uint32_t sizeOpen(void);
- int32_t witchBuffer(int32_t iEmeElement);
-
-
- private:
-
- std::vector listBuffer; //!< element List of the char Elements
-
- void removeAll(void); //!< remove all buffer
- int32_t m_idSelected;
-};
-
-
-// Constructeur
-classBufferManager::classBufferManager(void)
-{
- m_idSelected = -1;
- RegisterMultiCast(ednMsgGuiNew);
- RegisterMultiCast(ednMsgOpenFile);
- RegisterMultiCast(ednMsgGuiClose);
- RegisterMultiCast(ednMsgGuiSave);
- RegisterMultiCast(ednMsgCodeViewSelectedId);
- RegisterMultiCast(ednMsgBufferId);
-}
-
-classBufferManager::~classBufferManager(void)
-{
- //clean All Buffer
- APPL_INFO("~classBufferManager::removeAll();");
- removeAll();
- // clear The list of Buffer
- APPL_INFO("~classBufferManager::listBuffer.clear();");
- listBuffer.clear();
-}
-
-
-void classBufferManager::onReceiveMessage(const ewol::EMessage& _msg)
-{
- ewol::EObject::onReceiveMessage(_msg);
-
- if (_msg.getMessage() == ednMsgBufferId) {
- // select a new buffer ID :
- if (_msg.getData() == "") {
- APPL_ERROR("Request select buffer ID = \"\" ");
- } else {
- int32_t newID = -1;
- sscanf(_msg.getData().c_str(), "%d", &newID);
- if(true == Exist(newID)) {
- m_idSelected = newID;
- } else {
- m_idSelected = -1;
- APPL_ERROR("Request a non existant ID : " << newID << " reset to -1...");
- }
- }
- } else if (_msg.getMessage() == ednMsgGuiNew) {
- int32_t newOne = Create();
- if (-1 != newOne) {
- m_idSelected = newOne;
- SendMultiCast(ednMsgBufferId, m_idSelected);
- SendMultiCast(ednMsgBufferListChange);
- }
- } else if (_msg.getMessage() == ednMsgOpenFile) {
- if (_msg.getData() != "" ) {
- etk::FSNode myFile(_msg.getData());
- if (myFile.getNodeType() == etk::FSN_FILE) {
- APPL_DEBUG("request open file = \"" << _msg.getData() << "\" ?= \"" << myFile << "\"");
- int32_t newOne = open(myFile);
- if (-1 != newOne) {
- m_idSelected = newOne;
- SendMultiCast(ednMsgBufferId, m_idSelected);
- SendMultiCast(ednMsgBufferListChange);
- } else {
- // TODO : notify user that we can not open the request file...
- APPL_ERROR("Can not open the file : \"" << myFile << "\"");
- }
- } else {
- APPL_ERROR("Request to open an Unknox element file : " << myFile << " type:" << myFile.getNodeType());
- }
- }
- } else if (_msg.getMessage() == ednMsgGuiSave) {
- if (_msg.getData() == "") {
- APPL_ERROR("Null data for close file ... ");
- } else {
- if (_msg.getData() == "current") {
- // Check buffer existence
- if(true == Exist(m_idSelected)) {
- // If no name == > request a Gui display ...
- if (get(m_idSelected)->haveName() == false) {
- SendMultiCast(ednMsgGuiSaveAs, "current");
- } else {
- get(m_idSelected)->Save();
- }
- }
- } else {
- int32_t newId;
- sscanf(_msg.getData().c_str(), "%d", &newId);
- if (false == Exist(newId)) {
- APPL_ERROR("Request a save As with a non existant ID=" << newId);
- } else {
- // If no name == > request a Gui display ...
- if (get(newId)->haveName() == false) {
- SendMultiCast(ednMsgGuiSaveAs, newId);
- } else {
- get(m_idSelected)->Save();
- }
- }
- SendMultiCast(ednMsgBufferState, "saved");
- }
- }
- } else if (_msg.getMessage() == ednMsgGuiClose) {
- if (_msg.getData() == "") {
- APPL_ERROR("Null data for close file ... ");
- } else {
- if (_msg.getData() == "All") {
-
- } else {
- int32_t closeID = -1;
- if (_msg.getData() == "current") {
- closeID = m_idSelected;
- APPL_DEBUG("Close specific buffer ID" << closeID);
- } else {
- // close specific buffer ...
- sscanf(_msg.getData().c_str(), "%d", &closeID);
- APPL_DEBUG("Close specific buffer ID="<< closeID);
- }
- if(true == Exist(closeID)) {
- // get the new display buffer
- if (m_idSelected == closeID) {
- // Try previous buffer
- int32_t destBuffer = -1;
- for(int32_t ii=closeID-1; ii >= 0; ii--) {
- if (true == Exist(ii) ) {
- destBuffer = ii;
- break;
- }
- }
- // try next buffer
- if (-1 == destBuffer) {
- for(int32_t ii=closeID+1; ii < listBuffer.size(); ii++) {
- if (true == Exist(ii) ) {
- destBuffer = ii;
- break;
- }
- }
- }
- // set it to the currect display
- m_idSelected = destBuffer;
- SendMultiCast(ednMsgBufferId, destBuffer);
- }
- // remove requested buffer
- remove(closeID);
- SendMultiCast(ednMsgBufferListChange);
- } else {
- APPL_ERROR("Request close of a non existant ID : " << closeID);
- }
- }
- }
- } else if (_msg.getMessage() == ednMsgCodeViewSelectedId) {
- //Change the selected buffer
- if (_msg.getData() == "") {
- APPL_ERROR("Null data for changing buffer ID file ... ");
- } else {
- int32_t newId;
- sscanf(_msg.getData().c_str(), "%d", &newId);
- if (true == Exist(newId)) {
- m_idSelected = newId;
- } else {
- APPL_ERROR("code biew request the selection of an non -existant buffer == > reset to -1");
- m_idSelected = -1;
- }
- SendMultiCast(ednMsgBufferId, m_idSelected);
- SendMultiCast(ednMsgBufferListChange);
- }
- }
- /*
- switch (id)
- {
- // Check buffer existence
- if(true == Exist(dataID)) {
- // If no name == > request a Gui display ...
- if (get(dataID)->haveName() == false) {
- SendMessage(APPL_MSG__GUI_SHOW_SAVE_AS, dataID);
- } else {
- get(dataID)->Save();
- }
- }
- break;
- }
- */
-}
-
-void classBufferManager::removeAll(void) {
- int32_t i;
- for (i=0; i we open it ...
- return getId(myFile);
- }
-}
-
-BufferText * classBufferManager::get(int32_t BufferID) {
- // possible special case : -1;
- if (-1 >= BufferID) {
- return NULL;
- }
- // check if the Buffer existed
- if (BufferID < listBuffer.size()) {
- // check if the buffer already existed
- if (NULL != listBuffer[BufferID]) {
- return listBuffer[BufferID];
- } else {
- APPL_ERROR("non existing Buffer " << BufferID);
- }
- } else {
- APPL_ERROR("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.size());
- }
- return NULL;
-}
-
-bool classBufferManager::exist(int32_t BufferID) {
- if (-1 >= BufferID) {
- return false;
- }
- // check if the Buffer existed
- if (BufferID < listBuffer.size()) {
- // check if the buffer already existed
- if (NULL != listBuffer[BufferID]) {
- return true;
- }
- }
- return false;
-}
-
-bool classBufferManager::exist(etk::FSNode &myFile) {
- if (-1 == getId(myFile)) {
- return false;
- }
- return true;
-}
-
-int32_t classBufferManager::getId(etk::FSNode &myFile) {
- int32_t iii;
- // check if the Buffer existed
- for (iii=0; iii < listBuffer.size(); iii++) {
- // check if the buffer already existed
- if (NULL != listBuffer[iii]) {
- if ( listBuffer[iii]->getFileName() == myFile) {
- return iii;
- }
- }
- }
- return -1;
-}
-
-
-// return the number of buffer (open in the past) if 5 buffer open and 4 close == > return 5
-uint32_t classBufferManager::size(void) {
- return listBuffer.size();
-}
-
-// nb of opens file Now ...
-uint32_t classBufferManager::sizeOpen(void) {
- uint32_t jjj = 0;
- // check if the Buffer existed
- for (int32_t iii=0; iii= BufferID) {
- return false;
- }
- // check if the Buffer existed
- if (BufferID < listBuffer.size()) {
- // check if the buffer already existed
- if (NULL != listBuffer[BufferID]) {
- // TODO : Check if it saved...
- /*
- if (false == isSaved(BufferID) ) {
- APPL_INFO("Buffer " << BufferID << " : Not Saved", BufferID);
- }
- */
- // Delete the Buffer
- delete( listBuffer[BufferID] );
- listBuffer[BufferID] = NULL;
- /*
- ewol::widgetMessageMultiCast::Send(getWidgetId(), ednMsgBufferListChange);
- */
- return true;
- } else {
- APPL_INFO("non existing Buffer " << BufferID);
- return false;
- }
- } else {
- APPL_INFO("call an non existing Buffer number too hight : " << BufferID << " > " << listBuffer.size());
- return false;
- }
-}
-
-/**
- * @brief to get the element 14 in the buffer
- */
-int32_t classBufferManager::witchBuffer(int32_t iEmeElement) {
- int32_t i;
- for (i=0; i
+#include
#include
#include
#include
diff --git a/sources/appl/Gui/BufferView.cpp b/sources/appl/Gui/BufferView.cpp
index 2b1dbc8..7c55b54 100644
--- a/sources/appl/Gui/BufferView.cpp
+++ b/sources/appl/Gui/BufferView.cpp
@@ -8,10 +8,10 @@
#include
#include
-#include
-#include
+#include
+#include
//#include
-#include
+#include
#include
#undef __class__
diff --git a/sources/appl/Gui/BufferView.h b/sources/appl/Gui/BufferView.h
index 947e1b1..bd165ff 100644
--- a/sources/appl/Gui/BufferView.h
+++ b/sources/appl/Gui/BufferView.h
@@ -10,7 +10,7 @@
#define __BUFFER_VIEW_H__
#include
-#include
+#include
#include
#include
#include
diff --git a/sources/appl/Gui/MainWindows.cpp b/sources/appl/Gui/MainWindows.cpp
index 84aefef..f8d1ce8 100644
--- a/sources/appl/Gui/MainWindows.cpp
+++ b/sources/appl/Gui/MainWindows.cpp
@@ -9,10 +9,10 @@
#include
#include
-#include
-#include
-#include
-#include
+#include
+#include
+#include
+#include
#include
#include
@@ -37,10 +37,8 @@
#include
#include
-namespace appl
-{
- std::string getVersion(void)
- {
+namespace appl {
+ std::string getVersion(void) {
#define FIRST_YEAR (2010)
std::string tmpOutput = std::to_string(date::getYear()-FIRST_YEAR);
tmpOutput += ".";
@@ -482,7 +480,7 @@ void MainWindows::closeNotSavedFile(appl::Buffer* _buffer) {
popUpWidgetPush(tmpPopUp);
}
-void MainWindows::onObjectRemove(ewol::EObject * _removeObject) {
+void MainWindows::onObjectRemove(ewol::EObject* _removeObject) {
ewol::Windows::onObjectRemove(_removeObject);
if (m_widgetLabelFileName == _removeObject) {
m_widgetLabelFileName = NULL;
diff --git a/sources/appl/Gui/Search.cpp b/sources/appl/Gui/Search.cpp
index abc7b30..6a8e3f1 100644
--- a/sources/appl/Gui/Search.cpp
+++ b/sources/appl/Gui/Search.cpp
@@ -7,15 +7,12 @@
*/
#include "appl/global.h"
-#include "Search.h"
-#include "SearchData.h"
+#include "appl/Gui/Search.h"
#include "appl/BufferManager.h"
+#include "appl/Gui/TextViewer.h"
#include "appl/Gui/MainWindows.h"
#include "appl/globalMsg.h"
-#include
-#include
-
#undef __class__
#define __class__ "Search"
@@ -32,217 +29,118 @@ const char* const l_eventForwardCb = "appl-forward-CheckBox";
const char* const l_eventHideBt = "appl-hide-button";
Search::Search(void) :
- widget::Sizer(widget::Sizer::modeHori),
+ widget::Composer(widget::Composer::file, "DATA:GUI-Search.xml"),
+ m_viewerManager(NULL),
+ m_forward(true),
+ m_caseSensitive(false),
+ m_wrap(true),
m_searchEntry(NULL),
m_replaceEntry(NULL) {
addObjectType("appl::Search");
- m_forward = false;
- // TODO : change the mode of creating interface :
- /*
-
-
-
-
-
-
-
-
-
-
-
-
- */
- widget::Button * myButtonImage = NULL;
- myButtonImage = new widget::Button();
- if (NULL == myButtonImage) {
- APPL_ERROR("Widget allocation error == > it will missing in the display");
- } else {
- widget::Image* tmpImage = new widget::Image("THEME:GUI:Remove.svg");
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidget(tmpImage);
- myButtonImage->registerOnEvent(this, widget::Button::eventPressed, l_eventHideBt);
- subWidgetAdd(myButtonImage);
- }
-
- m_searchEntry = new widget::Entry();
- if (NULL == m_searchEntry) {
- APPL_ERROR("Widget allocation error == > it will missing in the display");
- } else {
- m_searchEntry->registerOnEvent(this, widget::Entry::eventModify, l_eventSearchEntry);
- m_searchEntry->registerOnEvent(this, widget::Entry::eventEnter, l_eventSearchEntryEnter);
- m_searchEntry->setExpand(bvec2(true,false));
- m_searchEntry->setFill(bvec2(true,false));
- subWidgetAdd(m_searchEntry);
- }
-
- myButtonImage = new widget::Button();
- if (NULL == myButtonImage) {
- APPL_ERROR("Widget allocation error == > it will missing in the display");
- } else {
- widget::Image* tmpImage = new widget::Image("THEME:GUI:Search.svg");
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidget(tmpImage);
- myButtonImage->registerOnEvent(this, widget::Button::eventPressed, l_eventSearchBt);
- subWidgetAdd(myButtonImage);
- }
-
- m_replaceEntry = new widget::Entry();
- if (NULL == m_replaceEntry) {
- APPL_ERROR("Widget allocation error == > it will missing in the display");
- } else {
- m_replaceEntry->registerOnEvent(this, widget::Entry::eventModify, l_eventReplaceEntry);
- m_replaceEntry->registerOnEvent(this, widget::Entry::eventEnter, l_eventReplaceEntryEnter);
- m_replaceEntry->setExpand(bvec2(true,false));
- m_replaceEntry->setFill(bvec2(true,false));
- subWidgetAdd(m_replaceEntry);
- }
-
- myButtonImage = new widget::Button();
- if (NULL == myButtonImage) {
- APPL_ERROR("Widget allocation error == > it will missing in the display");
- } else {
- widget::Image* tmpImage = new widget::Image("THEME:GUI:Replace.svg");
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidget(tmpImage);
- myButtonImage->registerOnEvent(this, widget::Button::eventPressed, l_eventReplaceBt);
- subWidgetAdd(myButtonImage);
- }
-
- myButtonImage = new widget::Button();
- if (NULL == myButtonImage) {
- APPL_ERROR("Widget allocation error == > it will missing in the display");
- } else {
- myButtonImage->setToggleMode(true);
-
- widget::Image* tmpImage = new widget::Image("THEME:GUI:CaseSensitive.svg");
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidget(tmpImage);
-
- tmpImage = new widget::Image("THEME:GUI:CaseSensitive.svg"); // TODO : set color on Image .... 0xFFFFFF5F
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidgetToggle(tmpImage);
-
- myButtonImage->setValue(!SearchData::getCase());
- myButtonImage->registerOnEvent(this, widget::Button::eventPressed, l_eventCaseCb);
- subWidgetAdd(myButtonImage);
- }
-
- myButtonImage = new widget::Button();
- if (NULL == myButtonImage) {
- APPL_ERROR("Widget allocation error == > it will missing in the display");
- } else {
- myButtonImage->setToggleMode(true);
-
- widget::Image* tmpImage = new widget::Image("THEME:GUI:WrapAround.svg");
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidget(tmpImage);
-
- tmpImage = new widget::Image("THEME:GUI:WrapAround.svg"); // TODO : set color on Image .... 0xFFFFFF5F
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidgetToggle(tmpImage);
-
- myButtonImage->setValue(!SearchData::getWrap());
- myButtonImage->registerOnEvent(this, widget::Button::eventPressed, l_eventWrapCb);
- subWidgetAdd(myButtonImage);
- }
-
- myButtonImage = new widget::Button();
- if (NULL == myButtonImage) {
- APPL_ERROR("Widget allocation error == > it will missing in the display");
- } else {
- myButtonImage->setToggleMode(true);
-
- widget::Image* tmpImage = new widget::Image("THEME:GUI:Up.svg");
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidget(tmpImage);
-
- tmpImage = new widget::Image("THEME:GUI:Down.svg");
- tmpImage->setImageSize(ewol::Dimension(vec2(8,8), ewol::Dimension::Millimeter));
- myButtonImage->setSubWidgetToggle(tmpImage);
-
- myButtonImage->setValue(!m_forward);
- myButtonImage->registerOnEvent(this, widget::Button::eventPressed, l_eventForwardCb);
- subWidgetAdd(myButtonImage);
- }
-
+ // load buffer manager:
+ m_viewerManager = appl::ViewerManager::keep();
+ // link event
+ registerOnEventNameWidget(this, "SEARCH:close", "pressed", l_eventHideBt);
+ registerOnEventNameWidget(this, "SEARCH:search-entry", "modify", l_eventSearchEntry);
+ registerOnEventNameWidget(this, "SEARCH:search-entry", "enter", l_eventSearchEntryEnter);
+ registerOnEventNameWidget(this, "SEARCH:search", "pressed", l_eventSearchBt);
+ registerOnEventNameWidget(this, "SEARCH:replace-entry", "modify", l_eventReplaceEntry);
+ registerOnEventNameWidget(this, "SEARCH:replace-entry", "enter", l_eventReplaceEntryEnter);
+ registerOnEventNameWidget(this, "SEARCH:replace", "pressed", l_eventReplaceBt);
+ registerOnEventNameWidget(this, "SEARCH:case", "value", l_eventCaseCb);
+ registerOnEventNameWidget(this, "SEARCH:wrap", "value", l_eventWrapCb);
+ registerOnEventNameWidget(this, "SEARCH:up-down", "value", l_eventForwardCb);
+ // set default properties
+ setConfigNamed("SEARCH:case", "value", std::to_string(m_caseSensitive));
+ setConfigNamed("SEARCH:wrap", "value", std::to_string(m_wrap));
+ setConfigNamed("SEARCH:up-down", "value", std::to_string(m_forward));
+ // get widget
+ m_searchEntry = dynamic_cast(getWidgetNamed("SEARCH:search-entry"));
+ m_replaceEntry = dynamic_cast(getWidgetNamed("SEARCH:replace-entry"));
+ // Display and hide event:
registerMultiCast(ednMsgGuiSearch);
// basicly hiden ...
hide();
}
Search::~Search(void) {
-
+ appl::ViewerManager::release(m_viewerManager);
+}
+
+void Search::find(void) {
+ if (m_viewerManager == NULL) {
+ APPL_WARNING("No viewer manager selected!!!");
+ return;
+ }
+ appl::TextViewer* viewer = m_viewerManager->getViewerSelected();
+ if (viewer == NULL) {
+ APPL_INFO("No viewer selected!!!");
+ return;
+ }
+ viewer->unSelect();
+ appl::Buffer::Iterator resultStart;
+ appl::Buffer::Iterator resultStop;
+ if (m_forward == true) {
+ if (viewer->find(viewer->cursor(), m_searchData, resultStart, resultStop, m_caseSensitive) == false) {
+ if ( m_wrap == false
+ || viewer->find(viewer->begin(), m_searchData, resultStart, resultStop, m_caseSensitive) == false) {
+ // TODO : Display an IHM pop-up
+ APPL_WARNING("No element find ...");
+ return;
+ }
+ }
+ viewer->select(resultStart, resultStop);
+ } else {
+ if (viewer->rfind(viewer->cursor(), m_searchData, resultStart, resultStop, m_caseSensitive) == false) {
+ if ( m_wrap == false
+ || viewer->rfind(viewer->end(), m_searchData, resultStart, resultStop, m_caseSensitive) == false) {
+ // TODO : Display an IHM pop-up
+ APPL_WARNING("No element find ...");
+ return;
+ }
+ }
+ viewer->select(resultStop, resultStart);
+ }
+}
+
+void Search::replace(void) {
+ if (m_viewerManager == NULL) {
+ APPL_WARNING("No viewer manager selected!!!");
+ return;
+ }
+ appl::TextViewer* viewer = m_viewerManager->getViewerSelected();
+ if (viewer == NULL) {
+ APPL_INFO("No viewer selected!!!");
+ return;
+ }
+ if (viewer->hasTextSelected() == false) {
+ // nothing to replace ...
+ return;
+ }
+ viewer->replace(m_replaceData);
}
void Search::onReceiveMessage(const ewol::EMessage& _msg) {
- widget::Sizer::onReceiveMessage(_msg);
- //APPL_INFO("Search receive message : \"" << eventId << "\" data=\"" << data << "\"");
+ widget::Composer::onReceiveMessage(_msg);
+ APPL_INFO("Search receive message : " << _msg);
if ( _msg.getMessage() == l_eventSearchEntry) {
- SearchData::setSearch(_msg.getData());
- } else if ( _msg.getMessage() == l_eventSearchEntryEnter) {
- SearchData::setSearch(_msg.getData());
- if (true == m_forward) {
- sendMultiCast(ednMsgGuiFind, "Previous");
- } else {
- sendMultiCast(ednMsgGuiFind, "Next");
- }
+ m_searchData = to_u32string(_msg.getData());
+ } else if ( _msg.getMessage() == l_eventSearchEntryEnter
+ || _msg.getMessage() == l_eventSearchBt) {
+ find();
} else if ( _msg.getMessage() == l_eventReplaceEntry) {
- SearchData::setReplace(_msg.getData());
- } else if ( _msg.getMessage() == l_eventReplaceEntryEnter) {
- SearchData::setReplace(_msg.getData());
- sendMultiCast(ednMsgGuiReplace, "Normal");
- if (true == m_forward) {
- sendMultiCast(ednMsgGuiFind, "Previous");
- } else {
- sendMultiCast(ednMsgGuiFind, "Next");
- }
- } else if ( _msg.getMessage() == l_eventSearchBt) {
- if (true == m_forward) {
- sendMultiCast(ednMsgGuiFind, "Previous");
- } else {
- sendMultiCast(ednMsgGuiFind, "Next");
- }
- } else if ( _msg.getMessage() == l_eventReplaceBt) {
- sendMultiCast(ednMsgGuiReplace, "Normal");
- if (true == m_forward) {
- sendMultiCast(ednMsgGuiFind, "Previous");
- } else {
- sendMultiCast(ednMsgGuiFind, "Next");
- }
+ m_replaceData = to_u32string(_msg.getData());
+ } else if ( _msg.getMessage() == l_eventReplaceEntryEnter
+ || _msg.getMessage() == l_eventReplaceBt) {
+ replace();
+ find();
} else if ( _msg.getMessage() == l_eventCaseCb) {
- if (_msg.getData() == "true") {
- SearchData::setCase(false);
- } else {
- SearchData::setCase(true);
- }
+ m_caseSensitive = stobool(_msg.getData());
} else if ( _msg.getMessage() == l_eventWrapCb) {
- if (_msg.getData() == "true") {
- SearchData::setWrap(false);
- } else {
- SearchData::setWrap(true);
- }
+ m_wrap = stobool(_msg.getData());
} else if ( _msg.getMessage() == l_eventForwardCb) {
- if (_msg.getData() == "true") {
- m_forward = false;
- } else {
- m_forward = true;
- }
+ m_forward = stobool(_msg.getData());
} else if ( _msg.getMessage() == l_eventHideBt) {
hide();
} else if ( _msg.getMessage() == ednMsgGuiSearch) {
@@ -265,12 +163,15 @@ void Search::onReceiveMessage(const ewol::EMessage& _msg) {
}
void Search::onObjectRemove(ewol::EObject * _removeObject) {
- widget::Sizer::onObjectRemove(_removeObject);
+ widget::Composer::onObjectRemove(_removeObject);
if (_removeObject == m_searchEntry) {
m_searchEntry = NULL;
}
if (_removeObject == m_replaceEntry) {
m_replaceEntry = NULL;
}
+ if (_removeObject == m_viewerManager) {
+ m_viewerManager = NULL;
+ }
}
diff --git a/sources/appl/Gui/Search.h b/sources/appl/Gui/Search.h
index c9853ab..f61c660 100644
--- a/sources/appl/Gui/Search.h
+++ b/sources/appl/Gui/Search.h
@@ -10,19 +10,35 @@
#define __SEARCH_H__
#include
-#include
+#include
#include
+#include
+#include
-class Search : public widget::Sizer
+class Search : public widget::Composer
{
private:
+ appl::ViewerManager* m_viewerManager; //!< handle on the buffer manager
bool m_forward;
- widget::Entry * m_searchEntry;
- widget::Entry * m_replaceEntry;
+ bool m_caseSensitive;
+ bool m_wrap;
+ widget::Entry* m_searchEntry;
+ widget::Entry* m_replaceEntry;
+ std::u32string m_searchData;
+ std::u32string m_replaceData;
public:
// Constructeur
Search(void);
~Search(void);
+ private:
+ /**
+ * @brief Find the next element that corespond at the search
+ */
+ void find(void);
+ /**
+ * @brief Replace the current selected text.
+ */
+ void replace(void);
public: // derived function
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
diff --git a/sources/appl/Gui/SearchData.cpp b/sources/appl/Gui/SearchData.cpp
deleted file mode 100644
index 552336e..0000000
--- a/sources/appl/Gui/SearchData.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#include
-#include
-
-
-#undef __class__
-#define __class__ "SearchData"
-
-
-static std::string m_findRequest = "";
-
-void SearchData::setSearch(const std::string &myData)
-{
- m_findRequest = myData;
-}
-void SearchData::getSearch(std::string &myData)
-{
- myData = m_findRequest;
-}
-bool SearchData::isSearchEmpty(void)
-{
- if(m_findRequest.size() > 0) {
- return false;
- }
- return true;
-}
-
-static std::string m_replaceRequest = "";
-void SearchData::setReplace(const std::string &myData)
-{
- m_replaceRequest = myData;
-}
-void SearchData::getReplace(std::string &myData)
-{
- myData = m_replaceRequest;
-}
-bool SearchData::isReplaceEmpty(void)
-{
- if(m_replaceRequest.size() > 0) {
- return false;
- }
- return true;
-}
-
-
-static bool m_case = false;
-void SearchData::setCase(bool value)
-{
- m_case = value;
-}
-bool SearchData::getCase(void)
-{
- return m_case;
-}
-
-
-static bool m_wrap = true;
-void SearchData::setWrap(bool value)
-{
- m_wrap = value;
-}
-bool SearchData::getWrap(void)
-{
- return m_wrap;
-}
-
-
-static bool m_RegExp = false;
-void SearchData::setRegExp(bool value)
-{
- m_RegExp = value;
-}
-bool SearchData::getRegExp(void)
-{
- return m_RegExp;
-}
-
-
diff --git a/sources/appl/Gui/SearchData.h b/sources/appl/Gui/SearchData.h
deleted file mode 100644
index 3abe786..0000000
--- a/sources/appl/Gui/SearchData.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * @author Edouard DUPIN
- *
- * @copyright 2010, Edouard DUPIN, all right reserved
- *
- * @license GPL v3 (see license file)
- */
-
-#ifndef __SEARCH_DATA_H__
-#define __SEARCH_DATA_H__
-
-#include
-#include
-
-namespace SearchData
-{
- void setSearch(const std::string &myData);
- void getSearch(std::string &myData);
- bool isSearchEmpty(void);
- void setReplace(const std::string &myData);
- void getReplace(std::string &myData);
- bool isReplaceEmpty(void);
- void setCase(bool value);
- bool getCase(void);
- void setWrap(bool value);
- bool getWrap(void);
- void setRegExp(bool value);
- bool getRegExp(void);
-}
-
-
-#endif
diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp
index a8c2370..c181cb1 100644
--- a/sources/appl/Gui/TextViewer.cpp
+++ b/sources/appl/Gui/TextViewer.cpp
@@ -8,13 +8,12 @@
#include
#include
-#include
-#include
-//#include
+#include
+#include
#include
-#include
#include
+#include
#include
#include
@@ -51,6 +50,7 @@ appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) :
// load buffer manager:
m_bufferManager = appl::BufferManager::keep();
+ m_viewerManager = appl::ViewerManager::keep();
// load color properties
m_paintingProperties = appl::GlyphPainting::keep("THEME:COLOR:textViewer.json");
@@ -79,12 +79,9 @@ appl::TextViewer::TextViewer(const std::string& _fontName, int32_t _fontSize) :
appl::TextViewer::~TextViewer(void) {
appl::textPluginManager::disconnect(*this);
- if (m_paintingProperties != NULL) {
- appl::GlyphPainting::release(m_paintingProperties);
- }
- if (m_bufferManager != NULL) {
- appl::BufferManager::release(m_bufferManager);
- }
+ appl::GlyphPainting::release(m_paintingProperties);
+ appl::BufferManager::release(m_bufferManager);
+ appl::ViewerManager::release(m_viewerManager);
}
bool appl::TextViewer::calculateMinSize(void) {
@@ -211,6 +208,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
m_buffer->hightlightGenerateLines(displayLocalSyntax, (int64_t)startingIt, m_size.y());
float maxSizeX = 0;
appl::HighlightInfo * HLColor = NULL;
+ bool DisplayCursorAndSelection = isSelectedLast();
appl::Buffer::Iterator it;
for (it = startingIt;
(bool)it == true;
@@ -226,7 +224,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
countColomn = 0;
maxSizeX = etk_max(m_displayText.getPos().x(), maxSizeX);
// Display the end line position only if we have the focus ...
- if (getFocus() == true) {
+ if (DisplayCursorAndSelection == true) {
if (it >= selectPosStart && it < selectPosStop) {
ewol::Drawing& draw = m_displayText.getDrawing();
draw.setColor(etk::Color<>(0xFF0000FF));
@@ -265,7 +263,7 @@ void appl::TextViewer::onRegenerateDisplay(void) {
}
m_buffer->expand(countColomn, *it, stringToDisplay);
// Display selection only if we have the focus ...
- if (getFocus() == true) {
+ if (DisplayCursorAndSelection == true) {
if (it >= selectPosStart && it < selectPosStop) {
m_displayText.setColor((*m_paintingProperties)[m_colorSelection].getForeground());
m_displayText.setColorBg((*m_paintingProperties)[m_colorSelection].getBackground());
@@ -687,12 +685,12 @@ void appl::TextViewer::updateScrolling(void) {
m_displayText.forceLineReturn();
}
realCursorPosition.setY(-m_displayText.getPos().y());
- realCursorPosition.setX(getScreenSize(m_buffer->getStartLine(m_buffer->cursor())+1, m_buffer->cursor())-10);
+ realCursorPosition.setX(getScreenSize(m_buffer->getStartLine(m_buffer->cursor()), m_buffer->cursor()));
APPL_VERBOSE("position=" << realCursorPosition << " scrool=" << m_originScrooled << " size" << m_size);
- if (realCursorPosition.x() < m_originScrooled.x()-lineSize*2.0f) {
+ if (realCursorPosition.x() < m_originScrooled.x()+lineSize*2.0f) {
m_originScrooled.setX(realCursorPosition.x()-lineSize*2.0f);
- } else if (realCursorPosition.x() > m_originScrooled.x()+m_size.x()-lineSize*2.0f-10) {
- m_originScrooled.setX(realCursorPosition.x()-m_size.x()+lineSize*2.0f+10);
+ } else if (realCursorPosition.x() > m_originScrooled.x()+(m_size.x()-m_lastOffsetDisplay)-lineSize*2.0f-10) {
+ m_originScrooled.setX(realCursorPosition.x()-(m_size.x()-m_lastOffsetDisplay)+lineSize*2.0f+10);
}
if (realCursorPosition.y() < m_originScrooled.y()+lineSize*2.0f) {
m_originScrooled.setY(realCursorPosition.y()-lineSize*2.0f);
@@ -704,7 +702,6 @@ void appl::TextViewer::updateScrolling(void) {
}
bool appl::TextViewer::moveCursor(const appl::Buffer::Iterator& _pos) {
- APPL_ERROR(" request move cursor : " << (int64_t)_pos);
if (m_buffer == NULL) {
return false;
}
@@ -713,7 +710,6 @@ bool appl::TextViewer::moveCursor(const appl::Buffer::Iterator& _pos) {
updateScrolling();
return true;
}
- APPL_ERROR(" call move cursor : " << (int64_t)_pos);
m_buffer->moveCursor((int64_t)_pos);
updateScrolling();
return true;
@@ -795,9 +791,7 @@ void appl::TextViewer::moveCursorRight(appl::TextViewer::moveMode _mode) {
default:
case moveLetter:
it = m_buffer->cursor();
- APPL_ERROR("Cursor position : " << (int64_t)it);
++it;
- APPL_ERROR("Cursor position new : " << (int64_t)it);
moveCursor(it);
break;
case moveWord:
@@ -821,7 +815,6 @@ void appl::TextViewer::moveCursorLeft(appl::TextViewer::moveMode _mode) {
case moveLetter:
it = m_buffer->cursor();
--it;
- APPL_ERROR("Cursor position : " << (int64_t)it);
moveCursor(it);
break;
case moveWord:
@@ -849,7 +842,6 @@ void appl::TextViewer::moveCursorUp(uint32_t _nbLine) {
if (m_buffer->getFavoriteUpDownPos() < 0) {
m_buffer->setFavoriteUpDownPos(getScreenSize(lineStartPos, m_buffer->cursor()));
}
- EWOL_DEBUG("move_up : " << m_buffer->getFavoriteUpDownPos());
// get the previous line
appl::Buffer::Iterator prevLineStartPos = m_buffer->countBackwardNLines(lineStartPos-1, _nbLine);
//APPL_INFO("Move line UP result : prevLineStartPos=" << prevLineStartPos);
@@ -876,7 +868,6 @@ void appl::TextViewer::moveCursorDown(uint32_t _nbLine) {
if (m_buffer->getFavoriteUpDownPos() < 0) {
m_buffer->setFavoriteUpDownPos(getScreenSize(lineStartPos, m_buffer->cursor()));
}
- EWOL_DEBUG("move down : " << m_buffer->getFavoriteUpDownPos());
// get the next line :
appl::Buffer::Iterator nextLineStartPos = m_buffer->countForwardNLines(lineStartPos, _nbLine);
//APPL_INFO("Move line DOWN result : nextLineStartPos=" << nextLineStartPos);
@@ -942,21 +933,15 @@ float appl::TextViewer::getScreenSize(const appl::Buffer::Iterator& _startLinePo
return ret;
}
-appl::TextViewer* appl::TextViewer::m_currentBufferSelect = NULL;
-
void appl::TextViewer::setCurrentSelect(void) {
- if (this == m_currentBufferSelect) {
- return;
- }
- m_currentBufferSelect = this;
- if (m_bufferManager != NULL) {
- m_bufferManager->setBufferSelected(m_buffer);
+ if (m_viewerManager != NULL) {
+ m_viewerManager->setViewerSelected(this, m_buffer);
}
}
bool appl::TextViewer::isSelectedLast(void) {
- if (this == m_currentBufferSelect) {
- return true;
+ if (m_viewerManager != NULL) {
+ return m_viewerManager->isLastSelected(this);
}
return false;
}
diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h
index 46472e5..5027743 100644
--- a/sources/appl/Gui/TextViewer.h
+++ b/sources/appl/Gui/TextViewer.h
@@ -17,6 +17,7 @@
#include
#include
#include
+#include
#include
namespace appl {
@@ -42,6 +43,7 @@ namespace appl {
esize_t m_colorNormal;
private:
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
+ appl::ViewerManager* m_viewerManager; //!< handle on the buffer manager
public:
TextViewer(const std::string& _fontName="", int32_t _fontSize=-1);
virtual ~TextViewer(void);
@@ -81,6 +83,9 @@ namespace appl {
bool write(const std::string& _data, const appl::Buffer::Iterator& _pos);
bool replace(const std::string& _data, const appl::Buffer::Iterator& _pos, const appl::Buffer::Iterator& _posEnd);
bool replace(const std::string& _data);
+ bool replace(const std::u32string& _data) {
+ return replace(to_u8string(_data));
+ }
void remove(void);
@@ -117,7 +122,6 @@ namespace appl {
appl::Buffer::Iterator getPosSize(const appl::Buffer::Iterator& _startLinePos, float _distance);
float getScreenSize(const appl::Buffer::Iterator& _startLinePos, const appl::Buffer::Iterator& _stopPos);
private:
- static TextViewer* m_currentBufferSelect; //!< to know which buffer is currently last selected
/**
* @brief Set the current buffer selected
*/
@@ -127,6 +131,121 @@ namespace appl {
* @return true if selected last
*/
bool isSelectedLast(void);
+ public:
+ /**
+ * @brief Check if the buffer is availlable
+ * @return true if a display buffer is present, false otherwise.
+ */
+ virtual bool hasBuffer(void) {
+ return m_buffer != NULL;
+ }
+ /**
+ * @brief Get the status of selection.
+ * @return true if we have a current selection, false otherwise.
+ */
+ virtual bool hasTextSelected(void) {
+ if (m_buffer==NULL) {
+ return false;
+ }
+ return m_buffer->hasTextSelected();
+ }
+ /**
+ * @brief Remove Selection of the buffer.
+ */
+ virtual void unSelect(void) {
+ if (m_buffer==NULL) {
+ return;
+ }
+ m_buffer->unSelect();
+ }
+ /**
+ * @brief Select a section of text.
+ * @param[in] _start Start position of the selection
+ * @param[in] _stop Stop position of the selection (the curor is set at this position)
+ */
+ virtual void select(appl::Buffer::Iterator& _start, appl::Buffer::Iterator& _stop) {
+ if (m_buffer==NULL) {
+ return;
+ }
+ moveCursor(_stop);
+ m_buffer->setSelectionPos(_start);
+ }
+ /**
+ * @brief Find a string in the buffer.
+ * @param[in] _pos Position to start the search of the element.
+ * @param[in] _search String to search.
+ * @param[out] _resultStart Find element start position.
+ * @param[out] _resultStop Find element end position.
+ * @param[in] _caseSensitive (optional) Search making attention of the case [default true]
+ * @return true if pos if fined.
+ */
+ virtual bool find(const appl::Buffer::Iterator& _pos,
+ const std::u32string& _search,
+ appl::Buffer::Iterator& _resultStart,
+ appl::Buffer::Iterator& _resultStop,
+ bool _caseSensitive = true) {
+ if (m_buffer==NULL) {
+ return false;
+ }
+ bool ret = m_buffer->search(_pos, _search, _resultStart, _caseSensitive);
+ if (ret == true) {
+ _resultStop = _resultStart + _search.size();
+ }
+ return ret;
+ }
+ /**
+ * @brief revers find a string in the buffer.
+ * @param[in] _pos Position to start the search of the element.
+ * @param[in] _search String to search.
+ * @param[out] _resultStart Find element start position.
+ * @param[out] _resultStop Find element end position.
+ * @param[in] _caseSensitive (optional) Search making attention of the case [default true]
+ * @return true if pos if fined.
+ */
+ virtual bool rfind(const appl::Buffer::Iterator& _pos,
+ const std::u32string& _search,
+ appl::Buffer::Iterator& _resultStart,
+ appl::Buffer::Iterator& _resultStop,
+ bool _caseSensitive = true) {
+ if (m_buffer==NULL) {
+ return false;
+ }
+ bool ret = m_buffer->searchBack(_pos, _search, _resultStart, _caseSensitive);
+ if (ret == true) {
+ _resultStop = _resultStart + _search.size();
+ }
+ return ret;
+ }
+ /**
+ * @brief Get the cursor position.
+ * @return The iterator on the cursor position
+ */
+ appl::Buffer::Iterator cursor(void) {
+ if (m_buffer==NULL) {
+ return appl::Buffer::Iterator();
+ }
+ return m_buffer->cursor();
+ }
+ /**
+ * @brief Get the begin position.
+ * @return The iterator on the begin position
+ */
+ appl::Buffer::Iterator begin(void) {
+ if (m_buffer==NULL) {
+ return appl::Buffer::Iterator();
+ }
+ return m_buffer->begin();
+ }
+ /**
+ * @brief Get the end position.
+ * @return The iterator on the end position
+ */
+ appl::Buffer::Iterator end(void) {
+ if (m_buffer==NULL) {
+ return appl::Buffer::Iterator();
+ }
+ return m_buffer->end();
+ }
};
};
diff --git a/sources/appl/Gui/ViewerManager.cpp b/sources/appl/Gui/ViewerManager.cpp
new file mode 100644
index 0000000..9ed4473
--- /dev/null
+++ b/sources/appl/Gui/ViewerManager.cpp
@@ -0,0 +1,77 @@
+/**
+ * @author Edouard DUPIN
+ *
+ * @copyright 2010, Edouard DUPIN, all right reserved
+ *
+ * @license GPL v3 (see license file)
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#undef __class__
+#define __class__ "ViewerManager"
+
+appl::ViewerManager::ViewerManager(void) :
+ ewol::Resource("???ViewerManager???"),
+ m_viewer(NULL) {
+ addObjectType("appl::ViewerManager");
+ // load buffer manager:
+ m_bufferManager = appl::BufferManager::keep();
+}
+
+appl::ViewerManager::~ViewerManager(void) {
+ appl::BufferManager::release(m_bufferManager);
+}
+
+void appl::ViewerManager::setViewerSelected(appl::TextViewer* _viewer, appl::Buffer* _buffer) {
+ if (m_viewer == _viewer) {
+ return;
+ }
+ m_viewer = _viewer;
+ if (m_bufferManager != NULL) {
+ m_bufferManager->setBufferSelected(_buffer);
+ }
+}
+
+void appl::ViewerManager::onReceiveMessage(const ewol::EMessage& _msg) {
+ APPL_DEBUG("receive message !!! " << _msg);
+}
+
+void appl::ViewerManager::onObjectRemove(ewol::EObject* _removeObject) {
+ ewol::Resource:: onObjectRemove(_removeObject);
+ if (_removeObject == m_viewer) {
+ m_viewer = NULL;
+ return;
+ }
+}
+
+appl::ViewerManager* appl::ViewerManager::keep(void) {
+ //EWOL_INFO("KEEP : appl::GlyphPainting : file : \"" << _filename << "\"");
+ appl::ViewerManager* object = static_cast(getManager().localKeep("???ViewerManager???"));
+ if (NULL != object) {
+ return object;
+ }
+ // this element create a new one every time ....
+ EWOL_INFO("CREATE : appl::ViewerManager: ???ViewerManager???");
+ object = new appl::ViewerManager();
+ if (NULL == object) {
+ EWOL_ERROR("allocation error of a resource : ???ViewerManager???");
+ return NULL;
+ }
+ getManager().localAdd(object);
+ return object;
+}
+
+void appl::ViewerManager::release(appl::ViewerManager*& _object) {
+ if (NULL == _object) {
+ return;
+ }
+ ewol::Resource* object2 = static_cast(_object);
+ getManager().release(object2);
+ _object = NULL;
+}
diff --git a/sources/appl/Gui/ViewerManager.h b/sources/appl/Gui/ViewerManager.h
new file mode 100644
index 0000000..d3850e1
--- /dev/null
+++ b/sources/appl/Gui/ViewerManager.h
@@ -0,0 +1,68 @@
+/**
+ * @author Edouard DUPIN
+ *
+ * @copyright 2010, Edouard DUPIN, all right reserved
+ *
+ * @license GPL v3 (see license file)
+ */
+
+#ifndef __VIEWER_MANAGER_H__
+#define __VIEWER_MANAGER_H__
+
+#include
+#include
+#include
+#include
+#include
+
+namespace appl {
+ class TextViewer;
+ class ViewerManager : public ewol::Resource {
+ protected:
+ ViewerManager(void);
+ ~ViewerManager(void);
+ private:
+ appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
+ appl::TextViewer* m_viewer;
+ public:
+ /**
+ * @brief Set the current buffer selected
+ * @param[in] _viewer Pointer on the viewer selected
+ */
+ void setViewerSelected(appl::TextViewer* _viewer, appl::Buffer* _buffer);
+ /**
+ * @brief Get the current buffer selected
+ * @return Pointer on the buffer selected
+ */
+ appl::TextViewer* getViewerSelected(void) {
+ return m_viewer;
+ };
+ /**
+ * @breif Check if the element is the last request selection
+ * @param[in] _viewer element selected.
+ * @return true if the element is selected
+ */
+ bool isLastSelected(appl::TextViewer* _viewer) {
+ return m_viewer == _viewer;
+ };
+ public: // herited function
+ void onReceiveMessage(const ewol::EMessage& _msg);
+ void onObjectRemove(ewol::EObject* _removeObject);
+ public: // resource manager
+ /**
+ * @brief keep the resource pointer.
+ * @note Never free this pointer by your own...
+ * @param[in] _filename Name of the configuration file.
+ * @return pointer on the resource or NULL if an error occured.
+ */
+ static appl::ViewerManager* keep(void);
+ /**
+ * @brief release the keeped resources
+ * @param[in,out] reference on the object pointer
+ */
+ static void release(appl::ViewerManager*& _object);
+ };
+};
+
+#endif
+
diff --git a/sources/appl/Highlight.cpp b/sources/appl/Highlight.cpp
index 053568d..891bc98 100644
--- a/sources/appl/Highlight.cpp
+++ b/sources/appl/Highlight.cpp
@@ -8,7 +8,7 @@
#include
#include
-#include
+#include
#include
#include
diff --git a/sources/appl/HighlightManager.h b/sources/appl/HighlightManager.h
index 9735eca..9241c73 100644
--- a/sources/appl/HighlightManager.h
+++ b/sources/appl/HighlightManager.h
@@ -12,7 +12,7 @@
#include
#include
-#include
+#include
#include
namespace appl {
diff --git a/sources/appl/HighlightPattern.cpp b/sources/appl/HighlightPattern.cpp
index 4506872..39bbc79 100644
--- a/sources/appl/HighlightPattern.cpp
+++ b/sources/appl/HighlightPattern.cpp
@@ -8,7 +8,7 @@
#include
#include
-#include
+#include
#undef __class__
#define __class__ "HighlightPattern"
diff --git a/sources/appl/HighlightPattern.h b/sources/appl/HighlightPattern.h
index 0b87c7d..5efde62 100644
--- a/sources/appl/HighlightPattern.h
+++ b/sources/appl/HighlightPattern.h
@@ -6,7 +6,7 @@
* @license GPL v3 (see license file)
*/
-#include
+#include
#ifndef __HIGHLIGHT_PATTERN_H__
#define __HIGHLIGHT_PATTERN_H__
diff --git a/sources/appl/TextPluginHistory.cpp b/sources/appl/TextPluginHistory.cpp
index a2acebe..53632ac 100644
--- a/sources/appl/TextPluginHistory.cpp
+++ b/sources/appl/TextPluginHistory.cpp
@@ -68,17 +68,6 @@ bool appl::TextPluginHistory::onReceiveMessage(appl::TextViewer& _textDrawer,
m_undo.pop_back();
return true;
}
- /*
- if (m_history[m_positionHistory]->m_removedText.size() == 0) {
- // just insert mode
- } else if (m_history[m_positionHistory]->m_posAdded == m_history[m_positionHistory]->m_endPosAdded) {
- // just remove mode
-
- } else {
- // just replace mode
-
- }
- */
appl::History *tmpElement = m_undo[m_undo.size()-1];
m_undo.pop_back();
m_redo.push_back(tmpElement);
@@ -95,7 +84,7 @@ void appl::TextPluginHistory::clearRedo(void) {
if (m_redo.size() == 0) {
return;
}
- for (esize_t iii=0; iiim_addedText = _data;
- tmpElement->m_posAdded = (esize_t)_pos;
- tmpElement->m_endPosRemoved = (esize_t)_pos;
+ tmpElement->m_posAdded = (int64_t)_pos;
+ tmpElement->m_endPosRemoved = (int64_t)_pos;
}
_textDrawer.m_buffer->write(_data, _pos);
if (tmpElement != NULL) {
- tmpElement->m_endPosAdded = (esize_t)_textDrawer.m_buffer->cursor();
+ tmpElement->m_endPosAdded = (int64_t)_textDrawer.m_buffer->cursor();
clearRedo();
m_undo.push_back(tmpElement);
}
@@ -151,14 +140,14 @@ bool appl::TextPluginHistory::onReplace(appl::TextViewer& _textDrawer,
}
appl::History *tmpElement = new appl::History();
if (tmpElement != NULL) {
- tmpElement->m_posAdded = (esize_t)_pos;
+ tmpElement->m_posAdded = (int64_t)_pos;
tmpElement->m_addedText = _data;
- tmpElement->m_endPosRemoved = (esize_t)_posEnd;
+ tmpElement->m_endPosRemoved = (int64_t)_posEnd;
_textDrawer.m_buffer->copy(tmpElement->m_removedText, _pos, _posEnd);
}
_textDrawer.m_buffer->replace(_data, _pos, _posEnd);
if (tmpElement != NULL) {
- tmpElement->m_endPosAdded = (esize_t)_textDrawer.m_buffer->cursor();
+ tmpElement->m_endPosAdded = (int64_t)_textDrawer.m_buffer->cursor();
clearRedo();
m_undo.push_back(tmpElement);
}
@@ -175,9 +164,9 @@ bool appl::TextPluginHistory::onRemove(appl::TextViewer& _textDrawer,
appl::History *tmpElement = new appl::History();
if (tmpElement != NULL) {
tmpElement->m_addedText = "";
- tmpElement->m_posAdded = (esize_t)_pos;
+ tmpElement->m_posAdded = (int64_t)_pos;
tmpElement->m_endPosAdded = tmpElement->m_posAdded;
- tmpElement->m_endPosRemoved = (esize_t)_posEnd;
+ tmpElement->m_endPosRemoved = (int64_t)_posEnd;
_textDrawer.m_buffer->copy(tmpElement->m_removedText, _pos, _posEnd);
clearRedo();
m_undo.push_back(tmpElement);
diff --git a/sources/appl/TextPluginHistory.h b/sources/appl/TextPluginHistory.h
index 6f86e3d..176bb8c 100644
--- a/sources/appl/TextPluginHistory.h
+++ b/sources/appl/TextPluginHistory.h
@@ -26,9 +26,9 @@ namespace appl {
};
std::string m_addedText;
std::string m_removedText;
- esize_t m_posAdded;
- esize_t m_endPosAdded;
- esize_t m_endPosRemoved;
+ int64_t m_posAdded;
+ int64_t m_endPosAdded;
+ int64_t m_endPosRemoved;
};
class TextPluginHistory : public appl::TextViewerPlugin {
public:
diff --git a/sources/appl/ctags/CTagsManager.cpp b/sources/appl/ctags/CTagsManager.cpp
index f813cc9..a24957b 100644
--- a/sources/appl/ctags/CTagsManager.cpp
+++ b/sources/appl/ctags/CTagsManager.cpp
@@ -8,8 +8,8 @@
#include
#include
-#include
-#include
+#include
+#include
#include
#include
#include
diff --git a/sources/appl/ctags/CTagsManager.h b/sources/appl/ctags/CTagsManager.h
index 667afb7..c170c09 100644
--- a/sources/appl/ctags/CTagsManager.h
+++ b/sources/appl/ctags/CTagsManager.h
@@ -11,8 +11,8 @@
#include
-#include "appl/globalMsg.h"
-#include "readtags.h"
+#include
+#include
#define MAX_REG_EXP_SEARCH (1024)
diff --git a/sources/appl/ctags/readtags.cpp b/sources/appl/ctags/readtags.cpp
index 86442d1..d392312 100644
--- a/sources/appl/ctags/readtags.cpp
+++ b/sources/appl/ctags/readtags.cpp
@@ -18,7 +18,7 @@
#include
#include /* to declare off_t */
-#include "readtags.h"
+#include
/*
* MACROS
diff --git a/sources/appl/global.cpp b/sources/appl/global.cpp
index 85a0882..02ab8da 100644
--- a/sources/appl/global.cpp
+++ b/sources/appl/global.cpp
@@ -7,13 +7,11 @@
*/
#include
-//#include
#include
#include
#include
#include
#include
-//#include
#undef __class__
#define __class__ "globals"
diff --git a/sources/lutin_edn.py b/sources/lutin_edn.py
index f759530..57b39f4 100755
--- a/sources/lutin_edn.py
+++ b/sources/lutin_edn.py
@@ -21,9 +21,9 @@ def Create(target):
myModule.AddSrcFile([
'appl/Gui/BufferView.cpp',
'appl/Gui/TextViewer.cpp',
+ 'appl/Gui/ViewerManager.cpp',
'appl/Gui/MainWindows.cpp',
'appl/Gui/Search.cpp',
- 'appl/Gui/SearchData.cpp',
'appl/Gui/TagFileSelection.cpp',
'appl/Gui/TagFileList.cpp',
'appl/Gui/WorkerSaveFile.cpp',
@@ -78,15 +78,9 @@ def Create(target):
myModule.CopyFolder('../data/theme/default/*.svg','theme/default/')
myModule.CopyFolder('../data/theme/colorWhite/*.json','theme/colorWhite/')
myModule.CopyFolder('../data/theme/colorBlack/*.json','theme/colorBlack/')
+ myModule.CopyFolder('../data/GUI-Search.xml','')
myModule.AddPath(lutinTools.GetCurrentPath(__file__))
- myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl")
- myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl/Buffer")
- myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl/Buffer/EdnBuf")
- myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl/Colorize")
- myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl/ctags")
- myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl/Gui")
- myModule.AddPath(lutinTools.GetCurrentPath(__file__)+"/appl/Highlight")
myModule.CopyFile("../data/Font/freefont/FreeSerif.ttf","fonts/FreeSerif.ttf")