macro

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

macro syntax is that 1. starts with TokenSeparator, 2. "e" after TokenSeparator such as "\e" skips any wait() command. 3. "n[number]" after TokenSeparator such as "\n100" represents inputting number 100.

Thus, valid macro "\e\n100" means 1. skip any wait until input required, 2. then input number 100.

Index

Constants

View Source
const (
	// represents token separator. e.g. "\Token1\Token2"
	TokenSeparator = `\`

	// represents skip any wait().
	TokenSkipWait = "e"

	// represents input number e.g. "n100" means 100.
	TokenNumberPrefix = "n"
)

Variables

View Source
var ErrorEmptyToken = errors.New("empry token")

error Token is empty

View Source
var ErrorNotMacro = errors.New("command is not macro")

the error indicates that command is not macro.

Functions

func LoadDefault

func LoadDefault(file string) error

Types

type Macro

type Macro struct {
	Tokens []Token
}

Macro is command sequence. Each command is represented as token.

var (
	// empty macro has tokens are zero length.
	EmptyMacro *Macro = &Macro{make([]Token, 0)}
)

func OneSkip

func OneSkip() *Macro

return new macro that has one skip token.

func Parse

func Parse(command string) (*Macro, error)

parse command as Macro and return it. it also retrun error parsed correctly? Macro is nil if error occured.

type Set

type Set []*Macro

Set is set of some Macros.

var DefaultSet Set = make([]*Macro, 0)

Default macro set

func (Set) Get

func (s Set) Get(no int) (*Macro, bool)

get deep copy of macro from macro Set.

type Token

type Token struct {
	Command string
	Type    TokenType
}

Token is a unit of macro.

type TokenType

type TokenType int8

represents type of token

const (
	TokenTypeNone TokenType = iota
	TokenTypeSkipWait
	TokenTypeNumber
)

Jump to

Keyboard shortcuts

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