nativeplatform

package
v0.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package nativeplatform provides operating-system queries and native clipboard transfers. Pig builds with CGO_ENABLED=0; Go callers use platform APIs or the X11 wire protocol directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsModifierPressed

func IsModifierPressed(name string) bool

IsModifierPressed mirrors the helper's isModifierPressed(name): it reports whether the named modifier ("shift", "command", "control", or "option") is held right now. It reports false when the platform has no helper, the system function cannot be loaded, or the name is unknown.

func ShutdownClipboard

func ShutdownClipboard()

ShutdownClipboard requests private X11 cancellation without holding process exit behind uninterruptible native setup.

Types

type NativeClipboard

type NativeClipboard struct {
	GetText  func(context.Context) (value *string, available bool, err error)
	GetImage func(context.Context) (value []byte, available bool, err error)
	// GetFilePaths returns the POSIX paths of file URLs on the clipboard, such as Finder file copies. available=false means unsupported (upstream undefined); a nil value with available=true means no files (upstream null).
	GetFilePaths               func(context.Context) (paths []string, available bool, err error)
	SetText                    func(context.Context, string) error
	EnableVirtualTerminalInput func() bool
	IsModifierPressed          func(string) bool
}

NativeClipboard carries the native helper's callable capabilities. An unavailable read returns available=false; an available read with a nil value means an empty clipboard. SetText is absent on Linux, where command tools retain selection ownership. Go strings preserve lone UTF-16 surrogate units as WTF-8; OS byte APIs encode them as UTF-8 replacement characters. The additional optional functions belong to the same platform helper object, preserving its identity when accessed through either upstream getter.

func GetNativeClipboard

func GetNativeClipboard() *NativeClipboard

GetNativeClipboard checks display presence without opening a connection. The helper object is cached; each read rechecks display availability through the OS.

func GetNativePlatformHelper

func GetNativePlatformHelper() *NativeClipboard

GetNativePlatformHelper returns the same helper used by clipboard access on Windows and macOS; Linux has only its lazy X11 clipboard helper.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL