menu

package
v0.0.0-...-e50c5d4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const PAGE_NUM = 10

Variables

This section is empty.

Functions

func BindKeyDown

func BindKeyDown(key string, callback func())

func BindKeysDown

func BindKeysDown(keys []string, callback func())

func KeyDownSendChan

func KeyDownSendChan(key rune) <-chan bool

KeyDownSendChan 返回一个chan,第一次按下key时发送到chan中,后续按下key时不发送

func MakeListInputFunc

func MakeListInputFunc(kv map[string]string, callBack func()) func()

MakeListInputFunc 创建一个输入列表的函数

func MakeUniListInputFunc

func MakeUniListInputFunc(kv uniKVMap, callBack func()) func()

MakeUniListInputFunc 创建一个通用输入列表的函数

func MakeUntilPressForFunc

func MakeUntilPressForFunc(f func()) func()

MakeUntilPressForFunc 创建一个按下esc才停止否则会一直循环调用的函数

func MakeUntilPressForShowFunc

func MakeUntilPressForShowFunc(printFunc func(), waitSecond int) func()

MakeUntilPressForShowFunc 返回一个每隔waitSecond刷新一次printFunc,收到endChan则停止的函数

func MakeUntilPressFunc

func MakeUntilPressFunc(f func(chan bool)) func()

MakeUntilPressFunc 创建一个按下一般都会返回的函数

func UniListFind

func UniListFind(kv uniKVSlice, nowSearch string) []int

func UniListFindNext

func UniListFindNext(kv uniKVSlice, nowSearch string, nowIndex int) int

func UniListFindPre

func UniListFindPre(kv uniKVSlice, nowSearch string, nowIndex int) int

func WaitKeyDown

func WaitKeyDown() rune

WaitKeyDown 阻塞式的等待按键按下

Types

type BindInfo

type BindInfo struct {
	/*
		类似于
		nodes:
		节点编号,节点名称,父节点,[子节点1,子节点2,子节点3]
		...
		root:
		节点编号
	*/
	LogicBindText string
	FuncBindList  []FuncBind
}

type BindJson

type BindJson struct {
	Nodes []struct {
		Id    int    `json:"id"`
		Name  string `json:"name"`
		Child []int  `json:"child"`
	} `json:"nodes"`
	Root int `json:"root"`
}

BindJson 用来确认菜单结构

{
    "nodes" : [
        {
            "id":0,
            "name" : "0号节点",
            "child" : [1,2,3]
        }
    ],
    "root" : 0
}

type FuncBind

type FuncBind struct {
	ID   int
	FUNC func()
}
type Menu struct {
	ID2Node map[int]MenuNode
	// contains filtered or unexported fields
}
func (m *Menu) Do()
func (m *Menu) Init(info BindInfo) bool
type MenuFuncNode interface {
	IsCallAble() bool
	Do()
	BindDo(func()) bool
}

MenuFuncNode 菜单功能节点

type MenuLogicNode interface {
	GetParent() MenuNode
	GetRoot() MenuNode
	GetAllChild() []MenuNode
	GetName() string
	GetID() int

	BindParent(parent MenuNode)
	BindChild(child MenuNode)
	BindRoot(root MenuNode)
	SetName(name string)
	SetID(ID int)
}

MenuLogicNode 菜单逻辑节点

type MenuNode interface {
	MenuFuncNode
	MenuLogicNode
}

MenuNode 菜单节点

type NormalMenuFuncNode

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

func (*NormalMenuFuncNode) BindDo

func (n *NormalMenuFuncNode) BindDo(f func()) bool

func (*NormalMenuFuncNode) Do

func (n *NormalMenuFuncNode) Do()

func (*NormalMenuFuncNode) IsCallAble

func (n *NormalMenuFuncNode) IsCallAble() bool

type NormalMenuLogicNode

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

func (*NormalMenuLogicNode) BindChild

func (n *NormalMenuLogicNode) BindChild(child MenuNode)

func (*NormalMenuLogicNode) BindParent

func (n *NormalMenuLogicNode) BindParent(parent MenuNode)

func (*NormalMenuLogicNode) BindRoot

func (n *NormalMenuLogicNode) BindRoot(root MenuNode)

func (*NormalMenuLogicNode) GetAllChild

func (n *NormalMenuLogicNode) GetAllChild() []MenuNode

func (*NormalMenuLogicNode) GetID

func (n *NormalMenuLogicNode) GetID() int

func (*NormalMenuLogicNode) GetName

func (n *NormalMenuLogicNode) GetName() string

func (*NormalMenuLogicNode) GetParent

func (n *NormalMenuLogicNode) GetParent() MenuNode

func (*NormalMenuLogicNode) GetRoot

func (n *NormalMenuLogicNode) GetRoot() MenuNode

func (*NormalMenuLogicNode) SetID

func (n *NormalMenuLogicNode) SetID(ID int)

func (*NormalMenuLogicNode) SetName

func (n *NormalMenuLogicNode) SetName(name string)

type NormalMenuNode

type NormalMenuNode struct {
	NormalMenuFuncNode
	NormalMenuLogicNode
}

type UnCallableMenuLogicNode

type UnCallableMenuLogicNode struct {
}

func (UnCallableMenuLogicNode) Do

func (receiver UnCallableMenuLogicNode) Do()

func (UnCallableMenuLogicNode) IsCallAble

func (receiver UnCallableMenuLogicNode) IsCallAble() bool

Jump to

Keyboard shortcuts

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