Windows should always try for console first.

We had problems where if $TERM was set on a Windows console, we would
fail to allocate the screen because of missing termios.  This caused
lots of problems for many Windows users.  This should make this easier
for folks who might have set $TERM for other reasons, even in a Windows
console environment.

Eventually we will want to support emitting characters for 256 color
support, but that's later.
This commit is contained in:
Garrett D'Amore 2019-03-19 00:07:29 -07:00
parent f0cffc65c6
commit 2fca0432ba
1 changed files with 4 additions and 7 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2016 The TCell Authors
// Copyright 2019 The TCell Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use file except in compliance with the License.
@ -198,14 +198,11 @@ type Screen interface {
// NewScreen returns a default Screen suitable for the user's terminal
// environment.
func NewScreen() (Screen, error) {
// First we attempt to obtain a terminfo screen. This should work
// in most places if $TERM is set.
if s, e := NewTerminfoScreen(); s != nil {
// Windows is happier if we try for a console screen first.
if s, _ := NewConsoleScreen(); s != nil {
return s, nil
} else if s, _ := NewConsoleScreen(); s != nil {
} else if s, e := NewTerminfoScreen(); s != nil {
return s, nil
} else {
return nil, e
}