display

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package display This package controls the display format, like grid/across/byline/...

Index

Constants

View Source
const (
	TreeUnicode
	TreeASCII
	TreeRectangle
)

Variables

View Source
var (
	UNICODEStyle     = table.StyleRounded
	ASCIIStyle       = table.StyleDefault
	DefaultTBStyle   = ASCIIStyle
	DefaultTreeStyle = TreeUnicode
)
View Source
var (
	CustomTermSize uint
)
View Source
var IncludeHyperlink = false
View Source
var Output io.Writer = os.Stdout

Functions

func DefaultTB

func DefaultTB(w table.Writer)

func RawPrint

func RawPrint(toPrint ...any) (n int, err error)

RawPrint used for print statistics like:

underwent 898 microseconds
statistic: 15 file(s), 5 dir(s), 0 link(s)

func WidthLen

func WidthLen(str string) int

func WidthNoHyperLinkLen

func WidthNoHyperLinkLen(str string) int

Types

type Across

type Across struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func (Across) AddAfterPrint

func (h Across) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (Across) AddBeforePrint

func (h Across) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (Across) DisablePostHook

func (h Across) DisablePostHook()

func (Across) DisablePreHook

func (h Across) DisablePreHook()

func (Across) EnablePostHook

func (h Across) EnablePostHook()

func (Across) EnablePreHook

func (h Across) EnablePreHook()

func (*Across) Print

func (a *Across) Print(items ...*item.FileInfo)

type Byline

type Byline struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func (Byline) AddAfterPrint

func (h Byline) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (Byline) AddBeforePrint

func (h Byline) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (Byline) DisablePostHook

func (h Byline) DisablePostHook()

func (Byline) DisablePreHook

func (h Byline) DisablePreHook()

func (Byline) EnablePostHook

func (h Byline) EnablePostHook()

func (Byline) EnablePreHook

func (h Byline) EnablePreHook()

func (*Byline) Print

func (b *Byline) Print(i ...*item.FileInfo)

type CSVPrinter

type CSVPrinter struct {
	*TablePrinter
}

func (CSVPrinter) AddAfterPrint

func (h CSVPrinter) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (CSVPrinter) AddBeforePrint

func (h CSVPrinter) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (CSVPrinter) DisablePostHook

func (h CSVPrinter) DisablePostHook()

func (CSVPrinter) DisablePreHook

func (h CSVPrinter) DisablePreHook()

func (CSVPrinter) EnablePostHook

func (h CSVPrinter) EnablePostHook()

func (CSVPrinter) EnablePreHook

func (h CSVPrinter) EnablePreHook()

func (*CSVPrinter) Print

func (c *CSVPrinter) Print(s ...*item.FileInfo)

type CommaPrint

type CommaPrint struct {
	*Across
	// contains filtered or unexported fields
}

func (CommaPrint) AddAfterPrint

func (h CommaPrint) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (CommaPrint) AddBeforePrint

func (h CommaPrint) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (CommaPrint) DisablePostHook

func (h CommaPrint) DisablePostHook()

func (CommaPrint) DisablePreHook

func (h CommaPrint) DisablePreHook()

func (CommaPrint) EnablePostHook

func (h CommaPrint) EnablePostHook()

func (CommaPrint) EnablePreHook

func (h CommaPrint) EnablePreHook()

func (*CommaPrint) Print

func (c *CommaPrint) Print(items ...*item.FileInfo)

type Content

type Content interface {
	String() string
}

type FitTerminal

type FitTerminal struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func (FitTerminal) AddAfterPrint

func (h FitTerminal) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (FitTerminal) AddBeforePrint

func (h FitTerminal) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (FitTerminal) DisablePostHook

func (h FitTerminal) DisablePostHook()

func (FitTerminal) DisablePreHook

func (h FitTerminal) DisablePreHook()

func (FitTerminal) EnablePostHook

func (h FitTerminal) EnablePostHook()

func (FitTerminal) EnablePreHook

func (h FitTerminal) EnablePreHook()

func (*FitTerminal) Print

func (f *FitTerminal) Print(i ...*item.FileInfo)

type HeaderMaker added in v0.27.0

type HeaderMaker struct {
	Header, Footer  bool
	IsBefore        bool
	LongestEachPart map[string]int
	AllPart         []string
}

func (HeaderMaker) Make added in v0.27.0

func (h HeaderMaker) Make(p Printer, Items ...*item.FileInfo)

type Hook

type Hook interface {
	AddBeforePrint(...func(Printer, ...*item.FileInfo))
	AddAfterPrint(...func(Printer, ...*item.FileInfo))
	DisablePreHook()
	EnablePreHook()
	DisablePostHook()
	EnablePostHook()
}

Hook is used to add pre-content and post-content like adding a header or footer:

Permissions Size Owner Group Time Modified Name

type ItemContent

type ItemContent struct {
	No             int
	Content        Content
	Prefix, Suffix string
}

func (*ItemContent) AddPrefix

func (i *ItemContent) AddPrefix(add string)

func (*ItemContent) AddSuffix

func (i *ItemContent) AddSuffix(add string)

func (*ItemContent) NO

func (i *ItemContent) NO() int

func (*ItemContent) SetPrefix

func (i *ItemContent) SetPrefix(s string)

func (*ItemContent) SetSuffix

func (i *ItemContent) SetSuffix(s string)

func (*ItemContent) String

func (i *ItemContent) String() string

type JsonPrinter

type JsonPrinter struct {
	*bufio.Writer

	Extra []any // RawPrint can't output in json, so we need an extra field
	// contains filtered or unexported fields
}

func (JsonPrinter) AddAfterPrint

