Documentation ¶
Overview ¶
Package mimedata defines MIME data support used in clipboard and drag-and-drop functions in the GoGi GUI. mimedata.Data struct contains format and []byte data, and multiple representations of the same data are encoded in mimedata.Mimes which is just a []mimedata.Data slice -- it can be encoded / decoded from mime multipart
Index ¶
Constants ¶
const ( MIMEVersion1 = "MIME-Version: 1.0" ContentType = "Content-Type" ContentTransferEncoding = "Content-Transfer-Encoding" )
Variables ¶
var ( // for ALL text formats, Go standard utf8 encoding is assumed -- standard for most? TextAny = "text/*" TextPlain = "text/plain" TextHTML = "text/html" TextURL = "text/uri-list" TextCSS = "text/css" TextCSV = "text/csv" // .ics calendar entry TextCalendar = "text/calendar" // text version of XML is for human-readable xml TextXML = "text/xml" ImageAny = "image/*" ImageJPEG = "image/jpeg" ImagePNG = "image/png" ImageGIF = "image/gif" ImageTIFF = "image/tiff" ImageSVG = "image/svg+xml" AudioAny = "audio/*" AudioWAV = "audio/wav" AudioMIDI = "audio/midi" AudioOGG = "audio/ogg" AudioAAC = "audio/aac" AudioMPEG = "audio/mpeg" AudioMP4 = "audio/mp4" VideoAny = "video/*" VideoMPEG = "video/mpeg" VideoAVI = "video/x-msvideo" VideoOGG = "video/ogg" VideoMP4 = "video/mp4" VideoH264 = "video/h264" VideoQuicktime = "video/quicktime" FontAny = "font/*" FontTTF = "font/ttf" AppRTF = "application/rtf" AppPDF = "application/pdf" AppJSON = "application/json" // app version of XML is for non-human-readable xml content AppXML = "application/xml" AppColor = "application/x-color" AppJavaScript = "application/javascript" AppGo = "application/go" // use this as a prefix for any GoGi-specific elements (e.g., AppGoGi + ".treeview") AppGoGi = "application/vnd.gogi" )
various standard MIME types -- see http://www.iana.org/assignments/media-types/media-types.xhtml for a big list
var ContentTransferEncodingB = ([]byte)(ContentTransferEncoding)
var ContentTypeB = ([]byte)(ContentType)
var MIMEVersion1B = ([]byte)(MIMEVersion1)
Functions ¶
func IsMultipart ¶
IsMultipart examines data bytes to see if it has a MIME-Version: 1.0 ContentType: multipart/* header -- returns the actual multipart media type, body of the data string after the header (assumed to be a single \n terminated line at start of string, and the boundary separating multipart elements (all from mime.ParseMediaType) -- mediaType is the mediaType if it is another MIME type -- can check that for non-empty string
Types ¶
type Data ¶
type Data struct { // MIME Type string representing the data, e.g., text/plain, text/html, text/xml, text/uri-list, image/jpg, png etc Type string // Data for the item Data []byte }
Data represents one element of MIME data as a type string and byte slice
func NewTextData ¶
NewTextData returns a Data representation of the string -- good idea to always have a text/plain representation of everything on clipboard / drag-n-drop
func NewTextDataBytes ¶
NewTextDataBytes returns a Data representation of the bytes string
type Mimes ¶
type Mimes []*Data
Mimes is a slice of mime data, potentially encoding the same data in different formats -- this is used for all oswin API's for maximum flexibility
func FromMultipart ¶
FromMultipart parses a MIME multipart representation of multiple data elements into corresponding mime data components
func NewTextBytes ¶
NewTextBytes returns a Mimes representation of the bytes string as a single text/plain Data
func NewTextPlus ¶
NewTextPlus returns a Mimes representation of an item as a text string plus a more specific type
func (Mimes) ToMultipart ¶
ToMultipart produces a MIME multipart representation of multiple data elements present in the stream -- this should be used in clip.Board whenever there are multiple elements to be pasted, because windows doesn't support multiple clip elements, and linux isn't very convenient either