mirror of https://github.com/gdamore/tcell.git
fixes #41 Fix GOPATH handling
This commit is contained in:
parent
c46d32264a
commit
02b78be6f2
|
@ -174,8 +174,8 @@ that are compiled into the program directly. This should minimize calling
|
||||||
out to database file searches.
|
out to database file searches.
|
||||||
|
|
||||||
The second is a JSON file, that contains the same information, which can
|
The second is a JSON file, that contains the same information, which can
|
||||||
be located either by the $TCELLDB environment file, or is located in the
|
be located either by the $TCELLDB environment file, $HOME/.tcelldb, or is
|
||||||
Go source directory.
|
located in the Go source directory as database.json.
|
||||||
|
|
||||||
These files (both the Go database.go and the database.json) file can be
|
These files (both the Go database.go and the database.json) file can be
|
||||||
generated using the mkinfo.go program. If you need to regnerate the
|
generated using the mkinfo.go program. If you need to regnerate the
|
||||||
|
|
29
terminfo.go
29
terminfo.go
|
@ -598,9 +598,8 @@ func loadFromFile(fname string, term string) (*Terminfo, error) {
|
||||||
// LookupTerminfo attemps to find a definition for the named $TERM.
|
// LookupTerminfo attemps to find a definition for the named $TERM.
|
||||||
// It first looks in the builtin database, which should cover just about
|
// It first looks in the builtin database, which should cover just about
|
||||||
// everyone. If it can't find one there, then it will attempt to read
|
// everyone. If it can't find one there, then it will attempt to read
|
||||||
// one from the JSON file located in either $TCELLDB, or in this package's
|
// one from the JSON file located in either $TCELLDB, $HOME/.tcelldb
|
||||||
// source directory. (XXX: Perhaps move that to $HOME/.tcelldb or somesuch
|
// or in this package's source directory as database.json).
|
||||||
// instead? What about somewhere in /etc?)
|
|
||||||
func LookupTerminfo(name string) (*Terminfo, error) {
|
func LookupTerminfo(name string) (*Terminfo, error) {
|
||||||
dblock.Lock()
|
dblock.Lock()
|
||||||
initDB()
|
initDB()
|
||||||
|
@ -609,16 +608,28 @@ func LookupTerminfo(name string) (*Terminfo, error) {
|
||||||
|
|
||||||
if t == nil {
|
if t == nil {
|
||||||
// Load the database located here. Its expected that TCELLSDB
|
// Load the database located here. Its expected that TCELLSDB
|
||||||
// points either to a single JSON file, or to a directory of
|
// points either to a single JSON file.
|
||||||
// of files all of which should be loaded.
|
|
||||||
if pth := os.Getenv("TCELLDB"); pth != "" {
|
if pth := os.Getenv("TCELLDB"); pth != "" {
|
||||||
t, _ = loadFromFile(pth, name)
|
t, _ = loadFromFile(pth, name)
|
||||||
} else {
|
}
|
||||||
pth = path.Join(os.Getenv("GOPATH"), "src",
|
if t == nil {
|
||||||
|
if pth := os.Getenv("HOME"); pth != "" {
|
||||||
|
fname := path.Join(pth, ".tcelldb")
|
||||||
|
t, _ = loadFromFile(fname, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if t == nil {
|
||||||
|
gopath := strings.Split(os.Getenv("GOPATH"),
|
||||||
|
string(os.PathListSeparator))
|
||||||
|
fname := path.Join("src",
|
||||||
"github.com", "gdamore", "tcell",
|
"github.com", "gdamore", "tcell",
|
||||||
"database.json")
|
"database.json")
|
||||||
t, _ = loadFromFile(pth, name)
|
for _, pth := range gopath {
|
||||||
|
t, _ = loadFromFile(path.Join(pth, fname), name)
|
||||||
|
if t != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if t != nil {
|
if t != nil {
|
||||||
dblock.Lock()
|
dblock.Lock()
|
||||||
|
|
Loading…
Reference in New Issue