ui

package
v0.0.0-...-0424493 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Gui event chan
	Gui = make(chan Event)

	// GuiQuit chan
	GuiQuit = make(chan bool)

	// GuiAck gui render finish ack
	GuiAck = make(chan bool)
)
View Source
var (
	// ColorDefault default color
	ColorDefault = &Color{termbox.ColorDefault, termbox.ColorDefault}
)
View Source
var (
	// ZeroPoint x and y all are 0
	ZeroPoint = &Point{0, 0}
)

Functions

func Batch

func Batch(ev ...Event)

Batch send batch events

func EachFileList

func EachFileList(fn func(int, *List))

EachFileList walk through all file list

func SetColors

func SetColors(cs map[string]*Color)

SetColors set colors to use

Types

type BatchTaskItem

type BatchTaskItem struct {
	*Drawable
	// contains filtered or unexported fields
}

BatchTaskItem render a batch task

func NewBatchTaskItem

func NewBatchTaskItem(p *Point, max, width int) *BatchTaskItem

NewBatchTaskItem create batch task

func (*BatchTaskItem) Draw

func (bt *BatchTaskItem) Draw() *Point

Draw it

func (*BatchTaskItem) SetData

func (bt *BatchTaskItem) SetData(name string, current int, subname string, subprogress int)

SetData update state

type Bookmark

type Bookmark struct {
	Width, Height int

	List *List
	*Drawable
	// contains filtered or unexported fields
}

Bookmark ui

func NewBookmark

func NewBookmark(p *Point, height int, names []string) *Bookmark

NewBookmark create bookmark

func (*Bookmark) Draw

func (b *Bookmark) Draw() *Point

Draw it

func (*Bookmark) SetData

func (b *Bookmark) SetData(names []string)

SetData reset bookmark data

type Box

type Box struct {
	*Drawable
	// contains filtered or unexported fields
}

Box rect with border

func NewBox

func NewBox(p *Point, item Drawer, padding ...int) *Box

NewBox create single line box

func NewDBox

func NewDBox(p *Point, item Drawer, padding ...int) *Box

NewDBox create double line box

func (*Box) Draw

func (b *Box) Draw() *Point

Draw it

type Clip

type Clip struct {
	*Text
	// contains filtered or unexported fields
}

Clip render clip

func NewClip

func NewClip(p *Point, height int) *Clip

NewClip create clip

func (*Clip) Close

func (c *Clip) Close()

Close popup

func (*Clip) Draw

func (c *Clip) Draw() *Point

Draw it

func (*Clip) Open

func (c *Clip) Open()

Open popup

func (*Clip) SetData

func (c *Clip) SetData(items []string)

SetData set data

type Color

type Color struct {
	FG, BG termbox.Attribute
}

Color represent the forecolor and background color of an point

func (*Color) Reverse

func (c *Color) Reverse() *Color

Reverse the color

type Column

type Column struct {
	Width, Height int

	*Drawable
	// contains filtered or unexported fields
}

Column container

func NewColumn

func NewColumn(p *Point, width, height int) *Column

NewColumn create column

func (*Column) Add

func (c *Column) Add(item Drawer) *ColumnItem

Add column

func (*Column) Add2

func (c *Column) Add2(item Drawer) *ColumnItem

Add2 column with double line

func (*Column) Draw

func (c *Column) Draw() *Point

Draw it

func (*Column) Last

func (c *Column) Last() *ColumnItem

Last the last column item

func (*Column) Remove

func (c *Column) Remove()

Remove the last column

func (*Column) RemoveAll

func (c *Column) RemoveAll()

RemoveAll the columns

func (*Column) Shift

func (c *Column) Shift(keepFirst bool)

Shift a clumn

type ColumnItem

type ColumnItem struct {
	*Drawable
	// contains filtered or unexported fields
}

ColumnItem a item

func (*ColumnItem) Clear

func (ci *ColumnItem) Clear()

Clear it

func (*ColumnItem) Draw

func (ci *ColumnItem) Draw() *Point

Draw it

type Drawable

type Drawable struct {
	*Rect
	*Color
}

Drawable contains base properties for draw

func NewDrawable

func NewDrawable(p *Point) *Drawable

NewDrawable create drawable

func (*Drawable) Draw

func (d *Drawable) Draw() *Point

Draw it

type Drawer

type Drawer interface {
	Draw() *Point
	Clear()
	// contains filtered or unexported methods
}

Drawer is the base interface for ui components

type Event

type Event struct {
	Type EventType
	Data interface{}
	Wait bool
}

Event object

type EventType

type EventType uint8

EventType event type

