sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Bindgen.Clipboard

Description

SDL provides access to the system clipboard, both for reading information from other processes and publishing information of its own.

This is not just text! SDL apps can access and publish data by mimetype.

Basic use (text)

Obtaining and publishing simple text to the system clipboard is as easy as calling SDL_GetClipboardText() and SDL_SetClipboardText(), respectively. These deal with C strings in UTF-8 encoding. Data transmission and encoding conversion is completely managed by SDL.

Clipboard callbacks (data other than text)

Things get more complicated when the clipboard contains something other than text. Not only can the system clipboard contain data of any type, in some cases it can contain the same data in different formats! For example, an image painting app might let the user copy a graphic to the clipboard, and offers it in .BMP, .JPG, or .PNG format for other apps to consume.

Obtaining clipboard data ("pasting") like this is a matter of calling SDL_GetClipboardData() and telling it the mimetype of the data you want. But how does one know if that format is available? SDL_HasClipboardData() can report if a specific mimetype is offered, and SDL_GetClipboardMimeTypes() can provide the entire list of mimetypes available, so the app can decide what to do with the data and what formats it can support.

Setting the clipboard ("copying") to arbitrary data is done with SDL_SetClipboardData. The app does not provide the data in this call, but rather the mimetypes it is willing to provide and a callback function. During the callback, the app will generate the data. This allows massive data sets to be provided to the clipboard, without any data being copied before it is explicitly requested. More specifically, it allows an app to offer data in multiple formats without providing a copy of all of them upfront. If the app has an image that it could provide in PNG or JPG format, it doesn't have to encode it to either of those unless and until something tries to paste it.

Primary Selection

The X11 and Wayland video targets have a concept of the "primary selection" in addition to the usual clipboard. This is generally highlighted (but not explicitly copied) text from various apps. SDL offers APIs for this through SDL_GetPrimarySelectionText() and SDL_SetPrimarySelectionText(). SDL offers these APIs on platforms without this concept, too, but only so far that it will keep a copy of a string that the app sets for later retrieval; the operating system will not ever attempt to change the string externally if it doesn't support a primary selection. Put UTF-8 text into the clipboard.

text
the text to store in the clipboard.
Returns
true on success or false on failure; call SDL_GetError() for more information.
Thread safety
This function should only be called on the main thread.
See also
sDL_GetClipboardText
See also
sDL_HasClipboardText

Since: 3.2.0

Synopsis

Documentation

newtype SDL_ClipboardDataCallback_Aux Source #

Auxiliary type used by SDL_ClipboardDataCallback

C declaration
SDL_ClipboardDataCallback, defined at SDL3/SDL_clipboard.h 210:31

Instances

Instances details
Generic SDL_ClipboardDataCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Associated Types

type Rep SDL_ClipboardDataCallback_Aux 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardDataCallback_Aux = D1 ('MetaData "SDL_ClipboardDataCallback_Aux" "SDL3.Sys.Bindgen.Clipboard" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_ClipboardDataCallback_Aux" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr Void -> PtrConst CChar -> Ptr CSize -> IO (PtrConst Void)))))
FromFunPtr SDL_ClipboardDataCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ToFunPtr SDL_ClipboardDataCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

HasCField SDL_ClipboardDataCallback_Aux "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Associated Types

type CFieldType SDL_ClipboardDataCallback_Aux "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ty ~ (Ptr Void -> PtrConst CChar -> Ptr CSize -> IO (PtrConst Void)) => HasField "unwrap" SDL_ClipboardDataCallback_Aux ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ty ~ (Ptr Void -> PtrConst CChar -> Ptr CSize -> IO (PtrConst Void)) => HasField "unwrap" (Ptr SDL_ClipboardDataCallback_Aux) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardDataCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardDataCallback_Aux = D1 ('MetaData "SDL_ClipboardDataCallback_Aux" "SDL3.Sys.Bindgen.Clipboard" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_ClipboardDataCallback_Aux" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr Void -> PtrConst CChar -> Ptr CSize -> IO (PtrConst Void)))))
type CFieldType SDL_ClipboardDataCallback_Aux "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

newtype SDL_ClipboardDataCallback Source #

Callback function that will be called when data for the specified mime-type is requested by the OS.

The callback function is called with NULL as the mime_type when the clipboard is cleared or new data is set. The clipboard is automatically cleared in SDL_Quit().

userdata
a pointer to the provided user data.
mime_type
the requested mime-type.
size
a pointer filled in with the length of the returned data.
Returns
a pointer to the data for the provided mime-type. Returning NULL or setting the length to 0 will cause zero length data to be sent to the "receiver", which should be able to handle this. The returned data will not be freed, so it needs to be retained and dealt with internally.
See also
sDL_SetClipboardData
C declaration
SDL_ClipboardDataCallback, defined at SDL3/SDL_clipboard.h 210:31

