Arrow keys work without Fn outside Text Entry

; . , / are arrows on their own unless the foreground App is editing
text (App::textEntryActive); Fn + those keys are arrows everywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
2026-10-02 13:59:49 +02:00
co-authored by Claude Opus 5.5
parent 51698a8011
commit 5fd351c45e
10 changed files with 82 additions and 6 deletions
+50
View File
@@ -175,6 +175,51 @@ void test_compose_state_is_visible_for_the_ui() {
TEST_ASSERT_EQUAL('^', m.pendingCompose());
}
void test_arrow_keys_work_without_fn_when_not_typing() {
KeyMapper m;
m.setTextEntry(false);
TEST_ASSERT_EQUAL(static_cast<int>(Key::Up), static_cast<int>(press(m, chars({';'}))[0].key));
release(m);
TEST_ASSERT_EQUAL(static_cast<int>(Key::Down), static_cast<int>(press(m, chars({'.'}))[0].key));
release(m);
TEST_ASSERT_EQUAL(static_cast<int>(Key::Left), static_cast<int>(press(m, chars({','}))[0].key));
release(m);
TEST_ASSERT_EQUAL(static_cast<int>(Key::Right), static_cast<int>(press(m, chars({'/'}))[0].key));
}
void test_arrow_keys_type_characters_during_text_entry() {
KeyMapper m;
m.setTextEntry(true);
auto ev = press(m, chars({';'}));
TEST_ASSERT_EQUAL(static_cast<int>(Key::Char), static_cast<int>(ev[0].key));
TEST_ASSERT_EQUAL(';', ev[0].ch);
}
void test_fn_arrows_work_in_both_modes() {
KeyMapper m;
m.setTextEntry(false);
TEST_ASSERT_EQUAL(static_cast<int>(Key::Up), static_cast<int>(press(m, withFn({';'}))[0].key));
release(m);
m.setTextEntry(true);
TEST_ASSERT_EQUAL(static_cast<int>(Key::Up), static_cast<int>(press(m, withFn({';'}))[0].key));
}
void test_other_characters_still_type_when_not_typing() {
KeyMapper m;
m.setTextEntry(false);
auto ev = press(m, chars({'w'}));
TEST_ASSERT_EQUAL('w', ev[0].ch);
}
void test_shifted_arrow_keys_type_their_symbols_when_not_typing() {
// Shift+; is ':' — the driver reports the shifted character, which isn't an arrow.
KeyMapper m;
m.setTextEntry(false);
RawKeys r = chars({':'});
r.shift = true;
TEST_ASSERT_EQUAL(':', press(m, r)[0].ch);
}
int main() {
UNITY_BEGIN();
RUN_TEST(test_plain_character);
@@ -191,5 +236,10 @@ int main() {
RUN_TEST(test_opt_followed_by_a_non_accent_types_it_normally);
RUN_TEST(test_pressing_opt_twice_cancels);
RUN_TEST(test_compose_state_is_visible_for_the_ui);
RUN_TEST(test_arrow_keys_work_without_fn_when_not_typing);
RUN_TEST(test_arrow_keys_type_characters_during_text_entry);
RUN_TEST(test_fn_arrows_work_in_both_modes);
RUN_TEST(test_other_characters_still_type_when_not_typing);
RUN_TEST(test_shifted_arrow_keys_type_their_symbols_when_not_typing);
return UNITY_END();
}