view

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EndPrompt prompt.Suggest = prompt.Suggest{
	Text:            "<cr>",
	Description:     "",
	DisableComplete: true,
}

EndPrompt end prompt

Functions

func Completer

func Completer(in prompt.Document) []prompt.Suggest

Completer 提示信息

func Executor

func Executor(commandLine string)

Executor 输入命令后,执行

func MergeSuggests

func MergeSuggests(destSuggests *[]prompt.Suggest, srcSuggests []prompt.Suggest)

MergeSuggests merge suggests

func Register

func Register(v *View, parent *View) (err error)

Register register view

func RegisterCommandParser

func RegisterCommandParser(name string, commandParser *parser.CommandParser, f ParseFunc) (err error)

RegisterCommandParser register commands to view

func RegisterGetContextListFunc

func RegisterGetContextListFunc(name string, getList GetViewContextListFunc) error

func RegisterShowViewCallback

func RegisterShowViewCallback(name string, callback ShowViewFunc) error

func SetCurrentView

func SetCurrentView(name string, text string, data interface{}) (err error)

SetCurrentView set view

func SetPrompt

func SetPrompt(p *prompt.Prompt)

SetPrompt 设置prompt

Types

type Context

type Context struct {
	Name  string
	Value interface{}
}

Context view context

type GetViewContextListFunc

type GetViewContextListFunc func() (ctxs []Context, err error)

type ParseFunc

type ParseFunc func(ctx Context, cmddefs []commands.CommandWordDef) error

ParseFunc parse func

type ShowViewFunc

type ShowViewFunc func(ctx Context) error

ShowFunc show this

type View

type View struct {
	Name              string
	DefaultViewText   string
	CommandLists      []commands.CommandList
	ParserProcs       []ParseFunc
	Ctx               Context
	Parent            *View
	Children          []*View
	GetContextList    GetViewContextListFunc
	ShowViewCallbacks []ShowViewFunc
}

View 系统视图

func GetCurrentView

func GetCurrentView() (v *View)

GetCurrentView 获取当前view视图

func GetView

func GetView(name string) (v *View)

GetView get view

func NewView

func NewView(name string, prompt string) (v *View)

NewView new view

func (*View) ExecCommnadLine

func (v *View) ExecCommnadLine(command string) (err error)

ExecCommnadLine 执行命令

func (*View) Exit

func (v *View) Exit()

Exit exit

func (*View) GetSuggests

func (v *View) GetSuggests(input string) (suggests []prompt.Suggest)

GetSuggests 获取当前视图的 suggest

func (*View) MatchElem

func (v *View) MatchElem(iterator *commands.CommandIterator, elem *commands.CommandWordDefElem) (match bool, defs []commands.CommandWordDef)

MatchElem match elem

func (*View) MatchGroup

func (v *View) MatchGroup(iterator *commands.CommandIterator, group *commands.CommandWordGroup) (match bool, defs []commands.CommandWordDef)

MatchGroup match group

func (*View) MatchNormalGroup

func (v *View) MatchNormalGroup(iterator *commands.CommandIterator, group *commands.CommandWordGroup) (match bool, defs []commands.CommandWordDef)

MatchNormalGroup match

func (*View) MatchWildGroup

func (v *View) MatchWildGroup(iterator *commands.CommandIterator, group *commands.CommandWordGroup) (match bool, defs []commands.CommandWordDef)

MatchWildGroup match

func (*View) RegisterCommandParser

func (v *View) RegisterCommandParser(commandParser *parser.CommandParser, f ParseFunc) (err error)

RegisterCommandParser 视图下的注册

Jump to

Keyboard shortcuts

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