use of jline.console.ConsoleReader in project grails-core by grails.
the class GrailsConsole method resetCompleters.
public void resetCompleters() {
final ConsoleReader reader = getReader();
if (reader != null) {
Collection<Completer> completers = reader.getCompleters();
for (Completer completer : completers) {
reader.removeCompleter(completer);
}
// for some unknown reason / bug in JLine you have to iterate over twice to clear the completers (WTF)
completers = reader.getCompleters();
for (Completer completer : completers) {
reader.removeCompleter(completer);
}
}
}
use of jline.console.ConsoleReader in project MinecraftForge by MinecraftForge.
the class TerminalConsoleAppender method start.
@Override
public void start() {
// Initialize the reader if that hasn't happened yet
if (!initialized && reader == null) {
initialized = true;
if (ENABLE_JLINE) {
final boolean hasConsole = System.console() != null;
if (hasConsole) {
try {
AnsiConsole.systemInstall();
reader = new ConsoleReader();
reader.setExpandEvents(false);
} catch (Exception e) {
LOGGER.warn("Failed to initialize terminal. Falling back to default.", e);
}
}
if (reader == null) {
if (hasConsole || System.getProperty("java.class.path").contains("idea_rt.jar")) {
// Disable advanced jline features
TerminalFactory.configure(OFF);
TerminalFactory.reset();
try {
reader = new ConsoleReader();
reader.setExpandEvents(false);
} catch (Exception e) {
LOGGER.warn("Failed to initialize fallback terminal. Falling back to standard output console.", e);
}
} else {
LOGGER.warn("Disabling terminal, you're running in an unsupported environment.");
}
}
}
}
super.start();
}
use of jline.console.ConsoleReader in project MinecraftForge by MinecraftForge.
the class TerminalHandler method handleCommands.
public static boolean handleCommands(DedicatedServer server) {
final ConsoleReader reader = TerminalConsoleAppender.getReader();
if (reader != null) {
TerminalConsoleAppender.setFormatter(new ConsoleFormatter());
reader.addCompleter(new ConsoleCommandCompleter(server));
String line;
while (!server.isServerStopped() && server.isServerRunning()) {
try {
line = reader.readLine("> ");
if (line == null) {
break;
}
line = line.trim();
if (!line.isEmpty()) {
server.addPendingCommand(line, server);
}
} catch (IOException e) {
logger.error("Exception handling console input", e);
}
}
return true;
} else {
TerminalConsoleAppender.setFormatter(new Function<String, String>() {
@Override
public String apply(String text) {
return TextFormatting.getTextWithoutFormattingCodes(text);
}
});
return false;
}
}
use of jline.console.ConsoleReader in project es6draft by anba.
the class JLineConsole method newConsoleReader.
private static ConsoleReader newConsoleReader(String programName) throws IOException {
final boolean isWindows = isWindows();
final String type = System.getProperty(TerminalFactory.JLINE_TERMINAL);
if (isWindows && type == null) {
TerminalFactory.registerFlavor(TerminalFactory.Flavor.WINDOWS, UnsupportedTerminal.class);
} else if (isWindows && type.equalsIgnoreCase(TerminalFactory.UNIX)) {
TerminalFactory.registerFlavor(TerminalFactory.Flavor.UNIX, CygwinTerminal.class);
}
FileInputStream in = new FileInputStream(FileDescriptor.in);
Terminal terminal = TerminalFactory.get();
ConsoleReader consoleReader = new ConsoleReader(programName, in, System.out, terminal, getDefaultEncoding());
consoleReader.setExpandEvents(false);
return consoleReader;
}
use of jline.console.ConsoleReader in project geode by apache.
the class ScriptExecutionDetails method createConsoleReader.
@Override
protected ConsoleReader createConsoleReader() {
ConsoleReader consoleReader = super.createConsoleReader();
consoleReader.setHistory(gfshHistory);
terminal = consoleReader.getTerminal();
return consoleReader;
}
Aggregations