-std::string TextEditor::AccessibleImpl::GetName() const
-{
- auto self = Toolkit::TextEditor::DownCast(Self());
- return self.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
-}
-
-std::string TextEditor::AccessibleImpl::GetText(size_t startOffset, size_t endOffset) const
-{
- if(endOffset <= startOffset)
- {
- return {};
- }
-
- auto self = Toolkit::TextEditor::DownCast(Self());
- auto text = self.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
-
- if(startOffset > text.size() || endOffset > text.size())
- {
- return {};
- }
-
- return text.substr(startOffset, endOffset - startOffset);
-}
-
-size_t TextEditor::AccessibleImpl::GetCharacterCount() const
-{
- auto self = Toolkit::TextEditor::DownCast(Self());
- auto text = self.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
-
- return text.size();
-}
-
-size_t TextEditor::AccessibleImpl::GetCursorOffset() const
-{
- auto slf = Toolkit::TextEditor::DownCast(Self());
- return Dali::Toolkit::GetImpl(slf).GetTextController()->GetCursorPosition();
-}
-
-bool TextEditor::AccessibleImpl::SetCursorOffset(size_t offset)
-{
- auto slf = Toolkit::TextEditor::DownCast(Self());
- auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
- if(offset > txt.size())
- {
- return false;
- }
-
- auto& slfImpl = Dali::Toolkit::GetImpl(slf);
- slfImpl.GetTextController()->ResetCursorPosition(offset);
- slfImpl.RequestTextRelayout();
-
- return true;
-}
-
-Dali::Accessibility::Range TextEditor::AccessibleImpl::GetTextAtOffset(size_t offset, Dali::Accessibility::TextBoundary boundary) const
-{
- auto self = Toolkit::TextEditor::DownCast(Self());
- auto text = self.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
- auto textSize = text.size();
-
- auto range = Dali::Accessibility::Range{};
-
- switch(boundary)
- {
- case Dali::Accessibility::TextBoundary::CHARACTER:
- {
- if(offset < textSize)
- {
- range.content = text[offset];
- range.startOffset = offset;
- range.endOffset = offset + 1;
- }
- break;
- }
- case Dali::Accessibility::TextBoundary::WORD:
- case Dali::Accessibility::TextBoundary::LINE:
- {
- auto textString = text.c_str();
- auto breaks = std::vector<char>(textSize, 0);
-
- if(boundary == Dali::Accessibility::TextBoundary::WORD)
- {
- Accessibility::Accessible::FindWordSeparationsUtf8(reinterpret_cast<const utf8_t*>(textString), textSize, "", breaks.data());
- }
- else
- {
- Accessibility::Accessible::FindLineSeparationsUtf8(reinterpret_cast<const utf8_t*>(textString), textSize, "", breaks.data());
- }
-
- auto index = 0u;
- auto counter = 0u;
- while(index < textSize && counter <= offset)
- {
- auto start = index;
- if(breaks[index])
- {
- while(breaks[index])
- {
- index++;
- }
- counter++;
- }
- else
- {
- if(boundary == Dali::Accessibility::TextBoundary::WORD)
- {
- index++;
- }
- if(boundary == Dali::Accessibility::TextBoundary::LINE)
- {
- counter++;
- }
- }
-
- if((counter > 0) && ((counter - 1) == offset))
- {
- range.content = text.substr(start, index - start + 1);
- range.startOffset = start;
- range.endOffset = index + 1;
- }
-
- if(boundary == Dali::Accessibility::TextBoundary::LINE)
- {
- index++;
- }
- }
- break;
- }
- case Dali::Accessibility::TextBoundary::SENTENCE:
- {
- /* not supported by default */
- break;
- }
- case Dali::Accessibility::TextBoundary::PARAGRAPH:
- {
- /* Paragraph is not supported by libunibreak library */
- break;
- }
- default:
- break;
- }
-
- return range;
-}
-
-Dali::Accessibility::Range TextEditor::AccessibleImpl::GetRangeOfSelection(size_t selectionIndex) const