[DEBUG] correction of the end cursor position
This commit is contained in:
parent
26d206caae
commit
a95a1e8033
@ -20,19 +20,25 @@ const char* const appl::Buffer::eventChangeName = "edn-buffer-name-change";
|
||||
|
||||
appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ (void) {
|
||||
m_value = etk::UChar::Null;
|
||||
if (m_current<0) {
|
||||
if (m_current < 0) {
|
||||
m_current = 0;
|
||||
return *this;
|
||||
}
|
||||
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()) {
|
||||
m_current = m_data->m_data.size();
|
||||
return *this;
|
||||
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 {
|
||||
m_current++;
|
||||
}
|
||||
}
|
||||
if (m_current >= m_data->m_data.size()) {
|
||||
m_current = m_data->m_data.size();
|
||||
}
|
||||
m_current+=nbChar;
|
||||
}
|
||||
APPL_DEBUG(" ==> return " << m_current);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -93,7 +99,7 @@ appl::Buffer::Iterator appl::Buffer::begin(void) {
|
||||
|
||||
appl::Buffer::Iterator appl::Buffer::end(void) {
|
||||
// TODO : chek the validity of the char ...
|
||||
return position( m_data.size()-1 );
|
||||
return position( m_data.size() );
|
||||
}
|
||||
|
||||
appl::Buffer::Iterator appl::Buffer::cursor(void) {
|
||||
@ -116,7 +122,7 @@ appl::Buffer::Buffer(void) :
|
||||
m_hasFileName(false),
|
||||
m_fileName(""),
|
||||
m_isModify(false),
|
||||
m_cursorPos(-1),
|
||||
m_cursorPos(0),
|
||||
m_cursorSelectPos(-1),
|
||||
m_cursorPreferredCol(-1),
|
||||
m_nbLines(1),
|
||||
@ -193,7 +199,7 @@ void appl::Buffer::setModification(bool _status) {
|
||||
|
||||
// TODO : Naming error
|
||||
void appl::Buffer::countNumberofLine(void) {
|
||||
m_nbLines = 0;
|
||||
m_nbLines = 1;
|
||||
for (Iterator it = begin();
|
||||
(bool)it == true;
|
||||
++it) {
|
||||
@ -201,9 +207,6 @@ void appl::Buffer::countNumberofLine(void) {
|
||||
++m_nbLines;
|
||||
}
|
||||
}
|
||||
if (m_nbLines == 0) {
|
||||
m_nbLines = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -260,6 +263,7 @@ bool appl::Buffer::searchBack(const appl::Buffer::Iterator& _pos, const char32_t
|
||||
|
||||
void appl::Buffer::moveCursor(int64_t _pos) {
|
||||
m_cursorPreferredCol = -1;
|
||||
APPL_DEBUG("move cursor : " << _pos << "/" << m_data.size());
|
||||
// selecting mode ...
|
||||
if (m_selectMode == true) {
|
||||
if (m_cursorSelectPos == -1) {
|
||||
@ -268,7 +272,7 @@ void appl::Buffer::moveCursor(int64_t _pos) {
|
||||
m_cursorSelectPos = 0;
|
||||
}
|
||||
}
|
||||
//APPL_DEBUG("Select : " << m_cursorSelectPos << " ==> " << newPos);
|
||||
//APPL_DEBUG("Select : " << m_cursorSelectPos << " ==> " << _pos);
|
||||
m_cursorPos = _pos;
|
||||
if (m_cursorPos == m_cursorSelectPos) {
|
||||
m_cursorSelectPos = -1;
|
||||
|
@ -101,8 +101,8 @@ namespace appl {
|
||||
if (m_current < 0) {
|
||||
return 0;
|
||||
}
|
||||
if (m_current >= m_data->m_data.size()) {
|
||||
return m_data->m_data.size()-1;
|
||||
if (m_current > m_data->m_data.size()) {
|
||||
return m_data->m_data.size();
|
||||
}
|
||||
return m_current;
|
||||
};
|
||||
|
@ -211,7 +211,8 @@ void appl::TextViewer::onRegenerateDisplay(void) {
|
||||
m_buffer->hightlightGenerateLines(displayLocalSyntax, (int64_t)startingIt, m_size.y());
|
||||
float maxSizeX = 0;
|
||||
appl::HighlightInfo * HLColor = NULL;
|
||||
for (appl::Buffer::Iterator it = startingIt;
|
||||
appl::Buffer::Iterator it;
|
||||
for (it = startingIt;
|
||||
(bool)it == true;
|
||||
++it) {
|
||||
if (it == m_buffer->cursor()) {
|
||||
@ -274,6 +275,9 @@ void appl::TextViewer::onRegenerateDisplay(void) {
|
||||
m_displayText.print(stringToDisplay);
|
||||
countColomn += stringToDisplay.size();
|
||||
}
|
||||
if (it == m_buffer->cursor()) {
|
||||
tmpCursorPosition = m_displayText.getPos();
|
||||
}
|
||||
maxSizeX = etk_max(m_displayText.getPos().x(), maxSizeX);
|
||||
// Display cursor only if we have the focus ...
|
||||
if ( tmpCursorPosition.z() != -1
|
||||
@ -700,6 +704,7 @@ 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;
|
||||
}
|
||||
@ -708,6 +713,7 @@ 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;
|
||||
@ -789,8 +795,9 @@ void appl::TextViewer::moveCursorRight(appl::TextViewer::moveMode _mode) {
|
||||
default:
|
||||
case moveLetter:
|
||||
it = m_buffer->cursor();
|
||||
++it;
|
||||
APPL_ERROR("Cursor position : " << (int64_t)it);
|
||||
++it;
|
||||
APPL_ERROR("Cursor position new : " << (int64_t)it);
|
||||
moveCursor(it);
|
||||
break;
|
||||
case moveWord:
|
||||
@ -812,7 +819,7 @@ void appl::TextViewer::moveCursorLeft(appl::TextViewer::moveMode _mode) {
|
||||
switch (_mode) {
|
||||
default:
|
||||
case moveLetter:
|
||||
it = m_buffer->cursor();;
|
||||
it = m_buffer->cursor();
|
||||
--it;
|
||||
APPL_ERROR("Cursor position : " << (int64_t)it);
|
||||
moveCursor(it);
|
||||
|
Loading…
x
Reference in New Issue
Block a user