treew

package
v0.0.0-...-dffcbd8 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultStyle = BoxDrawStyle()

Functions

This section is empty.

Types

type Prefix

type Prefix struct {
	Style *Style
	// contains filtered or unexported fields
}
Example
var pf Prefix
exampleTree(&pf)
Output:

This is some sort of preamble
┌─ Node 1
│  ├─ Node 1.1
│  │  This is more additional text
│  │  for node 1.1.
│  └─ Node 1.2
│     ├─ Node 1.2.1
│     │  By the way, this is what I want to add to 1.2.1!
│     └─ Node 1.2.2
│        └─ Node 1.2.1.1
└─ Node 3
And finally a footer
Example (Ascii)
pf := Prefix{Style: ASCIIStyle()}
exampleTree(&pf)
Output:

This is some sort of preamble
,-- Node 1
|   +-- Node 1.1
|   |   This is more additional text
|   |   for node 1.1.
|   `-- Node 1.2
|       +-- Node 1.2.1
|       |   By the way, this is what I want to add to 1.2.1!
|       `-- Node 1.2.2
|           `-- Node 1.2.1.1
`-- Node 3
And finally a footer
Example (Items)
pf := Prefix{Style: ItemStyle()}
exampleTree(&pf)
Output:

This is some sort of preamble
- Node 1
  - Node 1.1
    This is more additional text
    for node 1.1.
  - Node 1.2
    - Node 1.2.1
      By the way, this is what I want to add to 1.2.1!
    - Node 1.2.2
      - Node 1.2.1.1
- Node 3
And finally a footer

func (*Prefix) Ascend

func (p *Prefix) Ascend(up int) *Prefix

func (*Prefix) Cont

func (p *Prefix) Cont(s *Style) string

func (*Prefix) Descend

func (p *Prefix) Descend() *Prefix

func (*Prefix) First

func (p *Prefix) First(s *Style) string

func (*Prefix) Last

func (p *Prefix) Last(s *Style) string

func (*Prefix) Next

func (p *Prefix) Next(s *Style) string

func (*Prefix) String

func (p *Prefix) String(e PrefixElement, s *Style) string

type PrefixElement

type PrefixElement int
const (
	First PrefixElement = iota
	Next
	Cont
	Last
)

func Branch

func Branch(idx, len int) PrefixElement

func Root

func Root(idx, len int) PrefixElement

type Style

type Style struct {
	Branch string
	Gap    string
	First  string
	Next   string
	Last   string
}

func ASCIIStyle

func ASCIIStyle() *Style

func BoxDrawStyle

func BoxDrawStyle() *Style

func ItemStyle

func ItemStyle() *Style

type Writer

type Writer struct {
	// contains filtered or unexported fields
}
Example
w := NewWriter(os.Stdout, nil)
io.WriteString(w, "This is some sort of preamble")
io.WriteString(w.Descend().First(nil), "Node 1")
io.WriteString(w.Descend().Next(nil), `Node 1.1
This is more additional text
for node 1.1.`)
io.WriteString(w.Last(nil), "Node 1.2")
fmt.Fprint(w.Descend().Next(nil), "Node 1.2.1")
fmt.Fprint(w, "By the way, this is what I want to add to 1.2.1!")
fmt.Fprint(w.Last(nil), "Node 1.2.2")
fmt.Fprint(w.Descend().Last(nil), "Node 1.2.2.1")
fmt.Fprint(w.Ascend(3).Last(nil), "Node 3")
fmt.Fprint(w.Ascend(1), "And finally a footer")
Output:

This is some sort of preamble
┌─ Node 1
│  ├─ Node 1.1
│  │  This is more additional text
│  │  for node 1.1.
│  └─ Node 1.2
│     ├─ Node 1.2.1
│     │  By the way, this is what I want to add to 1.2.1!
│     └─ Node 1.2.2
│        └─ Node 1.2.2.1
└─ Node 3
And finally a footer

func NewWriter

func NewWriter(w io.Writer, s *Style) *Writer

func (*Writer) Ascend

func (w *Writer) Ascend(up int) *Writer

func (*Writer) Descend

func (w *Writer) Descend() *Writer

func (*Writer) First

func (w *Writer) First(s *Style) *Writer

func (*Writer) Last

func (w *Writer) Last(s *Style) *Writer

func (*Writer) Next

func (w *Writer) Next(s *Style) *Writer

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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