Skip to content

Commit

Permalink
[mod] fallback to grayscale if 8 color initialization fails
Browse files Browse the repository at this point in the history
  • Loading branch information
asciimoo committed Mar 14, 2017
1 parent fa4c1e8 commit e6f5674
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions wuzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/jroimartin/gocui"
"github.com/mattn/go-runewidth"
"github.com/nsf/termbox-go"
)

const VERSION = "0.3.0"
Expand Down Expand Up @@ -1617,13 +1618,18 @@ func main() {
}
}
}
g, err := gocui.NewGui(gocui.Output256)
if err != nil {
g, err = gocui.NewGui(gocui.OutputNormal)
if err != nil {
log.Panicln(err)
var g *gocui.Gui
var err error
for _, outputMode := range []gocui.OutputMode{gocui.Output256, gocui.OutputNormal, gocui.OutputMode(termbox.OutputGrayscale)} {
g, err = gocui.NewGui(outputMode)
if err == nil {
break
}
}
if err != nil {
log.Panicln(err)
}

if runtime.GOOS == WINDOWS_OS && runewidth.IsEastAsian() {
g.ASCII = true
}
Expand Down

0 comments on commit e6f5674

Please sign in to comment.