mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-14 22:12:46 +00:00
select keys can now de-select text (#973)
This commit is contained in:
parent
b9e116ed13
commit
544132974c
2 changed files with 10 additions and 5 deletions
|
@ -1761,7 +1761,7 @@ public class LatinIME extends InputMethodService implements
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case KeyCode.ARROW_RIGHT, KeyCode.ARROW_DOWN, KeyCode.WORD_RIGHT, KeyCode.PAGE_DOWN:
|
case KeyCode.ARROW_RIGHT, KeyCode.ARROW_DOWN, KeyCode.WORD_RIGHT, KeyCode.PAGE_DOWN:
|
||||||
if (!mInputLogic.mConnection.canForwardDeleteCharacters())
|
if (mInputLogic.mConnection.noTextAfterCursor())
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,9 +363,9 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
||||||
return mExpectedSelStart > 0;
|
return mExpectedSelStart > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canForwardDeleteCharacters() {
|
public boolean noTextAfterCursor() {
|
||||||
final CharSequence after = getTextAfterCursor(1, 0);
|
final CharSequence after = getTextAfterCursor(1, 0);
|
||||||
return !TextUtils.isEmpty(after);
|
return TextUtils.isEmpty(after);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -728,12 +728,17 @@ public final class RichInputConnection implements PrivateCommandPerformer {
|
||||||
|
|
||||||
public void selectAll() {
|
public void selectAll() {
|
||||||
if (!isConnected()) return;
|
if (!isConnected()) return;
|
||||||
mIC.performContextMenuAction(android.R.id.selectAll);
|
if (mExpectedSelStart != mExpectedSelEnd && mExpectedSelStart == 0 && noTextAfterCursor()) { // all text already selected
|
||||||
|
mIC.setSelection(mExpectedSelEnd, mExpectedSelEnd);
|
||||||
|
} else mIC.performContextMenuAction(android.R.id.selectAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectWord(final SpacingAndPunctuations spacingAndPunctuations, final String script) {
|
public void selectWord(final SpacingAndPunctuations spacingAndPunctuations, final String script) {
|
||||||
if (!isConnected()) return;
|
if (!isConnected()) return;
|
||||||
if (mExpectedSelStart != mExpectedSelEnd) return; // already something selected
|
if (mExpectedSelStart != mExpectedSelEnd) { // already something selected
|
||||||
|
mIC.setSelection(mExpectedSelEnd, mExpectedSelEnd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
final TextRange range = getWordRangeAtCursor(spacingAndPunctuations, script);
|
final TextRange range = getWordRangeAtCursor(spacingAndPunctuations, script);
|
||||||
if (range == null) return;
|
if (range == null) return;
|
||||||
mIC.setSelection(mExpectedSelStart - range.getNumberOfCharsInWordBeforeCursor(), mExpectedSelStart + range.getNumberOfCharsInWordAfterCursor());
|
mIC.setSelection(mExpectedSelStart - range.getNumberOfCharsInWordBeforeCursor(), mExpectedSelStart + range.getNumberOfCharsInWordAfterCursor());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue