Scoop API

scoop:scoop.window:0.1.0

platform/darwin/key_labels.scoop

Selected production source · platform/darwin/key_labels.scoop

1package scoop.window
3internal fun darwinLayoutLabel(scan: UInt): String? {
4 @Unsafe
5 {
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 -> None
12 }
13 } finally {
14 nativeKeyLabelRelease(result.bytes)
15 }
16 }
19@CLayout
20private struct NativeKeyLabel(val bytes: Ptr<UInt8>?, val length: Long, val error: Long)
22@Extern(name = "scoop_window_key_label")
23private fun nativeKeyLabel(scan: UInt): NativeKeyLabel
25@Extern(name = "scoop_window_key_label_release")
26private fun nativeKeyLabelRelease(bytes: Ptr<UInt8>?)