[DEV] simplyfy accec of element with adding iterator
This commit is contained in:
parent
cf8a720924
commit
408a22015c
@ -11,6 +11,63 @@
|
|||||||
#include <appl/Debug.h>
|
#include <appl/Debug.h>
|
||||||
#include <ewol/clipBoard.h>
|
#include <ewol/clipBoard.h>
|
||||||
|
|
||||||
|
appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ (void) {
|
||||||
|
if ( m_data != NULL
|
||||||
|
&& m_current < m_data->m_data.size() ) {
|
||||||
|
int8_t nbChar = etk::UChar::theoricUTF8Len(m_data->m_data[m_current]);
|
||||||
|
if (m_current+nbChar >= m_data->m_data.size()) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
m_current+=nbChar;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
appl::Buffer::Iterator& appl::Buffer::Iterator::operator-- (void) {
|
||||||
|
if ( m_data != NULL
|
||||||
|
&& m_current > 0) {
|
||||||
|
int32_t iii = -1;
|
||||||
|
while( etk::UChar::theoricUTF8First(m_data->m_data[m_current+iii]) == false
|
||||||
|
&& iii >= -6
|
||||||
|
&& m_current-iii>0) {
|
||||||
|
++iii;
|
||||||
|
};
|
||||||
|
m_current += iii;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
etk::UChar appl::Buffer::Iterator::operator* (void) const {
|
||||||
|
etk::UChar retVal = '\0';
|
||||||
|
APPL_CHECK_INOUT(m_current < m_data->m_data.size());
|
||||||
|
char tmpVal[5];
|
||||||
|
memset(tmpVal, 0, sizeof(tmpVal));
|
||||||
|
tmpVal[0] = m_data->m_data[m_current];
|
||||||
|
int8_t nbChar = etk::UChar::theoricUTF8Len(tmpVal[0]);
|
||||||
|
for (int32_t iii=1; iii<nbChar && m_current+iii<m_data->m_data.size(); ++iii) {
|
||||||
|
tmpVal[iii] = m_data->m_data[m_current+iii];
|
||||||
|
}
|
||||||
|
// transform ...
|
||||||
|
retVal.setUtf8(tmpVal);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
appl::Buffer::Iterator appl::Buffer::position(esize_t _pos) {
|
||||||
|
return appl::Buffer::Iterator(this, _pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
appl::Buffer::Iterator appl::Buffer::begin(void) {
|
||||||
|
return position(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
appl::Buffer::Iterator appl::Buffer::end(void) {
|
||||||
|
// TODO : chek the validity of the char ...
|
||||||
|
return position( m_data.size()-1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
appl::Buffer::Buffer(void) :
|
appl::Buffer::Buffer(void) :
|
||||||
m_cursorPos(0),
|
m_cursorPos(0),
|
||||||
m_cursorSelectPos(-1),
|
m_cursorSelectPos(-1),
|
||||||
@ -36,15 +93,14 @@ void appl::Buffer::setFileName(const etk::UString& _name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void appl::Buffer::moveCursorRight(appl::Buffer::moveMode _mode) {
|
void appl::Buffer::moveCursorRight(appl::Buffer::moveMode _mode) {
|
||||||
etk::UChar value;
|
Iterator it;
|
||||||
esize_t nbElement;
|
esize_t nbElement;
|
||||||
switch (_mode) {
|
switch (_mode) {
|
||||||
default:
|
default:
|
||||||
case moveLetter:
|
case moveLetter:
|
||||||
nbElement = get(m_cursorPos, value);
|
it = position(m_cursorPos);
|
||||||
if (nbElement>0) {
|
++it;
|
||||||
moveCursor(m_cursorPos + nbElement);
|
moveCursor(it.getPos());
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case moveWord:
|
case moveWord:
|
||||||
// TODO : ...
|
// TODO : ...
|
||||||
@ -60,14 +116,14 @@ void appl::Buffer::moveCursorRight(appl::Buffer::moveMode _mode) {
|
|||||||
|
|
||||||
void appl::Buffer::moveCursorLeft(appl::Buffer::moveMode _mode) {
|
void appl::Buffer::moveCursorLeft(appl::Buffer::moveMode _mode) {
|
||||||
etk::UChar value;
|
etk::UChar value;
|
||||||
|
Iterator it;
|
||||||
esize_t nbElement;
|
esize_t nbElement;
|
||||||
switch (_mode) {
|
switch (_mode) {
|
||||||
default:
|
default:
|
||||||
case moveLetter:
|
case moveLetter:
|
||||||
nbElement = getBack(m_cursorPos-1, value);
|
it = position(m_cursorPos);
|
||||||
if (nbElement>0) {
|
--it;
|
||||||
moveCursor(m_cursorPos - nbElement);
|
moveCursor(it.getPos());
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case moveWord:
|
case moveWord:
|
||||||
// TODO : ...
|
// TODO : ...
|
||||||
@ -132,7 +188,7 @@ esize_t appl::Buffer::startLine(esize_t _pos) {
|
|||||||
if (false == searchBack(_pos, etk::UChar::Return, startPos)) {
|
if (false == searchBack(_pos, etk::UChar::Return, startPos)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return startPos + 1;
|
return startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
esize_t appl::Buffer::endLine(esize_t _pos) {
|
esize_t appl::Buffer::endLine(esize_t _pos) {
|
||||||
@ -147,17 +203,15 @@ bool appl::Buffer::search(esize_t _pos, const etk::UChar& _search, esize_t& _res
|
|||||||
// move in the string
|
// move in the string
|
||||||
esize_t nbElementBuffer = 0;
|
esize_t nbElementBuffer = 0;
|
||||||
etk::UChar value;
|
etk::UChar value;
|
||||||
for(esize_t iii=_pos ; iii<m_data.size() ; iii+=nbElementBuffer ) {
|
for (Iterator it = position(m_cursorPos);
|
||||||
nbElementBuffer = get(iii, value);
|
it != end();
|
||||||
if (value == _search) {
|
++it) {
|
||||||
_result = iii;
|
if (*it == _search) {
|
||||||
|
_result = it;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (nbElementBuffer <= 0) {
|
|
||||||
nbElementBuffer = 1;
|
|
||||||
}
|
}
|
||||||
}
|
_result = end();
|
||||||
_result = m_data.size();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,15 +219,15 @@ bool appl::Buffer::searchBack(esize_t _pos, const etk::UChar& _search, esize_t&
|
|||||||
// move in the string
|
// move in the string
|
||||||
esize_t nbElementBuffer = 0;
|
esize_t nbElementBuffer = 0;
|
||||||
etk::UChar value;
|
etk::UChar value;
|
||||||
for(esize_t iii=_pos-1 ; iii >= 0 ; iii-=nbElementBuffer ) {
|
for (Iterator it = --position(m_cursorPos);
|
||||||
nbElementBuffer = getBack(iii, value);
|
it != begin();
|
||||||
if (value == _search) {
|
--it) {
|
||||||
_result = iii-nbElementBuffer;
|
//APPL_DEBUG("compare : " << *it << " ?= " << _search);
|
||||||
|
if (*it == _search) {
|
||||||
|
//APPL_DEBUG("find : " << (esize_t)it);
|
||||||
|
_result = it;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (nbElementBuffer <= 0) {
|
|
||||||
nbElementBuffer = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_result = 0;
|
_result = 0;
|
||||||
return false;
|
return false;
|
||||||
@ -237,34 +291,22 @@ bool appl::Buffer::onEventEntry(const ewol::EventEntry& _event, ewol::Text& _tes
|
|||||||
} else if (localValue == etk::UChar::Suppress ) {
|
} else if (localValue == etk::UChar::Suppress ) {
|
||||||
//APPL_INFO("keyEvent : <suppr> pos=" << m_cursorPos);
|
//APPL_INFO("keyEvent : <suppr> pos=" << m_cursorPos);
|
||||||
if (hasTextSelected()) {
|
if (hasTextSelected()) {
|
||||||
esize_t startPos = getStartSelectionPos();
|
removeSelection();
|
||||||
esize_t endPos = getStopSelectionPos();
|
|
||||||
m_data.remove(startPos, endPos-startPos);
|
|
||||||
m_selectMode = false;
|
|
||||||
moveCursor(startPos);
|
|
||||||
} else {
|
} else {
|
||||||
etk::UChar value;
|
int32_t dimention = (esize_t)(++position(m_cursorPos)) - m_cursorPos;
|
||||||
esize_t nbElement = get(m_cursorPos, value);
|
if (dimention > 0) {
|
||||||
if (nbElement>0) {
|
m_data.remove(m_cursorPos, dimention);
|
||||||
m_data.remove(m_cursorPos, nbElement);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (localValue == etk::UChar::Delete) {
|
} else if (localValue == etk::UChar::Delete) {
|
||||||
//APPL_INFO("keyEvent : <del> pos=" << m_cursorPos);
|
//APPL_INFO("keyEvent : <del> pos=" << m_cursorPos);
|
||||||
if (hasTextSelected()) {
|
if (hasTextSelected()) {
|
||||||
esize_t startPos = getStartSelectionPos();
|
removeSelection();
|
||||||
esize_t endPos = getStopSelectionPos();
|
|
||||||
m_data.remove(startPos, endPos-startPos);
|
|
||||||
m_selectMode = false;
|
|
||||||
moveCursor(startPos);
|
|
||||||
} else {
|
} else {
|
||||||
etk::UChar value;
|
int32_t dimention = m_cursorPos - (esize_t)(--position(m_cursorPos));
|
||||||
esize_t nbElement = getBack(m_cursorPos-1, value);
|
if (dimention > 0) {
|
||||||
if (nbElement>0) {
|
m_data.remove(m_cursorPos-dimention, dimention);
|
||||||
m_data.remove(m_cursorPos-nbElement, nbElement);
|
|
||||||
m_selectMode = false;
|
|
||||||
moveCursor(m_cursorPos-nbElement);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -273,20 +315,14 @@ bool appl::Buffer::onEventEntry(const ewol::EventEntry& _event, ewol::Text& _tes
|
|||||||
// normal adding char ...
|
// normal adding char ...
|
||||||
char output[5];
|
char output[5];
|
||||||
int32_t nbElement = localValue.getUtf8(output);
|
int32_t nbElement = localValue.getUtf8(output);
|
||||||
if (hasTextSelected()) {
|
if ( hasTextSelected() == false
|
||||||
esize_t startPos = getStartSelectionPos();
|
&& _event.getSpecialKey().isSetInsert() == true) {
|
||||||
esize_t endPos = getStopSelectionPos();
|
int32_t dimention = (esize_t)(++position(m_cursorPos)) - m_cursorPos;
|
||||||
m_data.replace(startPos, endPos-startPos, (int8_t*)output, nbElement);
|
m_data.replace(m_cursorPos, dimention, (int8_t*)output, nbElement);
|
||||||
moveCursor(startPos+nbElement);
|
|
||||||
} else {
|
|
||||||
if (_event.getSpecialKey().isSetInsert() == false) {
|
|
||||||
m_data.insert(m_cursorPos, (int8_t*)output, nbElement);
|
|
||||||
} else {
|
|
||||||
etk::UChar value;
|
|
||||||
esize_t nbElementRemove = get(m_cursorPos, value);
|
|
||||||
m_data.replace(m_cursorPos, nbElementRemove, (int8_t*)output, nbElement);
|
|
||||||
}
|
|
||||||
moveCursor(m_cursorPos+nbElement);
|
moveCursor(m_cursorPos+nbElement);
|
||||||
|
} else {
|
||||||
|
etk::UString myString = output;
|
||||||
|
paste(myString);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -408,32 +444,31 @@ void appl::Buffer::moveCursor(esize_t _pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool appl::Buffer::selectAround(int32_t _startPos, int32_t &_beginPos, int32_t &_endPos) {
|
bool appl::Buffer::selectAround(int32_t _startPos, int32_t &_beginPos, int32_t &_endPos) {
|
||||||
esize_t bufferElementSize;
|
etk::UChar currentValue = *position(_startPos);
|
||||||
esize_t previousElementSize;
|
_beginPos = 0;
|
||||||
etk::UChar currentValue;
|
_endPos = end();
|
||||||
get(_startPos, currentValue);
|
|
||||||
if ( currentValue == etk::UChar::Tabulation
|
if ( currentValue == etk::UChar::Tabulation
|
||||||
|| currentValue == etk::UChar::Space) {
|
|| currentValue == etk::UChar::Space) {
|
||||||
APPL_DEBUG("select spacer");
|
APPL_DEBUG("select spacer");
|
||||||
// special case we are looking for separation
|
// Search back
|
||||||
for (_beginPos=_startPos;
|
for (Iterator it = --position(_startPos);
|
||||||
_beginPos>=0;
|
it != begin();
|
||||||
previousElementSize = bufferElementSize,
|
--it) {
|
||||||
_beginPos-=bufferElementSize) {
|
currentValue = *it;
|
||||||
bufferElementSize = getBack(_beginPos, currentValue);
|
|
||||||
if ( currentValue != etk::UChar::Tabulation
|
if ( currentValue != etk::UChar::Tabulation
|
||||||
&& currentValue != etk::UChar::Space) {
|
&& currentValue != etk::UChar::Space) {
|
||||||
_beginPos += previousElementSize;
|
_beginPos = ++it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// special case we are looking for separation
|
// Search forward
|
||||||
for (_endPos=_startPos;
|
for (Iterator it = position(_startPos);
|
||||||
_endPos<m_data.size();
|
it != end();
|
||||||
_endPos+=bufferElementSize) {
|
++it) {
|
||||||
bufferElementSize = get(_endPos, currentValue);
|
currentValue = *it;
|
||||||
if ( currentValue != etk::UChar::Tabulation
|
if ( currentValue != etk::UChar::Tabulation
|
||||||
&& currentValue != etk::UChar::Space) {
|
&& currentValue != etk::UChar::Space) {
|
||||||
|
_endPos = it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -441,48 +476,48 @@ bool appl::Buffer::selectAround(int32_t _startPos, int32_t &_beginPos, int32_t &
|
|||||||
} else if( false == currentValue.isSpecialChar()){
|
} else if( false == currentValue.isSpecialChar()){
|
||||||
APPL_DEBUG("select normal Char");
|
APPL_DEBUG("select normal Char");
|
||||||
// Search back
|
// Search back
|
||||||
for (_beginPos=_startPos;
|
for (Iterator it = --position(_startPos);
|
||||||
_beginPos>=0;
|
it != begin();
|
||||||
previousElementSize = bufferElementSize,
|
--it) {
|
||||||
_beginPos-=bufferElementSize) {
|
currentValue = *it;
|
||||||
bufferElementSize = getBack(_beginPos, currentValue);
|
|
||||||
if ( currentValue != '_'
|
if ( currentValue != '_'
|
||||||
&& true == currentValue.isSpecialChar()) {
|
&& true == currentValue.isSpecialChar()) {
|
||||||
_beginPos += previousElementSize;
|
_beginPos = ++it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Search forward
|
// Search forward
|
||||||
for (_endPos=_startPos;
|
for (Iterator it = position(_startPos);
|
||||||
_endPos<m_data.size();
|
it != end();
|
||||||
_endPos+=bufferElementSize) {
|
++it) {
|
||||||
bufferElementSize = get(_endPos, currentValue);
|
currentValue = *it;
|
||||||
if ( currentValue != '_'
|
if ( currentValue != '_'
|
||||||
&& true == currentValue.isSpecialChar()) {
|
&& true == currentValue.isSpecialChar()) {
|
||||||
|
_endPos = it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
etk::UChar comparechar = currentValue;
|
|
||||||
APPL_DEBUG("select same char");
|
APPL_DEBUG("select same char");
|
||||||
|
etk::UChar comparechar = currentValue;
|
||||||
// Search back
|
// Search back
|
||||||
for (_beginPos=_startPos;
|
for (Iterator it = --position(_startPos);
|
||||||
_beginPos>=0;
|
it != begin();
|
||||||
previousElementSize = bufferElementSize,
|
--it) {
|
||||||
_beginPos-=bufferElementSize) {
|
currentValue = *it;
|
||||||
bufferElementSize = getBack(_beginPos, currentValue);
|
|
||||||
if (comparechar != currentValue) {
|
if (comparechar != currentValue) {
|
||||||
_beginPos += previousElementSize;
|
_beginPos = ++it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Search forward
|
// Search forward
|
||||||
for (_endPos=_startPos;
|
for (Iterator it = position(_startPos);
|
||||||
_endPos<m_data.size();
|
it != end();
|
||||||
_endPos+=bufferElementSize) {
|
++it) {
|
||||||
bufferElementSize = get(_endPos, currentValue);
|
currentValue = *it;
|
||||||
if (comparechar != currentValue) {
|
if (comparechar != currentValue) {
|
||||||
|
_endPos = it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -519,58 +554,43 @@ esize_t appl::Buffer::getPosSize(esize_t _startLinePos, float _distance, ewol::T
|
|||||||
etk::UString stringToDisplay;
|
etk::UString stringToDisplay;
|
||||||
_textDrawer.clear();
|
_textDrawer.clear();
|
||||||
_textDrawer.forceLineReturn();
|
_textDrawer.forceLineReturn();
|
||||||
esize_t previousElementPos = 0;
|
for (Iterator it = position(_startLinePos);
|
||||||
for (esize_t iii=_startLinePos;
|
it != end();
|
||||||
iii<m_data.size();
|
++it) {
|
||||||
previousElementPos=iii, iii+=bufferElementSize) {
|
currentValue = *it;
|
||||||
bufferElementSize = get(iii, currentValue);
|
|
||||||
if (bufferElementSize == 0) {
|
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
|
||||||
expand(countColomn, currentValue, stringToDisplay);
|
expand(countColomn, currentValue, stringToDisplay);
|
||||||
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
|
|
||||||
//m_displayText.setPos(positionCurentDisplay);
|
|
||||||
for (esize_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
for (esize_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
||||||
if (stringToDisplay[kkk] == etk::UChar::Return) {
|
if (stringToDisplay[kkk] == etk::UChar::Return) {
|
||||||
return iii;
|
return it;
|
||||||
} else {
|
} else {
|
||||||
_textDrawer.print(stringToDisplay[kkk]);
|
_textDrawer.print(stringToDisplay[kkk]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_textDrawer.getPos().x() >= _distance) {
|
if (_textDrawer.getPos().x() >= _distance) {
|
||||||
return iii;
|
return it;
|
||||||
}
|
}
|
||||||
countColomn += stringToDisplay.size();
|
countColomn += stringToDisplay.size();
|
||||||
}
|
}
|
||||||
return m_data.size();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : Rename ...
|
// TODO : Rename ...
|
||||||
float appl::Buffer::getScreenSize(esize_t _startLinePos, esize_t _stopPos, ewol::Text& _textDrawer)
|
float appl::Buffer::getScreenSize(esize_t _startLinePos, esize_t _stopPos, ewol::Text& _textDrawer)
|
||||||
{
|
{
|
||||||
float ret = 0;
|
float ret = 0;
|
||||||
esize_t bufferElementSize;
|
|
||||||
etk::UChar currentValue;
|
etk::UChar currentValue;
|
||||||
esize_t countColomn = 0;
|
esize_t countColomn = 0;
|
||||||
etk::UString stringToDisplay;
|
etk::UString stringToDisplay;
|
||||||
_textDrawer.clear();
|
_textDrawer.clear();
|
||||||
esize_t previousElementPos = 0;
|
|
||||||
|
|
||||||
APPL_DEBUG("search in " << _startLinePos << " " << _stopPos);
|
for (Iterator it = position(_startLinePos);
|
||||||
for (esize_t iii=_startLinePos;
|
it != end();
|
||||||
iii<m_data.size() && iii<=_stopPos;
|
++it) {
|
||||||
previousElementPos=iii, iii+=bufferElementSize) {
|
currentValue = *it;
|
||||||
bufferElementSize = get(iii, currentValue);
|
//APPL_DEBUG("parse : " << currentValue);
|
||||||
if (bufferElementSize == 0) {
|
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
|
||||||
APPL_DEBUG("parse : " << currentValue);
|
|
||||||
expand(countColomn, currentValue, stringToDisplay);
|
expand(countColomn, currentValue, stringToDisplay);
|
||||||
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
|
|
||||||
//m_displayText.setPos(positionCurentDisplay);
|
|
||||||
for (esize_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
for (esize_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
||||||
if (stringToDisplay[kkk] == etk::UChar::Return) {
|
if (stringToDisplay[kkk] == etk::UChar::Return) {
|
||||||
APPL_DEBUG("find \n");
|
|
||||||
return _textDrawer.getPos().x() + 2; // TODO : Add the +2 for the end of line ...
|
return _textDrawer.getPos().x() + 2; // TODO : Add the +2 for the end of line ...
|
||||||
} else {
|
} else {
|
||||||
_textDrawer.print(stringToDisplay[kkk]);
|
_textDrawer.print(stringToDisplay[kkk]);
|
||||||
@ -579,30 +599,23 @@ float appl::Buffer::getScreenSize(esize_t _startLinePos, esize_t _stopPos, ewol:
|
|||||||
ret = _textDrawer.getPos().x();
|
ret = _textDrawer.getPos().x();
|
||||||
countColomn += stringToDisplay.size();
|
countColomn += stringToDisplay.size();
|
||||||
}
|
}
|
||||||
APPL_DEBUG("end of buffer");
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : Rename && rework ...
|
// TODO : Rename && rework ...
|
||||||
esize_t appl::Buffer::getMousePosition(const vec2& _relativePos, ewol::Text& _textDrawer)
|
esize_t appl::Buffer::getMousePosition(const vec2& _relativePos, ewol::Text& _textDrawer) {
|
||||||
{
|
|
||||||
esize_t bufferElementSize;
|
|
||||||
etk::UChar currentValue;
|
etk::UChar currentValue;
|
||||||
vec3 tmpLetterSize = _textDrawer.calculateSize((etk::UChar)'A');
|
|
||||||
vec3 positionCurentDisplay(0,0,0);
|
vec3 positionCurentDisplay(0,0,0);
|
||||||
|
vec3 tmpLetterSize = _textDrawer.calculateSize((etk::UChar)'A');
|
||||||
esize_t countColomn = 0;
|
esize_t countColomn = 0;
|
||||||
etk::UString stringToDisplay;
|
etk::UString stringToDisplay;
|
||||||
_textDrawer.clear();
|
_textDrawer.clear();
|
||||||
_textDrawer.forceLineReturn();
|
_textDrawer.forceLineReturn();
|
||||||
esize_t previousElementPos = 0;
|
for (Iterator it = begin();
|
||||||
for (esize_t iii=0; iii<m_data.size(); previousElementPos=iii, iii+=bufferElementSize) {
|
it != end();
|
||||||
bufferElementSize = get(iii, currentValue);
|
++it) {
|
||||||
if (bufferElementSize == 0) {
|
currentValue = *it;
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
|
||||||
expand(countColomn, currentValue, stringToDisplay);
|
expand(countColomn, currentValue, stringToDisplay);
|
||||||
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
|
|
||||||
//m_displayText.setPos(positionCurentDisplay);
|
|
||||||
for (esize_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
for (esize_t kkk=0; kkk<stringToDisplay.size(); ++kkk) {
|
||||||
if (stringToDisplay[kkk] == etk::UChar::Return) {
|
if (stringToDisplay[kkk] == etk::UChar::Return) {
|
||||||
// TODO : Remove this, use the automatic line manager ...
|
// TODO : Remove this, use the automatic line manager ...
|
||||||
@ -617,66 +630,17 @@ esize_t appl::Buffer::getMousePosition(const vec2& _relativePos, ewol::Text& _te
|
|||||||
//APPL_DEBUG("line position : " << _textDrawer.getPos() << " " << positionCurentDisplay );
|
//APPL_DEBUG("line position : " << _textDrawer.getPos() << " " << positionCurentDisplay );
|
||||||
if ( _relativePos.x() >= positionCurentDisplay.x()
|
if ( _relativePos.x() >= positionCurentDisplay.x()
|
||||||
&& _relativePos.x() < _textDrawer.getPos().x() ) {
|
&& _relativePos.x() < _textDrawer.getPos().x() ) {
|
||||||
return iii;
|
return it;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return previousElementPos;
|
return --it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
positionCurentDisplay = _textDrawer.getPos();
|
positionCurentDisplay = _textDrawer.getPos();
|
||||||
countColomn += stringToDisplay.size();
|
countColomn += stringToDisplay.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_data.size();
|
return end();
|
||||||
}
|
|
||||||
|
|
||||||
esize_t appl::Buffer::get(esize_t _pos, etk::UChar& _value, unicode::charset_te _charset) const {
|
|
||||||
_value = '\0';
|
|
||||||
if (_pos<0 && _pos<m_data.size()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (_charset == unicode::EDN_CHARSET_UTF8) {
|
|
||||||
char tmpVal[5];
|
|
||||||
memset(tmpVal, 0, sizeof(tmpVal));
|
|
||||||
tmpVal[0] = m_data[_pos];
|
|
||||||
int8_t nbChar = etk::UChar::theoricUTF8Len(tmpVal[0]);
|
|
||||||
for (int32_t iii=1; iii<nbChar && _pos+iii<m_data.size(); ++iii) {
|
|
||||||
tmpVal[iii] = m_data[_pos+iii];
|
|
||||||
}
|
|
||||||
// transform ...
|
|
||||||
int32_t nbElement = _value.setUtf8(tmpVal);
|
|
||||||
return nbElement;
|
|
||||||
}
|
|
||||||
// TODO :: need to trancode iso == > UNICODE ...
|
|
||||||
_value.set(m_data[_pos]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
esize_t appl::Buffer::getBack(esize_t _pos, etk::UChar& _value, unicode::charset_te _charset) const {
|
|
||||||
_value = '\0';
|
|
||||||
if (_pos<0 && _pos<m_data.size()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (_charset == unicode::EDN_CHARSET_UTF8) {
|
|
||||||
char tmpVal[5];
|
|
||||||
char* pointerVal = &tmpVal[4];
|
|
||||||
memset(tmpVal, 0, sizeof(tmpVal));
|
|
||||||
*pointerVal = m_data[_pos];
|
|
||||||
int32_t iii=0;
|
|
||||||
while( etk::UChar::theoricUTF8First(*pointerVal) == false
|
|
||||||
&& pointerVal > tmpVal
|
|
||||||
&& _pos-iii>0) {
|
|
||||||
--pointerVal;
|
|
||||||
++iii;
|
|
||||||
*pointerVal = m_data[_pos - iii];
|
|
||||||
};
|
|
||||||
int32_t nbElement = _value.setUtf8(pointerVal);
|
|
||||||
return nbElement;
|
|
||||||
}
|
|
||||||
_value.set(m_data[_pos]);
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *ControlCodeTable[32] = {
|
static const char *ControlCodeTable[32] = {
|
||||||
@ -731,75 +695,61 @@ void appl::Buffer::expand(esize_t& _indent, const etk::UChar& _value, etk::UStri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO : No more used !!!
|
// TODO : No more used !!!
|
||||||
int32_t appl::Buffer::countDispChars(esize_t _posStart, esize_t _posEnd) {
|
int32_t appl::Buffer::countDispChars(esize_t _startPos, esize_t _posEnd) {
|
||||||
int32_t charCount = 0;
|
int32_t charCount = 0;
|
||||||
etk::UString expanded;
|
etk::UString expanded;
|
||||||
esize_t bufferElementSize;
|
|
||||||
etk::UChar value;
|
etk::UChar value;
|
||||||
//APPL_DEBUG("_posStart="<< _posStart << " _posEnd=" << _posEnd);
|
for (Iterator it = position(_startPos);
|
||||||
for(int32_t iii=_posStart; iii<_posEnd && iii<m_data.size() ; iii+=bufferElementSize ) {
|
it != end();
|
||||||
// get the element value:
|
++it) {
|
||||||
bufferElementSize = get(iii, value);
|
value = *it;
|
||||||
//APPL_DEBUG(" get : " << value << " size=" << bufferElementSize);
|
|
||||||
expand(charCount, value, expanded);
|
expand(charCount, value, expanded);
|
||||||
charCount += expanded.size();
|
charCount += expanded.size();
|
||||||
if (bufferElementSize <= 0) {
|
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//APPL_DEBUG(" result=" << charCount);
|
|
||||||
return charCount;
|
return charCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : No more used !!!
|
// TODO : No more used !!!
|
||||||
esize_t appl::Buffer::countForwardDispChars(esize_t _posStart, int32_t _nChars) {
|
esize_t appl::Buffer::countForwardDispChars(esize_t _startPos, int32_t _nChars) {
|
||||||
int32_t charCount = 0;
|
int32_t charCount = 0;
|
||||||
etk::UString expanded;
|
etk::UString expanded;
|
||||||
esize_t bufferElementSize;
|
|
||||||
etk::UChar value;
|
etk::UChar value;
|
||||||
int32_t iii;
|
for (Iterator it = position(_startPos);
|
||||||
for(iii = _posStart; charCount<_nChars && iii<m_data.size() ; iii+=bufferElementSize ) {
|
it != end();
|
||||||
// get the element value:
|
++it) {
|
||||||
bufferElementSize = get(iii, value);
|
value = *it;
|
||||||
if (value == etk::UChar::Return) {
|
if (value == etk::UChar::Return) {
|
||||||
return iii;
|
return it;
|
||||||
}
|
}
|
||||||
expand(charCount, value, expanded);
|
expand(charCount, value, expanded);
|
||||||
charCount += expanded.size();
|
charCount += expanded.size();
|
||||||
if (bufferElementSize <= 0) {
|
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
}
|
||||||
}
|
return end();
|
||||||
//APPL_DEBUG(" result=" << charCount);
|
|
||||||
return iii;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
esize_t appl::Buffer::countForwardNLines(esize_t _startPos, int32_t _nLines) {
|
esize_t appl::Buffer::countForwardNLines(esize_t _startPos, int32_t _nLines) {
|
||||||
if (_nLines <= 0) {
|
if (_nLines <= 0) {
|
||||||
return _startPos;
|
return _startPos;
|
||||||
} else if (_startPos > m_data.size() ) {
|
} else if (_startPos > m_data.size() ) {
|
||||||
return m_data.size();
|
return end();
|
||||||
}
|
}
|
||||||
esize_t bufferElementSize;
|
|
||||||
etk::UChar value;
|
etk::UChar value;
|
||||||
int32_t lineCount = 0;
|
int32_t lineCount = 0;
|
||||||
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
|
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
|
||||||
for(int32_t iii = _startPos+1; iii<m_data.size() ; iii+=bufferElementSize ) {
|
for (Iterator it = ++position(_startPos);
|
||||||
// get the element value:
|
it != end();
|
||||||
bufferElementSize = get(iii, value);
|
++it) {
|
||||||
|
value = *it;
|
||||||
if (value == etk::UChar::Return) {
|
if (value == etk::UChar::Return) {
|
||||||
lineCount++;
|
lineCount++;
|
||||||
if (lineCount == _nLines) {
|
if (lineCount == _nLines) {
|
||||||
//APPL_INFO(" == > (1) at position=" << myPosIt.Position()+1 );
|
//APPL_INFO(" == > (1) at position=" << myPosIt.Position()+1 );
|
||||||
return iii+1;
|
return (esize_t)it + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bufferElementSize <= 0) {
|
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//APPL_INFO(" == > (2) at position=" << myPosIt.Position() );
|
//APPL_INFO(" == > (2) at position=" << myPosIt.Position() );
|
||||||
return m_data.size();
|
return end();
|
||||||
}
|
}
|
||||||
|
|
||||||
esize_t appl::Buffer::countBackwardNLines(esize_t _startPos, int32_t _nLines) {
|
esize_t appl::Buffer::countBackwardNLines(esize_t _startPos, int32_t _nLines) {
|
||||||
@ -809,25 +759,22 @@ esize_t appl::Buffer::countBackwardNLines(esize_t _startPos, int32_t _nLines) {
|
|||||||
_startPos = m_data.size();
|
_startPos = m_data.size();
|
||||||
}
|
}
|
||||||
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
|
//APPL_INFO("startPos=" << startPos << " nLines=" << nLines);
|
||||||
esize_t bufferElementSize;
|
|
||||||
etk::UChar value;
|
etk::UChar value;
|
||||||
int32_t lineCount = 0;
|
int32_t lineCount = 0;
|
||||||
for(int32_t iii = _startPos-1; iii >= 0 ; iii-=bufferElementSize ) {
|
for (Iterator it = --position(_startPos);
|
||||||
// get the element value:
|
it != begin();
|
||||||
bufferElementSize = getBack(iii, value);
|
--it) {
|
||||||
|
value = *it;
|
||||||
if (value == etk::UChar::Return) {
|
if (value == etk::UChar::Return) {
|
||||||
lineCount++;
|
lineCount++;
|
||||||
if (lineCount >= _nLines) {
|
if (lineCount >= _nLines) {
|
||||||
//APPL_INFO(" == > (1) at position=" << myPosIt.Position()+1 );
|
//APPL_INFO(" == > (1) at position=" << myPosIt.Position()+1 );
|
||||||
return iii+1;
|
return ++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bufferElementSize <= 0) {
|
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//APPL_INFO(" == > (2) at position=0");
|
//APPL_INFO(" == > (2) at position=0");
|
||||||
return 0;
|
return begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -837,15 +784,11 @@ bool appl::Buffer::copy(etk::UString& _data) {
|
|||||||
if (hasTextSelected() == true) {
|
if (hasTextSelected() == true) {
|
||||||
esize_t startPos = getStartSelectionPos();
|
esize_t startPos = getStartSelectionPos();
|
||||||
esize_t endPos = getStopSelectionPos();
|
esize_t endPos = getStopSelectionPos();
|
||||||
esize_t bufferElementSize;
|
for (Iterator it = position(startPos);
|
||||||
etk::UChar value;
|
it != position(endPos) &&
|
||||||
for(int32_t iii = startPos; iii < endPos ; iii+=bufferElementSize ) {
|
it != end();
|
||||||
// get the element value:
|
++it) {
|
||||||
bufferElementSize = get(iii, value);
|
_data += *it;
|
||||||
_data += value;
|
|
||||||
if (bufferElementSize <= 0) {
|
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -875,3 +818,5 @@ void appl::Buffer::removeSelection(void) {
|
|||||||
moveCursor(startPos);
|
moveCursor(startPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,138 @@
|
|||||||
|
|
||||||
namespace appl {
|
namespace appl {
|
||||||
class Buffer : public ewol::EObject {
|
class Buffer : public ewol::EObject {
|
||||||
|
public:
|
||||||
|
|
||||||
|
class Iterator {
|
||||||
|
// Private data :
|
||||||
|
private:
|
||||||
|
esize_t m_current; //!< curent Id in the Buffer
|
||||||
|
appl::Buffer* m_data; //!< Pointer on the curent Buffer
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Basic itarator constructor with no link.
|
||||||
|
*/
|
||||||
|
Iterator(void):
|
||||||
|
m_current(0),
|
||||||
|
m_data(NULL) {
|
||||||
|
// nothing to do ...
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Recopy constructor.
|
||||||
|
* @param[in] _obj The Iterator that might be copy
|
||||||
|
*/
|
||||||
|
Iterator(const Iterator & _obj):
|
||||||
|
m_current(_obj.m_current),
|
||||||
|
m_data(_obj.m_data) {
|
||||||
|
// nothing to do ...
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Asignation operator.
|
||||||
|
* @param[in] _otherIterator The Iterator that might be copy
|
||||||
|
* @return reference on the curent Iterator
|
||||||
|
*/
|
||||||
|
Iterator& operator=(const Iterator & _obj) {
|
||||||
|
m_current = _obj.m_current;
|
||||||
|
m_data = _obj.m_data;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Basic destructor
|
||||||
|
*/
|
||||||
|
~Iterator(void) {
|
||||||
|
m_current = 0;
|
||||||
|
m_data = NULL;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief basic boolean cast
|
||||||
|
* @return true if the element is present in buffer
|
||||||
|
*/
|
||||||
|
operator bool (void) {
|
||||||
|
if (m_data == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (m_current < m_data->m_data.size());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief basic boolean cast
|
||||||
|
* @return true if the element is present in buffer
|
||||||
|
*/
|
||||||
|
operator esize_t (void) {
|
||||||
|
if (m_data == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return m_current;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Incremental operator
|
||||||
|
* @return Reference on the current iterator incremented
|
||||||
|
*/
|
||||||
|
Iterator& operator++ (void);
|
||||||
|
/**
|
||||||
|
* @brief Decremental operator
|
||||||
|
* @return Reference on the current iterator decremented
|
||||||
|
*/
|
||||||
|
Iterator& operator-- (void);
|
||||||
|
/**
|
||||||
|
* @brief Incremental operator
|
||||||
|
* @return Reference on a new iterator and increment the other one
|
||||||
|
*/
|
||||||
|
Iterator operator++ (int32_t) {
|
||||||
|
Iterator it(*this);
|
||||||
|
++(*this);
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Decremental operator
|
||||||
|
* @return Reference on a new iterator and decrement the other one
|
||||||
|
*/
|
||||||
|
Iterator operator-- (int32_t) {
|
||||||
|
Iterator it(*this);
|
||||||
|
--(*this);
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief egality iterator
|
||||||
|
* @return true if the iterator is identical pos
|
||||||
|
*/
|
||||||
|
bool operator== (const Iterator& _obj) {
|
||||||
|
if ( m_current == _obj.m_current
|
||||||
|
&& m_data == _obj.m_data) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief egality iterator
|
||||||
|
* @return true if the iterator is identical pos
|
||||||
|
*/
|
||||||
|
bool operator!= (const Iterator& _obj) {
|
||||||
|
if ( m_current != _obj.m_current
|
||||||
|
|| m_data != _obj.m_data) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief Get the value on the current element
|
||||||
|
* @return The request element value
|
||||||
|
*/
|
||||||
|
etk::UChar operator* (void) const ;
|
||||||
|
/**
|
||||||
|
* @brief Get the position in the buffer
|
||||||
|
* @return The requested position.
|
||||||
|
*/
|
||||||
|
esize_t getPos(void) {
|
||||||
|
return m_current;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Iterator(Buffer* _obj, int32_t _pos) :
|
||||||
|
m_current(_pos),
|
||||||
|
m_data(_obj) {
|
||||||
|
// nothing to do ...
|
||||||
|
}
|
||||||
|
friend class Buffer;
|
||||||
|
};
|
||||||
public:
|
public:
|
||||||
Buffer(void);
|
Buffer(void);
|
||||||
~Buffer(void) { };
|
~Buffer(void) { };
|
||||||
@ -102,22 +234,6 @@ namespace appl {
|
|||||||
* @return Position in the buffer
|
* @return Position in the buffer
|
||||||
*/
|
*/
|
||||||
esize_t getMousePosition(const vec2& _relativePos, ewol::Text& _textDrawer);
|
esize_t getMousePosition(const vec2& _relativePos, ewol::Text& _textDrawer);
|
||||||
/**
|
|
||||||
* @brief get the next element in the buffer.
|
|
||||||
* @param[in] _pos Position in the buffer
|
|
||||||
* @param[out] _value Unicode value read in the buffer
|
|
||||||
* @param[in] _charset Charset used to parse the current buffer
|
|
||||||
* @return number ofelement read in the buffer (to increment the position)
|
|
||||||
*/
|
|
||||||
esize_t get(esize_t _pos, etk::UChar& _value, unicode::charset_te _charset = unicode::EDN_CHARSET_UTF8) const;
|
|
||||||
/**
|
|
||||||
* @brief get the previous element in the buffer.
|
|
||||||
* @param[in] _pos Position in the buffer (last element of the element)
|
|
||||||
* @param[out] _value Unicode value read in the buffer
|
|
||||||
* @param[in] _charset Charset used to parse the current buffer
|
|
||||||
* @return number of element read in the buffer (to increment the position)
|
|
||||||
*/
|
|
||||||
esize_t getBack(esize_t _pos, etk::UChar& _value, unicode::charset_te _charset = unicode::EDN_CHARSET_UTF8) const;
|
|
||||||
/**
|
/**
|
||||||
* @brief Expand the specify char to have a user frendly display for special char and tabs
|
* @brief Expand the specify char to have a user frendly display for special char and tabs
|
||||||
* @param[in] _indent Curent indentation in the line
|
* @param[in] _indent Curent indentation in the line
|
||||||
@ -226,7 +342,23 @@ namespace appl {
|
|||||||
* @brief Remove the selection of the buffer. (do nothing if no secection)
|
* @brief Remove the selection of the buffer. (do nothing if no secection)
|
||||||
*/
|
*/
|
||||||
void removeSelection(void);
|
void removeSelection(void);
|
||||||
|
public: // iterator section :
|
||||||
|
/**
|
||||||
|
* @brief Get an iterator an an specific position
|
||||||
|
* @param[in] _pos Requested position of the iterator in the vector
|
||||||
|
* @return The Iterator
|
||||||
|
*/
|
||||||
|
Iterator position(esize_t _pos);
|
||||||
|
/**
|
||||||
|
* @brief Get an Iterator on the start position of the Vector
|
||||||
|
* @return The Iterator
|
||||||
|
*/
|
||||||
|
Iterator begin(void);
|
||||||
|
/**
|
||||||
|
* @brief Get an Iterator on the end position of the Vector
|
||||||
|
* @return The Iterator
|
||||||
|
*/
|
||||||
|
Iterator end(void);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,9 +122,8 @@ void appl::TextViewer::onRegenerateDisplay(void) {
|
|||||||
m_displayText.setColor(etk::Color<>(0, 0, 0, 256));
|
m_displayText.setColor(etk::Color<>(0, 0, 0, 256));
|
||||||
float countNbLine = 1;
|
float countNbLine = 1;
|
||||||
esize_t countColomn = 0;
|
esize_t countColomn = 0;
|
||||||
vec3 tmpLetterSize = m_displayText.calculateSize((etk::UChar)'A');
|
m_displayText.setPos(vec3(0.0f, m_size.y(), 0));
|
||||||
vec3 positionCurentDisplay(0.0f, m_size.y()-tmpLetterSize.y(), 0.0f);
|
m_displayText.forceLineReturn();
|
||||||
m_displayText.setPos(positionCurentDisplay);
|
|
||||||
// the siplay string :
|
// the siplay string :
|
||||||
etk::UString stringToDisplay;
|
etk::UString stringToDisplay;
|
||||||
esize_t bufferElementSize = 0;
|
esize_t bufferElementSize = 0;
|
||||||
@ -136,44 +135,31 @@ void appl::TextViewer::onRegenerateDisplay(void) {
|
|||||||
selectPosStart = -1;
|
selectPosStart = -1;
|
||||||
selectPosStop = -1;
|
selectPosStop = -1;
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii<buf.size(); iii+=bufferElementSize) {
|
for (appl::Buffer::Iterator it = m_buffer->begin();
|
||||||
if (iii == m_buffer->m_cursorPos) {
|
it != m_buffer->end();
|
||||||
|
++it) {
|
||||||
|
if ((esize_t)it == m_buffer->m_cursorPos) {
|
||||||
// need to display the cursor :
|
// need to display the cursor :
|
||||||
tmpCursorPosition = positionCurentDisplay;
|
tmpCursorPosition = m_displayText.getPos();
|
||||||
}
|
}
|
||||||
if (iii >= selectPosStart && iii < selectPosStop) {
|
currentValue = *it;
|
||||||
isSelect = true;
|
//APPL_DEBUG("display element '" << currentValue << "'at pos : " << m_displayText.getPos() );
|
||||||
} else {
|
|
||||||
isSelect = false;
|
|
||||||
}
|
|
||||||
bufferElementSize = m_buffer->get(iii, currentValue);
|
|
||||||
//APPL_DEBUG(" element size : " << iii << " : " << bufferElementSize);
|
//APPL_DEBUG(" element size : " << iii << " : " << bufferElementSize);
|
||||||
if (currentValue == etk::UChar::Return) {
|
if (currentValue == etk::UChar::Return) {
|
||||||
countNbLine += 1;
|
countNbLine += 1;
|
||||||
countColomn = 0;
|
countColomn = 0;
|
||||||
if (bufferElementSize == 0) {
|
m_displayText.forceLineReturn();
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
|
||||||
positionCurentDisplay.setX(0);
|
|
||||||
positionCurentDisplay.setY(positionCurentDisplay.y()-tmpLetterSize.y());
|
|
||||||
m_displayText.setPos(positionCurentDisplay);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_buffer->expand(countColomn, currentValue, stringToDisplay);
|
m_buffer->expand(countColomn, currentValue, stringToDisplay);
|
||||||
if (isSelect == true) {
|
if ((esize_t)it >= selectPosStart && (esize_t)it < selectPosStop) {
|
||||||
m_displayText.setColorBg(etk::Color<>(0x00FF00FF));
|
m_displayText.setColorBg(etk::Color<>(0x00FF00FF));
|
||||||
} else {
|
} else {
|
||||||
m_displayText.setColorBg(etk::Color<>(0x00000000));
|
m_displayText.setColorBg(etk::Color<>(0x00000000));
|
||||||
}
|
}
|
||||||
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
|
//APPL_DEBUG("display : '" << currentValue << "' == > '" << stringToDisplay << "'");
|
||||||
//m_displayText.setPos(positionCurentDisplay);
|
|
||||||
m_displayText.print(stringToDisplay);
|
m_displayText.print(stringToDisplay);
|
||||||
positionCurentDisplay = m_displayText.getPos();
|
|
||||||
countColomn += stringToDisplay.size();
|
countColomn += stringToDisplay.size();
|
||||||
|
|
||||||
if (bufferElementSize == 0) {
|
|
||||||
bufferElementSize = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (tmpCursorPosition.z()!=-1) {
|
if (tmpCursorPosition.z()!=-1) {
|
||||||
// display the cursor:
|
// display the cursor:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user