const (
	// BatchEvent multiple message
	BatchEvent EventType = iota

	// MessageEvent Data: string
	MessageEvent

	// ChangeGroupEvent Data: model.Workspace
	ChangeGroupEvent

	// ColumnContentChangeEvent Data: model.Column the current column
	ColumnContentChangeEvent

	// ToggleDetailEvent Data: model.Column the current column
	ToggleDetailEvent

	// ChangeSelectEvent Data: model.Column the current column
	ChangeSelectEvent

	// OpenRightEvent Data: model.Group current group
	OpenRightEvent

	// CloseRightEvent Data: model.Column, the new current colunn
	CloseRightEvent

	// ToParentEvent Data: model.Column, the current column
	ToParentEvent

	// ShiftEvent Data: model.Group
	ShiftEvent

	// JumpToEvent Data: model.Group
	JumpToEvent

	// ChangeRootEvent Data: model.Group
	ChangeRootEvent

	// ToggleBookmarkEvent Data: bool if to show bookmark
	ToggleBookmarkEvent

	// InputChangeEvent Data: [name string, value string]
	InputChangeEvent

	// QuitInputEvent Data: model.Column
	QuitInputEvent

	// BookmarkChangedEvent Data: model.Bookmark
	BookmarkChangedEvent

	// JumpRefreshEvent Data:
	JumpRefreshEvent

	// ClipChangedEvent clip changed Data CopySource
	ClipChangedEvent

	// TaskChangedEvent Data: TaskManager
	TaskChangedEvent

	// ToggleTaskDetailEvent Data: bool
	ToggleTaskDetailEvent

	// ShowHelpEvent Data: bool
	ShowHelpEvent

	// ToggleClipDetailEvent Data: bool
	ToggleClipDetailEvent
)

func (EventType) Send

func (et EventType) Send(data interface{})

Send event

func (EventType) With

func (et EventType) With(data interface{}) Event

With create Event

type FileList

type FileList struct {
	*Drawable
	// contains filtered or unexported fields
}

FileList is a list of file

func (*FileList) Draw

func (fl *FileList) Draw() *Point

Draw it

type FloatText

type FloatText struct {
	*Text
	// contains filtered or unexported fields
}

FloatText restore the cells after clear

func NewFloatText

func NewFloatText(p *Point, data string) *FloatText

NewFloatText create float text

func (*FloatText) Clear

func (ft *FloatText) Clear()

Clear it

func (*FloatText) Draw

func (ft *FloatText) Draw() *Point

Draw it

type FlowLayout

type FlowLayout struct {
	LeftPadding  int
	RightPadding int

	*Drawable
	// contains filtered or unexported fields
}

FlowLayout layout from left to right

func NewFlowLayout

func NewFlowLayout(p *Point, padding func(*Point) *Point, items ...Drawer) *FlowLayout

NewFlowLayout create flow layout

func (FlowLayout) Append

func (fl FlowLayout) Append(ds ...Drawer)

Append items to layout

func (*FlowLayout) Draw

func (fl *FlowLayout) Draw() *Point

Draw it

func (FlowLayout) Remove

func (fl FlowLayout) Remove(d Drawer)

Remove item from layout

type HLine

type HLine struct {
	*Text
	// contains filtered or unexported fields
}

HLine horizontal line

func NewHDLine

func NewHDLine(p *Point, width int) *HLine

NewHDLine create HLine

func NewHLine

func NewHLine(p *Point, width int) *HLine

NewHLine create HLine

func (*HLine) ChangeWidth

func (h *HLine) ChangeWidth(width int)

ChangeWidth change the line width

type JumpItem

type JumpItem struct {
	Key    []rune
	Action func() bool
	Point  *Point
}

JumpItem present

type Keyed

type Keyed struct {
	Key string

	*Drawable
	// contains filtered or unexported fields
}

Keyed is a container with key

func NewKeyed

func NewKeyed(p *Point, key string, item Drawer) *Keyed

NewKeyed create Keyed

func (*Keyed) Draw

func (k *Keyed) Draw() *Point

Draw it

type Label

type Label struct {
	Data string

	*Keyed
	// contains filtered or unexported fields
}

Label key value

func NewLabel

func NewLabel(p *Point, name, data string) *Label

NewLabel create label

func (*Label) SetData

func (l *Label) SetData(data string)

SetData set data

type List

type List struct {
	Selected int
	Height   int
	Data     []string

	*Drawable
	// contains filtered or unexported fields
}

List a list of string

func BookmarkList

func BookmarkList() *List

BookmarkList for jump bookmark

func ClipList

func ClipList() *List

ClipList the list inside clip detail

func CurrentFileList

func CurrentFileList() *List

CurrentFileList for jump current list

func NewHelp

func NewHelp(height int) *List

NewHelp create help

func NewList

func NewList(p *Point, selected, height int, items []string, colorHints []int) *List

