- Add more preedit styles for substring : SUB4, SUB5, SUB6, and SUB7.
- The preedit type is NONE, SUB1 ~ SUB7.
But, DALi changed the name exactly, such as 'UNDERLINE' instead of 'SUB1' and
'REVERSE' instead of 'SUB2'.
SUB4 ~ 7 are just to draw the text in underline with various background color.
- The index received from imf is a byte. So it should be converted to character index.
Change-Id: Iea64e1bfc27ff291cee592c839013171df75d31c
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
Internal::Adaptor::InputMethodContext::GetImplementation(*this).SetInputPanelPosition( x, y );
}
-Dali::InputMethodContext::PreeditStyle InputMethodContext::GetPreeditStyle() const
+void InputMethodContext::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const
{
- return Internal::Adaptor::InputMethodContext::GetImplementation(*this).GetPreeditStyle();
+ Internal::Adaptor::InputMethodContext::GetImplementation(*this).GetPreeditStyle( attrs );
}
// Signals
// EXTERNAL INCLUDES
#include <dali/public-api/events/key-event.h>
+#include <dali/public-api/common/dali-vector.h>
// EXTERNAL INCLUDES
#include <dali/public-api/object/base-handle.h>
*/
enum class PreeditStyle
{
- NONE, ///< None style
- UNDERLINE, ///< Underline substring style
- REVERSE, ///< Reverse substring style
- HIGHLIGHT ///< Highlight substring style
+ NONE, ///< None style
+ UNDERLINE, ///< Underline substring style
+ REVERSE, ///< Reverse substring style
+ HIGHLIGHT, ///< Highlight substring style
+ HIGHLIGHT_SUB4, ///< SUB4 substring style
+ HIGHLIGHT_SUB5, ///< SUB5 substring style
+ HIGHLIGHT_SUB6, ///< SUB6 substring style
+ HIGHLIGHT_SUB7 ///< SUB7 substring style
+ };
+
+ /**
+ * @brief This structure is for the preedit style types and indices.
+ */
+ struct PreeditAttrData
+ {
+ PreeditStyle preeditType; /// The preedit style type
+ unsigned int startIndex; /// The start index of preedit
+ unsigned int endIndex; /// The end index of preedit
};
/**
void SetInputPanelPosition( unsigned int x, unsigned int y );
/**
- * @brief Gets the preedit type.
+ * @brief Gets the preedit attrs data.
*
- * @return The preedit style type
+ * @param[out] attrs The preedit attrs data.
*/
- PreeditStyle GetPreeditStyle() const;
+ void GetPreeditStyle( Vector<PreeditAttrData>& attrs ) const;
public:
/**
* @copydoc Dali::InputMethodContext::GetPreeditStyle()
*/
- virtual Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const { return Dali::InputMethodContext::PreeditStyle(); }
+ virtual void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const {}
public: // Signals
DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::SetInputPanelPosition\n" );
}
-Dali::InputMethodContext::PreeditStyle InputMethodContextGeneric::GetPreeditStyle() const
+void InputMethodContextGeneric::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs) const
{
DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" );
-
- return Dali::InputMethodContext::PreeditStyle::NONE;
+ // Do Nothing
}
} // Adaptor
/**
* @copydoc Dali::InputMethodContext::GetPreeditStyle()
*/
- Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override;
+ void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const override;
public:
mSurroundingText(),
mRestoreAfterFocusLost( false ),
mIdleCallbackConnected( false ),
- mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE ),
mWindowId( GetWindowIdFromActor( actor ) )
{
ecore_imf_init();
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 );
// iterate through the list of attributes getting the type, start and end position.
for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
{
+ Dali::InputMethodContext::PreeditAttrData data;
+ data.startIndex = 0;
+ data.endIndex = 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' )
+ {
+ // 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
+ {
+ 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:
{
- mPreeditType = Dali::InputMethodContext::PreeditStyle::NONE;
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE;
break;
}
case ECORE_IMF_PREEDIT_TYPE_SUB1:
{
- mPreeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE;
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE;
break;
}
case ECORE_IMF_PREEDIT_TYPE_SUB2:
{
- mPreeditType = Dali::InputMethodContext::PreeditStyle::REVERSE;
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::REVERSE;
break;
}
case ECORE_IMF_PREEDIT_TYPE_SUB3:
{
- mPreeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT;
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT;
break;
}
- default:
+ case ECORE_IMF_PREEDIT_TYPE_SUB4:
{
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT_SUB4;
break;
}
- }
-
-#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.
-
- 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' )
+ case ECORE_IMF_PREEDIT_TYPE_SUB5:
{
- // 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 = 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 ));
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT_SUB5;
+ break;
+ }
+ case ECORE_IMF_PREEDIT_TYPE_SUB6:
+ {
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT_SUB6;
+ break;
+ }
+ case ECORE_IMF_PREEDIT_TYPE_SUB7:
+ {
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT_SUB7;
+ break;
+ }
+ default:
+ {
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE;
+ break;
}
}
+ mPreeditAttrs.PushBack( data );
}
}
mBackupOperations[Operation::SET_INPUT_PANEL_POSITION] = std::bind( &InputMethodContextEcoreWl::SetInputPanelPosition, this, x, y );
}
-Dali::InputMethodContext::PreeditStyle InputMethodContextEcoreWl::GetPreeditStyle() const
+void InputMethodContextEcoreWl::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const
{
DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextEcoreWl::GetPreeditStyle\n" );
- return mPreeditType;
+ attrs = mPreeditAttrs;
}
bool InputMethodContextEcoreWl::ProcessEventKeyDown( const KeyEvent& keyEvent )
/**
* @copydoc Dali::InputMethodContext::GetPreeditStyle()
*/
- Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override;
+ void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const override;
private:
/**
std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
InputMethodOptions mOptions;
- Dali::InputMethodContext::PreeditStyle mPreeditType;
+ Vector< Dali::InputMethodContext::PreeditAttrData > mPreeditAttrs; ///< Stores preedit attr data
int mWindowId;
};
mIMFCursorPosition( 0 ),
mSurroundingText(),
mRestoreAfterFocusLost( false ),
- mIdleCallbackConnected( false ),
- mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE )
+ mIdleCallbackConnected( false )
{
ecore_imf_init();
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 );
// iterate through the list of attributes getting the type, start and end position.
for ( l = attrs, (attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast<Ecore_IMF_Preedit_Attr*>( eina_list_data_get(l) ) ))
{
+ Dali::InputMethodContext::PreeditAttrData data;
+ data.startIndex = 0;
+ data.endIndex = 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' )
+ {
+ // 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
+ {
+ 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:
{
- mPreeditType = Dali::InputMethodContext::PreeditStyle::NONE;
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE;
break;
}
case ECORE_IMF_PREEDIT_TYPE_SUB1:
{
- mPreeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE;
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::UNDERLINE;
break;
}
case ECORE_IMF_PREEDIT_TYPE_SUB2:
{
- mPreeditType = Dali::InputMethodContext::PreeditStyle::REVERSE;
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::REVERSE;
break;
}
case ECORE_IMF_PREEDIT_TYPE_SUB3:
{
- mPreeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT;
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT;
break;
}
- default:
+ case ECORE_IMF_PREEDIT_TYPE_SUB4:
{
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT_SUB4;
break;
}
- }
-
-#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.
-
- 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' )
+ case ECORE_IMF_PREEDIT_TYPE_SUB5:
{
- // 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<int>( 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 ));
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT_SUB5;
+ break;
+ }
+ case ECORE_IMF_PREEDIT_TYPE_SUB6:
+ {
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT_SUB6;
+ break;
+ }
+ case ECORE_IMF_PREEDIT_TYPE_SUB7:
+ {
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::HIGHLIGHT_SUB7;
+ break;
+ }
+ default:
+ {
+ data.preeditType = Dali::InputMethodContext::PreeditStyle::NONE;
+ break;
}
}
+ mPreeditAttrs.PushBack( data );
}
}
// ecore_imf_context_input_panel_position_set() is supported from ecore-imf 1.21.0 version.
}
-Dali::InputMethodContext::PreeditStyle InputMethodContextX::GetPreeditStyle() const
+void InputMethodContextX::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const
{
DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextX::GetPreeditStyle\n" );
- return mPreeditType;
+ attrs = mPreeditAttrs;
}
bool InputMethodContextX::ProcessEventKeyDown( const KeyEvent& keyEvent )
/**
* @copydoc Dali::InputMethodContext::GetPreeditStyle()
*/
- Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override;
+ void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const override;
private:
/**
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
InputMethodOptions mOptions;
- Dali::InputMethodContext::PreeditStyle mPreeditType;
+ Vector< Dali::InputMethodContext::PreeditAttrData > mPreeditAttrs; ///< Stores preedit attr data
};
} // namespace Adaptor
mIMFCursorPosition( 0 ),\r
mSurroundingText(),\r
mRestoreAfterFocusLost( false ),\r
- mIdleCallbackConnected( false ),\r
- mPreeditType( Dali::InputMethodContext::PreeditStyle::NONE )\r
+ mIdleCallbackConnected( false )\r
{\r
\r
actor.OnStageSignal().Connect( this, &InputMethodContextWin::OnStaged );\r
DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelPosition\n" );\r
}\r
\r
-Dali::InputMethodContext::PreeditStyle InputMethodContextWin::GetPreeditStyle() const\r
+void InputMethodContextWin::GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const\r
{\r
DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetPreeditStyle\n" );\r
- return mPreeditType;\r
+ attrs = mPreeditAttrs;\r
}\r
\r
bool InputMethodContextWin::ProcessEventKeyDown( const KeyEvent& keyEvent )\r
/**\r
* @copydoc Dali::InputMethodContext::GetPreeditStyle()\r
*/\r
- Dali::InputMethodContext::PreeditStyle GetPreeditStyle() const override;\r
+ void GetPreeditStyle( Vector< Dali::InputMethodContext::PreeditAttrData >& attrs ) const override;\r
\r
private:\r
/**\r
bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.\r
bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.\r
InputMethodOptions mOptions;\r
- Dali::InputMethodContext::PreeditStyle mPreeditType;\r
+ Vector< Dali::InputMethodContext::PreeditAttrData > mPreeditAttrs;\r
};\r
\r
} // namespace Adaptor\r