[DEV] review all the search bar

This commit is contained in:
Edouard DUPIN 2013-11-23 18:30:52 +01:00
parent a95a1e8033
commit 60903845c1
27 changed files with 646 additions and 808 deletions

28
data/GUI-Search.xml Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<composer>
<sizer mode="hori" expand="true,false" fill="true" lock="true">
<button name="SEARCH:close">
<image src="THEME:GUI:Remove.svg" fill="true" size="7,7mm"/>
</button>
<entry name="SEARCH:search-entry" expand="true" fill="true"/>
<button name="SEARCH:search">
<image src="THEME:GUI:Search.svg" fill="true" size="7,7mm"/>
</button>
<entry name="SEARCH:replace-entry" expand="true" fill="true"/>
<button name="SEARCH:replace">
<image src="THEME:GUI:Replace.svg" fill="true" size="7,7mm"/>
</button>
<button name="SEARCH:case">
<image src="THEME:GUI:CaseSensitive.svg" fill="true" size="7,7mm" hover="Close search bar"/>
<image src="THEME:GUI:CaseSensitive.svg" fill="true" size="7,7mm" hover="Close search bar"/>
</button>
<button name="SEARCH:wrap">
<image src="THEME:GUI:WrapAround.svg" fill="true" size="7,7mm" hover="Close search bar"/>
<image src="THEME:GUI:WrapAround.svg" fill="true" size="7,7mm" hover="Close search bar"/>
</button>
<button name="SEARCH:up-down">
<image src="THEME:GUI:Up.svg" fill="true" size="7,7mm" hover="Close search bar"/>
<image src="THEME:GUI:Down.svg" fill="true" size="7,7mm" hover="Close search bar"/>
</button>
</sizer>
</composer>

View File

@ -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) {

View File

@ -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.

View File

@ -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<BufferText*> 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<listBuffer.size(); i++) {
remove(i);
}
SendMultiCast(ednMsgGuiClose, "All");
}
/**
* @brief Create a new buffer with no name and empty
* @return The ID of the curent buffer where the file is loaded
*/
int32_t classBufferManager::create(void) {
// allocate a new Buffer
BufferText *myBuffer = new BufferText();
// add at the list of element
listBuffer.push_back(myBuffer);
int32_t basicID = listBuffer.size() - 1;
return basicID;
}
/**
* @brief open a file with the name set in parameters
* @param[in] filename curent filename
* @return The ID of the curent buffer where the file is loaded
* @todo : check if this file is not curently open and return the old ID
*/
int32_t classBufferManager::open(etk::FSNode &myFile) {
if (false == exist(myFile)) {
// allocate a new Buffer
BufferText *myBuffer = new BufferText(myFile);
// add at the list of element
listBuffer.push_back(myBuffer);
return listBuffer.size() - 1;
} else {
// the buffer already existed == > 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<listBuffer.size(); iii++) {
// check if the buffer already existed
if (NULL != listBuffer[iii]) {
jjj++;
}
}
return jjj;
}
bool classBufferManager::remove(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]) {
// 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<listBuffer.size(); i++) {
if (NULL != listBuffer[i]) {
iEmeElement--;
// find the element :
if (0 == iEmeElement) {
return i;
}
}
}
return -1;
}
appl::Buffer* get(const std::string& _filename);
appl::Buffer* get(esize_t _bufferID);
esize_t size(void):
#endif

View File

@ -9,7 +9,7 @@
#ifndef __BUFFER_MANAGER_H__
#define __BUFFER_MANAGER_H__
#include <Buffer.h>
#include <appl/Buffer.h>
#include <appl/globalMsg.h>
#include <ewol/widget/Widget.h>
#include <ewol/resources/Resource.h>

View File

@ -8,10 +8,10 @@
#include <appl/debug.h>
#include <appl/global.h>
#include <BufferView.h>
#include <BufferManager.h>
#include <appl/Gui/BufferView.h>
#include <appl/BufferManager.h>
//#include <ColorizeManager.h>
#include <MainWindows.h>
#include <appl/Gui/MainWindows.h>
#include <ewol/renderer/EObject.h>
#undef __class__

