Scoop API

scoop:scoop.surface:0.1.0

src/shared/shortcuts/builders.scoop

Selected production source · src/shared/shortcuts/builders.scoop

1package scoop.surface
3import scoop.window.ShortcutChord
5public fun shortcutBinding(
6 chord: ShortcutChord,
7 action: () -> Unit,
8 configure: ShortcutBindingBuilder.() -> Unit = {}
9): ShortcutBinding {
10 val builder = ShortcutBindingBuilder()
11 builder.configure()
12 return ShortcutBinding(chord, builder.enabled, builder.allowRepeat, builder.canExecute, action)
15public class ShortcutBindingBuilder internal constructor() {
16 public var enabled: Boolean = true
17 public var allowRepeat: Boolean = false
18 public var canExecute: () -> Boolean = { true }
21public fun shortcuts(configure: ShortcutsBuilder.() -> Unit = {}): Array<ShortcutBinding> {
22 val builder = ShortcutsBuilder()
23 builder.configure()
24 return builder.snapshot()
27public class ShortcutsBuilder internal constructor() {
28 private val entries = ArrayList<ShortcutBinding>()
29 public fun add(value: ShortcutBinding): Unit {
30 entries.add(value)
31 }
32 public fun addAll(values: Array<ShortcutBinding>): Unit {
33 for (value in values)
34 add(value)
35 }
36 public fun binding(
37 chord: ShortcutChord,
38 action: () -> Unit,
39 configure: ShortcutBindingBuilder.() -> Unit = {}
40 ): Unit {
41 add(shortcutBinding(chord, action, configure))
42 }
43 internal fun snapshot(): Array<ShortcutBinding> = entries.toArray()