scoop:scoop.surface:0.1.0
src/shared/shortcuts/matching.scoop
Selected production source · src/shared/shortcuts/matching.scoop
1
package scoop.surface3
import scoop.window.*5
internal fun checkedBindings(bindings: Array<ShortcutBinding>): Array<ShortcutBinding> {6
for (index in 0L ..< bindings.size) {7
val current = bindings[index]8
if (!current.enabled)9
continue10
for (previous in 0L ..< index) {11
val other = bindings[previous]12
requireInput(13
!other.enabled || !current.chord.equivalentTo(other.chord),14
"duplicate enabled shortcut combination"15
)16
}17
}18
return bindings19
}21
/** Protect text shortcuts using the backend's actual AltGr information. */22
internal fun shortcutAllowed(context: RoutedEventContext, event: KeyEvent): Boolean {23
if (context.currentTarget === context.target)24
return true25
val editing = context.target.area?.textInput ?: false26
if (!editing)27
return true28
when (event.logicalKey) {29
case Dead(_) -> return false30
else -> {}31
}32
val modifiers = event.modifiers33
val textModifier =34
modifiers.altGraph ?: (modifiers.control && modifiers.alt && !modifiers.superKey)35
if (!textModifier && (modifiers.superKey || modifiers.control))36
return true37
return when (event.logicalKey) {38
case Named(val value) -> value != NamedKey.Space39
else -> false40
}41
}