Do not proceed if $TERM is invalid

Related #305
This commit is contained in:
Junegunn Choi
2015-07-28 14:35:46 +09:00
parent dce6fe6f2d
commit 02bd2d2adf
2 changed files with 10 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ package curses
import "C"
import (
"fmt"
"os"
"os/signal"
"syscall"
@@ -258,6 +259,10 @@ func Init(theme *ColorTheme, black bool, mouse bool) {
C.setlocale(C.LC_ALL, C.CString(""))
_screen = C.newterm(nil, C.stderr, C.stdin)
if _screen == nil {
fmt.Println("Invalid $TERM: " + os.Getenv("TERM"))
os.Exit(1)
}
C.set_term(_screen)
if mouse {
C.mousemask(C.ALL_MOUSE_EVENTS, nil)