hex/ios/HEXShared/FullKeyboard/FullKeyboardView+Settings.swift
Dax 0c1c13d71b
ios: add Dvorak punctuation keys experiment (#2373)
* ios: add Dvorak punctuation keys experiment

Settings › Experiments › Dvorak punctuation keys (off by default,
experiments.dvorakPunctuation) adds comma and period ahead of P on English's
Dvorak row 1, whose nine keys narrow to start at the left margin and end at the
same delete key, and a semicolon just left of the space bar, taking a letter's
width from it where the bar still holds a letter-wide space. With shift or caps
lock they type < > :. On the Duo's split keyboard only the left half takes the
two punctuation keys, on a pitch narrowed so it keeps its right edge and the
split gap doesn't move, and the semicolon takes from the left space bar.

A URL or email field keeps its own . key instead of a second key of the same
kind. With the experiment off every layout is key for key the one it was; a
docked iPad keeps Apple's own rows. Adaptive touch names the narrower key plane
apart from Apple's Dvorak, so the two don't share what they learn.

Unit tests only (KeyboardLayoutTests, FullKeyboardEngineTests): no CI compiles
the iOS targets.

* ios: fix the Dvorak punctuation experiment's review findings

The tests' KeyboardLayout calls were out of argument order and their left-margin
and split-gap arithmetic used windowInset, metrics.gap and referenceW where the
builders use horizontalInset + metrics.side, SplitGeometry.gap and
SplitGeometry.keyWidth. Row-1 keys are now filtered to character keys so delete
isn't taken for the row's last key.

The layout's stored dvorakPunctuation is false unless the arrangement is
Dvorak's, so QWERTY keyboards and other layouts compare and learn exactly as
before; Adaptive touch keys its signature on a new hasDvorakPunctuationRow
(layer, letters, field == .text), so a QWERTY, a non-letter page or a Dvorak
URL/email field keeps its learned centres.

Auto-capitalization no longer turns , . ; into < > :. ShiftStateMachine now
tracks whether shift is automatic, and commitCharacter, displayLabel and
keycapLabel take the shifted symbol only from a shift you pressed or caps lock.
The docked iPad's two-symbol keys keep following auto-capitalization as before,
and letters capitalize either way.

Also: the new string-catalog entries sit where their keys sort, the READMEs say
"key for key", and the feature map notes the split left half's narrower top row.

Unit tests only: no CI compiles the iOS targets.
2026-11-22 09:31:25 -05:00

55 lines
2.3 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import UIKit
/// The keyboard's key layout settings (Settings › Keyboard and Settings › Experiments),
/// applied on every sync: where the Hex key sits, the number row, and whether the Duo unfolded
/// draws one keyboard. Switches that only change typing behaviour stay in
/// `FullKeyboardView.syncSettings`.
@MainActor
extension FullKeyboardView {
/// Settings › Keyboard › Hex key: Right (the strip's trailing end) or Left (its leading
/// end), kept in `HexKeyPlacement.current` too for typing logs.
func syncHexPlacement() {
let placement = hexPlacementOverride ?? FullKeyboardSettings().hexKeyPlacement
HexKeyPlacement.current = placement
guard engine.hexPlacement != placement else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.hexPlacement = placement
setNeedsLayout()
}
/// Settings › Keyboard › Number row: the keyboard grows by the row, so the host is asked
/// for the new height.
func syncNumberRow() {
let shows = FullKeyboardSettings().numberRow
guard engine.showsNumberRow != shows else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.showsNumberRow = shows
setNeedsLayout()
onPreferredHeightChange?()
}
/// Settings › Experiments › Join the keyboard when unfolded: the Duo unfolded upright draws
/// one keyboard rather than the split one. The rows keep their heights, so the host is asked
/// for nothing.
func syncJoinsUnfoldedKeyboard() {
let joins = FullKeyboardSettings().joinsKeyboardWhenUnfolded
guard engine.joinsUnfoldedKeyboard != joins else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.joinsUnfoldedKeyboard = joins
setNeedsLayout()
}
/// Settings › Experiments › Dvorak punctuation keys: English's Dvorak letters gain comma,
/// period and semicolon keys. No row changes height, so the host is asked for nothing.
func syncDvorakPunctuation() {
let on = FullKeyboardSettings().dvorakPunctuation
guard engine.dvorakPunctuation != on else { return }
plane.cancelAllTouches()
dismissStyleMenu()
engine.dvorakPunctuation = on
setNeedsLayout()
}
}