Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
99 lines
3.8 KiB
Go
99 lines
3.8 KiB
Go
//go:build darwin && !ios
|
|
|
|
package darwin
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"github.com/ebitengine/purego"
|
|
)
|
|
|
|
var (
|
|
cfRunLoopGetMain func() uintptr
|
|
cfRunLoopSourceCreate func(alloc uintptr, order int, ctx unsafe.Pointer) uintptr
|
|
cfRunLoopAddSource func(rl, src, mode uintptr)
|
|
cfRelease func(obj uintptr)
|
|
kCFRunLoopCommonModes uintptr
|
|
|
|
// LaunchServices.
|
|
lsSetDefaultHandlerForURLScheme func(scheme, bundleID id) int32
|
|
lsCopyDefaultHandlerForURLScheme func(scheme id) id
|
|
|
|
// Power.
|
|
iopsCopyPowerSourcesInfo func() uintptr
|
|
iopsGetProvidingPowerSourceType func(snapshot uintptr) id
|
|
cgEventSourceSecondsSinceLastType func(state int32, eventType uint32) float64
|
|
|
|
// cgEventGetLocation is CGEventGetLocation: where an event happened,
|
|
// in the display space of Core Graphics.
|
|
cgEventGetLocation func(event uintptr) NSPoint
|
|
|
|
cgDisplayIsBuiltin func(display uint32) bool
|
|
cgDisplayRotation func(display uint32) float64
|
|
nsBeep func()
|
|
|
|
// Carbon hot keys.
|
|
getApplicationEventTarget func() uintptr
|
|
registerEventHotKey func(keyCode, modifiers uint32, hotKeyID eventHotKeyID, target uintptr, options uint32, outRef *uintptr) int32
|
|
unregisterEventHotKey func(ref uintptr) int32
|
|
installEventHandler func(target, handler uintptr, numTypes uint32, list *eventTypeSpec, userData uintptr, outRef *uintptr) int32
|
|
getEventParameter func(event uintptr, name, typ uint32, outType uintptr, size uintptr, outSize uintptr, data unsafe.Pointer) int32
|
|
)
|
|
|
|
// Called by address on every Signal, like the hot functions of objc.go.
|
|
var cfRunLoopSourceSignalFn, cfRunLoopWakeUpFn uintptr
|
|
|
|
type eventHotKeyID struct {
|
|
Signature uint32
|
|
ID uint32
|
|
}
|
|
|
|
type eventTypeSpec struct {
|
|
Class uint32
|
|
Kind uint32
|
|
}
|
|
|
|
func loadCF() {
|
|
purego.RegisterLibFunc(&cfRunLoopGetMain, libCF, "CFRunLoopGetMain")
|
|
purego.RegisterLibFunc(&cfRunLoopSourceCreate, libCF, "CFRunLoopSourceCreate")
|
|
purego.RegisterLibFunc(&cfRunLoopAddSource, libCF, "CFRunLoopAddSource")
|
|
cfRunLoopSourceSignalFn = mustDlsym(libCF, "CFRunLoopSourceSignal")
|
|
cfRunLoopWakeUpFn = mustDlsym(libCF, "CFRunLoopWakeUp")
|
|
purego.RegisterLibFunc(&cfRelease, libCF, "CFRelease")
|
|
p, err := purego.Dlsym(libCF, "kCFRunLoopCommonModes")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
kCFRunLoopCommonModes = **(**uintptr)(unsafe.Pointer(&p))
|
|
|
|
purego.RegisterLibFunc(&lsSetDefaultHandlerForURLScheme, libCoreServices, "LSSetDefaultHandlerForURLScheme")
|
|
purego.RegisterLibFunc(&lsCopyDefaultHandlerForURLScheme, libCoreServices, "LSCopyDefaultHandlerForURLScheme")
|
|
|
|
if iokit, err := purego.Dlopen("/System/Library/Frameworks/IOKit.framework/IOKit", purego.RTLD_GLOBAL|purego.RTLD_NOW); err == nil {
|
|
purego.RegisterLibFunc(&iopsCopyPowerSourcesInfo, iokit, "IOPSCopyPowerSourcesInfo")
|
|
purego.RegisterLibFunc(&iopsGetProvidingPowerSourceType, iokit, "IOPSGetProvidingPowerSourceType")
|
|
}
|
|
purego.RegisterLibFunc(&cgEventSourceSecondsSinceLastType, libCG, "CGEventSourceSecondsSinceLastEventType")
|
|
|
|
purego.RegisterLibFunc(&cgEventGetLocation, libCG, "CGEventGetLocation")
|
|
purego.RegisterLibFunc(&cgDisplayIsBuiltin, libCG, "CGDisplayIsBuiltin")
|
|
purego.RegisterLibFunc(&cgDisplayRotation, libCG, "CGDisplayRotation")
|
|
purego.RegisterLibFunc(&nsBeep, libAppKit, "NSBeep")
|
|
|
|
purego.RegisterLibFunc(&getApplicationEventTarget, libCarbon, "GetApplicationEventTarget")
|
|
purego.RegisterLibFunc(®isterEventHotKey, libCarbon, "RegisterEventHotKey")
|
|
purego.RegisterLibFunc(&unregisterEventHotKey, libCarbon, "UnregisterEventHotKey")
|
|
purego.RegisterLibFunc(&installEventHandler, libCarbon, "InstallEventHandler")
|
|
purego.RegisterLibFunc(&getEventParameter, libCarbon, "GetEventParameter")
|
|
}
|
|
|
|
// constString reads an exported NSString constant such as
|
|
// NSPasteboardTypeString.
|
|
func constString(lib uintptr, name string) id {
|
|
p, err := purego.Dlsym(lib, name)
|
|
if err != nil || p == 0 {
|
|
return 0
|
|
}
|
|
return **(**id)(unsafe.Pointer(&p))
|
|
}
|