private static Database ReadDatabase(string term)
{
// This follows the same search order as prescribed by ncurses.
Database db;
// First try a location specified in the TERMINFO environment variable.
string terminfo = Environment.GetEnvironmentVariable("TERMINFO");
if (!string.IsNullOrWhiteSpace(terminfo) && (db = ReadDatabase(term, terminfo)) != null)
{
return db;
}
// Then try in the user's home directory.
string home = PersistedFiles.GetHomeDirectory();
if (!string.IsNullOrWhiteSpace(home) && (db = ReadDatabase(term, home + "/.terminfo")) != null)
{
return db;
}
// Then try a set of well-known locations.
foreach (string terminfoLocation in _terminfoLocations)
{
if ((db = ReadDatabase(term, terminfoLocation)) != null)
{
return db;
}
}
// Couldn't find one
return null;
}