57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package d2interface
|
|
|
|
import (
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2input"
|
|
)
|
|
|
|
// TermCategory applies styles to the lines in the Terminal
|
|
type TermCategory int
|
|
|
|
const (
|
|
TermCategoryNone TermCategory = iota
|
|
TermCategoryInfo
|
|
TermCategoryWarning
|
|
TermCategoryError
|
|
)
|
|
|
|
// TermVis is an enumeration of the Terminal's visibility states
|
|
type termVis int
|
|
|
|
// Terminal visibility state
|
|
const (
|
|
termVisHidden termVis = iota
|
|
termVisShowing
|
|
termVisShown
|
|
termVisHiding
|
|
)
|
|
|
|
// Terminal is a drop-down terminal and shell
|
|
// It is used throughout the codebase, most parts of the engine will
|
|
// `bind` commands, which are available for use in the shell
|
|
type Terminal interface {
|
|
BindLogger()
|
|
|
|
Advance(elapsed float64) error
|
|
OnKeyDown(event d2input.KeyEvent) bool
|
|
OnKeyChars(event d2input.KeyCharsEvent) bool
|
|
Render(surface Surface) error
|
|
Execute(command string) error
|
|
OutputRaw(text string, category TermCategory)
|
|
Output(format string, params ...interface{})
|
|
OutputInfo(format string, params ...interface{})
|
|
OutputWarning(format string, params ...interface{})
|
|
OutputError(format string, params ...interface{})
|
|
OutputClear()
|
|
IsVisible() bool
|
|
Hide()
|
|
Show()
|
|
BindAction(name, description string, action interface{}) error
|
|
UnbindAction(name string) error
|
|
}
|
|
|
|
// TerminalLogger is used tomake the Terminal write out
|
|
// (eg. to the system shell or to a file)
|
|
type TerminalLogger interface {
|
|
Write(p []byte) (int, error)
|
|
}
|