io.termd.core.term.TermInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of termd-core Show documentation
Show all versions of termd-core Show documentation
An open source terminal daemon library providing terminal handling in Java,
back ported to Alibaba by core engine team to support running on JDK 6+.
The newest version!
/*
* Copyright 2015 Julien Viet
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.termd.core.term;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.Map;
/**
* A term info database.
*
* @author Julien Viet
*/
public class TermInfo {
private static TermInfo loadDefault() {
try {
InputStream in = TermInfo.class.getResourceAsStream("terminfo.src");
TermInfoParser parser = new TermInfoParser(new InputStreamReader(in, "US-ASCII"));
TermInfoBuilder builder = new TermInfoBuilder();
parser.parseDatabase(builder);
return builder.build();
} catch (Throwable t) {
t.printStackTrace();
return null;
}
}
private static final TermInfo DEFAULT = loadDefault();
/**
* @return the default term info database loaded from the {@code terminfo.src} resource
*/
public static TermInfo defaultInfo() {
return DEFAULT;
}
final Map devices;
TermInfo(Map devices) {
this.devices = devices;
}
/**
* Return a particular known device given its name.
*
* @param name the device name
* @return the device or null
*/
public Device getDevice(String name) {
return devices.get(name);
}
/**
* @return the devices present in this term info database.
*/
public Collection devices() {
return devices.values();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy