mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-22 21:23:02 +01:00
* iOS keyboard: Experiments › Comma and period keys beside the space bar * iOS keyboard: comma and period keys: accurate docs, no-room sweep * iOS keyboard: comma and period keys: correct the no-room note * iOS keyboard: comma and period keys: upright only in the no-room note
67 lines
2.7 KiB
Swift
67 lines
2.7 KiB
Swift
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()
|
||
}
|
||
|
||
/// Settings › Experiments › Comma and period keys: a comma and a period join the space bar
|
||
/// on an iPhone's letters page in a text field. No row changes height, so the host is asked
|
||
/// for nothing.
|
||
func syncCommaPeriodKeys() {
|
||
let on = FullKeyboardSettings().commaPeriodKeys
|
||
guard engine.commaPeriodKeys != on else { return }
|
||
plane.cancelAllTouches()
|
||
dismissStyleMenu()
|
||
engine.commaPeriodKeys = on
|
||
setNeedsLayout()
|
||
}
|
||
}
|