Documentation
¶
Index ¶
- Variables
- func BuildANSIString(lines [][]ANSILineToken, padding int) string
- func ChooseByCategory(category string, categoryDir []fs.DirEntry, categoryFiles embed.FS, ...) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping)
- func ChooseByIndex(idx int, entryIdx int, metadataFiles embed.FS, metadataRootDir string) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping, error)
- func ChooseByName(names map[string][]int, nameToken string, metadataFiles embed.FS, ...) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping)
- func ChooseByNameAndCategory(names map[string][]int, nameToken string, metadataFiles embed.FS, ...) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping)
- func ChooseByRandomIndex(totalInBytes []byte) (int, int)
- func ListNames(names map[string][]int) []string
- func Print(args Args, choice int, names []string, categories []string, cows embed.FS)
- func RandomInt(n int) int
- func ReverseANSIString(lines [][]ANSILineToken) [][]ANSILineToken
- func ReverseUnicodeString(s string) string
- func TokeniseANSIString(msg string) [][]ANSILineToken
- func UnicodeStringLength(s string) int
- type ANSILineToken
- type Args
- type BoxChars
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BuildANSIString ¶ added in v0.16.0
func BuildANSIString(lines [][]ANSILineToken, padding int) string
func ChooseByCategory ¶ added in v0.11.0
func ChooseByCategory(category string, categoryDir []fs.DirEntry, categoryFiles embed.FS, categoryRootDir string, metadataFiles embed.FS, metadataRootDir string) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping)
ChooseByCategory chooses a pokemon via a requested category 1. It loads the category search structure and finds the name of a random Pokemon matching the entry e.g. if given the category "small", this function might pick the file `1.cat` in - categories/
- small/
- 1.cat
- 44.cat
This file contains entries representing the <pokemon metadata index>/<the pokemon entry index>, e.g. "4/1" would represent 4.metadata, and the 2nd entry in that file 2. Using the indexes, load the corresponding metadata file and entry, and then return it
func ChooseByIndex ¶ added in v0.17.0
func ChooseByIndex(idx int, entryIdx int, metadataFiles embed.FS, metadataRootDir string) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping, error)
func ChooseByName ¶ added in v0.11.0
func ChooseByName(names map[string][]int, nameToken string, metadataFiles embed.FS, metadataRootDir string) (pokedex.PokemonMetadata, pokedex.PokemonEntryMapping)
func ChooseByNameAndCategory ¶ added in v0.12.2
func ChooseByRandomIndex ¶ added in v0.11.0
func Print ¶ added in v0.11.0
The main print function! This uses a chosen pokemon's index, names and categories, and an embedded filesystem of cowfile data 1. The text received from STDIN is printed inside a speech bubble 2. The cowfile data is retrieved using the matching index, decompressed (un-gzipped), 3. The pokemon is printed along with the name & category information
func ReverseANSIString ¶ added in v0.16.0
func ReverseANSIString(lines [][]ANSILineToken) [][]ANSILineToken
func ReverseUnicodeString ¶ added in v0.16.0
func TokeniseANSIString ¶ added in v0.16.0
func TokeniseANSIString(msg string) [][]ANSILineToken
func UnicodeStringLength ¶ added in v0.14.0
Returns the length of a string, taking into account Unicode characters and ANSI escape codes.
Types ¶
type ANSILineToken ¶ added in v0.16.0
type Args ¶ added in v0.11.0
type Args struct {
Width int
NoWrap bool
DrawBubble bool
TabSpaces string
NoTabSpaces bool
NoCategoryInfo bool
ListCategories bool
ListNames bool
ListNameToken string
Category string
NameToken string
IDToken string
JapaneseName bool
ShowID bool
BoxChars *BoxChars
DrawInfoBorder bool
FlipPokemon bool
Help bool
Verbose bool
}
type BoxChars ¶ added in v0.14.2
type BoxChars struct {
HorizontalEdge string
VerticalEdge string
TopRightCorner string
TopLeftCorner string
BottomRightCorner string
BottomLeftCorner string
BalloonString string
BalloonTether string
Separator string
RightArrow string
CategorySeparator string
}
var ( AsciiBoxChars *BoxChars = &BoxChars{ HorizontalEdge: "-", VerticalEdge: "|", TopRightCorner: "\\", TopLeftCorner: "/", BottomRightCorner: "/", BottomLeftCorner: "\\", BalloonString: "\\", BalloonTether: "¡", Separator: "|", RightArrow: ">", CategorySeparator: "/", } UnicodeBoxChars *BoxChars = &BoxChars{ HorizontalEdge: "─", VerticalEdge: "│", TopRightCorner: "╮", TopLeftCorner: "╭", BottomRightCorner: "╯", BottomLeftCorner: "╰", BalloonString: "╲", BalloonTether: "╲", Separator: "│", RightArrow: "→", CategorySeparator: "/", } SingleWidthChars map[string]bool = map[string]bool{ "♀": true, "♂": true, } )