From 2fca0432ba2d854410ab0a63d7d6f3f9ce3a5e48 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 19 Mar 2019 00:07:29 -0700 Subject: [PATCH] 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. --- screen.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/screen.go b/screen.go index 9551af6..99816a0 100644 --- a/screen.go +++ b/screen.go @@ -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 }