diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 708855e..85d8c64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -170,7 +170,7 @@ jobs: instrument -e publish_key 1 -e class "$test#t0_publishesDeviceKey" || exit 1 adb shell cat /sdcard/Android/data/app.bellterm/files/e2e/device.pub >> ~/.ssh/authorized_keys instrument -e host 10.0.2.2 -e port 2222 -e user "$(id -un)" -e fingerprint "$FINGERPRINT" \ - -e machine b-machine -e machine_workspace on-b -e class "$test#t8_switchesToSavedMachine,$test#t9_changelogListsReleases" + -e machine b-machine -e machine_workspace on-b -e class "$test#t8_switchesToSavedMachine,$test#t9_changelogListsReleases,$test#t10_shiftLatchesForTheNextKey" SCRIPT - uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 diff --git a/README.md b/README.md index 5352c8f..1a5f1bd 100644 --- a/README.md +++ b/README.md @@ -93,9 +93,10 @@ Android conventions it follows: A foreground-service notification shows the attachment, with **Disconnect**. - The soft keyboard types straight into the focused pane: no suggestions or autocorrect, and CJK input methods compose in place at the cursor. -- An extra-keys row sits above the keyboard: Esc, Tab, latching **Ctrl** and - **Alt** for the next key, arrows and paging keys that repeat while held, and - symbols phone keyboards hide. +- An extra-keys row sits above the keyboard: Esc, Tab, latching **Shift**, + **Ctrl** and **Alt** for the next key (they combine, e.g. Shift+← or + Ctrl+Shift+→), arrows and paging keys that repeat while held, and symbols + phone keyboards hide. - Drag or fling to scroll a pane, pinch to change the font size, long-press to select text with the system **Copy / Paste** toolbar. The bell can vibrate, and the screen can stay on during a session. diff --git a/app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt b/app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt index 14e3cfc..1e31210 100644 --- a/app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt +++ b/app/src/androidTest/java/app/bellterm/e2e/GlassUiTest.kt @@ -4,6 +4,7 @@ import android.content.ClipboardManager import android.content.Context import android.content.Intent import android.os.Build +import android.view.KeyEvent import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By import androidx.test.uiautomator.Direction @@ -305,6 +306,36 @@ class GlassUiTest { need(By.res("action:keys")) } + /** Issue #31: Shift latches from the extra-keys row and reaches the pane with the next key. */ + @Test + fun t10_shiftLatchesForTheNextKey() { + val host = InstrumentationRegistry.getArguments().getString("host") + assumeTrue("no host given; skipping the live connection", host != null) + connectHost(host!!) + need(By.res("extra_keys")) + val connection = app.connections.value.values.single() + val pane = { connection.frame.value?.panes?.firstOrNull { it.focused }?.id } + val screen = { connection.frame.value?.runs?.joinToString("") { it.text }.orEmpty() } + assertTrue("a focused pane", waitFor { pane() != null }) + // cat -v shows the bytes each key sends: ESC as ^[. + connection.text(pane(), "clear; cat -v\n") + Thread.sleep(SETTLE) + + need(By.res("key:Shift")).click() + shot("23_shift_latched") + need(By.res("key:←")).click() + assertTrue("Shift+← reaches the pane as CSI 1;2D", waitFor { "^[[1;2D" in screen() }) + need(By.res("key:Shift")).click() + need(By.res("key:Tab")).click() + assertTrue("Shift+Tab reaches the pane as back-tab", waitFor { "^[[Z" in screen() }) + // The latch was used up: a plain ← follows. + need(By.res("key:←")).click() + assertTrue("an unlatched ← stays plain", waitFor { "^[[Z^[[D" in screen() }) + shot("24_shift_chords") + + connection.chord(pane(), 'c'.code, KeyEvent.META_CTRL_ON) + } + /** Adds [host] from the instrumentation arguments as a node, opens it, and trusts its key when vouched for. */ private fun connectHost(host: String) { val args = InstrumentationRegistry.getArguments() diff --git a/app/src/main/java/app/bellterm/ui/terminal/ExtraKeys.kt b/app/src/main/java/app/bellterm/ui/terminal/ExtraKeys.kt index cd081e6..a8a31a2 100644 --- a/app/src/main/java/app/bellterm/ui/terminal/ExtraKeys.kt +++ b/app/src/main/java/app/bellterm/ui/terminal/ExtraKeys.kt @@ -59,6 +59,7 @@ sealed interface ExtraKey { val DefaultExtraKeys: List = listOf( ExtraKey.Key("Esc", KeyEvent.KEYCODE_ESCAPE), ExtraKey.Key("Tab", KeyEvent.KEYCODE_TAB), + ExtraKey.Modifier("Shift", KeyEvent.META_SHIFT_ON), ExtraKey.Modifier("Ctrl", KeyEvent.META_CTRL_ON), ExtraKey.Modifier("Alt", KeyEvent.META_ALT_ON), ExtraKey.Key("←", KeyEvent.KEYCODE_DPAD_LEFT, repeats = true), @@ -76,7 +77,7 @@ val DefaultExtraKeys: List = listOf( ) /** - * The row of keys a phone keyboard lacks. Ctrl and Alt latch for the next key + * The row of keys a phone keyboard lacks. Shift, Ctrl and Alt latch for the next key * or character, as on Termux; arrows and paging keys repeat while held. Keys * are small glass caps; a latched modifier fills with the session's [accent]. */ diff --git a/app/src/main/java/app/bellterm/ui/terminal/TerminalView.kt b/app/src/main/java/app/bellterm/ui/terminal/TerminalView.kt index 369944d..be76bb2 100644 --- a/app/src/main/java/app/bellterm/ui/terminal/TerminalView.kt +++ b/app/src/main/java/app/bellterm/ui/terminal/TerminalView.kt @@ -44,7 +44,7 @@ class TerminalView(context: Context) : View(context) { fun onCopy(startColumn: Int, startRow: Int, endColumn: Int, endRow: Int) fun onPaste() fun onFontSize(sp: Float) - /** Ctrl or Alt latched by the extra-keys row was used up. */ + /** Shift, Ctrl or Alt latched by the extra-keys row was used up. */ fun onModifiersConsumed() } @@ -507,8 +507,14 @@ class TerminalView(context: Context) : View(context) { private fun sendText(text: String) { if (text.isEmpty()) return val meta = latchedMeta - if (meta and (KEY_CTRL or KEY_ALT) != 0 && text.codePointCount(0, text.length) == 1) { - listener?.onChord(text.codePointAt(0), meta) + if (meta != 0 && text.codePointCount(0, text.length) == 1) { + var codepoint = text.codePointAt(0) + if (meta and KEY_SHIFT != 0) codepoint = Character.toUpperCase(codepoint) + if (meta and (KEY_CTRL or KEY_ALT) != 0) { + listener?.onChord(codepoint, meta) + } else { + listener?.onText(String(Character.toChars(codepoint))) + } consumeLatch() return } @@ -571,6 +577,7 @@ class TerminalView(context: Context) : View(context) { companion object { const val MIN_FONT_SP = 7f const val MAX_FONT_SP = 32f + private const val KEY_SHIFT = KeyEvent.META_SHIFT_ON private const val KEY_CTRL = KeyEvent.META_CTRL_ON private const val KEY_ALT = KeyEvent.META_ALT_ON private const val KeyCharacterMapCombining = android.view.KeyCharacterMap.COMBINING_ACCENT diff --git a/native/src/input/tests.rs b/native/src/input/tests.rs index cb2b249..8686d02 100644 --- a/native/src/input/tests.rs +++ b/native/src/input/tests.rs @@ -128,3 +128,26 @@ fn touches_become_clicks_and_wheel_steps() { }] )); } + +#[test] +fn shift_reaches_navigation_keys() { + let left = key( + keycode::DPAD_LEFT, + Modifiers::from_meta_state(0x1), + None, + false, + ) + .unwrap(); + assert_eq!(code(&left), (&ClientKeyCode::Left, Modifiers::SHIFT)); + let both = key( + keycode::DPAD_LEFT, + Modifiers::from_meta_state(0x1 | 0x1000), + None, + false, + ) + .unwrap(); + assert_eq!( + code(&both), + (&ClientKeyCode::Left, Modifiers::SHIFT | Modifiers::CTRL) + ); +} diff --git a/release-notes/1.1.3.en.txt b/release-notes/1.1.3.en.txt new file mode 100644 index 0000000..a0809ff --- /dev/null +++ b/release-notes/1.1.3.en.txt @@ -0,0 +1 @@ +The extra-keys row has a Shift key: tap Shift, then a key, to send Shift+← or Shift+Tab, alone or with Ctrl and Alt. diff --git a/release-notes/1.1.3.zh.txt b/release-notes/1.1.3.zh.txt new file mode 100644 index 0000000..2be3403 --- /dev/null +++ b/release-notes/1.1.3.zh.txt @@ -0,0 +1 @@ +扩展按键行新增 Shift:先点 Shift 再点按键,即可发送 Shift+← 或 Shift+Tab,也可以和 Ctrl、Alt 组合。 diff --git a/site/changelog/index.html b/site/changelog/index.html index d620b28..f01a9be 100644 --- a/site/changelog/index.html +++ b/site/changelog/index.html @@ -35,6 +35,12 @@

Changelog

Android releases, newest first. The Android app offers each one on its own; the iOS beta on TestFlight picks up the same changes in a later build.

+

1.1.3

+

· Android · Release on GitHub

+ +

1.1.2

· Android · Release on GitHub