nsf / termbox-go

Pure Go termbox implementation
http://godoc.org/github.com/nsf/termbox-go
MIT License
4.66k stars 372 forks source link

device not configured #210

Closed Not-Nik closed 5 years ago

Not-Nik commented 5 years ago

When I try to execute this code:

package main

import (
    term "github.com/nsf/termbox-go"
)

func reset() {
    term.Sync()
}

func main() {
    err := term.Init()
    if err != nil {
        panic(err)
    }

    defer term.Close()
    for {
        ev := term.PollEvent()
        if ev.Type == term.EventKey {
            switch ev.Key {
            case term.KeyEsc:
                break
            }
        } else if ev.Type == term.EventError {
            panic(ev.Err)
        }
    }
}

I get this error

panic: open /dev/tty: device not configured

goroutine 1 [running]:
main.main()
    /Users/nikolas/Desktop/Go-Projects/Terminaltor/main.go:14 +0xe2

Process finished with exit code 2
rationull commented 5 years ago

What OS and shell/terminal are you running? I can't reproduce this on macOS with Terminal.app.

Also your example program won't terminate on Escape the way you probably intend it to :). The break will break out of the switch statement. You need a labeled break on the loop, or set a flag that terminates the loop.

Not-Nik commented 5 years ago

So, I'm on a Mac too (Mojave, MacBook Air 2013) but I've been running this via GoLand. When I execute it with the Terminal, I don't get this error and everything works fine(with your tip)... Strange...

rationull commented 5 years ago

Are you running it from a terminal in GoLang or directly from the IDE via a Run Configuration? If the latter then this seems logical since presumably there wouldn't be a terminal. In that case, I would say this is not an issue with termbox.

Not-Nik commented 5 years ago

Yeah, I was trying to run it via a Run Config. Thanks for your help.

rationull commented 5 years ago

It's too bad -- it would be great to be able to run a Run Config attached to an integrated terminal. Debugging would be much more convenient.

Looks like this is the JetBrains issue that tracks this feature request: https://youtrack.jetbrains.com/issue/IDEABKL-6701

It sounds like in PyCharm specifically there is maybe some support for this: https://youtrack.jetbrains.com/issue/PY-19938 but I'm not seeing anything for IntelliJ generally or for Go.