Documentation ¶
Index ¶
- Constants
- Variables
- func Remove(nodes ...Node)
- func Render()
- func Select(node Node)
- func Start(fy uint16, keyBordEvent bool)
- type Canvas
- type CanvasAttr
- type CanvasPosition
- type CanvasPositionType
- type CanvasStyle
- type CanvasVolume
- type Event
- type EventCallBack
- type Key
- type Node
- type NodeStack
- type PaintingTree
- type Quadrilateral
- func (ql *Quadrilateral) AddEventListener(event uint8, callback EventCallBack) error
- func (ql *Quadrilateral) DeleteEventListener(event uint8, callback EventCallBack) error
- func (ql *Quadrilateral) GetAttr() (CanvasAttr, error)
- func (ql *Quadrilateral) GetChildren() ([]Node, error)
- func (ql *Quadrilateral) GetKeyBord() (keyboard.KeyEvent, error)
- func (ql *Quadrilateral) GetParent() (Node, error)
- func (ql *Quadrilateral) GetPosition() (CanvasPosition, error)
- func (ql *Quadrilateral) GetProps() (map[string]string, error)
- func (ql *Quadrilateral) GetStyle() (CanvasStyle, error)
- func (ql *Quadrilateral) GetVolume() (CanvasVolume, error)
- func (ql *Quadrilateral) Insert(node ...Node) error
- func (ql *Quadrilateral) Remove() error
- func (ql *Quadrilateral) RemoveChildren(node Node) error
- func (ql *Quadrilateral) SetPosition(position CanvasPosition, pType ...CanvasPositionType) error
- func (ql *Quadrilateral) SetProps(key, value string) error
- func (ql *Quadrilateral) SetStyle(style CanvasStyle) error
- func (ql *Quadrilateral) SetText(text string) error
- func (ql *Quadrilateral) SetVolume(volume CanvasVolume) error
- type RenderZIndexTree
Constants ¶
const ( Auto int = math.MaxInt //Display declaration run program adaptive SizeReLoadFrequency uint16 = 10 //Frequency of window query, in ms BodyName = "body" //The Name of the top-level node is fixed, but the node whose Name is body may have more than body. When getting body, it is recommended to use the global variable instead of the GetNodeByName function QuadrilateralTag = "quadrilateral" //Tag of different types of nodes. Here, the tag is a quadrangle ZIndexRenderType uint8 = 0 //Different types of renderers, which can get Node through the hierarchy PackageName = "TMLRenderer" //Package name, usually used for information printing RenderLazy = time.Microsecond //Asynchronous wait time )
Universal constant
const ( None uint8 = 0 //This style is usually not valid ContinuousLine uint8 = 1 //Continuous line DottedLine uint8 = 2 //Dashed line PositionX uint8 = 1 //Used for x centering in Position PositionY uint8 = 2 //Used for y centering in Position PositionXY uint8 = 3 //Used for x and y centering in Position PositionRightX uint8 = 4 //x aligned to the right PositionRightY uint8 = 5 //y aligned to the bottom PositionRightXY uint8 = 6 //xy aligned to the bottom right )
style correlation constant
const ( OperatingEmptyNodeError = "you are trying to operate a node that has been unmounted node" DeleteTopLeveNodeError = "you are trying to delete a top-level node, which is not allowed to be destroyed" WrongCursorMovementDirectionError = "incorrect cursor movement. Please check the writing specification" RenderUninitializedNodeError = "trying to render an uninitialized node" GetWindowSizeError = "an attempt to get the window size failed, causing the framework to fail: " ParentNodeNil = "The parent node is nil, and setting the parent node to nil may cause the cursor to reset" )
Error information constant
const ( BlackColor = "\033[30m" //Black color RedColor = "\033[31m" //Red color GreenColor = "\033[32m" //Green color YellowColor = "\033[33m" //Yellow color BlueColor = "\033[34m" //Blue color PurpleColor = "\033[35m" //Purple color CyanColor = "\033[36m" //Cyan color WhiteColor = "\033[37m" //White color BlackBackGroundColor = "\033[40m" //Black background color RedBackGroundColor = "\033[41m" //Red background color GreenBackGroundColor = "\033[42m" //Green background color YellowBackGroundColor = "\033[43m" //Yellow background color BlueBackGroundColor = "\033[44m" //Blue background color PurpleBackGroundColor = "\033[45m" //Purple background color CyanBackGroundColor = "\033[46m" //Cyan background color WhiteBackGroundColor = "\033[47m" //White background color )
VT100 exclusive
const ( OnMove uint8 = 0 OnSizeChange uint8 = 1 OnShow uint8 = 2 OnHidden uint8 = 3 OnInput uint8 = 4 OnRemove uint8 = 5 OnSelect uint8 = 6 OnKeyBord uint8 = 7 )
Event specific constant
const ( KeyF1 keyboard.Key = 0xFFFF - iota KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyInsert KeyDelete KeyHome KeyEnd KeyPgup KeyPgdn KeyArrowUp KeyArrowDown KeyArrowLeft KeyArrowRight )
Keycode
const ( KeyCtrlTilde keyboard.Key = 0x00 KeyCtrl2 keyboard.Key = 0x00 KeyCtrlSpace keyboard.Key = 0x00 KeyCtrlA keyboard.Key = 0x01 KeyCtrlB keyboard.Key = 0x02 KeyCtrlC keyboard.Key = 0x03 KeyCtrlD keyboard.Key = 0x04 KeyCtrlE keyboard.Key = 0x05 KeyCtrlF keyboard.Key = 0x06 KeyCtrlG keyboard.Key = 0x07 KeyBackspace keyboard.Key = 0x08 KeyCtrlH keyboard.Key = 0x08 KeyTab keyboard.Key = 0x09 KeyCtrlI keyboard.Key = 0x09 KeyCtrlJ keyboard.Key = 0x0A KeyCtrlK keyboard.Key = 0x0B KeyCtrlL keyboard.Key = 0x0C KeyEnter keyboard.Key = 0x0D KeyCtrlM keyboard.Key = 0x0D KeyCtrlN keyboard.Key = 0x0E KeyCtrlO keyboard.Key = 0x0F KeyCtrlP keyboard.Key = 0x10 KeyCtrlQ keyboard.Key = 0x11 KeyCtrlR keyboard.Key = 0x12 KeyCtrlS keyboard.Key = 0x13 KeyCtrlT keyboard.Key = 0x14 KeyCtrlU keyboard.Key = 0x15 KeyCtrlV keyboard.Key = 0x16 KeyCtrlW keyboard.Key = 0x17 KeyCtrlX keyboard.Key = 0x18 KeyCtrlY keyboard.Key = 0x19 KeyCtrlZ keyboard.Key = 0x1A KeyEsc keyboard.Key = 0x1B KeyCtrlLsqBracket keyboard.Key = 0x1B KeyCtrl3 keyboard.Key = 0x1B KeyCtrl4 keyboard.Key = 0x1C KeyCtrlBackslash keyboard.Key = 0x1C KeyCtrl5 keyboard.Key = 0x1D KeyCtrlRsqBracket keyboard.Key = 0x1D KeyCtrl6 keyboard.Key = 0x1E KeyCtrl7 keyboard.Key = 0x1F KeyCtrlSlash keyboard.Key = 0x1F KeyCtrlUnderscore keyboard.Key = 0x1F KeySpace keyboard.Key = 0x20 KeyBackspace2 keyboard.Key = 0x7F KeyCtrl8 keyboard.Key = 0x7F )
Variables ¶
var ( SysWidth int = 0 //Global width SysHeight int = 0 //Global altitude Body Node = nil //Root node DefaultStyle = CanvasStyle{ Display: true, BorderType: None, AutoSize: false, ShowText: true, Color: WhiteColor, BackGroundColor: BlackBackGroundColor, } SelectNode Node = nil //The currently selected node )
Universal variable
Functions ¶
func Select ¶
func Select(node Node)
Select Select a node to be used as the output node to listen for onKeyBord events. This node must listen for OnKeyBord events. Otherwise, the node automatically rolls back until the parent node has a listener or Body @parma node Selected node
func Start ¶
Start initializes the service, using the framework's mandatory function, which does most of the initialization @parma autoFlash: Whether to automatically render, and the relatively timely response to the window during automatic rendering fy: rendering frequency and window size acquisition frequency, the base unit is ms keyBordEvent: whether to enable key event listening
Types ¶
type CanvasAttr ¶
type CanvasAttr struct { Name string //Node name Tag string //Node type Key string //Node unique identifier }
CanvasAttr some key information of Canvas
type CanvasPosition ¶
type CanvasPosition struct { X int //x-axis position Y int //y-axis position Type CanvasPositionType //different position types, such as center display ZIndex uint32 //weight, the higher the display priority, the higher the weight canvas will cover the lower weight (only valid at the same level) // contains filtered or unexported fields }
CanvasPosition canvas position information, as well as its weight
type CanvasPositionType ¶
CanvasPositionType the type represented by position
type CanvasStyle ¶
type CanvasStyle struct { Display bool //whether to display, not delete AutoSize bool //adaptive size, its size inherits from the parent element, and will be overwritten by valid values when volume's width\height is not equal to 0 BorderType uint8 //whether to display border, and BorderColor string //border color Color string //text color BackGroundColor string //background color ShowText bool //whether to display text }
CanvasStyle describes the style
type CanvasVolume ¶
CanvasVolume describes the volume parameters of canvas
type Event ¶
type Event = map[uint8][]EventCallBack
type EventCallBack ¶
EventCallBack callback function type
type Node ¶
type Node interface { Insert(node ...Node) error //insert elements into the current node SetVolume(volume CanvasVolume) error //set the volume by the Volume field SetPosition(position CanvasPosition, pType ...CanvasPositionType) error //set the Position field related properties SetStyle(style CanvasStyle) error //set the Style related properties GetVolume() (CanvasVolume, error) //return the current node's related volume GetPosition() (CanvasPosition, error) //get the Position field related information GetStyle() (CanvasStyle, error) //get the style GetProps() (map[string]string, error) //get the Props SetProps(key, value string) error //set the Props custom field GetKeyBord() (keyboard.KeyEvent, error) //try to get the keyboard event value of the current node (only accurate when obtained in the event) AddEventListener(event uint8, callback EventCallBack) error //add event listener DeleteEventListener(event uint8, callback EventCallBack) error //delete event listener GetAttr() (CanvasAttr, error) //get the Attr field related information RemoveChildren(node Node) error //delete a child node GetParent() (Node, error) //get the parent node GetChildren() ([]Node, error) //get all child nodes Remove() error //self-delete SetText(text string) error //set text // contains filtered or unexported methods }
Node the common interface that elements need to implement
func CreateQuadrilateral ¶
CreateQuadrilateral Creates a quadrilateral Canvas @parma Name: Creates the name of the quadrilateral to mark the node, but does not force uniqueness @return creates a node that will be loaded into each global repository before it returns
type NodeStack ¶
type NodeStack []Node
func GetNodeByName ¶
GetNodeByName Tries to get a Node by Name @parma Name: node.Name @return The obtained node stack and the obtained result
type PaintingTree ¶
type PaintingTree interface { GetNode() (Node, bool) // Get the next node Init(NodeStack) // initialize }
PaintingTree 绘画树的接口
type Quadrilateral ¶
type Quadrilateral struct { Canvas //inherited struct keyboard.KeyEvent //store the data generated by key bord events // contains filtered or unexported fields }
Quadrilateral a square Canvas
func (*Quadrilateral) AddEventListener ¶
func (ql *Quadrilateral) AddEventListener(event uint8, callback EventCallBack) error
func (*Quadrilateral) DeleteEventListener ¶
func (ql *Quadrilateral) DeleteEventListener(event uint8, callback EventCallBack) error
func (*Quadrilateral) GetAttr ¶
func (ql *Quadrilateral) GetAttr() (CanvasAttr, error)
func (*Quadrilateral) GetChildren ¶
func (ql *Quadrilateral) GetChildren() ([]Node, error)
func (*Quadrilateral) GetKeyBord ¶
func (ql *Quadrilateral) GetKeyBord() (keyboard.KeyEvent, error)
func (*Quadrilateral) GetParent ¶
func (ql *Quadrilateral) GetParent() (Node, error)
func (*Quadrilateral) GetPosition ¶
func (ql *Quadrilateral) GetPosition() (CanvasPosition, error)
func (*Quadrilateral) GetStyle ¶
func (ql *Quadrilateral) GetStyle() (CanvasStyle, error)
func (*Quadrilateral) GetVolume ¶
func (ql *Quadrilateral) GetVolume() (CanvasVolume, error)
func (*Quadrilateral) Insert ¶
func (ql *Quadrilateral) Insert(node ...Node) error
func (*Quadrilateral) Remove ¶
func (ql *Quadrilateral) Remove() error
func (*Quadrilateral) RemoveChildren ¶
func (ql *Quadrilateral) RemoveChildren(node Node) error
func (*Quadrilateral) SetPosition ¶
func (ql *Quadrilateral) SetPosition(position CanvasPosition, pType ...CanvasPositionType) error
func (*Quadrilateral) SetProps ¶
func (ql *Quadrilateral) SetProps(key, value string) error
func (*Quadrilateral) SetStyle ¶
func (ql *Quadrilateral) SetStyle(style CanvasStyle) error
func (*Quadrilateral) SetText ¶
func (ql *Quadrilateral) SetText(text string) error
func (*Quadrilateral) SetVolume ¶
func (ql *Quadrilateral) SetVolume(volume CanvasVolume) error
type RenderZIndexTree ¶
type RenderZIndexTree struct {
// contains filtered or unexported fields
}
RenderZIndexTree A hierarchy tree generated from the RenderStack
func (*RenderZIndexTree) GetNode ¶
func (rt *RenderZIndexTree) GetNode() (Node, bool)
GetNode Gets the next node
func (*RenderZIndexTree) Init ¶
func (rt *RenderZIndexTree) Init(nodes NodeStack)