xgbsel

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

README

xgbsel

Easy clipboard/selection manipulation and access with xgb and xgbutil.

Documentation

Overview

Package xgbsel provides easy clipboard/selection manipulation and access with xgb and xgbutil.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claim

type Claim struct {
	// contains filtered or unexported fields
}

Claim represents a claim that a window has on a particular selection.

func NewClaim

func NewClaim(window *xwindow.Window, selection xproto.Atom, data Data) *Claim

NewClaim claims ownership of a specified selection, and allows using data passed to it to fulfill requests for the selection's contents.

func (*Claim) HandleSelectionRequest

func (claim *Claim) HandleSelectionRequest(
	connection *xgbutil.XUtil,
	event xevent.SelectionRequestEvent,
)

While the selection claim is active, HandleSelectionRequest should be called when the owner window recieves a SelectionRequest event.

type Confidence

type Confidence int
const (
	ConfidenceNone Confidence = iota
	ConfidencePartial
	ConfidenceFull
)

type Data

type Data interface {
	Convert(Target) (reader io.ReadSeekCloser, ok bool)
	Supported() []Target
}

Data represents a polymorphic data structure

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request represents an ongoing request for the selection contents.

func NewRequest

func NewRequest(requestor Requestor, source, destination xproto.Atom) *Request

NewRequest sends a new selection request.

func (*Request) HandlePropertyNotify

func (request *Request) HandlePropertyNotify(
	connection *xgbutil.XUtil,
	event xevent.PropertyNotifyEvent,
)

While the selection request is active, HandlePropertyNotify should be called when the requesting window recieves a PropertyNotify event.

func (*Request) HandleSelectionNotify

func (request *Request) HandleSelectionNotify(
	connection *xgbutil.XUtil,
	event xevent.SelectionNotifyEvent,
)

While the selection request is active, HandleSelectionNotify should be called when the requesting window recieves a SelectionNotify event.

type Requestor

type Requestor interface {
	Window() *xwindow.Window
	Choose(from []Target) (chosen Target, ok bool)
	Success(Target, io.ReadCloser)
	Failure(error)
}

Requestor provices details about the request such as the window that is requesting the selection data, and what targets it accepts.

type Target

type Target string

Target represents an X selection target. It defines the type of data stored within an X selection. This data may be a mime type, or a more specific name that is unique to X. A list of these names can be found here: https://tronche.com/gui/x/icccm/sec-2.html#s-2.6.2

func MimeToTargets

func MimeToTargets(mime string) []Target

MimeToTargets returns a list of targets that correspond to a specified MIME type.

func (Target) ToMime

func (target Target) ToMime() (string, Confidence)

ToMime converts the specified target to a MIME type. Because a single MIME type may correspond to several targets, a confidence value is returned representing how good of a match it is. If data is represented by multiple targets, they can be checked one after the other and the one with the highest confidence value chosen.

Directories

Path Synopsis
examples
paste
Example paste shows how to read text data from the CLIPBOARD selection.
Example paste shows how to read text data from the CLIPBOARD selection.

Jump to

Keyboard shortcuts

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