Documentation
¶
Overview ¶
Package client implements the transport-independent GPUI protocol client.
Index ¶
- Constants
- type Capabilities
- type Click
- type Client
- func (c *Client) Capabilities() *Capabilities
- func (c *Client) ClipboardText(ctx context.Context) (string, error)
- func (c *Client) CreateModel(ctx context.Context, value []byte) (*Model, error)
- func (c *Client) Dispatch(ctx context.Context, event *Event) error
- func (c *Client) DispatchEvents(ctx context.Context) error
- func (c *Client) NextEvents(ctx context.Context) ([]*Event, error)
- func (c *Client) OnClick(handler func(context.Context, *Event) error) uint64
- func (c *Client) OnEvent(handler func(context.Context, *Event) error) uint64
- func (c *Client) OnTextChange(handler func(context.Context, *Event) error) uint64
- func (c *Client) OpenURL(ctx context.Context, url string) error
- func (c *Client) OpenWindow(ctx context.Context, options WindowOptions, root *scene.Node) (*Window, error)
- func (c *Client) PromptPaths(ctx context.Context, options *PathPrompt, ...) (func(), error)
- func (c *Client) PromptSavePath(ctx context.Context, options *SavePathPrompt, ...) (func(), error)
- func (c *Client) Quit(ctx context.Context) error
- func (c *Client) RemoveHandler(id uint64)
- func (c *Client) SetMenus(ctx context.Context, menus ...*Menu) error
- func (c *Client) Supports(feature string) bool
- func (c *Client) UploadResource(ctx context.Context, kind ResourceKind, mediaType string, data []byte) (*Resource, error)
- func (c *Client) WriteClipboardText(ctx context.Context, text string) error
- type ColorSchemeChanged
- type ErrorCode
- type Event
- type EventAction
- type EventClick
- type EventColorSchemeChanged
- type EventDataDrop
- type EventFileDrop
- type EventFocusChanged
- type EventKeyDown
- type EventKeyUp
- type EventModelChanged
- type EventMouseDown
- type EventMouseMove
- type EventMouseUp
- type EventPathResult
- type EventScroll
- type EventTextChanged
- type EventViewUpdated
- type EventWindowClosed
- type EventWindowResized
- type FileDrop
- type FocusChanged
- type KeyEvent
- type Menu
- type MenuItem
- type Model
- func (m *Model) Handle() *scene.Handle
- func (m *Model) Observe(ctx context.Context, handler func(context.Context, *ModelState) error) (*Subscription, error)
- func (m *Model) Read(ctx context.Context) (*ModelState, error)
- func (m *Model) Release(ctx context.Context) error
- func (m *Model) Update(ctx context.Context, expectedRevision uint64, value []byte) (*ModelState, error)
- type ModelState
- type MouseButton
- type Operation
- type PathPrompt
- type PathResult
- type PointerEvent
- type ProtocolError
- type Resource
- type ResourceKind
- type SavePathPrompt
- type Subscription
- type TextChanged
- type Transport
- type ViewUpdated
- type Window
- func (w *Window) ActionTarget(element uint64) *scene.FocusTarget
- func (w *Window) Activate(ctx context.Context) error
- func (w *Window) Close(ctx context.Context) error
- func (w *Window) ColorScheme() (scheme scene.ColorScheme, ok bool)
- func (w *Window) Command(ctx context.Context, operation WindowOperation, title string, size *scene.Size) error
- func (w *Window) DispatchAction(ctx context.Context, element uint64, name string, payload []byte) error
- func (w *Window) EmbedTarget() (uint64, uint32)
- func (w *Window) Focus(ctx context.Context, element uint64) error
- func (w *Window) Handle() *scene.Handle
- func (w *Window) Minimize(ctx context.Context) error
- func (w *Window) OnColorSchemeChanged(handler func(context.Context, scene.ColorScheme) error) (remove func())
- func (w *Window) OnResized(handler func(context.Context, WindowSize) error) (remove func())
- func (w *Window) Resize(ctx context.Context, width, height float32) error
- func (w *Window) ScrollTo(ctx context.Context, element uint64, item uint32) error
- func (w *Window) Set(ctx context.Context, root *scene.Node) error
- func (w *Window) SetTitle(ctx context.Context, title string) error
- func (w *Window) Size() (size WindowSize, ok bool)
- func (w *Window) ToggleFullscreen(ctx context.Context) error
- func (w *Window) ViewHandle() *scene.Handle
- func (w *Window) Zoom(ctx context.Context) error
- type WindowClosed
- type WindowOperation
- type WindowOptions
- type WindowResized
- type WindowSize
Constants ¶
const ( MouseUnspecified = pb.MouseButton_MOUSE_BUTTON_UNSPECIFIED MouseLeft = pb.MouseButton_MOUSE_BUTTON_LEFT MouseRight = pb.MouseButton_MOUSE_BUTTON_RIGHT MouseMiddle = pb.MouseButton_MOUSE_BUTTON_MIDDLE )
MouseButton values use concise application-facing names.
const ( ResourceUnspecified = pb.ResourceKind_RESOURCE_KIND_UNSPECIFIED ResourceImage = pb.ResourceKind_RESOURCE_KIND_IMAGE ResourceSVG = pb.ResourceKind_RESOURCE_KIND_SVG ResourceFont = pb.ResourceKind_RESOURCE_KIND_FONT )
ResourceKind values use concise application-facing names.
const ( WindowUnspecified = pb.WindowOperation_WINDOW_OPERATION_UNSPECIFIED WindowActivate = pb.WindowOperation_WINDOW_OPERATION_ACTIVATE WindowMinimize = pb.WindowOperation_WINDOW_OPERATION_MINIMIZE WindowZoom = pb.WindowOperation_WINDOW_OPERATION_ZOOM WindowFullscreen = pb.WindowOperation_WINDOW_OPERATION_FULLSCREEN WindowSetTitle = pb.WindowOperation_WINDOW_OPERATION_SET_TITLE WindowResize = pb.WindowOperation_WINDOW_OPERATION_RESIZE )
WindowOperation values use concise application-facing names.
const ( ErrorUnspecified = pb.ErrorCode_ERROR_CODE_UNSPECIFIED ErrorInvalidArgument = pb.ErrorCode_ERROR_CODE_INVALID_ARGUMENT ErrorUnsupported = pb.ErrorCode_ERROR_CODE_UNSUPPORTED ErrorStaleHandle = pb.ErrorCode_ERROR_CODE_STALE_HANDLE ErrorStaleRevision = pb.ErrorCode_ERROR_CODE_STALE_REVISION ErrorWrongSession = pb.ErrorCode_ERROR_CODE_WRONG_SESSION ErrorClosed = pb.ErrorCode_ERROR_CODE_CLOSED ErrorBackpressure = pb.ErrorCode_ERROR_CODE_BACKPRESSURE ErrorInternal = pb.ErrorCode_ERROR_CODE_INTERNAL )
ErrorCode values use concise application-facing names.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
type Capabilities = pb.Capabilities
Client service values retain their generated accessors and protobuf identity.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is safe for concurrent commands. NextEvents and DispatchEvents share one ordered event consumer. Application state mutated by callbacks should remain on that event goroutine, or use the application's own synchronization.
func (*Client) Capabilities ¶
func (c *Client) Capabilities() *Capabilities
func (*Client) CreateModel ¶
func (*Client) Dispatch ¶
Dispatch invokes the registered callback for a received event. Use it with NextEvents to combine UI input and background results on one state-owning goroutine. It does not commit or acknowledge an event by itself.
func (*Client) DispatchEvents ¶
DispatchEvents runs handlers sequentially until canceled or a handler fails. Window lifecycle events can be consumed directly with NextEvents instead.
func (*Client) NextEvents ¶
NextEvents acknowledges the preceding received batch. Cancellation can be retried: Rust retains unacknowledged events. Use one consumer per Client.
func (*Client) OnClick ¶
OnClick registers a handler without exposing a Go pointer to Rust. IDs are never reused. Call RemoveHandler when the application no longer needs one.
func (*Client) OnEvent ¶
OnEvent registers a native interaction/action callback. Callbacks run only when the application dispatches events, never synchronously during painting.
func (*Client) OnTextChange ¶
OnTextChange registers a callback for native text edits, including IME composition. Use InputState.Accept to ignore obsolete edits after a reset.
func (*Client) OpenWindow ¶
func (*Client) PromptPaths ¶
func (c *Client) PromptPaths(ctx context.Context, options *PathPrompt, callback func(context.Context, *PathResult) error) (func(), error)
PromptPaths displays an asynchronous OS picker. The callback runs through Dispatch/DispatchEvents. The returned function detaches the callback; it does not dismiss an already displayed OS dialog. No file contents are read.
func (*Client) PromptSavePath ¶
func (c *Client) PromptSavePath(ctx context.Context, options *SavePathPrompt, callback func(context.Context, *PathResult) error) (func(), error)
func (*Client) RemoveHandler ¶
func (*Client) SetMenus ¶
SetMenus replaces the application menu bar. Menu actions target stable nodes and logical actions; closed/removed/unbound targets are ignored on dispatch.
func (*Client) UploadResource ¶
type ColorSchemeChanged ¶ added in v0.0.2
type ColorSchemeChanged = pb.ColorSchemeChanged
Events and payloads are shared with existing protobuf callers without conversion.
type EventAction ¶
type EventAction = pb.Event_Action
Event kinds expose the wire oneof cases without generated underscore names.
type EventClick ¶
type EventClick = pb.Event_Click
Event kinds expose the wire oneof cases without generated underscore names.
type EventColorSchemeChanged ¶ added in v0.0.2
type EventColorSchemeChanged = pb.Event_ColorSchemeChanged
Event kinds expose the wire oneof cases without generated underscore names.
type EventDataDrop ¶
type EventDataDrop = pb.Event_DataDrop
Event kinds expose the wire oneof cases without generated underscore names.
type EventFileDrop ¶
type EventFileDrop = pb.Event_FileDrop
Event kinds expose the wire oneof cases without generated underscore names.
type EventFocusChanged ¶
type EventFocusChanged = pb.Event_FocusChanged
Event kinds expose the wire oneof cases without generated underscore names.
type EventKeyDown ¶
type EventKeyDown = pb.Event_KeyDown
Event kinds expose the wire oneof cases without generated underscore names.
type EventKeyUp ¶
type EventKeyUp = pb.Event_KeyUp
Event kinds expose the wire oneof cases without generated underscore names.
type EventModelChanged ¶
type EventModelChanged = pb.Event_ModelChanged
Event kinds expose the wire oneof cases without generated underscore names.
type EventMouseDown ¶
type EventMouseDown = pb.Event_MouseDown
Event kinds expose the wire oneof cases without generated underscore names.
type EventMouseMove ¶
type EventMouseMove = pb.Event_MouseMove
Event kinds expose the wire oneof cases without generated underscore names.
type EventMouseUp ¶
type EventMouseUp = pb.Event_MouseUp
Event kinds expose the wire oneof cases without generated underscore names.
type EventPathResult ¶
type EventPathResult = pb.Event_PathResult
Event kinds expose the wire oneof cases without generated underscore names.
type EventScroll ¶
type EventScroll = pb.Event_Scroll
Event kinds expose the wire oneof cases without generated underscore names.
type EventTextChanged ¶
type EventTextChanged = pb.Event_TextChanged
Event kinds expose the wire oneof cases without generated underscore names.
type EventViewUpdated ¶
type EventViewUpdated = pb.Event_ViewUpdated
Event kinds expose the wire oneof cases without generated underscore names.
type EventWindowClosed ¶
type EventWindowClosed = pb.Event_WindowClosed
Event kinds expose the wire oneof cases without generated underscore names.
type EventWindowResized ¶ added in v0.0.2
type EventWindowResized = pb.Event_WindowResized
Event kinds expose the wire oneof cases without generated underscore names.
type FocusChanged ¶
type FocusChanged = pb.FocusChanged
Events and payloads are shared with existing protobuf callers without conversion.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is a session-owned serializable entity, backed by a GPUI Entity on the native backend. Values are opaque bytes (for example, an application protobuf). Updates use compare-and-swap revisions; canceled writes are never retried.
type ModelState ¶
type ModelState = pb.ModelState
Client service values retain their generated accessors and protobuf identity.
type MouseButton ¶
type MouseButton = pb.MouseButton
Events and payloads are shared with existing protobuf callers without conversion.
type PathPrompt ¶
type PathPrompt = pb.PathPrompt
Client service values retain their generated accessors and protobuf identity.
type PathResult ¶
type PathResult = pb.PathResult
Client service values retain their generated accessors and protobuf identity.
type PointerEvent ¶
type PointerEvent = pb.PointerEvent
Events and payloads are shared with existing protobuf callers without conversion.
type ProtocolError ¶
func (*ProtocolError) Error ¶
func (e *ProtocolError) Error() string
type Resource ¶
type Resource struct {
// contains filtered or unexported fields
}
Resource is a session-owned uploaded asset. Release rejects assets still referenced by an installed view. Font faces remain installed until app exit.
type ResourceKind ¶
type ResourceKind = pb.ResourceKind
Client service values retain their generated accessors and protobuf identity.
type SavePathPrompt ¶
type SavePathPrompt = pb.SavePathPrompt
Client service values retain their generated accessors and protobuf identity.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription owns an observer callback. Close it when finished. Delivery uses the client's ordinary acknowledged event stream and requires event dispatch.
type TextChanged ¶
type TextChanged = pb.TextChanged
Events and payloads are shared with existing protobuf callers without conversion.
type Transport ¶
Transport owns the byte boundary. Implementations must copy requests before retaining them and return independently owned response bytes.
type ViewUpdated ¶
type ViewUpdated = pb.ViewUpdated
Events and payloads are shared with existing protobuf callers without conversion.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window owns its root view. Its references become invalid when it closes.
func (*Window) ActionTarget ¶
func (w *Window) ActionTarget(element uint64) *scene.FocusTarget
ActionTarget returns the serializable target used in native menu items.
func (*Window) ColorScheme ¶ added in v0.0.2
func (w *Window) ColorScheme() (scheme scene.ColorScheme, ok bool)
ColorScheme returns whether the window is drawn light or dark, as reported when it opened and updated as Dispatch receives changes. ok is false when the backend lacks the window-color-scheme capability.
func (*Window) DispatchAction ¶
func (*Window) EmbedTarget ¶
EmbedTarget identifies this window's view to a host extension that creates embedded views in it.
func (*Window) OnColorSchemeChanged ¶ added in v0.0.2
func (w *Window) OnColorSchemeChanged(handler func(context.Context, scene.ColorScheme) error) (remove func())
OnColorSchemeChanged registers a callback that Dispatch runs, on the dispatching goroutine, after the window switches between the light and dark color schemes. The returned function removes the callback.
func (*Window) OnResized ¶ added in v0.0.2
func (w *Window) OnResized(handler func(context.Context, WindowSize) error) (remove func())
OnResized registers a callback that Dispatch runs, on the dispatching goroutine, after the window's drawable area changes. A live resize is coalesced, so the callback sees the latest size rather than every step. The returned function removes the callback.
func (*Window) Set ¶
Set replaces a complete view. A successful response means installed, not necessarily painted. Revisions are consumed even on cancellation because an operation may commit immediately before cancellation wins the response race.
func (*Window) Size ¶ added in v0.0.2
func (w *Window) Size() (size WindowSize, ok bool)
Size returns the window's drawable area, as reported when it opened and updated as Dispatch receives resizes. ok is false when the backend lacks the window-size capability.
func (*Window) ViewHandle ¶
type WindowClosed ¶
type WindowClosed = pb.WindowClosed
Events and payloads are shared with existing protobuf callers without conversion.
type WindowOperation ¶
type WindowOperation = pb.WindowOperation
Client service values retain their generated accessors and protobuf identity.
type WindowOptions ¶
type WindowResized ¶ added in v0.0.2
type WindowResized = pb.WindowResized
Events and payloads are shared with existing protobuf callers without conversion.
type WindowSize ¶ added in v0.0.2
type WindowSize struct{ Width, Height float32 }
WindowSize is a window's drawable area in logical pixels.