Search is back
This commit is contained in:
@@ -1090,46 +1090,41 @@ void BufferText::Search(etk::UString &data, bool back, bool caseSensitive, bool
|
||||
APPL_WARNING("no search data");
|
||||
return;
|
||||
}
|
||||
etk::VectorType<uniChar_t> mVectSearch;
|
||||
mVectSearch = data.GetVector();
|
||||
APPL_TODO("Remove for now ...");
|
||||
/*
|
||||
if (false == back) {
|
||||
//APPL_INFO("search data Forward : startSearchPos=" << startSearchPos );
|
||||
int32_t foundPos;
|
||||
bool findSomething = m_EdnBuf.SearchForward(startSearchPos, mVectSearch, &foundPos, caseSensitive);
|
||||
int32_t foundPosEnd;
|
||||
bool findSomething = m_EdnBuf.SearchForward(startSearchPos, data, &foundPos, &foundPosEnd, caseSensitive);
|
||||
if( false == findSomething
|
||||
&& true == wrap)
|
||||
{
|
||||
//APPL_INFO("WrapMode !!! 0 ==> end");
|
||||
findSomething = m_EdnBuf.SearchForward(0, mVectSearch, &foundPos, caseSensitive);
|
||||
findSomething = m_EdnBuf.SearchForward(0, data, &foundPos, &foundPosEnd, caseSensitive);
|
||||
}
|
||||
// if find data :
|
||||
if (true == findSomething) {
|
||||
// select new position
|
||||
int32_t endSelectionPos = foundPos+mVectSearch.Size();
|
||||
SetInsertPosition(endSelectionPos);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, endSelectionPos);
|
||||
SetInsertPosition(foundPosEnd);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, foundPosEnd);
|
||||
}
|
||||
} else {
|
||||
//APPL_INFO("search data Backward : " << data.GetDirectPointer() );
|
||||
int32_t foundPos;
|
||||
bool findSomething = m_EdnBuf.SearchBackward(startSearchPos, mVectSearch, &foundPos, caseSensitive);
|
||||
int32_t foundPosEnd;
|
||||
bool findSomething = m_EdnBuf.SearchBackward(startSearchPos, data, &foundPos, &foundPosEnd, caseSensitive);
|
||||
if( false == findSomething
|
||||
&& true == wrap)
|
||||
{
|
||||
//APPL_INFO("WrapMode !!! end ==> 0");
|
||||
findSomething = m_EdnBuf.SearchBackward(m_EdnBuf.Size(), mVectSearch, &foundPos, caseSensitive);
|
||||
findSomething = m_EdnBuf.SearchBackward(m_EdnBuf.Size(), data, &foundPos, &foundPosEnd, caseSensitive);
|
||||
}
|
||||
// if find data :
|
||||
if (true == findSomething) {
|
||||
// select new position
|
||||
int32_t endSelectionPos = foundPos+mVectSearch.Size();
|
||||
SetInsertPosition(foundPos);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, endSelectionPos);
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, foundPos, foundPosEnd);
|
||||
}
|
||||
}
|
||||
*/
|
||||
m_centerRequested = true;
|
||||
RequestUpdateOfThePosition();
|
||||
}
|
||||
|
@@ -986,13 +986,25 @@ bool EdnBuf::charMatch(char first, char second, bool caseSensitive)
|
||||
* @return false ==> not found data
|
||||
*
|
||||
*/
|
||||
bool EdnBuf::SearchForward(int32_t startPos, etk::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive)
|
||||
bool EdnBuf::SearchForward(int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive)
|
||||
{
|
||||
etk::VectorType<int8_t> searchVect;
|
||||
if (true == m_isUtf8) {
|
||||
char * tmpPointer = search.Utf8Data();
|
||||
while (*tmpPointer != '\0') {
|
||||
searchVect.PushBack(*tmpPointer++);
|
||||
}
|
||||
} else {
|
||||
etk::VectorType<unsigned int> tmppp = search.GetVector();
|
||||
convertUnicodeToIso(m_charsetType, tmppp, searchVect);
|
||||
}
|
||||
// remove the '\0' at the end of the string ...
|
||||
searchVect.PopBack();
|
||||
int32_t position;
|
||||
int32_t searchLen = searchVect.Size();
|
||||
int32_t dataLen = m_data.Size();
|
||||
char currentChar = '\0';
|
||||
//APPL_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
|
||||
APPL_INFO(" startPos=" << startPos << " searchLen=" << searchLen);
|
||||
for (position=startPos; position<dataLen - (searchLen-1); position++) {
|
||||
currentChar = m_data[position];
|
||||
if (true == charMatch(currentChar, searchVect[0], caseSensitive)) {
|
||||
@@ -1007,11 +1019,13 @@ bool EdnBuf::SearchForward(int32_t startPos, etk::VectorType<int8_t> &searchVect
|
||||
}
|
||||
if (true == found) {
|
||||
*foundPos = position;
|
||||
*foundPosEnd = position + searchVect.Size();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
*foundPos = m_data.Size();
|
||||
*foundPosEnd = m_data.Size();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1027,8 +1041,21 @@ bool EdnBuf::SearchForward(int32_t startPos, etk::VectorType<int8_t> &searchVect
|
||||
* @return false ==> not found data
|
||||
*
|
||||
*/
|
||||
bool EdnBuf::SearchBackward(int32_t startPos, etk::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive)
|
||||
bool EdnBuf::SearchBackward(int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive)
|
||||
{
|
||||
etk::VectorType<int8_t> searchVect;
|
||||
if (true == m_isUtf8) {
|
||||
char * tmpPointer = search.Utf8Data();
|
||||
while (*tmpPointer != '\0') {
|
||||
searchVect.PushBack(*tmpPointer++);
|
||||
}
|
||||
} else {
|
||||
etk::VectorType<unsigned int> tmppp = search.GetVector();
|
||||
convertUnicodeToIso(m_charsetType, tmppp, searchVect);
|
||||
}
|
||||
// remove the '\0' at the end of the string ...
|
||||
searchVect.PopBack();
|
||||
|
||||
int32_t position;
|
||||
int32_t searchLen = searchVect.Size();
|
||||
char currentChar = '\0';
|
||||
@@ -1047,11 +1074,13 @@ bool EdnBuf::SearchBackward(int32_t startPos, etk::VectorType<int8_t> &searchVec
|
||||
}
|
||||
if (true == found) {
|
||||
*foundPos = position - (searchLen-1);
|
||||
*foundPosEnd = position + searchVect.Size();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
*foundPos = m_data.Size();
|
||||
*foundPosEnd = m_data.Size();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -115,8 +115,8 @@ class EdnBuf {
|
||||
int32_t CountForwardNLines( int32_t startPos, int32_t nLines);
|
||||
int32_t CountBackwardNLines( int32_t startPos, int32_t nLines);
|
||||
|
||||
bool SearchForward( int32_t startPos, etk::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive = true);
|
||||
bool SearchBackward( int32_t startPos, etk::VectorType<int8_t> &searchVect, int32_t *foundPos, bool caseSensitive = true);
|
||||
bool SearchForward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
|
||||
bool SearchBackward( int32_t startPos, etk::UString &search, int32_t *foundPos, int32_t *foundPosEnd, bool caseSensitive = true);
|
||||
bool SearchForward( int32_t startPos, char searchChar, int32_t *foundPos);
|
||||
bool SearchBackward( int32_t startPos, char searchChar, int32_t *foundPos);
|
||||
bool SelectAround( int32_t startPos, int32_t &beginPos, int32_t &endPos);
|
||||
|
Reference in New Issue
Block a user