Gopher2600/debugger/ui/plainterminal.go
steve 8ddaec1233 o debugger
- scripts now pass through input loop, allowing commands that
    control the emulation (like RUN or STEP) to be effective
    - reworked ONSTEP and ONHALT commands
    - added STICK0 and STICK1 commands

o memory / pia
    - improved RAM debugging output
2020-01-05 18:58:32 +00:00

53 lines
1.1 KiB
Go

package ui
import (
"fmt"
"gopher2600/debugger/input"
"os"
)
// PlainTerminal is the default, most basic terminal interface
type PlainTerminal struct {
}
// Initialise perfoms any setting up required for the terminal
func (pt *PlainTerminal) Initialise() error {
return nil
}
// CleanUp perfoms any cleaning up required for the terminal
func (pt *PlainTerminal) CleanUp() {
}
// RegisterTabCompleter adds an implementation of TabCompleter to the terminal
func (pt *PlainTerminal) RegisterTabCompleter(tc *input.TabCompletion) {
}
// UserPrint is the plain terminal print routine
func (pt PlainTerminal) UserPrint(pp PrintProfile, s string, a ...interface{}) {
switch pp {
case Error:
s = fmt.Sprintf("* %s", s)
case Script:
s = fmt.Sprintf("> %s", s)
case Help:
s = fmt.Sprintf(" %s", s)
}
fmt.Printf(s, a...)
if pp != Prompt {
fmt.Println("")
}
}
// UserRead is the plain terminal read routine
func (pt PlainTerminal) UserRead(input []byte, prompt string, interruptChannel chan func()) (int, error) {
pt.UserPrint(Prompt, prompt)
n, err := os.Stdin.Read(input)
if err != nil {
return n, err
}
return n, nil
}