*
* TODO : report the selection to the selection
* manager in JSVGComponent.
*/
protected void selectSubString(Element element, int charnum, int nchars) {
TextNode textNode = getTextNode();
AttributedCharacterIterator aci;
aci = textNode.getAttributedCharacterIterator();
if (aci == null)
return;
int firstChar = getElementStartIndex(element);
if ( firstChar == -1 )
return;
List list = getTextRuns(textNode);
int lastChar = getElementEndIndex(element);
CharacterInformation firstInfo, lastInfo;
firstInfo = getCharacterInformation(list, firstChar,charnum,aci);
lastInfo = getCharacterInformation(list, firstChar,charnum+nchars-1,aci);
Mark firstMark, lastMark;
firstMark = textNode.getMarkerForChar(firstInfo.characterIndex,true);
if ( lastInfo != null && lastInfo.characterIndex <= lastChar ){
lastMark = textNode.getMarkerForChar(lastInfo.characterIndex,false);
}
else{
lastMark = textNode.getMarkerForChar(lastChar,false);
}
ctx.getUserAgent().setTextSelection(firstMark,lastMark);
}