Since: 3.2.0

Instances

Instances details
Storable SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Generic SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Associated Types

type Rep SDL_ClipboardDataCallback 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardDataCallback = D1 ('MetaData "SDL_ClipboardDataCallback" "SDL3.Sys.Bindgen.Clipboard" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_ClipboardDataCallback" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FunPtr SDL_ClipboardDataCallback_Aux))))
Show SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Eq SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Ord SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

HasFFIType SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ReadRaw SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

StaticSize SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

WriteRaw SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

HasCField SDL_ClipboardDataCallback "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ty ~ FunPtr SDL_ClipboardDataCallback_Aux => HasField "unwrap" SDL_ClipboardDataCallback ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ty ~ FunPtr SDL_ClipboardDataCallback_Aux => HasField "unwrap" (Ptr SDL_ClipboardDataCallback) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardDataCallback = D1 ('MetaData "SDL_ClipboardDataCallback" "SDL3.Sys.Bindgen.Clipboard" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_ClipboardDataCallback" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FunPtr SDL_ClipboardDataCallback_Aux))))
type FFIType SDL_ClipboardDataCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type CFieldType SDL_ClipboardDataCallback "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

newtype SDL_ClipboardCleanupCallback_Aux Source #

Auxiliary type used by SDL_ClipboardCleanupCallback

C declaration
SDL_ClipboardCleanupCallback, defined at SDL3/SDL_clipboard.h 222:24

Constructors

SDL_ClipboardCleanupCallback_Aux 

Fields

Instances

Instances details
Generic SDL_ClipboardCleanupCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Associated Types

type Rep SDL_ClipboardCleanupCallback_Aux 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardCleanupCallback_Aux = D1 ('MetaData "SDL_ClipboardCleanupCallback_Aux" "SDL3.Sys.Bindgen.Clipboard" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_ClipboardCleanupCallback_Aux" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr Void -> IO ()))))
FromFunPtr SDL_ClipboardCleanupCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ToFunPtr SDL_ClipboardCleanupCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

HasCField SDL_ClipboardCleanupCallback_Aux "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Associated Types

type CFieldType SDL_ClipboardCleanupCallback_Aux "unwrap" 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ty ~ (Ptr Void -> IO ()) => HasField "unwrap" SDL_ClipboardCleanupCallback_Aux ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ty ~ (Ptr Void -> IO ()) => HasField "unwrap" (Ptr SDL_ClipboardCleanupCallback_Aux) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardCleanupCallback_Aux Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardCleanupCallback_Aux = D1 ('MetaData "SDL_ClipboardCleanupCallback_Aux" "SDL3.Sys.Bindgen.Clipboard" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_ClipboardCleanupCallback_Aux" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Ptr Void -> IO ()))))
type CFieldType SDL_ClipboardCleanupCallback_Aux "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

newtype SDL_ClipboardCleanupCallback Source #

Callback function that will be called when the clipboard is cleared, or when new data is set.

userdata
a pointer to the provided user data.
See also
sDL_SetClipboardData
C declaration
SDL_ClipboardCleanupCallback, defined at SDL3/SDL_clipboard.h 222:24

Since: 3.2.0

Instances

Instances details
Storable SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Generic SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Associated Types

type Rep SDL_ClipboardCleanupCallback 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardCleanupCallback = D1 ('MetaData "SDL_ClipboardCleanupCallback" "SDL3.Sys.Bindgen.Clipboard" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_ClipboardCleanupCallback" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FunPtr SDL_ClipboardCleanupCallback_Aux))))
Show SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Eq SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

Ord SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

HasFFIType SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ReadRaw SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

StaticSize SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

WriteRaw SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

HasCField SDL_ClipboardCleanupCallback "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ty ~ FunPtr SDL_ClipboardCleanupCallback_Aux => HasField "unwrap" SDL_ClipboardCleanupCallback ty Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

ty ~ FunPtr SDL_ClipboardCleanupCallback_Aux => HasField "unwrap" (Ptr SDL_ClipboardCleanupCallback) (Ptr ty :: Type) Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type Rep SDL_ClipboardCleanupCallback = D1 ('MetaData "SDL_ClipboardCleanupCallback" "SDL3.Sys.Bindgen.Clipboard" "sdl3-bindgen-sys-0.0.1.0-inplace" 'True) (C1 ('MetaCons "SDL_ClipboardCleanupCallback" 'PrefixI 'True) (S1 ('MetaSel ('Just "unwrap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FunPtr SDL_ClipboardCleanupCallback_Aux))))
type FFIType SDL_ClipboardCleanupCallback Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard

type CFieldType SDL_ClipboardCleanupCallback "unwrap" Source # 
Instance details

Defined in SDL3.Sys.Bindgen.Clipboard