Initial patterm project

This commit is contained in:
2026-05-14 13:37:20 +01:00
commit 69ef09aac4
40 changed files with 6521 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
//go:build !nocgo
package vt
/*
// This preamble must contain DECLARATIONS ONLY — cgo refuses to compile
// a file that both defines functions in its preamble and has //export
// directives. The helper definitions live in ghostty.go's preamble.
#include <stdint.h>
#include <stddef.h>
#include <ghostty/vt.h>
*/
import "C"
import (
"runtime/cgo"
"unsafe"
)
//export pattermGhosttyWritePty
func pattermGhosttyWritePty(_ C.GhosttyTerminal, userdata unsafe.Pointer, data *C.uint8_t, length C.size_t) {
if userdata == nil || data == nil || length == 0 {
return
}
h := cgo.Handle(uintptr(userdata))
v := h.Value()
e, ok := v.(*GhosttyEmulator)
if !ok || e == nil {
return
}
cb := e.writePTYCallback()
if cb == nil {
return
}
buf := C.GoBytes(unsafe.Pointer(data), C.int(length))
cb(buf)
}