layout

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComntID       string = "COMNT"                // comntid is the comment block identification that must be "COMNT"
	SauceID       string = "SAUCE"                // sauceid is the SAUCE identification that must be "SAUCE"
	SauceVersion  string = "00"                   // sauce version number that is always "00"
	SauceSeek     string = SauceID + SauceVersion // sauceseek is the sauce id and version value to lookup
	ComntLineSize int    = 64                     // comntlinesize is the fix length in bytes of an individual comment line
	ComntMaxLines int    = 255                    // comntmaxlines is the maximum permitted number of lines for a block of comments
)
View Source
const Unsupported = "no preference"

Unsupported is a legacy value used by Letter-spacing and Aspect Ratio. It acts as an unsupported placeholder for SAUCE versions prior to v00.5 from Nov 2013.

Variables

View Source
var (
	ErrParseDate = errors.New("parse date to integer conversion")
	ErrSauceDate = errors.New("sauce date error")
)
View Source
var ErrFileType = errors.New("unknown filetype")
View Source
var ErrInvalid = errors.New("invalid value")

Functions

func CommentByBreak

func CommentByBreak(b []byte) []string

CommentByBreak parses the SAUCE comment by line break characters.

func CommentByLine

func CommentByLine(b []byte) []string

CommentByLine parses the SAUCE comment by lines of 64 characters.

func Index

func Index(b []byte) int

Index returns the position of the SAUCE00 ID or -1 if no ID exists.

func UnsignedBinary1

func UnsignedBinary1(b [1]byte) uint8

UnsignedBinary1 returns the unsigned 1 byte integer from b using little-endian byte order.

func UnsignedBinary2

func UnsignedBinary2(b [2]byte) uint16

func UnsignedBinary4

func UnsignedBinary4(b [4]byte) uint16

Types

type ANSIFlagAR

type ANSIFlagAR struct {
	Flag ArBit  `json:"flag" xml:"flag"`                          // ar aspect ratio value
	Info string `json:"interpretation" xml:"interpretation,attr"` // info description of the value
}

ANSIFlagAR is the interpretation of the SAUCE Flags aspect ratio binary bits.

type ANSIFlagB

type ANSIFlagB struct {
	Flag BBit   `json:"flag" xml:"flag"`                          // flag the non-blink "iCE Color" toggle
	Info string `json:"interpretation" xml:"interpretation,attr"` // info description of the toggle
}

ANSIFlagB is the interpretation of the SAUCE Flags non-blink mode binary bit.

type ANSIFlagLS

type ANSIFlagLS struct {
	Flag LsBit  `json:"flag" xml:"flag"`                          // lsbit letter-spacing value
	Info string `json:"interpretation" xml:"interpretation,attr"` // info description of the value
}

ANSIFlagLS is the interpretation of the SAUCE Flags letter spacing binary bits.

type ANSIFlags

type ANSIFlags struct {
	Decimal         Flags      `json:"decimal" xml:"decimal,attr"`         // decimal, unsigned integer flags value
	Binary          string     `json:"binary" xml:"binary,attr"`           // binary notation flags value
	B               ANSIFlagB  `json:"nonBlinkMode" xml:"non_blink_mode"`  // b is the non-blink "iCE Color" toggle
	LS              ANSIFlagLS `json:"letterSpacing" xml:"letter_spacing"` // ls is the letter-spacing value
	AR              ANSIFlagAR `json:"aspectRatio" xml:"aspect_ratio"`     // ar is the aspect ratio value
	Interpretations string     `json:"-" xml:"-"`                          // interpretations are humanized descriptions of the bits
}

ANSIFlags allow an author of ANSi and similar files to provide a clue to a viewer/editor how to render the image.

func (*ANSIFlags) String

func (a *ANSIFlags) String() string

type ArBit

type ArBit string

ArBit is the Aspect Ratio two bit value.

func (ArBit) String

func (ar ArBit) String() string

type Archive

type Archive uint

Archive and compressed files.

const (
	Zip Archive = iota
	Arj
	Lzh
	Arc
	Tar
	Zoo
	Rar
	Uc2
	Pak
	Sqz
)

func (Archive) String

func (a Archive) String() string

type Audio

type Audio uint

Audio or music files.

const (
	Mod Audio = iota
	Composer669
	Stm
	S3m
	Mtm
	Far
	Ult
	Amf
	Dmf
	Okt
	Rol
	Cmf
	Midi
	Sadt
	Voc
	Wave
	Smp8
	Smp8s
	Smp16
	Smp16s
	Patch8
	Patch16
	Xm
	Hsc
	It
)

