cui

package
v0.0.0-...-ba4a4a7 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Blue

func Blue(text string) string

func BlueDk

func BlueDk(text string) string

func ColorRune

func ColorRune(color Color, r rune) string

func ColorText

func ColorText(color Color, text string) string

func Cyan

func Cyan(text string) string

func CyanDk

func CyanDk(text string) string

func Dark

func Dark(text string) string

func Gray

func Gray(text string) string

func Green

func Green(text string) string

func GreenDk

func GreenDk(text string) string

func Magenta

func Magenta(text string) string

func MagentaDk

func MagentaDk(text string) string

func NewCommandUI

func NewCommandUI(version string) *ui

func Red

func Red(text string) string

func RedDk

func RedDk(text string) string

func SetWindowTitle

func SetWindowTitle(text string)

func White

func White(text string) string

func Yellow

func Yellow(text string) string

func YellowDk

func YellowDk(text string) string

Types

type BoundFunc

type BoundFunc func(ww, wh int) Rect

func Bounds

func Bounds(b Rect) BoundFunc

func CenterBounds

func CenterBounds(minWidth, minHeight, maxWidth, maxHeight int) BoundFunc

func FullScreen

func FullScreen() BoundFunc

func Relative

func Relative(bf BoundFunc, relative func(b Rect) Rect) BoundFunc

type Color

type Color int
const (
	CBlack Color = iota + 30
	CRed
	CGreen
	CYellow
	CBlue
	CMagenta
	CCyan
	CWhite
	CGray
	CDark
	CRedDk
	CGreenDk
	CYellowDk
	CBlueDk
	CMagentaDk
	CCyanDk
)

Foreground text colors

type Menu interface {
	Add(item ...MenuItem)
	AddItems(items []MenuItem)
	Show(x int, y int)
	OnClose(onClose func())
}
type MenuItem struct {
	Text      string
	Title     string
	Key       string
	Action    func()
	Items     []MenuItem
	ItemsFunc func() []MenuItem

	ReuseBounds bool
	// contains filtered or unexported fields
}
func MenuSeparator(text string) MenuItem

type MessageBox

type MessageBox struct {
	OnOK       func()
	OnClose    func()
	ShowCancel bool
	// contains filtered or unexported fields
}

func NewMessageBox

func NewMessageBox(ui *ui, text, title string) *MessageBox

func (*MessageBox) Close

func (t *MessageBox) Close()

func (*MessageBox) Show

func (t *MessageBox) Show()

type Notifier

type Notifier interface {
	NotifyChanged()
}

type Progress

type Progress interface {
	Close()
}

type Rect

type Rect struct {
	X, Y, W, H int
}

type Runner

type Runner interface {
	PostOnUIThread(func())
}

type UI

type UI interface {
	NewView(text string) View
	NewViewFromPageFunc(f func(viewPort ViewPage) ViewText) View
	NewViewFromTextFunc(f func(viewPage ViewPage) string) View
	Post(f func())
	ShowProgress(format string, v ...interface{}) Progress
	ShowMessageBox(title string, format string, v ...interface{})
	ShowErrorMessageBox(format string, v ...interface{})
	MessageBox(title, text string) *MessageBox
	ResizeAllViews()
	NewMenu(title string) Menu
	Version() string
	Quit()
}

type View

type View interface {
	Properties() *ViewProperties
	Show(BoundFunc)
	SetBound(BoundFunc)
	SyncWithView(view View)
	SetCurrentView()
	SetTop()
	SetTitle(title string)
	NotifyChanged()
	SetKey(key interface{}, handler func())
	DeleteKey(key interface{})
	ViewPage() ViewPage
	ReadLines() []string
	SetText(text string)
	Clear()
	PostOnUIThread(func())
	Close()
	ScrollHorizontal(scroll int)
	ScrollVertical(scroll int)
	OnKeyArrowUp()
	OnKeyArrowDown()
	SetCurrentLine(line int)
	ShowLineAtTop(line int, forceScroll bool)
	ShowFrame(isShow bool)
}

type ViewPage

type ViewPage struct {
	Width                 int
	Height                int
	FirstLine             int
	CurrentLine           int
	FirstCharIndex        int
	IsHorizontalScrolling bool
	MaxLineWidth          int
}

type ViewProperties

type ViewProperties struct {
	Title                   string
	HasFrame                bool
	HideCurrentLineMarker   bool
	HideVerticalScrollbar   bool
	HideHorizontalScrollbar bool

	OnLoad           func()
	OnClose          func()
	OnMouseLeft      func(x, y int)
	OnMouseRight     func(x, y int)
	OnMouseOutside   func()
	OnMoved          func()
	Name             string
	IsEditable       bool
	IsWrap           bool
	IsMoveUpDownWrap bool
	OnEdit           func()
	OnMoveCursor     func()
}

Properties that adjust view behavior and can be accessed via View.Properties()

type ViewText

type ViewText struct {
	Lines    []string
	Total    int
	MaxWidth int
}

type Viewer

type Viewer interface {
	Notifier
	Runner
}

Jump to

Keyboard shortcuts

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