org

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayChunks added in v0.0.2

func DisplayChunks(prefix string, chunks orgTree)

func SetVerbosity added in v0.0.2

func SetVerbosity(level int)

Types

type BasicChunk

type BasicChunk struct {
	Type OrgType
	Id   OrgId
	Text string
}

OrgBlocks are self-contained and offer an alternative to text updates Concatenating the text of all blocks produces the complete document

func (*BasicChunk) AsOrgChunk

func (ch *BasicChunk) AsOrgChunk() *BasicChunk

type Block

type Block struct {
	BasicChunk
	Label    int
	LabelEnd int
	Content  int
	End      int // start of last line
}

func (*Block) LabelText

func (ch *Block) LabelText() string

type Chunk

type Chunk interface {
	Jsonable
	AsOrgChunk() *BasicChunk
	// contains filtered or unexported methods
}

type ChunkChanges

type ChunkChanges struct {
	Changed idSet
	Added   idSet
	Removed []OrgId
	Linked  map[OrgId]doc.Set[string]
}

func (*ChunkChanges) DataChanges

func (ch *ChunkChanges) DataChanges(chunks *OrgChunks) map[string]any

func (*ChunkChanges) IsEmpty

func (ch *ChunkChanges) IsEmpty() bool

func (*ChunkChanges) Merge

func (ch *ChunkChanges) Merge(more *ChunkChanges)

func (*ChunkChanges) Order

func (ch *ChunkChanges) Order(chunks *OrgChunks) []OrgId

type ChunkRef

type ChunkRef struct {
	Chunk
	*OrgChunks
}

func (ChunkRef) AllText

func (blk ChunkRef) AllText(sb strings.Builder)

func (ChunkRef) Children

func (blk ChunkRef) Children() []OrgId

func (ChunkRef) MarshalJSON

func (ref ChunkRef) MarshalJSON() ([]byte, error)

func (ChunkRef) Next

func (blk ChunkRef) Next() OrgId

func (ChunkRef) Parent

func (blk ChunkRef) Parent() OrgId

func (ChunkRef) Prev

func (blk ChunkRef) Prev() OrgId

type ComparableChunk

type ComparableChunk interface {
	comparable
	Chunk
}

type DataBlock

type DataBlock interface {
	Chunk
	SetValue(value any) (str string, err error)
}

type Headline

type Headline struct {
	BasicChunk
	Level int
}

type Jsonable

type Jsonable interface {
	// contains filtered or unexported methods
}

type Keyword

type Keyword struct {
	BasicChunk
	Label    int
	LabelEnd int
	Content  int
}

type OrgChunks

type OrgChunks struct {
	ChunkIds    map[OrgId]Chunk
	Chunks      orgTree
	PendingText *strings.Builder
	MaxId       int
	Next        map[OrgId]OrgId
	Prev        map[OrgId]OrgId
	Parent      map[OrgId]OrgId
	Children    map[OrgId][]OrgId
}

func NewOrgChunks

func NewOrgChunks() *OrgChunks

func Parse

func Parse(doc string) *OrgChunks

func (*OrgChunks) GetChunk

func (chunks *OrgChunks) GetChunk(id string) ChunkRef

func (*OrgChunks) GetChunkNamed

func (chunks *OrgChunks) GetChunkNamed(name string) ChunkRef

func (*OrgChunks) LocateChunkNamed

func (chunks *OrgChunks) LocateChunkNamed(name string) (int, ChunkRef)

func (*OrgChunks) MarshalJSON

func (chunks *OrgChunks) MarshalJSON() ([]byte, error)

func (*OrgChunks) RelinkHierarchy

func (chunks *OrgChunks) RelinkHierarchy(changes *ChunkChanges)

func (*OrgChunks) Replace

func (chunks *OrgChunks) Replace(offset, len int, text string) *ChunkChanges

returns changed blocks

func (*OrgChunks) Sort

func (chunks *OrgChunks) Sort(chunkList []Chunk)

type OrgId

type OrgId string

type OrgMeasure

type OrgMeasure struct {
	Count int
	Width int
	Names doc.Set[string]
	Ids   doc.Set[OrgId]
}

type OrgStorage

type OrgStorage interface {
	GetBlock(name string) string
	StoreBlock(name string)
	RemoveBlock(name string)
}

type OrgType

type OrgType int64
const (
	HeadlineType OrgType = iota
	TextType
	SourceType
	BlockType
	ResultsType
	HtmlType
	DrawerType
	KeywordType
	TableType
)

type SourceBlock

type SourceBlock struct {
	Block
	Options []string
	Value   any // parsed value for supported data types
	// these are relevant only if there is a preceding name element
	NameStart int
	NameEnd   int // this is 0 if there is no name
	SrcStart  int // this is 0 if there is no name
}

if this has children, the last one will be a results block

func (*SourceBlock) IsData

func (ch *SourceBlock) IsData() bool

func (*SourceBlock) IsNamedData

func (ch *SourceBlock) IsNamedData() bool

func (*SourceBlock) Language

func (ch *SourceBlock) Language() string

func (*SourceBlock) Name

func (ch *SourceBlock) Name() string

func (*SourceBlock) SetValue

func (ch *SourceBlock) SetValue(value any) (str string, err error)

type TableBlock

type TableBlock struct {
	BasicChunk
	Cells [][]string // 2D array of cell strings
	Value any        // 2D array of JSON-compatible values
	// these are relevant only if there is a preceding name element
	NameStart int
	NameEnd   int // this is 0 if there is no name
	TblStart  int // this is 0 if there is no name
}

func (*TableBlock) Name

func (ch *TableBlock) Name() string

func (*TableBlock) SetValue

func (ch *TableBlock) SetValue(value any) (str string, err error)

Jump to

Keyboard shortcuts

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