Shift+Enter always sends newline, misc. fixes

This commit is contained in:
2024-11-21 23:54:45 +01:00
parent 68f48dce09
commit a7de68929a
@@ -33,11 +33,9 @@ import android.view.inputmethod.InputConnection;
import java.util.ArrayList;
// TODO: Revamp the keymap system — separate device keymap, keymap types (12-key, alphabetic, etc.)
// TODO: Revamp meta keys, no need to separately track both alt and shift
// TODO: Add auto-capitalization
// TODO: Add auto-periods
// TODO: Add auto-correct
// TODO: Shift+Enter always inserts a newline
// TODO: Emojis with popup window
// TODO: Composing with diacritics, polytonic Greek as well
// TODO: Add a new popup menu with per app settings, that is:
@@ -113,11 +111,12 @@ public class TitanboardIME extends InputMethodService {
}
// Workaround for default Android behaviour that pisses people off.
if (keyCode == KeyEvent.KEYCODE_DEL && (event.isAltPressed() || event.isShiftPressed())) {
if (keyCode == KeyEvent.KEYCODE_DEL && mMetaKeyManager.getAlt().isPressed()) {
return true;
}
if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_ENTER) {
if (keyCode == KeyEvent.KEYCODE_DEL
|| (keyCode == KeyEvent.KEYCODE_ENTER && !mMetaKeyManager.getShift().isPressed())) {
mMetaKeyManager.adjustMetaStateAfterKeypress();
mInputView.updateStateText();
return false;
@@ -135,6 +134,14 @@ public class TitanboardIME extends InputMethodService {
return false;
}
// If shift is held down and enter is pressed, always insert a newline.
if (keyCode == KeyEvent.KEYCODE_ENTER && mMetaKeyManager.getShift().isPressed()) {
conn.commitText("\n", 1);
mMetaKeyManager.adjustMetaStateAfterKeypress();
mInputView.updateStateText();
return true;
}
if (event.getRepeatCount() == 0 && !symbols.isEmpty()) {
mMetaKeyManager.adjustMetaStateAfterKeypress();
mInputView.updateStateText();
@@ -163,9 +170,11 @@ public class TitanboardIME extends InputMethodService {
mHandler.postDelayed(mSymbolAutoCycler, mPreferenceHolder.getCycleSpeed());
}
}
return true;
}
return true;
return false;
}
public boolean onKeyUp(int keyCode, KeyEvent event) {