[DEV] add element availlable ==> bug when adding special char

This commit is contained in:
Edouard DUPIN 2013-09-26 22:16:40 +02:00
parent 19d3750f01
commit 1a56f4c49c
4 changed files with 34 additions and 31 deletions

View File

@ -46,9 +46,11 @@ bool appl::Buffer::OnEventEntry(const ewol::EventEntry& _event)
}
if (_event.GetChar() == etk::UniChar::Tabulation) {
m_data.Insert(m_cursorPos, '\t');
m_cursorPos += 1;
} else if (_event.GetChar() == etk::UniChar::Return) {
m_data.Insert(m_cursorPos, '\n');
} else if (_event.GetChar() == etk::UniChar::Backspace ) {
m_cursorPos += 1;
} else if (_event.GetChar() == etk::UniChar::Suppress ) {
APPL_INFO("keyEvent : <suppr> pos=" << m_cursorPos);
} else if (_event.GetChar() == etk::UniChar::Delete) {
APPL_INFO("keyEvent : <del> pos=" << m_cursorPos);
@ -61,6 +63,7 @@ bool appl::Buffer::OnEventEntry(const ewol::EventEntry& _event)
values.PushBack(output[iii]);
}
m_data.Insert(m_cursorPos, values);
m_cursorPos += nbElement;
}
return true;
}
@ -72,3 +75,23 @@ bool appl::Buffer::OnEventEntry(const ewol::EventEntry& _event)
}
return false;
}
esize_t appl::Buffer::Get(esize_t _pos, etk::UniChar& _value, unicode::charset_te _charset) const
{
_value = '\0';
if (_charset == unicode::EDN_CHARSET_UTF8) {
char tmpVal[5];
tmpVal[0] = m_data[_pos];
tmpVal[1] = m_data[_pos+1];
tmpVal[2] = m_data[_pos+2];
tmpVal[3] = m_data[_pos+3];
tmpVal[4] = '\0';
// transform ...
int32_t nbElement = _value.SetUtf8(tmpVal);
return nbElement;
}
// TODO :: need to trancode iso ==> UNICODE ...
_value.Set(m_data[_pos]);
return 1;
}

View File

@ -46,6 +46,14 @@ namespace appl
public:
esize_t m_cursorPos; //!< cursor position.
bool OnEventEntry(const ewol::EventEntry& _event);
/**
* @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::UniChar& _value, unicode::charset_te _charset) const;
};
};

View File

@ -87,26 +87,6 @@ void appl::TextViewer::OnDraw(void)
WidgetScrooled::OnDraw();
}
esize_t appl::TextViewer::Get(esize_t _pos, etk::UniChar& _value, unicode::charset_te _charset) const
{
_value = '\0';
if (_charset == unicode::EDN_CHARSET_UTF8) {
char tmpVal[5];
tmpVal[0] = m_buffer->GetData()[_pos];
tmpVal[1] = m_buffer->GetData()[_pos+1];
tmpVal[2] = m_buffer->GetData()[_pos+2];
tmpVal[3] = m_buffer->GetData()[_pos+3];
tmpVal[4] = '\0';
// transform ...
int32_t nbElement = _value.SetUtf8(tmpVal);
return nbElement;
}
// TODO :: need to trancode iso ==> UNICODE ...
_value.Set(m_buffer->GetData()[_pos]);
return 1;
}
static const char *ControlCodeTable[32] = {
"NUL", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "ht", "nl", "vt", "np", "cr", "so", "si",
"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb", "can", "em", "sub", "esc", "fs", "gs", "rs", "us"};
@ -217,7 +197,7 @@ void appl::TextViewer::OnRegenerateDisplay(void)
// need to display the cursor :
tmpCursorPosition = positionCurentDisplay;
}
bufferElementSize = Get(iii, currentValue, unicode::EDN_CHARSET_UTF8);
bufferElementSize = m_buffer->Get(iii, currentValue, unicode::EDN_CHARSET_UTF8);
//APPL_DEBUG(" element size : " << iii << " : " << bufferElementSize);
if (currentValue == etk::UniChar::Return) {
countNbLine += 1;
@ -274,7 +254,7 @@ bool appl::TextViewer::OnEventInput(const ewol::EventInput& _event)
if (m_buffer != NULL) {
}
GetFocus();
KeepFocus();
return true;
}

View File

@ -47,14 +47,6 @@ namespace appl
virtual void OnGetFocus(void);
virtual void OnLostFocus(void);
private:
/**
* @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::UniChar& _value, unicode::charset_te _charset) const;
/**
* @brief Expand the specify char to have a user frendly display for special char and tabs
* @param[in] _indent Curent indentation in the line