Documentation
¶
Index ¶
- Constants
- func Interval(dur time.Duration, call func() error)
- func Run(prog string, args ...string) ([]byte, error)
- func RunRealtime(prog string, args ...string) error
- func ScreenPrintf(ms MenuScreen, format string, args ...interface{})
- func ScreenPrintln(ms MenuScreen, line string)
- type Error
- type KeyCalibration
- type KeycodeBinding
- type KeycodeListener
- type Menu
- type MenuConfig
- type MenuEngine
- func (me *MenuEngine) Action()
- func (me *MenuEngine) AddMenu(menuID string, menu *MenuItemList)
- func (me *MenuEngine) BindKeys()
- func (me *MenuEngine) Calibrate(keyCalibrationFile string) error
- func (me *MenuEngine) ChangeMenu(menuID string)
- func (me *MenuEngine) ClearMenus()
- func (me *MenuEngine) DisplayText(txt string)
- func (me *MenuEngine) ErrorText(err, extra string)
- func (me *MenuEngine) Explorer(workingDir, bin string)
- func (me *MenuEngine) GetRender() *MenuFrame
- func (me *MenuEngine) Home()
- func (me *MenuEngine) Hook(id string, hook func(me *MenuEngine))
- func (me *MenuEngine) LoadMenu(id string, itemList *MenuItemList)
- func (me *MenuEngine) Lock()
- func (me *MenuEngine) NextItem()
- func (me *MenuEngine) PrevItem()
- func (me *MenuEngine) PrevMenu()
- func (me *MenuEngine) Redraw()
- func (me *MenuEngine) RemoveMenu(menuID string)
- func (me *MenuEngine) ResetHistory()
- func (me *MenuEngine) Run(command string)
- func (me *MenuEngine) RunRealtime(command string)
- func (me *MenuEngine) SetScreen(screen MenuScreen)
- func (me *MenuEngine) Unlock()
- func (me *MenuEngine) Vars(in string) string
- type MenuFrame
- type MenuItem
- type MenuItemList
- type MenuKeycodeBinding
- type MenuScreen
Constants ¶
const (
ERR_CANCELLED = Error("calibrator: cancelled")
)
Variables ¶
This section is empty.
Functions ¶
func RunRealtime ¶
func ScreenPrintf ¶
func ScreenPrintf(ms MenuScreen, format string, args ...interface{})
func ScreenPrintln ¶
func ScreenPrintln(ms MenuScreen, line string)
Types ¶
type KeyCalibration ¶
type KeyCalibration struct {
Ready bool
Cancel bool
Action string
KLs []*KeycodeListener
}
type KeycodeBinding ¶
type KeycodeBinding struct {
Handler func() //The binding handler function that will be called when this binding activates
Keycode uint16 //The Linux-designated keycode for this binding
OnRelease bool //If this binding should activate when the button is released instead of when pressed
}
KeycodeBinding holds a binding between a Linux keycode and a bare Go handler
type KeycodeListener ¶
type KeycodeListener struct {
RootBind func(keyboard string, keycode uint16, onRelease bool) //Fallback if no other bindings match an event
Bindings []*KeycodeBinding
Keyboard string
KeyLogger *keylogger.KeyLogger
// contains filtered or unexported fields
}
KeycodeListener holds a Linux keycode listener
func NewKeycodeListener ¶
func NewKeycodeListener(keyboard string) (*KeycodeListener, error)
NewKeycodeListener returns a new keycode listener
func (*KeycodeListener) Bind ¶
func (kl *KeycodeListener) Bind(keycode uint16, onRelease bool, handler func())
Bind binds a keycode to a handler, bind nil to remove all bindings to the keycode
func (*KeycodeListener) Close ¶
func (kl *KeycodeListener) Close()
Close closes the keycode listener
func (*KeycodeListener) RemoveBind ¶
func (kl *KeycodeListener) RemoveBind(keycode uint16)
RemoveBind removes all bindings to a keycode
func (*KeycodeListener) Run ¶
func (kl *KeycodeListener) Run()
Run starts the keycode listener and blocks until it's closed
type Menu ¶
type Menu struct {
Config *MenuConfig
Engine *MenuEngine
Screen *MenuScreen
Keysrv []*KeycodeListener
}
func (*Menu) SetScreen ¶
func (m *Menu) SetScreen(screen MenuScreen)
type MenuConfig ¶
type MenuConfig struct {
Environment map[string]string `json:"environment"`
Keybinds []*MenuKeycodeBinding `json:"keybinds"`
HomeMenu string `json:"home"`
Menus map[string]*MenuItemList `json:"menus"`
}
type MenuEngine ¶
type MenuEngine struct {
//Menu navigation
Menus map[string]*MenuItemList
HomeMenu string
LoadedMenu string
MenuHistory []string
ItemHistory []int
Environment map[string]string //global variables set by menus
ItemCursor int
Locked bool
Return string //return value set by some menu types
Hooks map[string]func(me *MenuEngine) //run a hook after changing to a menu
//Rendering control
Screen MenuScreen
LinesV, LinesH int
}
MenuEngine holds a list of menus and acts as the menu interface
func NewMenuEngine ¶
func NewMenuEngine() *MenuEngine
NewMenuEngine returns a menu engine ready to be used
func (*MenuEngine) Action ¶
func (me *MenuEngine) Action()
Action activates the selected item's action, such as navigating to a menu or executing a program
func (*MenuEngine) AddMenu ¶
func (me *MenuEngine) AddMenu(menuID string, menu *MenuItemList)
AddMenu adds a menu to the menu list
func (*MenuEngine) BindKeys ¶
func (me *MenuEngine) BindKeys()
func (*MenuEngine) Calibrate ¶
func (me *MenuEngine) Calibrate(keyCalibrationFile string) error
func (*MenuEngine) ChangeMenu ¶
func (me *MenuEngine) ChangeMenu(menuID string)
ChangeMenu changes to another available menu
func (*MenuEngine) ClearMenus ¶
func (me *MenuEngine) ClearMenus()
ClearMenus clears the total menu list
func (*MenuEngine) DisplayText ¶
func (me *MenuEngine) DisplayText(txt string)
DisplayText generates a text message menu with menuID "INTERNAL_DISPLAY_TEXT" and navigates to it It is used internally as well as being made available, so refrain from using menuIDs starting with "INTERNAL"
func (*MenuEngine) ErrorText ¶
func (me *MenuEngine) ErrorText(err, extra string)
ErrorText generates an error message menu with menuID "INTERNAL_ERROR_TEXT" and navigates to it It is used internally as well as being made available, so refrain from using menuIDs starting with "INTERNAL"
func (*MenuEngine) Explorer ¶
func (me *MenuEngine) Explorer(workingDir, bin string)
Explorer abuses the powers of AddMenu, ChangeMenu, and PrevMenu to create a file browser with support for passing a selected file to an executable
func (*MenuEngine) GetRender ¶
func (me *MenuEngine) GetRender() *MenuFrame
GetRender returns a rendered menu text to be displayed immediately, as the menu state can change freely before and after
func (*MenuEngine) Hook ¶
func (me *MenuEngine) Hook(id string, hook func(me *MenuEngine))
func (*MenuEngine) LoadMenu ¶
func (me *MenuEngine) LoadMenu(id string, itemList *MenuItemList)
func (*MenuEngine) Lock ¶
func (me *MenuEngine) Lock()
func (*MenuEngine) NextItem ¶
func (me *MenuEngine) NextItem()
NextItem navigates to the next menu item, or to the first if none next
func (*MenuEngine) PrevItem ¶
func (me *MenuEngine) PrevItem()
PrevItem navigates to the previous menu item, or to the last if none previous
func (*MenuEngine) PrevMenu ¶
func (me *MenuEngine) PrevMenu()
PrevMenu returns to the last menu in history
func (*MenuEngine) Redraw ¶
func (me *MenuEngine) Redraw()
func (*MenuEngine) RemoveMenu ¶
func (me *MenuEngine) RemoveMenu(menuID string)
RemoveMenu removes a menu from the menu list
func (*MenuEngine) ResetHistory ¶
func (me *MenuEngine) ResetHistory()
ResetHistory clears the linked item and menu histories, and resets the cursor to item 0
func (*MenuEngine) Run ¶
func (me *MenuEngine) Run(command string)
Run runs the given command, but halts the menu engine until completion
func (*MenuEngine) RunRealtime ¶
func (me *MenuEngine) RunRealtime(command string)
RunRealtime runs the given command, but doesn't halt the menu engine
func (*MenuEngine) SetScreen ¶
func (me *MenuEngine) SetScreen(screen MenuScreen)
func (*MenuEngine) Unlock ¶
func (me *MenuEngine) Unlock()
func (*MenuEngine) Vars ¶
func (me *MenuEngine) Vars(in string) string
Vars returns a string formatted with all vars replaced, in order from longest var name to shortest to avoid partial var name replacements
type MenuFrame ¶
type MenuFrame struct {
}
func (*MenuFrame) Vars ¶
func (mf *MenuFrame) Vars(me *MenuEngine) *MenuFrame
type MenuItem ¶
type MenuItem struct {
Text string `json:"text"`
Desc string `json:"desc"`
Type string `json:"type"` //menu, exec, explorer[:pwd], note, var name
Action string `json:"action"` //var: string[:limit]|number[:min[:max]]|file[:extension1[,extension2,...]]|bool|opts:opt1,opt2,[opt3,...]
}
MenuItem holds an item for a menu, such as a button, a checkbox, or an input box
type MenuItemList ¶
type MenuItemList struct {
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Items []*MenuItem `json:"items"` //items to display on the page
NoGoBack bool `json:"noGoBack"` //hides the go back button
NoSelector bool `json:"noSelector"` //hides the item cursor
DefaultCur int `json:"defaultCur"` //the cursor to set by default
Exec string `json:"exec"` //a line interpreted as an exec action
}
MenuItemList holds a list of items to interact with
func (*MenuItemList) AddItem ¶
func (m *MenuItemList) AddItem(name, desc, itemType, action string)
type MenuKeycodeBinding ¶
type MenuScreen ¶
type MenuScreen interface {
//Offloading for rendering the menu string, locks the menu until method returns
Render(*MenuFrame)
GetFrame() *MenuFrame //Returns the cached menu frame
Clear()
//Monospaced terminal screen size
GetWidth() int
GetHeight() int
}
MenuScreen is a wrapper for a screen manager, which could theoretically wrap multiple screens...