View File

@ -10,7 +10,7 @@
#define __BUFFER_VIEW_H__
#include <appl/debug.h>
#include <BufferManager.h>
#include <appl/BufferManager.h>
#include <appl/globalMsg.h>
#include <ewol/widget/List.h>
#include <ewol/widget/Windows.h>

View File

@ -9,10 +9,10 @@
#include <appl/debug.h>
#include <appl/global.h>
#include <MainWindows.h>
#include <BufferView.h>
#include <TextViewer.h>
#include <Search.h>
#include <appl/Gui/MainWindows.h>
#include <appl/Gui/BufferView.h>
#include <appl/Gui/TextViewer.h>
#include <appl/Gui/Search.h>
#include <ewol/widget/Button.h>
#include <ewol/widget/CheckBox.h>
@ -37,10 +37,8 @@
#include <appl/Gui/WorkerCloseFile.h>
#include <appl/Gui/WorkerCloseAllFile.h>
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;

View File

@ -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 <ewol/widget/Button.h>
#include <ewol/widget/Image.h>
#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 :
/*
<composer>
<sizer mode="hori" expand="true,false" fill="true" lock="true">
<button name="SEARCH:close">
<image src="THEME:GUI:Remove.svg" fill="true" size="70,70mm"/>
</button>
<entry name="SEARCH:search-entry" expand="true" fill="true"/>
<button name="SEARCH:search">
<image src="THEME:GUI:Search.svg" fill="true" size="70,70mm"/>
</button>
<entry name="SEARCH:replace-entry" expand="true" fill="true"/>
<button name="SEARCH:replace">
<image src="THEME:GUI:Replace.svg" fill="true" size="70,70mm"/>
</button>
<button name="SEARCH:case">
<image src="THEME:GUI:CaseSensitive.svg" fill="true" size="70,70mm" hover="Close search bar"/>
<image src="THEME:GUI:CaseSensitive.svg" fill="true" size="70,70mm" hover="Close search bar"/>
</button>
<button name="SEARCH:wrap">
<image src="THEME:GUI:WrapAround.svg" fill="true" size="70,70mm" hover="Close search bar"/>
<image src="THEME:GUI:WrapAround.svg" fill="true" size="70,70mm" hover="Close search bar"/>
</button>
<button name="SEARCH:up-down">
<image src="THEME:GUI:Up.svg" fill="true" size="70,70mm" hover="Close search bar"/>
<image src="THEME:GUI:Down.svg" fill="true" size="70,70mm" hover="Close search bar"/>
</button>
</size>
</composer>
*/
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<widget::Entry*>(getWidgetNamed("SEARCH:search-entry"));
m_replaceEntry = dynamic_cast<widget::Entry*>(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;
}
}

View File

@ -10,19 +10,35 @@
#define __SEARCH_H__
#include <appl/debug.h>
#include <ewol/widget/Sizer.h>
#include <ewol/widget/Composer.h>
#include <ewol/widget/Entry.h>
#include <appl/Buffer.h>
#include <appl/Gui/ViewerManager.h>
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);

View File

@ -1,85 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/global.h>
#include <SearchData.h>
#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;
}

View File

@ -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 <etk/UString.h>
#include <appl/debug.h>
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

View File

@ -8,13 +8,12 @@
#include <appl/debug.h>
#include <appl/global.h>
#include <TextViewer.h>
#include <BufferManager.h>
//#include <ColorizeManager.h>
#include <appl/Gui/TextViewer.h>
#include <appl/BufferManager.h>
#include <ewol/clipBoard.h>
#include <SearchData.h>
#include <ewol/widget/WidgetManager.h>
#include <appl/Gui/ViewerManager.h>
#include <ewol/renderer/EObject.h>
#include <appl/TextPluginManager.h>
@ -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;
}

View File

