tag

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package tag provides a representation for short, descriptive words or phrases, used to describe the contents of a file.

The combination of multiple tags can help to uniquely classify files.

TIX's primary goal is management of duplicate files, including the alignment of their tags.

Since file tagging is a manual, almost random task, it is highly unlikely that all duplicates of a file will have the same set of tags. Some tags can be expected to be common to all duplicates, others may represent aspects of the file which were not considered while tagging the other duplicates.

There is also the consideration of inconsistent spelling, capitalisation or colorisation of tags.

This package provides:

  • basic tag attributes: text and color

  • merging the tags of multiple, identical files into a single tag set

  • while maintaining a (hopefully) recognisable order

  • identification and alignment of inconsitently spellt tags

  • the permanent replacement of tags

  • e.g. always replace 'important' with 'prio 1'

Index

Constants

View Source
const (
	None   ColorID = iota // None represents an uncolored (transparent) tag
	Red            = iota // Red represents a red tag
	Orange         = iota // Orange represents a orange tag
	Yellow         = iota // Yellow represents a yellow tag
	Green          = iota // Green represents a green tag
	Blue           = iota // Blue represents a blue tag
	Purple         = iota // Purple represents a purple tag
	Grey           = iota // Grey represents a grey tag

)

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorID

type ColorID byte

ColorID is a single-character identifier for the 8 colors that Apple defined for their file tags.

func AllColors

func AllColors() []ColorID

AllColors returns the full list of available colors in a "pleasing" order, sorted by their hue.

func ColorWithID

func ColorWithID(id byte) ColorID

ColorWithID returns the colorID for a color's byte id (0 .. 7)

Any unknown id will return the constant None

func ColorWithIDOrName

func ColorWithIDOrName(idOrName string) ColorID

ColorWithIDOrName returns a colorID for a single-digit string number between "0" and "7" or, alternatively, the name of the color may be provided, e.g. "none", "red", "orange", "yellow", "green", "blue", "purple", "grey"

Any unknown color will return the color constant None

func ColorWithIDString

func ColorWithIDString(stringID string) ColorID

ColorWithIDString returns the colorID for a color's string id ("0" .. "7")

Any unknown id will return the constant None

func ColorWithName

func ColorWithName(name string) ColorID

ColorWithName returns the colorID for a color's name.

Valid names: "none", "red", "orange", "yellow", "green", "blue", "purple", "grey"

Any unknown color will return the color constant None

func (ColorID) BackgroundRGB

func (id ColorID) BackgroundRGB() string

BackgroundRGB returns the color's background RGB(A) color specification (alias for color.RGB())

func (ColorID) BorderRGB

func (id ColorID) BorderRGB() string

BorderRGB returns the RGB(A) specification for the border of a tag's color swatch

func (ColorID) ID

func (id ColorID) ID() byte

ID returns the color's byte ID (0x0 .. 0x7)

func (ColorID) IDString

func (id ColorID) IDString() string

IDString returns the color's string IDString ("0" .. "7")

func (ColorID) Name

func (id ColorID) Name() string

Name returns the color's name

func (ColorID) RGB

func (id ColorID) RGB() string

RGB return's the color's background RGB(A) color specification as a 3-8 digit hexadecimal number without any adornments. e.g. "A357D7"

type List

type List []*Tag

List represents the ordered list of tags for a single file

func NewTagList

func NewTagList() List

NewTagList only provides a common New... interface to a simple list of tags

func (List) IsEqual

func (this List) IsEqual(other List) bool

func (List) Strings

func (tl List) Strings() []string

Strings returns the list of tags as strings... only required to get around go's limited type casting

type Preferences

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

func NewPreferences

func NewPreferences() *Preferences

func (*Preferences) NewTag

func (p *Preferences) NewTag(name, color string) *Tag

type Set

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

Set collect multiple TagLists and provides methods for merging them into a single, common TagList which can be applied to all instances of a duplicated file.

func NewSet

func NewSet() *Set

NewSet creates a new TagSet

func (*Set) AddTagList

func (ts *Set) AddTagList(tl List)

AddTagList adds an ordered list of tags to the set (for eventual merging)

func (*Set) ClearPreferredTags

func (ts *Set) ClearPreferredTags()

ClearPreferredTags removes all tag preferences, reverting to the most recently used name and color of each tag.

func (*Set) MergedTagList

func (ts *Set) MergedTagList() List

MergedTagList returns a TagList containing the full set of tags found in all TagLists within this TagSet, in an order that should keep the original order in tact as much as possible, while favouring later TagLists over earlier tag lists.

func (*Set) PreferTag

func (ts *Set) PreferTag(t *Tag)

PreferTag can be used to override the derived representation of a tag with a user-selected preference.

Note that this overrides both the tag's name as well as its color

func (*Set) TagColors

func (ts *Set) TagColors(id string) []ColorID

TagColors returns the full list of colors that were used for a tag within this TagSet

func (*Set) TagLists

func (ts *Set) TagLists() []List

TagLists returns the list of tagLists, in the order they were added to this TagSet

func (*Set) TagNames

func (ts *Set) TagNames(id string) []string

TagNames returns the full list of names that were used for a tag within this TagSet

type Tag

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

Tag represents a single tag, with a name and color

func NewTag

func NewTag(name, color string) *Tag

NewTag creates a new tag with a name and color.

The color may be a color id ("0" .. "7") or name ("none", "red", "orange", "yellow", "green", "blue", "purple", "grey"). Any other color strings will be translate to the color None

An empty string may be provided for either name or color, however, nil will be returned if neither name nor color are defined.

func (*Tag) Color

func (t *Tag) Color() ColorID

Color returns the ColorID of the tag

func (*Tag) ID

func (t *Tag) ID() string

ID returns a lower-case representation of a tag, with all non-alphanumeric characters replaced by spaces.

func (*Tag) Name

func (t *Tag) Name() string

Name returns the name of the tag

func (*Tag) SetColor

func (t *Tag) SetColor(c string)

func (*Tag) String

func (t *Tag) String() string

String provides a string containing the tag's name and the name of its color

Jump to

Keyboard shortcuts

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