scoop:scoop.window:0.1.0
platform/darwin/key_labels.scoop
Selected production source · platform/darwin/key_labels.scoop
1
package scoop.window3
internal fun darwinLayoutLabel(scan: UInt): String? {4
@Unsafe5
{6
val result = nativeKeyLabel(scan)7
try {8
checkNativeStatus(result.error, "query shortcut key label")9
return when (result.bytes) {10
case Some(val bytes) -> Some(String.fromUtf8(bytes, result.length))11
case None -> None12
}13
} finally {14
nativeKeyLabelRelease(result.bytes)15
}16
}17
}19
@CLayout20
private struct NativeKeyLabel(val bytes: Ptr<UInt8>?, val length: Long, val error: Long)22
@Extern(name = "scoop_window_key_label")23
private fun nativeKeyLabel(scan: UInt): NativeKeyLabel25
@Extern(name = "scoop_window_key_label_release")26
private fun nativeKeyLabelRelease(bytes: Ptr<UInt8>?)