@ -17,6 +17,7 @@
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Drawing.h>
#include <appl/BufferManager.h>
#include <appl/Gui/ViewerManager.h>
#include <tuple>
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();
}
};
};

View File

@ -0,0 +1,77 @@
/**
* @author Edouard DUPIN
*
* @copyright 2010, Edouard DUPIN, all right reserved
*
* @license GPL v3 (see license file)
*/
#include <appl/debug.h>
#include <appl/global.h>
#include <appl/Gui/ViewerManager.h>
#include <appl/Gui/TextViewer.h>
#include <ewol/renderer/EObject.h>
#include <ewol/renderer/EObjectManager.h>
#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<appl::ViewerManager*>(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<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -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 <appl/Buffer.h>
#include <appl/globalMsg.h>
#include <ewol/widget/Widget.h>
#include <ewol/resources/Resource.h>
#include <appl/BufferManager.h>
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

View File

@ -8,7 +8,7 @@
#include <appl/debug.h>
#include <appl/global.h>
#include <Highlight.h>
#include <appl/Highlight.h>
#include <exml/exml.h>
#include <ewol/resources/ResourceManager.h>

View File

@ -12,7 +12,7 @@
#include <etk/UString.h>
#include <appl/globalMsg.h>
#include <Highlight.h>
#include <appl/Highlight.h>
#include <ewol/widget/Widget.h>
namespace appl {

View File

@ -8,7 +8,7 @@
#include <appl/debug.h>
#include <appl/global.h>
#include <HighlightPattern.h>
#include <appl/HighlightPattern.h>
#undef __class__
#define __class__ "HighlightPattern"

View File

@ -6,7 +6,7 @@
* @license GPL v3 (see license file)
*/
#include <Highlight.h>
#include <appl/Highlight.h>
#ifndef __HIGHLIGHT_PATTERN_H__
#define __HIGHLIGHT_PATTERN_H__

View File

@ -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; iii<m_redo.size(); ++iii) {
for (size_t iii=0; iii<m_redo.size(); ++iii) {
if (m_redo[iii] == NULL) {
continue;
}
@ -109,7 +98,7 @@ void appl::TextPluginHistory::clearUndo(void) {
if (m_undo.size() == 0) {
return;
}
for (esize_t iii=0; iii<m_undo.size(); ++iii) {
for (size_t iii=0; iii<m_undo.size(); ++iii) {
if (m_undo[iii] == NULL) {
continue;
}
@ -129,12 +118,12 @@ bool appl::TextPluginHistory::onWrite(appl::TextViewer& _textDrawer,
appl::History *tmpElement = new appl::History();
if (tmpElement != NULL) {
tmpElement->m_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);

View File

@ -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:

View File

@ -8,8 +8,8 @@
#include <appl/debug.h>
#include <appl/global.h>
#include <CTagsManager.h>
#include <BufferManager.h>
#include <appl/ctags/CTagsManager.h>
#include <appl/BufferManager.h>
#include <ewol/renderer/EObject.h>
#include <ewol/renderer/eContext.h>
#include <ewol/widget/meta/FileChooser.h>

View File

@ -11,8 +11,8 @@
#include <ewol/widget/Widget.h>
#include "appl/globalMsg.h"
#include "readtags.h"
#include <appl/globalMsg.h>
#include <appl/ctags/readtags.h>
#define MAX_REG_EXP_SEARCH (1024)

View File

@ -18,7 +18,7 @@
#include <errno.h>
#include <sys/types.h> /* to declare off_t */
#include "readtags.h"
#include <appl/ctags/readtags.h>
/*
* MACROS

View File

@ -7,13 +7,11 @@
*/
#include <appl/global.h>
//#include <ColorizeManager.h>
#include <appl/globalMsg.h>
#include <ewol/renderer/EObject.h>
#include <ewol/renderer/eContext.h>
#include <ewol/resources/ResourceManager.h>
#include <etk/os/FSNode.h>
//#include <ewol/UserConfig.h>
#undef __class__
#define __class__ "globals"

View File

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