func (h JsonPrinter) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (JsonPrinter) AddBeforePrint

func (h JsonPrinter) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (JsonPrinter) DisablePostHook

func (h JsonPrinter) DisablePostHook()

func (JsonPrinter) DisablePreHook

func (h JsonPrinter) DisablePreHook()

func (JsonPrinter) EnablePostHook

func (h JsonPrinter) EnablePostHook()

func (JsonPrinter) EnablePreHook

func (h JsonPrinter) EnablePreHook()

func (*JsonPrinter) Print

func (j *JsonPrinter) Print(items ...*item.FileInfo)

type MDPrinter

type MDPrinter struct {
	*TablePrinter
}

func (MDPrinter) AddAfterPrint

func (h MDPrinter) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (MDPrinter) AddBeforePrint

func (h MDPrinter) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (MDPrinter) DisablePostHook

func (h MDPrinter) DisablePostHook()

func (MDPrinter) DisablePreHook

func (h MDPrinter) DisablePreHook()

func (MDPrinter) EnablePostHook

func (h MDPrinter) EnablePostHook()

func (MDPrinter) EnablePreHook

func (h MDPrinter) EnablePreHook()

func (*MDPrinter) Print

func (m *MDPrinter) Print(s ...*item.FileInfo)

type PrettyPrinter

type PrettyPrinter interface {
	SetTitle(title string)
	AddHeader(headers string)
	AddFooter(footer string)
	Printer
}

type Printer

type Printer interface {
	Print(s ...*item.FileInfo)
	Hook
	io.Writer
}

Printer is the interface of all printers. all printers should implement this interface

func NewAcross

func NewAcross() Printer

func NewByline

func NewByline() Printer

func NewCSVPrinter

func NewCSVPrinter() Printer

func NewCommaPrint

func NewCommaPrint() Printer

func NewFitTerminal

func NewFitTerminal() Printer

func NewJsonPrinter

func NewJsonPrinter() Printer

func NewMDPrinter

func NewMDPrinter() Printer

func NewTSVPrinter

func NewTSVPrinter() Printer

func NewTablePrinter

func NewTablePrinter(opts ...func(writer table.Writer)) Printer

func NewZero

func NewZero() Printer

type StringContent

type StringContent string

func (StringContent) String

func (s StringContent) String() string

type TSVPrinter

type TSVPrinter struct {
	*TablePrinter
}

func (TSVPrinter) AddAfterPrint

func (h TSVPrinter) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (TSVPrinter) AddBeforePrint

func (h TSVPrinter) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (TSVPrinter) DisablePostHook

func (h TSVPrinter) DisablePostHook()

func (TSVPrinter) DisablePreHook

func (h TSVPrinter) DisablePreHook()

func (TSVPrinter) EnablePostHook

func (h TSVPrinter) EnablePostHook()

func (TSVPrinter) EnablePreHook

func (h TSVPrinter) EnablePreHook()

func (*TSVPrinter) Print

func (t *TSVPrinter) Print(s ...*item.FileInfo)

type TablePrinter

type TablePrinter struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func (TablePrinter) AddAfterPrint

func (h TablePrinter) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (TablePrinter) AddBeforePrint

func (h TablePrinter) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (*TablePrinter) AddFooter

func (t *TablePrinter) AddFooter(footer string)

func (*TablePrinter) AddHeader

func (t *TablePrinter) AddHeader(headers string)

func (TablePrinter) DisablePostHook

func (h TablePrinter) DisablePostHook()

func (TablePrinter) DisablePreHook

func (h TablePrinter) DisablePreHook()

func (TablePrinter) EnablePostHook

func (h TablePrinter) EnablePostHook()

func (TablePrinter) EnablePreHook

func (h TablePrinter) EnablePreHook()

func (*TablePrinter) Print

func (t *TablePrinter) Print(s ...*item.FileInfo)

func (*TablePrinter) PrintBase

func (t *TablePrinter) PrintBase(fn func() string, s ...*item.FileInfo)

func (*TablePrinter) SetTitle

func (t *TablePrinter) SetTitle(title string)

type TreePrinter

type TreePrinter struct {
	*bufio.Writer

	NO bool
	// contains filtered or unexported fields
}

func NewTreePrinter

func NewTreePrinter() *TreePrinter

func (TreePrinter) AddAfterPrint

func (h TreePrinter) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (TreePrinter) AddBeforePrint

func (h TreePrinter) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (TreePrinter) DisablePostHook

func (h TreePrinter) DisablePostHook()

func (TreePrinter) DisablePreHook

func (h TreePrinter) DisablePreHook()

func (TreePrinter) EnablePostHook

func (h TreePrinter) EnablePostHook()

func (TreePrinter) EnablePreHook

func (h TreePrinter) EnablePreHook()

func (*TreePrinter) Print

func (t *TreePrinter) Print(s ...*item.FileInfo)

type Zero

type Zero struct {
	*bufio.Writer
	// contains filtered or unexported fields
}

func (Zero) AddAfterPrint

func (h Zero) AddAfterPrint(f ...func(Printer, ...*item.FileInfo))

func (Zero) AddBeforePrint

func (h Zero) AddBeforePrint(f ...func(Printer, ...*item.FileInfo))

func (Zero) DisablePostHook

func (h Zero) DisablePostHook()

func (Zero) DisablePreHook

func (h Zero) DisablePreHook()

func (Zero) EnablePostHook

func (h Zero) EnablePostHook()

func (Zero) EnablePreHook

func (h Zero) EnablePreHook()

func (*Zero) Print

func (z *Zero) Print(items ...*item.FileInfo)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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