layout

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

ANSiFlags allow an author of ANSi and similar files to provide a clue to a viewer / editor how to render the image. The 8 bits in the ANSiFlags contain the following information: 0 0 0 A R L S B B: Non-blink mode (iCE Color). LS: Letter-spacing (a.k.a. 8/9 pixel font selection). AR: Aspect Ratio. See http://www.acid.org/info/sauce/sauce.htm#ANSiFlags.

An archive file data type. See http://www.acid.org/info/sauce/sauce.htm#FileType

An audio file data type. See http://www.acid.org/info/sauce/sauce.htm#FileType

This is a raw memory copy of a text mode screen. Also known as a .BIN file. This is essentially a collection of character and attribute pairs. See http://www.acid.org/info/sauce/sauce.htm#FileType

Bitmap graphic and animation files. See http://www.acid.org/info/sauce/sauce.htm#FileType

A character based file. These files are typically interpreted sequentially. Also known as streams. See http://www.acid.org/info/sauce/sauce.htm#FileType

A SAUCE comment block is an optional, variable sized structure that holds up to 255 lines of additional information, each line 64 characters wide. There are as many comment lines as is mentioned in the Comments field of the SAUCE record. If the Comments field is set to 0, there should not be a comment block at all. See http://www.acid.org/info/sauce/sauce.htm

Type of data. SAUCE supports 8 different types and an undefined value. See http://www.acid.org/info/sauce/sauce.htm

The date the file was created. The format for the date is CCYYMMDD (century, year, month, day). Example: 4 May 2013 would be stored as "20130504". See http://www.acid.org/info/sauce/sauce.htm

A executable file. Any executable file. .exe, .dll, .bat, ... Executable scripts such as .vbs should be tagged as Source. See http://www.acid.org/info/sauce/sauce.htm#FileType

Type of file. See http://www.acid.org/info/sauce/sauce.htm#FileType

Undefined filetype. You could use this to add SAUCE to a custom or proprietary file, without giving it any particular meaning or interpretation. See http://www.acid.org/info/sauce/sauce.htm#FileType

A vector graphic file. See http://www.acid.org/info/sauce/sauce.htm#FileType

An XBin or eXtended BIN file. See http://www.acid.org/info/sauce/sauce.htm#FileType

Index

Constants

View Source
const (
	ComntID       string = "COMNT"                // SAUCE comment block identification. This should be equal to "COMNT".
	SauceID       string = "SAUCE"                // SAUCE identification, this should be equal to "SAUCE".
	SauceVersion  string = "00"                   // SAUCE version number, should be "00".
	SauceSeek     string = SauceID + SauceVersion // SAUCE sequence to seek.
	ComntLineSize int    = 64                     // A SAUCE comment line is 64 characters wide.
	ComntMaxLines int    = 255                    // A SAUCE comment is variable sized structure that holds up to 255 lines of additional information.
)
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

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"`                          // Aspect Ratio value.
	Info string `json:"interpretation" xml:"interpretation,attr"` // A 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"`                          // Non-blink mode (iCE Color) toggle.
	Info string `json:"interpretation" xml:"interpretation,attr"` // A 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"`                          // Letter-spacing value.
	Info string `json:"interpretation" xml:"interpretation,attr"` // A 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"`         // Flags value as an unsigned integer.
	Binary          string     `json:"binary" xml:"binary,attr"`           // Flags value in binary notation.
	B               ANSIFlagB  `json:"nonBlinkMode" xml:"non_blink_mode"`  // Non-blink mode (iCE Color) value.
	LS              ANSIFlagLS `json:"letterSpacing" xml:"letter_spacing"` // Letter-spacing value.
	AR              ANSIFlagAR `json:"aspectRatio" xml:"aspect_ratio"`     // Aspect Ratio value.
	Interpretations string     `json:"-" xml:"-"`                          // Humanized descriptions of the ANSIFlags 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 // 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 // The (nick)name or handle of the creator of the file.

func (Author) String

func (b Author) String() string

type BBit

type BBit string // Non-blink mode (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"`       // SAUCE comment block identification, this should be "COMNT"
	Count   int      `json:"count" xml:"count,attr"` // The reported number of lines in the SAUCE comment block.
	Index   int      `json:"-" xml:"-"`              // The calculated starting position of the comment block.
	Comment []string `json:"lines" xml:"line"`       // Lines of text, each line should be 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 // Number of lines in the extra SAUCE comment block.

type Comnt

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

type Data

type Data []byte // Data is 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 // Type of data.

type Datas

type Datas struct {
	Type TypeOfData `json:"type" xml:"type"` // A unsigned integer DataType.
	Name string     `json:"name" xml:"name"` // Name of the DataType.
}

Datas is the SAUCE DataType value and name.

type Date

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

func (Date) String

func (b Date) String() string

type Dates

type Dates struct {
	Value string    `json:"value" xml:"value"`      // SAUCE date format, CCYYMMDD (century, year, month, day).
	Time  time.Time `json:"iso" xml:"date"`         // Time as a time type.
	Epoch int64     `json:"epoch" xml:"epoch,attr"` // Unix time, 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 // The original file size not including the SAUCE information.

type FileType

type FileType [1]byte // Type of file.

type Files

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

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 // The name of the group or company the creator is employed by.

func (Group) String

func (b Group) String() string

type ID added in v1.1.0

type ID [5]byte // SAUCE identification.

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"`          // Size as bytes.
	Decimal string `json:"decimal" xml:"decimal,attr"` // Decimal returns the file size as a base 10 value.
	Binary  string `json:"binary" xml:"binary,attr"`   // Binary returns the file size as a base 2 value.
}

Sizes is the original file size in multiple formats.

type TFlags

type TFlags [1]byte // Type dependant flags.

type TInfo1

type TInfo1 [2]byte // Type dependant numeric information field 1.

type TInfo2

type TInfo2 [2]byte // Type dependant numeric information field 2.

type TInfo3

type TInfo3 [2]byte // Type dependant numeric information field 3.

type TInfo4

type TInfo4 [2]byte // Type dependant numeric information field 4.

type TInfoS

type TInfoS [22]byte // Type dependant string information field.

func (TInfoS) String

func (t TInfoS) String() string

type Title

type Title [35]byte // The 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                    // A character based file.
	Bitmaps                       // Bitmap graphic and animation files.
	Vectors                       // A vector graphic file.
	Audios                        // An audio file.
	BinaryTexts                   // This is a raw memory copy of a text mode screen. Also known as a .BIN file.
	XBins                         // An XBin or eXtended BIN file.
	Archives                      // An archive file.
	Executables                   // A executable file.
)

func (TypeOfData) String

func (d TypeOfData) String() string

type TypeOfFile

type TypeOfFile uint

TypeOfData 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 // SAUCE 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