func (Audio) String

func (a Audio) String() string

type Author

type Author [20]byte // author is nickname or handle of creator of the file

func (Author) String

func (b Author) String() string

type BBit

type BBit string

BBit is the non-blink "iCE Color" bit value.

func (BBit) String

func (b BBit) String() string

type BinaryText

type BinaryText uint

BinaryText is a raw memory copy of a text mode screen.

const (
	BinaryScreenImage BinaryText = iota
)

func (BinaryText) String

func (b BinaryText) String() string

type Bitmap

type Bitmap uint

Bitmap graphic and animation files.

const (
	Gif Bitmap = iota
	Pcx
	Lbm
	Tga
	Fli
	Flc
	Bmp
	Gl
	Dl
	Wpg
	Png
	Jpg
	Mpg
	Avi
)

func (Bitmap) String

func (b Bitmap) String() string

type Character

type Character uint

Character files more commonly referred as text files.

const (
	ASCII Character = iota
	Ansi
	AnsiMation
	RipScript
	PCBoard
	Avatar
	HTML
	Source
	TundraDraw
)

func (Character) Desc

func (c Character) Desc() string

Desc is the character description.

func (Character) String

func (c Character) String() string

type Comment

type Comment struct {
	ID      string   `json:"id" xml:"id,attr"`       // id is the SAUCE comment block identification, this should be "COMNT"
	Count   int      `json:"count" xml:"count,attr"` // count are the reported number of lines in the SAUCE comment block
	Index   int      `json:"-" xml:"-"`              // index are the calculated starting position of the comment block
	Comment []string `json:"lines" xml:"line"`       // comment value, each comment line should be comprised of 64 characters
}

Comment contains the optional SAUCE comment block. A SAUCE comment block is an optional, variable sized structure that holds up to 255 lines of additional information, each line 64 characters wide.

type Comments

type Comments [1]byte // comments are the number of lines in the extra SAUCE comment block

type Comnt

type Comnt struct {
	Index  int      // index is the calculated starting position of the comment block
	Length int      // length is the calculated length of the comment block
	Count  Comments // count are the reported number of lines in the SAUCE comment block
	Lines  []byte   // lines of text
}

type Data

type Data []byte // data is a copy of the input data

func (Data) Comnt

func (d Data) Comnt(count Comments, sauceIndex int) Comnt

func (Data) Extract

func (d Data) Extract() Layout

func (Data) TInfo1

func (d Data) TInfo1(i int) TInfo1

func (Data) TInfo2

func (d Data) TInfo2(i int) TInfo2

func (Data) TInfo3

func (d Data) TInfo3(i int) TInfo3

func (Data) TInfo4

func (d Data) TInfo4(i int) TInfo4

func (Data) TInfoS

func (d Data) TInfoS(i int) TInfoS

type DataType

type DataType [1]byte // data type is the type of file, such as an raster image

type Datas

type Datas struct {
	Type TypeOfData `json:"type" xml:"type"` // typeofdata is the unsigned data type
	Name string     `json:"name" xml:"name"` // name of the data type
}

Datas is the SAUCE DataType value and name.

type Date

type Date [8]byte // date the file was created

func (Date) String

func (b Date) String() string

type Dates

type Dates struct {
	Value string    `json:"value" xml:"value"`      // date format using CCYYMMDD (century, year, month, day)
	Time  time.Time `json:"iso" xml:"date"`         // time as a go time type
	Epoch int64     `json:"epoch" xml:"epoch,attr"` // epoch unix time, is the number of seconds since 1 Jan 1970
}

Dates is the date the file was created, in multiple time formats.

type Executable

type Executable uint

Executable program files.

const (
	Exe Executable = iota
)

func (Executable) String

func (e Executable) String() string

type FileSize

type FileSize [4]byte // file size of original file size without the sauce data

type FileType

type FileType [1]byte // file type is the technical format of the file, such as a GIF

type Files

type Files struct {
	Type TypeOfFile `json:"type" xml:"type"` // type of file unsigned integer
	Name string     `json:"name" xml:"name"` // name of the file type
}

Files is the SAUCE FileType value and name.

type Flags

type Flags uint8

Flags is the SAUCE Flags field.

func (Flags) Parse

func (f Flags) Parse() ANSIFlags

type Group

type Group [20]byte // group or company name the author worked for

func (Group) String

func (b Group) String() string

type ID added in v1.1.0

type ID [5]byte // id is the sauce identifier

func (ID) String added in v1.1.0

func (b ID) String() string

type Info

type Info struct {
	// Value of the field.
	Value uint16 `json:"value" xml:"value"`
	// Info is a description of the value.
	Info string `json:"info" xml:"type,attr"`
}

Info is the type for the SAUCE TInfo1, TInfo2, TInfo3 and TInfo4 fields.

type Infos

type Infos struct {
	// Info1 dependant numeric information field 1.
	Info1 Info `json:"1" xml:"type1"`
	// Info2 dependant numeric information field 2.
	Info2 Info `json:"2" xml:"type2"`
	// Info3 dependant numeric information field 3.
	Info3 Info `json:"3" xml:"type3"`
	// Flags are file type dependant flags.
	Flags ANSIFlags `json:"flags" xml:"flags"`
	// Font field allows an author to provide a clue to the viewer/editor which font to use to render the image.
	Font string `json:"fontName" xml:"fontname"`
}

Infos includes the SAUCE fields dependant on both DataType and FileType.

type Layout

type Layout struct {
	ID       ID
	Version  Version
	Title    Title
	Author   Author
	Group    Group
	Date     Date
	Filesize FileSize
	Datatype DataType
	Filetype FileType
	Tinfo1   TInfo1
	Tinfo2   TInfo2
	Tinfo3   TInfo3
	Tinfo4   TInfo4
	Comments Comments
	TFlags   TFlags
	TInfoS   TInfoS
	Comnt    Comnt
}

func (*Layout) CommentBlock

func (d *Layout) CommentBlock() Comment

CommentBlock parses the optional SAUCE comment block.

func (*Layout) DataType

func (d *Layout) DataType() Datas

func (*Layout) Dates

func (d *Layout) Dates() Dates

func (*Layout) Description

func (d *Layout) Description() string

func (*Layout) FileType

func (d *Layout) FileType() Files

func (*Layout) InfoType

func (d *Layout) InfoType() Infos

func (*Layout) Sizes

func (d *Layout) Sizes() Sizes

type LsBit

type LsBit string // Letter-spacing two bit value.

func (LsBit) String

func (ls LsBit) String() string

type None

type None uint
const (
	Undefined None = iota
)

func (None) String

func (n None) String() string

type Sizes

type Sizes struct {
	Bytes   uint16 `json:"bytes" xml:"bytes"`          // bytes as an integer
	Decimal string `json:"decimal" xml:"decimal,attr"` // decimal is a base 10 value
	Binary  string `json:"binary" xml:"binary,attr"`   // binary is a base 2 value
}

Sizes is the original file size in multiple formats.

type TFlags

type TFlags [1]byte // tflags are the type dependant flags

type TInfo1

type TInfo1 [2]byte // tinfo1 is type dependant numeric information field 1

type TInfo2

type TInfo2 [2]byte // tinfo2 is type dependant numeric information field 2

type TInfo3

type TInfo3 [2]byte // tinfo3 is type dependant numeric information field 3

type TInfo4

type TInfo4 [2]byte // tinfo4 is type dependant numeric information field 4

type TInfoS

type TInfoS [22]byte // tinfos are the type dependant string information field

func (TInfoS) String

func (t TInfoS) String() string

type Title

type Title [35]byte // title of the file

func (Title) String

func (b Title) String() string

type TypeOfData

type TypeOfData uint

TypeOfData is the SAUCE DataType.

const (
	Nones       TypeOfData = iota // undefined filetype
	Characters                    // characters and plain text based files
	Bitmaps                       // bitmap, graphic and animation files
	Vectors                       // vector graphic files
	Audios                        // audio and sound files
	BinaryTexts                   // binary texts that are raw memory copies of a text mode screen, also known as a 'bin' file
	XBins                         // xbin or extended bin file
	Archives                      // archived file such as a zip package
	Executables                   // executable file that is an application or program launcher
)

func (TypeOfData) String

func (d TypeOfData) String() string

type TypeOfFile

type TypeOfFile uint

TypeOfFile is the SAUCE FileType.

type Vector

type Vector uint

Vector graphic files.

const (
	Dxf Vector = iota
	Dwg
	Wpvg
	Kinetix
)

func (Vector) String

func (v Vector) String() string

type Version

type Version [2]byte // version number

func (Version) String

func (b Version) String() string

type XBin

type XBin uint

XBin or extended binary text files.

const (
	ExtendedBin XBin = iota
)

func (XBin) String

func (x XBin) String() string

Jump to

Keyboard shortcuts

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