Improve non-stdin case

This commit is contained in:
Ivan Izaguirre 2019-04-14 13:06:35 +02:00
parent 1247d58912
commit 5e718cdbe2
2 changed files with 9 additions and 6 deletions

View File

@ -22,11 +22,13 @@ type ansiConsoleFrontend struct {
keyChannel chan uint8
extraLineFeeds chan int
textUpdated bool
stdinKeyboard bool
}
func newAnsiConsoleFrontend(a *Apple2) *ansiConsoleFrontend {
func newAnsiConsoleFrontend(a *Apple2, stdinKeyboard bool) *ansiConsoleFrontend {
var fe ansiConsoleFrontend
fe.apple2 = a
fe.stdinKeyboard = stdinKeyboard
fe.subscribeToTextPages()
return &fe
}
@ -121,8 +123,9 @@ func (fe *ansiConsoleFrontend) textModeGoRoutine() {
}
fmt.Println(strings.Repeat("#", 44))
fmt.Print("\033[KLine: ")
if fe.stdinKeyboard {
fmt.Print("\033[KLine: ")
}
}
time.Sleep(refreshDelayMs * time.Millisecond)
}

View File

@ -44,10 +44,10 @@ func (a *Apple2) AddDisk2(diskRomFile string, diskImage string) {
}
// Run starts the Apple2 emulation
func (a *Apple2) Run(log bool, consoleKeyboard bool) {
func (a *Apple2) Run(log bool, stdinKeyboard bool) {
// Init frontend
fe := newAnsiConsoleFrontend(a)
if consoleKeyboard {
fe := newAnsiConsoleFrontend(a, stdinKeyboard)
if stdinKeyboard {
a.io.setKeyboardProvider(fe)
}
if !log {