* granularity is line.)
*/
private void moveCursorUsingSelectionGranularity(LineInfo targetLineInfo, int x,
boolean updatePreferredColumn) {
Line targetLine = targetLineInfo.line();
int roundedTargetColumn = buffer.convertXToRoundedVisibleColumn(x, targetLine);
// Forward if the cursor anchor will be ahead of the base anchor
boolean growForward =
AnchorUtils.compare(baseAnchor, targetLineInfo.number(), roundedTargetColumn) <= 0;
LineInfo newLineInfo = targetLineInfo;
int newColumn = roundedTargetColumn;
switch (selectionGranularity) {
case WORD:
if (growForward) {
/*
* Floor the column so the last pixel of the last character of the
* current word does not trigger a finding of the next word
*/
newColumn =
TextUtils.findNextWord(
targetLine.getText(),
buffer.convertXToColumn(x, targetLine, RoundingStrategy.FLOOR), false);
} else {
// See note above about flooring, but we ceil here instead
newColumn =
TextUtils.findPreviousWord(
targetLine.getText(),
buffer.convertXToColumn(x, targetLine, RoundingStrategy.CEIL), false);
}
break;
case LINE: