diff --git a/jni/edn/Buffer/Buffer.cpp b/jni/edn/Buffer/Buffer.cpp index 22556e6..f9b3321 100644 --- a/jni/edn/Buffer/Buffer.cpp +++ b/jni/edn/Buffer/Buffer.cpp @@ -270,7 +270,7 @@ void Buffer::cursorMove(ewol::eventKbMoveType_te moveTypeEvent) * @return --- * */ -void Buffer::AddChar(char * UTF8data) +void Buffer::AddChar(uniChar_t unicodeData) { // nothing to do } diff --git a/jni/edn/Buffer/Buffer.h b/jni/edn/Buffer/Buffer.h index 135ea39..e9b7ef1 100644 --- a/jni/edn/Buffer/Buffer.h +++ b/jni/edn/Buffer/Buffer.h @@ -88,7 +88,7 @@ class Buffer { ewol::OObject2DTextColored* OOTextBoldItalic, ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY); virtual void ForceReDraw(bool allElement); - virtual void AddChar(char * UTF8data); + virtual void AddChar(uniChar_t unicodeData); virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent); virtual void MouseSelectFromCursorTo(int32_t width, int32_t height); virtual void MouseEvent(int32_t width, int32_t height); diff --git a/jni/edn/Buffer/BufferText.cpp b/jni/edn/Buffer/BufferText.cpp index ef7ace2..f32c4bc 100644 --- a/jni/edn/Buffer/BufferText.cpp +++ b/jni/edn/Buffer/BufferText.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -1035,102 +1036,94 @@ void BufferText::UpdateWindowsPosition(bool centerPage) * @return --- * */ -void BufferText::AddChar(char * UTF8data) +void BufferText::AddChar(uniChar_t unicodeData) { int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd; bool SelectionIsRect; bool haveSelectionActive = m_EdnBuf.GetSelectionPos(SELECTION_PRIMARY, SelectionStart, SelectionEnd, SelectionIsRect, SelectionRectStart, SelectionRectEnd); - - int32_t size=strlen(UTF8data); - bool actionDone = false; - if (1==size) { - if (UTF8data[0] == 0x09) { - if (false == haveSelectionActive) { + if (unicodeData == 0x09) { + if (false == haveSelectionActive) { + etk::VectorType tmpVect; + tmpVect.PushBack(0x09); + m_EdnBuf.Insert(m_cursorPos, tmpVect); + SetInsertPosition(m_cursorPos+1, true); + } else { + // Indent depend of the multiline in the selection ... + // count the number of line : + int32_t nbSelectedLines = m_EdnBuf.CountLines(SelectionStart, SelectionEnd); + if (0 == nbSelectedLines) { etk::VectorType tmpVect; tmpVect.PushBack(0x09); - m_EdnBuf.Insert(m_cursorPos, tmpVect); - SetInsertPosition(m_cursorPos+1, true); - } else { - // Indent depend of the multiline in the selection ... - // count the number of line : - int32_t nbSelectedLines = m_EdnBuf.CountLines(SelectionStart, SelectionEnd); - if (0 == nbSelectedLines) { - etk::VectorType tmpVect; - tmpVect.PushBack(0x09); - m_EdnBuf.ReplaceSelected(SELECTION_PRIMARY, tmpVect); - SetInsertPosition(SelectionStart+tmpVect.Size(), true); - } else { - if (true == ewol::IsSetShift() ) { - m_cursorPos = m_EdnBuf.UnIndent(SELECTION_PRIMARY); - } else { - m_cursorPos = m_EdnBuf.Indent(SELECTION_PRIMARY); - } - } - } - actionDone = true; - } else if (UTF8data[0] == '\n') { - etk::VectorType tmpVect; - if (true == ewol::IsSetShift()) { - tmpVect.PushBack('\r'); - } else { - tmpVect.PushBack('\n'); - // if Auto indent Enable ==> we get the start of the previous line and add it to tne new one - if (true == globals::IsSetAutoIndent() ) { - int32_t l_lineStart; - // Get the begin of the line or the begin of the line befor selection - if (false == haveSelectionActive) { - l_lineStart = m_EdnBuf.StartOfLine(m_cursorPos); - } else { - l_lineStart = m_EdnBuf.StartOfLine(SelectionStart); - } - // add same characters in the temporar buffer - for (int32_t kk=l_lineStart; kk pos=" << m_cursorPos); - if (false == haveSelectionActive) { - m_EdnBuf.Remove(m_cursorPos, m_cursorPos+1); } else { - m_EdnBuf.RemoveSelected(SELECTION_PRIMARY); - SetInsertPosition(SelectionStart, true); + if (true == ewol::IsSetShift() ) { + m_cursorPos = m_EdnBuf.UnIndent(SELECTION_PRIMARY); + } else { + m_cursorPos = m_EdnBuf.Indent(SELECTION_PRIMARY); + } } - actionDone = true; - } else if (UTF8data[0] == 0x08) { - //EDN_INFO("keyEvent : pos=" << m_cursorPos); - if (false == haveSelectionActive) { - m_EdnBuf.Remove(m_cursorPos-1, m_cursorPos); - SetInsertPosition(m_cursorPos-1, true); - } else { - m_EdnBuf.RemoveSelected(SELECTION_PRIMARY); - SetInsertPosition(SelectionStart, true); - } - actionDone = true; } - } - - if (false == actionDone) { + } else if (unicodeData == '\n') { + etk::VectorType tmpVect; + if (true == ewol::IsSetShift()) { + tmpVect.PushBack('\r'); + } else { + tmpVect.PushBack('\n'); + // if Auto indent Enable ==> we get the start of the previous line and add it to tne new one + if (true == globals::IsSetAutoIndent() ) { + int32_t l_lineStart; + // Get the begin of the line or the begin of the line befor selection + if (false == haveSelectionActive) { + l_lineStart = m_EdnBuf.StartOfLine(m_cursorPos); + } else { + l_lineStart = m_EdnBuf.StartOfLine(SelectionStart); + } + // add same characters in the temporar buffer + for (int32_t kk=l_lineStart; kk pos=" << m_cursorPos); + if (false == haveSelectionActive) { + m_EdnBuf.Remove(m_cursorPos, m_cursorPos+1); + } else { + m_EdnBuf.RemoveSelected(SELECTION_PRIMARY); + SetInsertPosition(SelectionStart, true); + } + } else if (unicodeData == 0x08) { + //EDN_INFO("keyEvent : pos=" << m_cursorPos); + if (false == haveSelectionActive) { + m_EdnBuf.Remove(m_cursorPos-1, m_cursorPos); + SetInsertPosition(m_cursorPos-1, true); + } else { + m_EdnBuf.RemoveSelected(SELECTION_PRIMARY); + SetInsertPosition(SelectionStart, true); + } + } else { + // normal adding char ... if (true == m_EdnBuf.GetUTF8Mode()) { + char tmpUTF8[16]; + unicode::convertUnicodeToUtf8(unicodeData, tmpUTF8); etk::VectorType tmpVect; - int32_t localOfset = strlen(UTF8data); - tmpVect.PushBack((int8_t*)UTF8data, localOfset); + int32_t localOfset = strlen(tmpUTF8); + tmpVect.PushBack((int8_t*)tmpUTF8, localOfset); if (false == haveSelectionActive) { m_EdnBuf.Insert(m_cursorPos, tmpVect); SetInsertPosition(m_cursorPos+localOfset, true); @@ -1141,7 +1134,7 @@ void BufferText::AddChar(char * UTF8data) } else { // convert in the Good ISO format : char output_ISO; - convertUtf8ToIso(m_EdnBuf.GetCharsetType(), UTF8data, output_ISO); + unicode::convertUnicodeToIso(m_EdnBuf.GetCharsetType(), unicodeData, output_ISO); //printf(" insert : \"%s\"==> 0x%08x=%d ", UTF8data, (unsigned int)output_ISO, (int)output_ISO); etk::VectorType tmpVect; tmpVect.PushBack(output_ISO); diff --git a/jni/edn/Buffer/BufferText.h b/jni/edn/Buffer/BufferText.h index 5a9ba29..49acce5 100644 --- a/jni/edn/Buffer/BufferText.h +++ b/jni/edn/Buffer/BufferText.h @@ -54,7 +54,7 @@ class BufferText : public Buffer { int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY); void ForceReDraw(bool allElement); - void AddChar(char * UTF8data); + void AddChar(uniChar_t unicodeData); void cursorMove(ewol::eventKbMoveType_te moveTypeEvent); void MouseSelectFromCursorTo(int32_t width, int32_t height); void MouseEvent(int32_t width, int32_t height); diff --git a/jni/edn/CustumWidget/CodeView/CodeView.cpp b/jni/edn/CustumWidget/CodeView/CodeView.cpp index e04c5c7..bf019ca 100644 --- a/jni/edn/CustumWidget/CodeView/CodeView.cpp +++ b/jni/edn/CustumWidget/CodeView/CodeView.cpp @@ -126,11 +126,11 @@ void CodeView::OnRegenerateDisplay(void) } -bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]) +bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData) { //EDN_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent); if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) { - m_bufferManager->Get(m_bufferID)->AddChar(UTF8_data); + m_bufferManager->Get(m_bufferID)->AddChar(unicodeData); MarkToReedraw(); } return true; diff --git a/jni/edn/CustumWidget/CodeView/CodeView.h b/jni/edn/CustumWidget/CodeView/CodeView.h index 0126d63..668d505 100644 --- a/jni/edn/CustumWidget/CodeView/CodeView.h +++ b/jni/edn/CustumWidget/CodeView/CodeView.h @@ -54,7 +54,7 @@ class CodeView :public ewol::WidgetScrooled bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y); public: virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y); - virtual bool OnEventKb(ewol::eventKbType_te typeEvent, char UTF8_data[UTF8_MAX_SIZE]); + virtual bool OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData); virtual bool OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveType_te moveTypeEvent); virtual void OnGetFocus(void); virtual void OnLostFocus(void);