X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Finput%2Fubuntu-x11%2Finput-method-context-impl-x.cpp;h=7101b586aa014138cd815353de399ef0edd26b95;hb=aae144428d03c9e315384225ad33c057b42ea408;hp=ca80d03c5fa4bffc46f6573c6cf027ee1d19af88;hpb=9a0f20ec7c6630ac7e4f7df308d123623456eb51;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp index ca80d03..7101b58 100755 --- a/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp +++ b/dali/internal/input/ubuntu-x11/input-method-context-impl-x.cpp @@ -19,21 +19,22 @@ #include // EXTERNAL INCLUDES -#include -#include #include -#include #include +#include #include // INTERNAL INCLUDES -#include +#include +#include #include -#include -#include -#include #include +#include +#include #include +#include +#include +#include namespace Dali { @@ -312,6 +313,8 @@ void InputMethodContextX::PreEditChanged( void*, ImfContext* imfContext, void* e Ecore_IMF_Preedit_Attr* attr; + mPreeditAttrs.Clear(); + // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string. // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string. ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition ); @@ -321,38 +324,85 @@ void InputMethodContextX::PreEditChanged( void*, ImfContext* imfContext, void* e // iterate through the list of attributes getting the type, start and end position. for ( l = attrs, (attr = static_cast( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast( eina_list_data_get(l) ) )) { -#ifdef DALI_PROFILE_UBUNTU - if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF) -#else // DALI_PROFILE_UBUNTU - if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF) -#endif // DALI_PROFILE_UBUNTU - { - // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages. + Dali::InputMethodContext::PreeditAttributeData data; + data.startIndex = 0; + data.endIndex = 0; - size_t visualCharacterIndex = 0; - size_t byteIndex = 0; + size_t visualCharacterIndex = 0; + size_t byteIndex = 0; - // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ). - const char leadByte = preEditString[byteIndex]; - while( leadByte != '\0' ) + // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ). + const char leadByte = preEditString[byteIndex]; + while( leadByte != '\0' ) + { + // attr->end_index is provided as a byte position not character and we need to know the character position. + const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character. + if( byteIndex <= attr->start_index ) + { + data.startIndex = visualCharacterIndex; + } + if ( byteIndex >= attr->end_index ) + { + data.endIndex = visualCharacterIndex; + break; + // end loop as found cursor position that matches byte position + } + else { - // attr->end_index is provided as a byte position not character and we need to know the character position. - const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character. - if ( byteIndex == attr->end_index ) - { - cursorPosition = static_cast( visualCharacterIndex ); - break; - // end loop as found cursor position that matches byte position - } - else - { - byteIndex += currentSequenceLength; // jump to next character - visualCharacterIndex++; // increment character count so we know our position for when we get a match - } - - DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString )); + byteIndex += currentSequenceLength; // jump to next character + visualCharacterIndex++; // increment character count so we know our position for when we get a match } } + + switch( attr->preedit_type ) + { + case ECORE_IMF_PREEDIT_TYPE_NONE: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB1: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB2: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::REVERSE; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB3: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB4: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_1; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB5: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_2; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB6: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_3; + break; + } + case ECORE_IMF_PREEDIT_TYPE_SUB7: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::CUSTOM_PLATFORM_STYLE_4; + break; + } + default: + { + data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE; + break; + } + } + mPreeditAttrs.PushBack( data ); } } @@ -790,6 +840,12 @@ void InputMethodContextX::SetInputPanelPosition( unsigned int x, unsigned int y // ecore_imf_context_input_panel_position_set() is supported from ecore-imf 1.21.0 version. } +void InputMethodContextX::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttributeData >& attrs ) const +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" ); + attrs = mPreeditAttrs; +} + bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent ) { bool eventHandled( false ); @@ -810,13 +866,13 @@ bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent ) ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier ); ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier ); -#ifdef defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) -#ifdef (ECORE_VERSION_MINOR >= 14) +#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) +#if (ECORE_VERSION_MINOR >= 14) ecoreKeyDownEvent.dev_name = ""; ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD; ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE; #endif // Since ecore_imf 1.14 version -#ifdef (ECORE_VERSION_MINOR >= 22) +#if (ECORE_VERSION_MINOR >= 22) ecoreKeyDownEvent.keycode = keyEvent.keyCode; #endif // Since ecore_imf 1.22 version #endif // Since ecore_imf Version 1 @@ -869,11 +925,11 @@ bool InputMethodContextX::ProcessEventKeyUp( const KeyEvent& keyEvent ) ecoreKeyUpEvent.timestamp = keyEvent.time; ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier ); ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier ); -#ifdef defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) -#ifdef (ECORE_VERSION_MINOR >= 14) +#if defined(ECORE_VERSION_MAJOR) && (ECORE_VERSION_MAJOR >= 1) && defined(ECORE_VERSION_MINOR) +#if (ECORE_VERSION_MINOR >= 14) ecoreKeyUpEvent.dev_name = ""; #endif // Since ecore_imf 1.14 version -#ifdef (ECORE_VERSION_MINOR >= 22) +#if (ECORE_VERSION_MINOR >= 22) ecoreKeyUpEvent.keycode = keyEvent.keyCode; #endif // Since ecore_imf 1.22 version #endif // Since ecore_imf Version 1