本文整理汇总了Java中org.jline.terminal.TerminalBuilder类的典型用法代码示例。如果您正苦于以下问题:Java TerminalBuilder类的具体用法?Java TerminalBuilder怎么用?Java TerminalBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TerminalBuilder类属于org.jline.terminal包,在下文中一共展示了TerminalBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
private void execute(Ssh.ExecuteParams params) {
log.info("Execute received {}", params);
try {
Terminal terminal = TerminalBuilder.builder()
.streams(params.getIn(), params.getOut())
.build();
String[] args = params.getCommand().split(" ");
getContext().getCommandManager().runCommand(args[0],
new CommandContext(getContext(), terminal),
args);
terminal.flush();
}
catch (IOException e) {
log.error("Unable to execute command", e);
}
}
示例2: GraphflowCli
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
/**
* Constructs a CLI client that connects to the Graphflow server at the provided {@code
* host:port}.
*
* @param grpcHost The gRPC server hostname.
* @param grpcPort The gRPC server port.
*/
GraphflowCli(String grpcHost, int grpcPort) throws IOException {
super(grpcHost, grpcPort);
Logger.getLogger("org.jline").setLevel(Level.OFF);
File historyFile = new File(HISTORY_FLE);
LineReaderBuilder lineReaderBuilder = LineReaderBuilder.builder().terminal(
TerminalBuilder.builder().build());
try {
if (!historyFile.exists()) {
historyFile.createNewFile();
}
if (historyFile.canWrite()) {
isHistoryEnabled = true;
lineReaderBuilder = lineReaderBuilder.variable(LineReader.HISTORY_FILE,
historyFile).history(new DefaultHistory());
}
} catch (IOException e) {
// Ignore
}
lineReader = lineReaderBuilder.build();
}
示例3: open
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
@Override
public void open() {
parser = createParser();
try {
terminal = (terminalBuilder != null ? terminalBuilder : TerminalBuilder.builder()).build();
} catch (IOException e) {
throw SpongeUtils.wrapException(e);
}
LineReaderBuilder lineReaderBuilder = LineReaderBuilder.builder().appName(VersionInfo.PRODUCT).terminal(terminal).parser(parser);
if (completer != null) {
lineReaderBuilder.completer(completer);
}
reader = lineReaderBuilder.build();
}
示例4: lineReader
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
private static LineReader lineReader(Parser parser) {
try {
return LineReaderBuilder.builder().terminal(TerminalBuilder.terminal()).parser(parser).build();
} catch (IOException e) {
throw new RuntimeException(e.getMessage(), e);
}
}
示例5: Shell
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public Shell() throws IOException {
commandPrefix = ":";
prompt = "> ";
Terminal terminal = TerminalBuilder.builder()
.build();
reader = LineReaderBuilder.builder()
.terminal(terminal)
.build();
logger.trace("create interpreter");
interpreter = new NaiveInterpreter();
// need to have a global ast builder, otherwise the symbol table is lost
logger.trace("create ast builder");
astBuilder = new ReikaAstBuilder(false);
}
示例6: provideTerminal
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
@Provides
@Singleton
static Terminal provideTerminal() {
try {
return TerminalBuilder.terminal();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例7: processInputs
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public void processInputs(InputStream is, OutputStream os, String terminalType) {
try (Terminal terminal = TerminalBuilder.builder().system(false).type(terminalType).streams(is, os).build()) {
LineReader reader = LineReaderBuilder.builder().terminal(terminal).completer(completer).build();
createDefaultSessionContext(reader, terminal);
ConsoleIO.writeOutput(SUPPORTED_COMMANDS_MESSAGE);
processUserInput(reader);
} catch (IOException ex) {
log.error("Error building terminal instance", ex);
}
}
示例8: newTerminal
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
/**
* Creates a new terminal.
*
* @return new terminal
*/
static Terminal newTerminal() {
try {
return TerminalBuilder.builder()
.dumb(true)
.build();
} catch (IOException e) {
throw illegalStateWithCauseOf(e);
}
}
示例9: main
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public static void main(String[] args) {
try (Terminal term = TerminalBuilder.builder().type("unix").name("Java FileSystem").build()) {
System.out.println("Welcome to the Java Cloud FileSystem Provider CLI");
new Cli(term).run();
System.out.println("Goodbye!");
} catch (IOException e) {
throw new RuntimeException("Cannot build terminal", e);
}
}
示例10: JLineTerminal
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public JLineTerminal(OutputFormat outputFormat, KsqlRestClient restClient) {
super(outputFormat, restClient);
try {
terminal = TerminalBuilder.builder().system(true).build();
} catch (IOException e) {
throw new RuntimeException("JLineTerminal failed to start!", e);
}
// Ignore ^C when not reading a line
terminal.handle(org.jline.terminal.Terminal.Signal.INT, org.jline.terminal.Terminal.SignalHandler.SIG_IGN);
}
示例11: InternalJlineManager
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
private InternalJlineManager() throws Exception
{
Logger.getLogger( "org.jline" ).setLevel( Level.ALL );
terminal = TerminalBuilder.builder().dumb( true ).build();
lineReader = LineReaderBuilder.builder()
.terminal( terminal ).appName( "Kvantum" ).build();
}
示例12: setTerminalBuilder
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public void setTerminalBuilder(TerminalBuilder terminalBuilder) {
this.terminalBuilder = terminalBuilder;
}
示例13: getTerminalBuilder
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public TerminalBuilder getTerminalBuilder() {
return terminalBuilder;
}
示例14: testInteractive
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
@Test
public void testInteractive() throws Exception {
PipedInputStream in = new PipedInputStream();
try (PipedOutputStream pipedOutputStream = new PipedOutputStream(in)) {
outIn = pipedOutputStream;
ByteArrayOutputStream out = new ByteArrayOutputStream();
engine = StandaloneEngine.builder().commandLineArgs("-k", "examples/standalone/interactive.py", "-i")
.interactiveModeConsoleSupplier(() -> {
JLineInteractiveModeConsole console = new JLineInteractiveModeConsole();
console.setTerminalBuilder(TerminalBuilder.builder().streams(in, out));
return console;
}).build();
SpongeUtils.executeConcurrentlyOnce(engine, () -> {
engine.startup();
engine.getInteractiveMode().loop();
});
await().atMost(10, TimeUnit.SECONDS)
.until(() -> engine != null && engine.isRunning() && engine.getInteractiveMode().isRunning());
// Print the message.
write("print 'Starting interactive mode tests.'");
// Send the alarm.
write("EPS.event(\"alarm\").send()");
await().atMost(10, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "alarms").intValue() >= 1);
// Create trigger and send event.
writeMulti("class T(Trigger):\\");
writeMulti(" def onConfigure(self):\\");
writeMulti(" self.event = \"notification\"\\");
writeMulti(" def onRun(self, event):\\");
writeMulti(" EPS.getVariable(\"notifications\").incrementAndGet()\\");
writeMulti(" print \"Received the notification!\"");
write("");
write("EPS.enable(T)");
write("EPS.event(\"notification\").send()");
await().atMost(10, TimeUnit.SECONDS)
.until(() -> engine.getOperations().getVariable(Number.class, "notifications").intValue() >= 1);
assertFalse(engine.isError());
} finally {
if (engine != null) {
engine.shutdown();
}
}
}
示例15: Debugger
import org.jline.terminal.TerminalBuilder; //导入依赖的package包/类
public Debugger() throws IOException {
this.ticksStats = new TicksStats();
this.traceBuffer = new TraceBuffer(64);
this.log = new ArrayList<>();
this.levels = new EnumMap<>(Component.class);
for (Component c : Component.values()) {
levels.put(c, Level.Info);
}
levels.put(Component.Memory, Level.Warning);
state = State.Running;
this.terminal = TerminalBuilder.terminal();
this.views = new ArrayList<>();
this.views.add(new Overview(this));
this.views.add(new CPUView(this));
breakpoints = new Breakpoints(this);
this.views.add(breakpoints);
this.views.add(new VIPView(this));
this.views.add(new VSUView(this));
this.views.add(new MemoryView(this));
this.views.add(new OthersView(this));
this.views.add(new Logs(log, terminal, levels));
this.size = new Size();
size.copy(terminal.getSize());
if (size.getRows() == 0) {
throw new RuntimeException("0-row term");
}
if (size.getColumns() == 0) {
Integer columns = terminal.getNumericCapability(InfoCmp.Capability.columns);
if (columns != null) {
size.setColumns(columns);
}
}
this.display = new Display(terminal, true);
originalAttributes = terminal.enterRawMode();
prevWinchHandler = terminal.handle(Terminal.Signal.WINCH, this::resize);
terminal.puts(InfoCmp.Capability.enter_ca_mode);
terminal.puts(InfoCmp.Capability.keypad_xmit);
display.clear();
display.reset();
display.resize(size.getRows(), size.getColumns());
bindingReader = new BindingReader(terminal.reader());
keyMap = initKeyMap();
inputThread = new InputThread();
inputThread.start();
}