diff --git a/sources/appl/Buffer/Buffer.cpp b/sources/appl/Buffer/Buffer.cpp index 9490735..4b74bb6 100644 --- a/sources/appl/Buffer/Buffer.cpp +++ b/sources/appl/Buffer/Buffer.cpp @@ -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 : pos=" << m_cursorPos); } else if (_event.GetChar() == etk::UniChar::Delete) { APPL_INFO("keyEvent : 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; +} diff --git a/sources/appl/Buffer/Buffer.h b/sources/appl/Buffer/Buffer.h index c41b759..557fe18 100644 --- a/sources/appl/Buffer/Buffer.h +++ b/sources/appl/Buffer/Buffer.h @@ -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; }; }; diff --git a/sources/appl/Gui/TextViewer.cpp b/sources/appl/Gui/TextViewer.cpp index 1f84c3b..c8489ff 100644 --- a/sources/appl/Gui/TextViewer.cpp +++ b/sources/appl/Gui/TextViewer.cpp @@ -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; } diff --git a/sources/appl/Gui/TextViewer.h b/sources/appl/Gui/TextViewer.h index e362032..b000a89 100644 --- a/sources/appl/Gui/TextViewer.h +++ b/sources/appl/Gui/TextViewer.h @@ -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