glopher

package
v0.0.0-...-445cf5a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefiFormatPlain = DefiFormat('m') // plain text
	DefiFormatHTML  = DefiFormat('h') // html
	DefiFormatXDXF  = DefiFormat('x') // xdxf
)
View Source
var Newline = []byte{'\n'}

Functions

func CountBlocks

func CountBlocks(r io.Reader, sep []byte) (int, error)

func EscapeNTB

func EscapeNTB(st string, bar bool) string

EscapeNTB escapes Newline, Tab, Baskslash, and vertical Bar (if bar=True)

func JoinByBarEscapeNTB

func JoinByBarEscapeNTB(parts []string) string

func PluginNames

func PluginNames() []string

func ReadInfo

func ReadInfo(reader EntryReader, maxNonInfo int) (*StrOrderedMap, []*Entry, error)

func RegisterPluginType1

func RegisterPluginType1(p PluginType1)

func RegisterPluginType2

func RegisterPluginType2(p PluginType1)

func SplitByBarUnescapeNTB

func SplitByBarUnescapeNTB(st string) []string

SplitByBarUnescapeNTB: splits by "|" (and not "\\|") then unescapes Newline (\\n), Tab (\\t), Baskslash (\\) and Bar (\\|) in each part

func UnescapeNTB

func UnescapeNTB(st string, bar bool) string

UnescapeNTB: unscapes Newline, Tab, Baskslash, and vertical Bar (if bar=True)

Types

type DefiFormat

type DefiFormat int8

format of the definition

type Entry

type Entry struct {
	Error      error
	Word       string
	Defi       string
	AltWord    []string
	AltDefi    []string
	DefiFormat DefiFormat
	IsInfo     bool
}

type EntryHeap

type EntryHeap []*Entry

func (EntryHeap) Len

func (h EntryHeap) Len() int

func (EntryHeap) Less

func (h EntryHeap) Less(i, j int) bool

func (*EntryHeap) Pop

func (h *EntryHeap) Pop() any

func (*EntryHeap) Push

func (h *EntryHeap) Push(x any)

func (EntryHeap) Swap

func (h EntryHeap) Swap(i, j int)

type EntryReader

type EntryReader struct {
	Plug     PluginType1
	Next     func() *Entry
	Filename string
}

type Glossary

type Glossary interface {
	LimitedGlossary
	Filename() string
	SetFilename(string)
	// DefaultDefiFormat() DefiFormat
	SetProgressBar(ProgressBar)
	Len() int
	Read(filename string, format string) error
	Write(filename string, format string) error
}

func NewGlossary

func NewGlossary() Glossary

type LimitedGlossary

type LimitedGlossary interface {
	Info() *StrOrderedMap
	Iter() <-chan *Entry
}

type Option

type Option struct {
	Value any
	Name  string
}

type OptionType

type OptionType struct {
	ValueType reflect.Type
	Name      string
}

type PluginBase

type PluginBase interface {
	Name() string
	Description() string
	Extentions() []string
	ReadOptionTypes() []*OptionType
	WriteOptionsTypes() []*OptionType
	Count(filename string) (int, error)
	Write(glos LimitedGlossary, filename string, options ...Option) error
}

type PluginType1

type PluginType1 interface {
	PluginBase
	Read(filename string, options ...Option) (func() *Entry, error)
}

func PluginByName

func PluginByName(name string) PluginType1

type PluginType2

type PluginType2 interface {
	PluginBase
	Read2(filename string, options ...Option) (<-chan *Entry, error)
}

type ProgressBar

type ProgressBar interface {
	SetTotal(total int)
	Start(msg string) // may be called 1 or 2 times
	Update(index int)
	SetMessage(msg string)
}

type StrOrderedMap

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

func NewStrOrderedMap

func NewStrOrderedMap() *StrOrderedMap

func (*StrOrderedMap) Get

func (m *StrOrderedMap) Get(key string) (string, bool)

func (*StrOrderedMap) GetDefault

func (m *StrOrderedMap) GetDefault(key string, defaultVal string) string

func (*StrOrderedMap) Items

func (m *StrOrderedMap) Items() [][2]string

func (*StrOrderedMap) Len

func (m *StrOrderedMap) Len() int

func (*StrOrderedMap) Pop

func (m *StrOrderedMap) Pop(key string) (string, bool)

func (*StrOrderedMap) Set

func (m *StrOrderedMap) Set(key string, value string)

Set does not change the order of keys if the key is already present

Jump to

Keyboard shortcuts

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