2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/text-controller-text-updater.h>
22 #include <dali/integration-api/debug.h>
26 #include <dali-toolkit/internal/text/character-set-conversion.h>
27 #include <dali-toolkit/internal/text/markup-processor.h>
28 #include <dali-toolkit/internal/text/text-controller-impl.h>
29 #include <dali-toolkit/internal/text/text-editable-control-interface.h>
33 #if defined(DEBUG_ENABLED)
34 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_CONTROLS");
45 void Controller::TextUpdater::SetText(Controller& controller, const std::string& text)
47 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::SetText\n");
49 Controller::Impl& impl = *controller.mImpl;
51 // Reset keyboard as text changed
52 impl.ResetInputMethodContext();
54 // Remove the previously set text and style.
55 ResetText(controller);
58 controller.ClearStyleData();
60 CharacterIndex lastCursorIndex = 0u;
62 EventData*& eventData = impl.mEventData;
64 if(nullptr != eventData)
66 // If popup shown then hide it by switching to Editing state
67 if((EventData::SELECTING == eventData->mState) ||
68 (EventData::EDITING_WITH_POPUP == eventData->mState) ||
69 (EventData::EDITING_WITH_GRAB_HANDLE == eventData->mState) ||
70 (EventData::EDITING_WITH_PASTE_POPUP == eventData->mState))
72 impl.ChangeState(EventData::EDITING);
78 ModelPtr& model = impl.mModel;
79 LogicalModelPtr& logicalModel = model->mLogicalModel;
80 model->mVisualModel->SetTextColor(impl.mTextColor);
82 MarkupProcessData markupProcessData(logicalModel->mColorRuns,
83 logicalModel->mFontDescriptionRuns,
84 logicalModel->mEmbeddedItems,
85 logicalModel->mAnchors);
88 const uint8_t* utf8 = NULL;
89 if(impl.mMarkupProcessorEnabled)
91 ProcessMarkupString(text, markupProcessData);
92 textSize = markupProcessData.markupProcessedText.size();
94 // This is a bit horrible but std::string returns a (signed) char*
95 utf8 = reinterpret_cast<const uint8_t*>(markupProcessData.markupProcessedText.c_str());
99 textSize = text.size();
101 // This is a bit horrible but std::string returns a (signed) char*
102 utf8 = reinterpret_cast<const uint8_t*>(text.c_str());
105 // Convert text into UTF-32
106 Vector<Character>& utf32Characters = logicalModel->mText;
107 utf32Characters.Resize(textSize);
109 // Transform a text array encoded in utf8 into an array encoded in utf32.
110 // It returns the actual number of characters.
111 Length characterCount = Utf8ToUtf32(utf8, textSize, utf32Characters.Begin());
112 utf32Characters.Resize(characterCount);
114 DALI_ASSERT_DEBUG(textSize >= characterCount && "Invalid UTF32 conversion length");
115 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::SetText %p UTF8 size %d, UTF32 size %d\n", &controller, textSize, logicalModel->mText.Count());
117 // The characters to be added.
118 impl.mTextUpdateInfo.mNumberOfCharactersToAdd = logicalModel->mText.Count();
120 // To reset the cursor position
121 lastCursorIndex = characterCount;
123 // Update the rest of the model during size negotiation
124 impl.QueueModifyEvent(ModifyEvent::TEXT_REPLACED);
126 // The natural size needs to be re-calculated.
127 impl.mRecalculateNaturalSize = true;
129 // The text direction needs to be updated.
130 impl.mUpdateTextDirection = true;
132 // Apply modifications to the model
133 impl.mOperationsPending = ALL_OPERATIONS;
137 controller.ShowPlaceholderText();
140 // Resets the cursor position.
141 controller.ResetCursorPosition(lastCursorIndex);
143 // Scrolls the text to make the cursor visible.
144 controller.ResetScrollPosition();
146 impl.RequestRelayout();
148 if(nullptr != eventData)
150 // Cancel previously queued events
151 eventData->mEventQueue.clear();
154 // Do this last since it provides callbacks into application code.
155 if(NULL != impl.mEditableControlInterface)
157 impl.mEditableControlInterface->TextChanged(true);
161 void Controller::TextUpdater::InsertText(Controller& controller, const std::string& text, Controller::InsertType type)
163 Controller::Impl& impl = *controller.mImpl;
164 EventData*& eventData = impl.mEventData;
166 DALI_ASSERT_DEBUG(nullptr != eventData && "Unexpected InsertText")
168 if(NULL == eventData)
173 bool removedPrevious = false;
174 bool removedSelected = false;
175 bool maxLengthReached = false;
177 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::InsertText %p %s (%s) mPrimaryCursorPosition %d mPreEditFlag %d mPreEditStartPosition %d mPreEditLength %d\n", &controller, text.c_str(), (COMMIT == type ? "COMMIT" : "PRE_EDIT"), eventData->mPrimaryCursorPosition, eventData->mPreEditFlag, eventData->mPreEditStartPosition, eventData->mPreEditLength);
179 ModelPtr& model = impl.mModel;
180 LogicalModelPtr& logicalModel = model->mLogicalModel;
182 // TODO: At the moment the underline runs are only for pre-edit.
183 model->mVisualModel->mUnderlineRuns.Clear();
185 // Remove the previous InputMethodContext pre-edit.
186 if(eventData->mPreEditFlag && (0u != eventData->mPreEditLength))
188 removedPrevious = RemoveText(controller,
189 -static_cast<int>(eventData->mPrimaryCursorPosition - eventData->mPreEditStartPosition),
190 eventData->mPreEditLength,
191 DONT_UPDATE_INPUT_STYLE);
193 eventData->mPrimaryCursorPosition = eventData->mPreEditStartPosition;
194 eventData->mPreEditLength = 0u;
198 // Remove the previous Selection.
199 removedSelected = RemoveSelectedText(controller);
202 Vector<Character> utf32Characters;
203 Length characterCount = 0u;
207 // Convert text into UTF-32
208 utf32Characters.Resize(text.size());
210 // This is a bit horrible but std::string returns a (signed) char*
211 const uint8_t* utf8 = reinterpret_cast<const uint8_t*>(text.c_str());
213 // Transform a text array encoded in utf8 into an array encoded in utf32.
214 // It returns the actual number of characters.
215 characterCount = Utf8ToUtf32(utf8, text.size(), utf32Characters.Begin());
216 utf32Characters.Resize(characterCount);
218 DALI_ASSERT_DEBUG(text.size() >= utf32Characters.Count() && "Invalid UTF32 conversion length");
219 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "UTF8 size %d, UTF32 size %d\n", text.size(), utf32Characters.Count());
222 if(0u != utf32Characters.Count()) // Check if Utf8ToUtf32 conversion succeeded
224 // The placeholder text is no longer needed
225 if(impl.IsShowingPlaceholderText())
227 ResetText(controller);
230 impl.ChangeState(EventData::EDITING);
232 // Handle the InputMethodContext (predicitive text) state changes
235 // InputMethodContext is no longer handling key-events
236 impl.ClearPreEditFlag();
240 if(!eventData->mPreEditFlag)
242 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Entered PreEdit state\n");
244 // Record the start of the pre-edit text
245 eventData->mPreEditStartPosition = eventData->mPrimaryCursorPosition;
248 eventData->mPreEditLength = utf32Characters.Count();
249 eventData->mPreEditFlag = true;
251 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "mPreEditStartPosition %d mPreEditLength %d\n", eventData->mPreEditStartPosition, eventData->mPreEditLength);
254 const Length numberOfCharactersInModel = logicalModel->mText.Count();
256 // Restrict new text to fit within Maximum characters setting.
257 Length maxSizeOfNewText = std::min((impl.mMaximumNumberOfCharacters - numberOfCharactersInModel), characterCount);
258 maxLengthReached = (characterCount > maxSizeOfNewText);
260 // The cursor position.
261 CharacterIndex& cursorIndex = eventData->mPrimaryCursorPosition;
263 // Update the text's style.
265 // Updates the text style runs by adding characters.
266 logicalModel->UpdateTextStyleRuns(cursorIndex, maxSizeOfNewText);
268 // Get the character index from the cursor index.
269 const CharacterIndex styleIndex = (cursorIndex > 0u) ? cursorIndex - 1u : 0u;
271 // Retrieve the text's style for the given index.
273 impl.RetrieveDefaultInputStyle(style);
274 logicalModel->RetrieveStyle(styleIndex, style);
276 InputStyle& inputStyle = eventData->mInputStyle;
278 // Whether to add a new text color run.
279 const bool addColorRun = (style.textColor != inputStyle.textColor) && !inputStyle.isDefaultColor;
281 // Whether to add a new font run.
282 const bool addFontNameRun = (style.familyName != inputStyle.familyName) && inputStyle.isFamilyDefined;
283 const bool addFontWeightRun = (style.weight != inputStyle.weight) && inputStyle.isWeightDefined;
284 const bool addFontWidthRun = (style.width != inputStyle.width) && inputStyle.isWidthDefined;
285 const bool addFontSlantRun = (style.slant != inputStyle.slant) && inputStyle.isSlantDefined;
286 const bool addFontSizeRun = (style.size != inputStyle.size) && inputStyle.isSizeDefined;
291 const VectorBase::SizeType numberOfRuns = logicalModel->mColorRuns.Count();
292 logicalModel->mColorRuns.Resize(numberOfRuns + 1u);
294 ColorRun& colorRun = *(logicalModel->mColorRuns.Begin() + numberOfRuns);
295 colorRun.color = inputStyle.textColor;
296 colorRun.characterRun.characterIndex = cursorIndex;
297 colorRun.characterRun.numberOfCharacters = maxSizeOfNewText;
306 const VectorBase::SizeType numberOfRuns = logicalModel->mFontDescriptionRuns.Count();
307 logicalModel->mFontDescriptionRuns.Resize(numberOfRuns + 1u);
309 FontDescriptionRun& fontDescriptionRun = *(logicalModel->mFontDescriptionRuns.Begin() + numberOfRuns);
313 fontDescriptionRun.familyLength = inputStyle.familyName.size();
314 fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
315 memcpy(fontDescriptionRun.familyName, inputStyle.familyName.c_str(), fontDescriptionRun.familyLength);
316 fontDescriptionRun.familyDefined = true;
318 // The memory allocated for the font family name is freed when the font description is removed from the logical model.
323 fontDescriptionRun.weight = inputStyle.weight;
324 fontDescriptionRun.weightDefined = true;
329 fontDescriptionRun.width = inputStyle.width;
330 fontDescriptionRun.widthDefined = true;
335 fontDescriptionRun.slant = inputStyle.slant;
336 fontDescriptionRun.slantDefined = true;
341 fontDescriptionRun.size = static_cast<PointSize26Dot6>(inputStyle.size * impl.mFontSizeScale * 64.f);
342 fontDescriptionRun.sizeDefined = true;
345 fontDescriptionRun.characterRun.characterIndex = cursorIndex;
346 fontDescriptionRun.characterRun.numberOfCharacters = maxSizeOfNewText;
349 // Insert at current cursor position.
350 Vector<Character>& modifyText = logicalModel->mText;
352 auto pos = modifyText.End();
353 if(cursorIndex < numberOfCharactersInModel)
355 pos = modifyText.Begin() + cursorIndex;
357 unsigned int realPos = pos - modifyText.Begin();
358 modifyText.Insert(pos, utf32Characters.Begin(), utf32Characters.Begin() + maxSizeOfNewText);
360 if(NULL != impl.mEditableControlInterface)
362 impl.mEditableControlInterface->TextInserted(realPos, maxSizeOfNewText, text);
365 TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
367 // Mark the first paragraph to be updated.
368 if(Layout::Engine::SINGLE_LINE_BOX == impl.mLayoutEngine.GetLayout())
370 textUpdateInfo.mCharacterIndex = 0;
371 textUpdateInfo.mNumberOfCharactersToRemove = textUpdateInfo.mPreviousNumberOfCharacters;
372 textUpdateInfo.mNumberOfCharactersToAdd = numberOfCharactersInModel + maxSizeOfNewText;
373 textUpdateInfo.mClearAll = true;
377 textUpdateInfo.mCharacterIndex = std::min(cursorIndex, textUpdateInfo.mCharacterIndex);
378 textUpdateInfo.mNumberOfCharactersToAdd += maxSizeOfNewText;
381 if(impl.mMarkupProcessorEnabled)
383 InsertTextAnchor(controller, maxSizeOfNewText, cursorIndex);
386 // Update the cursor index.
387 cursorIndex += maxSizeOfNewText;
389 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Inserted %d characters, new size %d new cursor %d\n", maxSizeOfNewText, logicalModel->mText.Count(), eventData->mPrimaryCursorPosition);
392 if((0u == logicalModel->mText.Count()) &&
393 impl.IsPlaceholderAvailable())
395 // Show place-holder if empty after removing the pre-edit text
396 controller.ShowPlaceholderText();
397 eventData->mUpdateCursorPosition = true;
398 impl.ClearPreEditFlag();
400 else if(removedPrevious ||
402 (0 != utf32Characters.Count()))
404 // Queue an inserted event
405 impl.QueueModifyEvent(ModifyEvent::TEXT_INSERTED);
407 eventData->mUpdateCursorPosition = true;
410 eventData->mScrollAfterDelete = true;
414 eventData->mScrollAfterUpdatePosition = true;
420 DALI_LOG_INFO(gLogFilter, Debug::Verbose, "MaxLengthReached (%d)\n", logicalModel->mText.Count());
422 impl.ResetInputMethodContext();
424 if(NULL != impl.mEditableControlInterface)
426 // Do this last since it provides callbacks into application code
427 impl.mEditableControlInterface->MaxLengthReached();
432 void Controller::TextUpdater::PasteText(Controller& controller, const std::string& stringToPaste)
434 InsertText(controller, stringToPaste, Text::Controller::COMMIT);
435 Controller::Impl& impl = *controller.mImpl;
436 impl.ChangeState(EventData::EDITING);
437 impl.RequestRelayout();
439 if(NULL != impl.mEditableControlInterface)
441 // Do this last since it provides callbacks into application code
442 impl.mEditableControlInterface->TextChanged(true);
446 bool Controller::TextUpdater::RemoveText(
447 Controller& controller,
449 int numberOfCharacters,
450 UpdateInputStyleType type)
452 bool removed = false;
454 Controller::Impl& impl = *controller.mImpl;
455 EventData*& eventData = impl.mEventData;
457 if(nullptr == eventData)
462 ModelPtr& model = impl.mModel;
463 LogicalModelPtr& logicalModel = model->mLogicalModel;
465 DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::RemoveText %p mText.Count() %d cursor %d cursorOffset %d numberOfCharacters %d\n", &controller, logicalModel->mText.Count(), eventData->mPrimaryCursorPosition, cursorOffset, numberOfCharacters);
467 if(!impl.IsShowingPlaceholderText())
469 // Delete at current cursor position
470 Vector<Character>& currentText = logicalModel->mText;
471 CharacterIndex& previousCursorIndex = eventData->mPrimaryCursorPosition;
473 CharacterIndex cursorIndex = 0;
475 // Validate the cursor position & number of characters
476 if((static_cast<int>(eventData->mPrimaryCursorPosition) + cursorOffset) >= 0)
478 cursorIndex = eventData->mPrimaryCursorPosition + cursorOffset;
481 if((cursorIndex + numberOfCharacters) > currentText.Count())
483 numberOfCharacters = currentText.Count() - cursorIndex;
486 TextUpdateInfo& textUpdateInfo = impl.mTextUpdateInfo;
488 if(eventData->mPreEditFlag || // If the preedit flag is enabled, it means two (or more) of them came together i.e. when two keys have been pressed at the same time.
489 ((cursorIndex + numberOfCharacters) <= textUpdateInfo.mPreviousNumberOfCharacters))
491 // Mark the paragraphs to be updated.
492 if(Layout::Engine::SINGLE_LINE_BOX == impl.mLayoutEngine.GetLayout())
494 textUpdateInfo.mCharacterIndex = 0;
495 textUpdateInfo.mNumberOfCharactersToRemove = textUpdateInfo.mPreviousNumberOfCharacters;
496 textUpdateInfo.mNumberOfCharactersToAdd = textUpdateInfo.mPreviousNumberOfCharacters - numberOfCharacters;
497 textUpdateInfo.mClearAll = true;
501 textUpdateInfo.mCharacterIndex = std::min(cursorIndex, textUpdateInfo.mCharacterIndex);
502 textUpdateInfo.mNumberOfCharactersToRemove += numberOfCharacters;
505 // Update the input style and remove the text's style before removing the text.
507 if(UPDATE_INPUT_STYLE == type)
509 InputStyle& eventDataInputStyle = eventData->mInputStyle;
511 // Keep a copy of the current input style.
512 InputStyle currentInputStyle;
513 currentInputStyle.Copy(eventDataInputStyle);
515 // Set first the default input style.
516 impl.RetrieveDefaultInputStyle(eventDataInputStyle);
518 // Update the input style.
519 logicalModel->RetrieveStyle(cursorIndex, eventDataInputStyle);
521 // Compare if the input style has changed.
522 const bool hasInputStyleChanged = !currentInputStyle.Equal(eventDataInputStyle);
524 if(hasInputStyleChanged)
526 const InputStyle::Mask styleChangedMask = currentInputStyle.GetInputStyleChangeMask(eventDataInputStyle);
527 // Queue the input style changed signal.
528 eventData->mInputStyleChangedQueue.PushBack(styleChangedMask);
532 // If the number of current text and the number of characters to be deleted are same,
533 // it means all texts should be removed and all Preedit variables should be initialized.
534 if((currentText.Count() - numberOfCharacters == 0) && (cursorIndex == 0))
536 impl.ClearPreEditFlag();
537 textUpdateInfo.mNumberOfCharactersToAdd = 0;
540 // Updates the text style runs by removing characters. Runs with no characters are removed.
541 logicalModel->UpdateTextStyleRuns(cursorIndex, -numberOfCharacters);
543 // Remove the characters.
544 Vector<Character>::Iterator first = currentText.Begin() + cursorIndex;
545 Vector<Character>::Iterator last = first + numberOfCharacters;
547 if(NULL != impl.mEditableControlInterface)
550 Utf32ToUtf8(first, numberOfCharacters, utf8);
551 impl.mEditableControlInterface->TextDeleted(cursorIndex, numberOfCharacters, utf8);
554 currentText.Erase(first, last);
556 if(impl.mMarkupProcessorEnabled)
558 RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
561 // Cursor position retreat
562 previousCursorIndex = cursorIndex;
564 eventData->mScrollAfterDelete = true;
566 if(EventData::INACTIVE == eventData->mState)
568 impl.ChangeState(EventData::EDITING);
571 DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", &controller, numberOfCharacters);
579 bool Controller::TextUpdater::RemoveSelectedText(Controller& controller)
581 bool textRemoved(false);
583 Controller::Impl& impl = *controller.mImpl;
585 if(EventData::SELECTING == impl.mEventData->mState)
587 std::string removedString;
588 impl.RetrieveSelection(removedString, true);
590 if(!removedString.empty())
593 impl.ChangeState(EventData::EDITING);
595 if(impl.mMarkupProcessorEnabled)
597 int cursorOffset = -1;
598 int numberOfCharacters = removedString.length();
599 CharacterIndex& cursorIndex = impl.mEventData->mPrimaryCursorPosition;
600 CharacterIndex previousCursorIndex = cursorIndex + numberOfCharacters;
602 RemoveTextAnchor(controller, cursorOffset, numberOfCharacters, previousCursorIndex);
610 void Controller::TextUpdater::ResetText(Controller& controller)
612 Controller::Impl& impl = *controller.mImpl;
613 LogicalModelPtr& logicalModel = impl.mModel->mLogicalModel;
616 logicalModel->mText.Clear();
618 // Reset the embedded images buffer.
619 logicalModel->ClearEmbeddedImages();
621 // Reset the anchors buffer.
622 logicalModel->ClearAnchors();
624 // We have cleared everything including the placeholder-text
625 impl.PlaceholderCleared();
627 impl.mTextUpdateInfo.mCharacterIndex = 0u;
628 impl.mTextUpdateInfo.mNumberOfCharactersToRemove = impl.mTextUpdateInfo.mPreviousNumberOfCharacters;
629 impl.mTextUpdateInfo.mNumberOfCharactersToAdd = 0u;
631 // Clear any previous text.
632 impl.mTextUpdateInfo.mClearAll = true;
634 // The natural size needs to be re-calculated.
635 impl.mRecalculateNaturalSize = true;
637 // The text direction needs to be updated.
638 impl.mUpdateTextDirection = true;
640 // Apply modifications to the model
641 impl.mOperationsPending = ALL_OPERATIONS;
644 void Controller::TextUpdater::InsertTextAnchor(Controller& controller, int numberOfCharacters, CharacterIndex previousCursorIndex)
646 Controller::Impl& impl = *controller.mImpl;
647 ModelPtr& model = impl.mModel;
648 LogicalModelPtr& logicalModel = model->mLogicalModel;
650 for(auto& anchor : logicalModel->mAnchors)
652 if(anchor.endIndex < previousCursorIndex) // [anchor] CUR
656 if(anchor.startIndex < previousCursorIndex) // [anCURr]
658 anchor.endIndex += numberOfCharacters;
662 anchor.startIndex += numberOfCharacters;
663 anchor.endIndex += numberOfCharacters;
665 DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::InsertTextAnchor[%p] Anchor[%s] start[%d] end[%d]\n", &controller, anchor.href, anchor.startIndex, anchor.endIndex);
669 void Controller::TextUpdater::RemoveTextAnchor(Controller& controller, int cursorOffset, int numberOfCharacters, CharacterIndex previousCursorIndex)
671 Controller::Impl& impl = *controller.mImpl;
672 ModelPtr& model = impl.mModel;
673 LogicalModelPtr& logicalModel = model->mLogicalModel;
674 Vector<Anchor>::Iterator it = logicalModel->mAnchors.Begin();
676 while(it != logicalModel->mAnchors.End())
678 Anchor& anchor = *it;
680 if(anchor.endIndex <= previousCursorIndex && cursorOffset == 0) // [anchor] CUR >>
684 else if(anchor.endIndex <= previousCursorIndex && cursorOffset == -1) // [anchor] << CUR
686 int endIndex = anchor.endIndex;
687 int offset = previousCursorIndex - endIndex;
688 int index = endIndex - (numberOfCharacters - offset);
695 if((int)anchor.startIndex >= endIndex)
699 delete[] anchor.href;
701 it = logicalModel->mAnchors.Erase(it);
706 anchor.endIndex = endIndex;
709 else if(anchor.startIndex >= previousCursorIndex && cursorOffset == -1) // << CUR [anchor]
711 anchor.startIndex -= numberOfCharacters;
712 anchor.endIndex -= numberOfCharacters;
714 else if(anchor.startIndex >= previousCursorIndex && cursorOffset == 0) // CUR >> [anchor]
716 int startIndex = anchor.startIndex;
717 int endIndex = anchor.endIndex;
718 int index = previousCursorIndex + numberOfCharacters - 1;
720 if(startIndex > index)
722 anchor.startIndex -= numberOfCharacters;
723 anchor.endIndex -= numberOfCharacters;
725 else if(endIndex > index + 1)
727 anchor.endIndex -= numberOfCharacters;
733 delete[] anchor.href;
735 it = logicalModel->mAnchors.Erase(it);
739 else if(cursorOffset == -1) // [<< CUR]
741 int startIndex = anchor.startIndex;
742 int index = previousCursorIndex - numberOfCharacters;
744 if(startIndex >= index)
746 anchor.startIndex = index;
748 anchor.endIndex -= numberOfCharacters;
750 else if(cursorOffset == 0) // [CUR >>]
752 anchor.endIndex -= numberOfCharacters;
756 // When this condition is reached, someting is wrong.
757 DALI_LOG_ERROR("Controller::RemoveTextAnchor[%p] Invaild state cursorOffset[%d]\n", &controller, cursorOffset);
760 DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::RemoveTextAnchor[%p] Anchor[%s] start[%d] end[%d]\n", &controller, anchor.href, anchor.startIndex, anchor.endIndex);
768 } // namespace Toolkit