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

This commit is contained in:
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;
};
};