NewList create a list

func (*List) Draw

func (l *List) Draw() *Point

Draw it

func (*List) JumpItems

func (fl *List) JumpItems(namefn func(int) string, fn func(int) func() bool) []*JumpItem

JumpItems jump items of file list

func (*List) Select

func (l *List) Select(item int)

Select change the selected item to item

func (*List) SetData

func (l *List) SetData(items []string, hints []int, selected int)

SetData update items

type Path

type Path struct {
	*Keyed

	PathItems []string
	// contains filtered or unexported fields
}

Path represent seperated path

func NewPath

func NewPath(p *Point, name string, path string) *Path

NewPath create path

func (*Path) ItemRects

func (p *Path) ItemRects() []*Rect

ItemRects rect for jump

func (*Path) JumpItems

func (p *Path) JumpItems(fn func(string) func() bool) []*JumpItem

JumpItems jump items of path

func (*Path) SetValue

func (p *Path) SetValue(path string)

SetValue update value

type Point

type Point struct {
	X, Y int
}

Point represent a point in screen

func Move

func Move(d Drawer, p *Point) *Point

Move a drawer

func Redraw

func Redraw(d Drawer) *Point

Redraw clear it and draw again

func (*Point) Down

func (p *Point) Down() *Point

Down returns the bottom point of current point

func (*Point) DownN

func (p *Point) DownN(n int) *Point

DownN returns the nth bottom point of current point

func (*Point) Equals

func (p *Point) Equals(o *Point) bool

Equals is used to compare two point

func (*Point) Left

func (p *Point) Left() *Point

Left returns the left point of current point

func (*Point) LeftN

func (p *Point) LeftN(n int) *Point

LeftN returns the nth left point of current point

func (*Point) MoveDown

func (p *Point) MoveDown() *Point

MoveDown moves the current point to the bottom by 1 and reterns it self

func (*Point) MoveDownN

func (p *Point) MoveDownN(n int) *Point

MoveDownN moves the current point to the bottom by n and reterns it self

func (*Point) MoveLeft

func (p *Point) MoveLeft() *Point

MoveLeft moves the current point to the left by 1 and reterns it self

func (*Point) MoveLeftN

func (p *Point) MoveLeftN(n int) *Point

MoveLeftN moves the current point to the left by N and reterns it self

func (*Point) MoveRight

func (p *Point) MoveRight() *Point

MoveRight moves the current point to the right by 1 and reterns it self

func (*Point) MoveRightN

func (p *Point) MoveRightN(n int) *Point

MoveRightN moves the current point to the right by N and reterns it self

func (*Point) MoveUp

func (p *Point) MoveUp() *Point

MoveUp moves the current point to the above by 1 and reterns it self

func (*Point) MoveUpN

func (p *Point) MoveUpN(n int) *Point

MoveUpN moves the current point to the above by n and reterns it self

func (*Point) Right

func (p *Point) Right() *Point

Right returns the right point of current point

func (*Point) RightN

func (p *Point) RightN(n int) *Point

RightN returns the nth right point of current point

func (*Point) To

func (p *Point) To(p2 *Point) *Rect

To creates a rect with another point

func (*Point) ToRect

func (p *Point) ToRect() *Rect

ToRect creates a empty rect

func (*Point) Up

func (p *Point) Up() *Point

Up returns the top point of current point

func (*Point) UpN

func (p *Point) UpN(n int) *Point

UpN returns the nth top point of current point

type Popup struct {
	Item Drawer

	*Drawable
	// contains filtered or unexported fields
}

Popup restore covered after clear

func NewPopup

func NewPopup(p *Point, item Drawer) *Popup

NewPopup create popup

func (*Popup) Clear

func (p *Popup) Clear()

Clear it

func (*Popup) Draw

func (p *Popup) Draw() *Point

Draw it

type ProgressBar

type ProgressBar struct {
	Width    int
	Progress int

	*Drawable
	// contains filtered or unexported fields
}

ProgressBar a progress bar

func NewProgressBar

func NewProgressBar(p *Point, width, progress int) *ProgressBar

NewProgressBar create progress bar

func (*ProgressBar) Draw

func (pb *ProgressBar) Draw() *Point

Draw it

type Rect

type Rect struct {
	Start, End *Point
}

Rect represent a rectangle position

func (*Rect) Clear

func (r *Rect) Clear()

Clear the content of the Rect

type RightAlignFlowLayout

type RightAlignFlowLayout struct {
	*FlowLayout
	Start *Point
}

RightAlignFlowLayout right align

func NewRightAlignFlowLayout

func NewRightAlignFlowLayout(p *Point, padding func(*Point) *Point, items ...Drawer) *RightAlignFlowLayout

NewRightAlignFlowLayout create right align flow layout

func (RightAlignFlowLayout) Append

func (fl RightAlignFlowLayout) Append(ds ...Drawer)

Append items to layout

func (*RightAlignFlowLayout) Draw

func (ra *RightAlignFlowLayout) Draw() *Point

Draw it

func (RightAlignFlowLayout) Remove

func (fl RightAlignFlowLayout) Remove(d Drawer)

Remove item from layout

type Status

type Status struct {
	*Drawable
	// contains filtered or unexported fields
}

Status bar

func NewStatus

func NewStatus(p *Point, width int) *Status

NewStatus create status bar

func (*Status) Add

func (s *Status) Add(padding int) *StatusItem

Add statusbar item

func (*Status) Backup

func (s *Status) Backup() *StatusBackup

Backup statusbar state

func (*Status) Clear

func (s *Status) Clear()

Clear it

func (*Status) Draw

func (s *Status) Draw() *Point

Draw it

func (*Status) Set

func (s *Status) Set(idx int, str string) *Point

Set string to status bar

type StatusBackup

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

StatusBackup backup status bar state

func (*StatusBackup) Restore

func (b *StatusBackup) Restore() *Status

Restore statusbar state

type StatusItem

type StatusItem struct {
	*Text
	// contains filtered or unexported fields
}

StatusItem item in status bar

type Tab

type Tab struct {
	Current int

	*Keyed
	// contains filtered or unexported fields
}

Tab is the ui tab sheet

func NewTab

func NewTab(p *Point, name string, names []string) *Tab

NewTab create tab

func (*Tab) JumpItems

func (t *Tab) JumpItems(fn func(int) func() bool) []*JumpItem

JumpItems jump items of tab

func (*Tab) SwitchTo

func (t *Tab) SwitchTo(selected int) *Point

SwitchTo update select index

type Task

type Task struct {
	*Text
	// contains filtered or unexported fields
}

Task ui

func NewTask

func NewTask(p *Point) *Task

NewTask create task

func (*Task) Close

func (t *Task) Close()

Close popup

func (*Task) JumpItems

func (t *Task) JumpItems(fn func(int) func() bool) []*JumpItem

JumpItems for cancel task

func (*Task) Open

func (t *Task) Open()

Open popup

func (*Task) SetData

func (t *Task) SetData(ts []model.Task)

SetData update state

type TaskItem

type TaskItem struct {
	*Drawable
	// contains filtered or unexported fields
}

TaskItem render a task

func NewTaskItem

func NewTaskItem(p *Point, name string, width int) *TaskItem

NewTaskItem create task item

func (*TaskItem) Draw

func (ti *TaskItem) Draw() *Point

Draw it

func (*TaskItem) SetData

func (ti *TaskItem) SetData(name string, progress int)

SetData update the progress

type Text

type Text struct {
	Data string
	*Drawable
}

Text represent a drawable text

func NewText

func NewText(p *Point, data string) *Text

NewText create a Text

func (*Text) Draw

func (t *Text) Draw() *Point

Draw the text

type UI

type UI struct {
	Tab  *Tab
	Path *Path
	Clip *Clip

	Task *Task

	Column   *Column
	Bookmark *Bookmark

	Status        *Status
	StatusMessage *StatusBackup
	StatusInput   *StatusBackup
	// contains filtered or unexported fields
}

UI hold all ui items

func Recreate

func Recreate(wo *model.Workspace) *UI

Recreate UI after resize

func Start

func Start(wo *model.Workspace) *UI

Start ui

func (*UI) Redraw

func (*UI) Redraw()

Redraw redraw ui

type VLine

type VLine struct {
	*Drawable
	// contains filtered or unexported fields
}

VLine vertical line

func NewVDLine

func NewVDLine(p *Point, height int) *VLine

NewVDLine create double vertical line

func NewVLine

func NewVLine(p *Point, height int) *VLine

NewVLine create vline

func (*VLine) Draw

func (v *VLine) Draw() *Point

Draw it

type VerticalLayout

type VerticalLayout struct {
	TopPadding, BottomPadding int

	*Drawable
	// contains filtered or unexported fields
}

VerticalLayout vertical flow layout

func NewVerticalLayout

func NewVerticalLayout(p *Point, padding func(*Point) *Point, items ...Drawer) *VerticalLayout

NewVerticalLayout create flow layout

func (VerticalLayout) Append

func (fl VerticalLayout) Append(ds ...Drawer)

Append items to layout

func (VerticalLayout) Draw

func (vl VerticalLayout) Draw() *Point

Draw it

func (VerticalLayout) Remove

func (fl VerticalLayout) Remove(d Drawer)

Remove item from layout

Jump to

Keyboard shortcuts

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