本文整理了Java中org.jline.terminal.Terminal.handle()
方法的一些代码示例,展示了Terminal.handle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Terminal.handle()
方法的具体详情如下:
包路径:org.jline.terminal.Terminal
类名称:Terminal
方法名:handle
暂无
代码示例来源:origin: confluentinc/ksql
@Override
public void handle(
final Terminal.Signal signal,
final Terminal.SignalHandler signalHandler
) {
terminal.handle(signal, signalHandler);
}
代码示例来源:origin: confluentinc/ksql
private static Terminal buildTerminal() {
try {
final Terminal terminal = TerminalBuilder.builder().system(true).build();
// Ignore ^C when not reading a line
terminal.handle(Terminal.Signal.INT, Terminal.SignalHandler.SIG_IGN);
return terminal;
} catch (final IOException e) {
throw new RuntimeException("JLineTerminal failed to start!", e);
}
}
}
代码示例来源:origin: apache/flink
private Tuple2<Attributes, Map<Signal, SignalHandler>> prepareTerminal() {
final Terminal terminal = client.getTerminal();
final Attributes prevAttributes = terminal.getAttributes();
// adopted from org.jline.builtins.Nano
// see also https://en.wikibooks.org/wiki/Serial_Programming/termios#Basic_Configuration_of_a_Serial_Interface
// no line processing
// canonical mode off, echo off, echo newline off, extended input processing off
Attributes newAttr = new Attributes(prevAttributes);
newAttr.setLocalFlags(EnumSet.of(LocalFlag.ICANON, LocalFlag.ECHO, LocalFlag.IEXTEN), false);
// turn off input processing
newAttr.setInputFlags(EnumSet.of(Attributes.InputFlag.IXON, Attributes.InputFlag.ICRNL, Attributes.InputFlag.INLCR), false);
// one input byte is enough to return from read, inter-character timer off
newAttr.setControlChar(Attributes.ControlChar.VMIN, 1);
newAttr.setControlChar(Attributes.ControlChar.VTIME, 0);
newAttr.setControlChar(Attributes.ControlChar.VINTR, 0);
terminal.setAttributes(newAttr);
final Map<Signal, SignalHandler> prevSignals = new HashMap<>();
prevSignals.put(Signal.WINCH, terminal.handle(Signal.WINCH, this::handleSignal));
prevSignals.put(Signal.INT, terminal.handle(Signal.INT, this::handleSignal));
prevSignals.put(Signal.QUIT, terminal.handle(Signal.QUIT, this::handleSignal));
return Tuple2.of(prevAttributes, prevSignals);
}
代码示例来源:origin: apache/samza
private void restoreTerminal(TerminalStatus status) {
// Signal handlers
terminal.handle(Terminal.Signal.INT, status.handler_INT);
terminal.handle(Terminal.Signal.QUIT, status.handler_QUIT);
terminal.handle(Terminal.Signal.TSTP, status.handler_TSTP);
terminal.handle(Terminal.Signal.CONT, status.handler_CONT);
terminal.handle(Terminal.Signal.WINCH, status.handler_WINCH);
// Attributes
terminal.setAttributes(status.attributes);
// Capability
terminal.puts(InfoCmp.Capability.exit_ca_mode);
terminal.puts(InfoCmp.Capability.cursor_visible);
}
代码示例来源:origin: apache/karaf
public JLineTerminal(org.jline.terminal.Terminal terminal) {
this.terminal = terminal;
for (Signal signal : Signal.values()) {
terminal.handle(signal, this::handle);
handlers.put(signal, SignalHandler.SIG_DFL);
}
}
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core
public JLineTerminal(org.jline.terminal.Terminal terminal) {
this.terminal = terminal;
for (Signal signal : Signal.values()) {
terminal.handle(signal, this::handle);
handlers.put(signal, SignalHandler.SIG_DFL);
}
}
代码示例来源:origin: com.github.fonimus/ssh-shell-starter
@Override
public SignalHandler handle(Signal signal, SignalHandler signalHandler) {
return delegate().handle(signal, signalHandler);
}
代码示例来源:origin: com.github.fonimus/spring-boot-ssh-shell-starter
@Override
public SignalHandler handle(Signal signal, SignalHandler signalHandler) {
return delegate().handle(signal, signalHandler);
}
代码示例来源:origin: apache/karaf
@Override
public Object execute() throws Exception {
if (arguments == null || arguments.length() == 0) {
System.err.println("Argument expected");
} else {
WatchTask watchTask = new WatchTask();
executorService.scheduleAtFixedRate(watchTask, 0, interval, TimeUnit.SECONDS);
try {
Terminal terminal = (Terminal) session.get(".jline.terminal");
Terminal.SignalHandler prev = terminal.handle(Terminal.Signal.INT, this::abort);
Attributes attr = terminal.enterRawMode();
try {
reading = Thread.currentThread();
while (terminal.reader().read(1) == NonBlockingReader.READ_EXPIRED);
} finally {
reading = null;
terminal.setAttributes(attr);
terminal.handle(Terminal.Signal.INT, prev);
}
} catch (InterruptedIOException e) {
// Ignore
} finally {
abort = true;
executorService.shutdownNow();
}
}
return null;
}
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.commands
@Override
public Object execute() throws Exception {
if (arguments == null || arguments.length() == 0) {
System.err.println("Argument expected");
} else {
WatchTask watchTask = new WatchTask();
executorService.scheduleAtFixedRate(watchTask, 0, interval, TimeUnit.SECONDS);
try {
Terminal terminal = (Terminal) session.get(".jline.terminal");
Terminal.SignalHandler prev = terminal.handle(Terminal.Signal.INT, this::abort);
Attributes attr = terminal.enterRawMode();
try {
reading = Thread.currentThread();
while (terminal.reader().read(1) == NonBlockingReader.READ_EXPIRED);
} finally {
reading = null;
terminal.setAttributes(attr);
terminal.handle(Terminal.Signal.INT, prev);
}
} catch (InterruptedIOException e) {
// Ignore
} finally {
abort = true;
executorService.shutdownNow();
}
}
return null;
}
代码示例来源:origin: apache/samza
prevStatus.handler_INT = terminal.handle(Terminal.Signal.INT, this::handleSignal);
prevStatus.handler_QUIT = terminal.handle(Terminal.Signal.QUIT, this::handleSignal);
prevStatus.handler_TSTP = terminal.handle(Terminal.Signal.TSTP, this::handleSignal);
prevStatus.handler_CONT = terminal.handle(Terminal.Signal.CONT, this::handleSignal);
prevStatus.handler_WINCH = terminal.handle(Terminal.Signal.WINCH, this::handleSignal);
代码示例来源:origin: org.jline/jline-builtins
public void run() throws IOException {
SignalHandler prevWinchHandler = terminal.handle(Signal.WINCH, this::resize);
SignalHandler prevIntHandler = terminal.handle(Signal.INT, this::interrupt);
SignalHandler prevSuspHandler = terminal.handle(Signal.TSTP, this::suspend);
Attributes attributes = terminal.enterRawMode();
terminal.puts(Capability.enter_ca_mode);
terminal.flush();
terminal.setAttributes(attributes);
terminal.handle(Signal.WINCH, prevWinchHandler);
terminal.handle(Signal.INT, prevIntHandler);
terminal.handle(Signal.TSTP, prevSuspHandler);
代码示例来源:origin: org.jline/jline
public void run() throws IOException {
SignalHandler prevWinchHandler = terminal.handle(Signal.WINCH, this::resize);
SignalHandler prevIntHandler = terminal.handle(Signal.INT, this::interrupt);
SignalHandler prevSuspHandler = terminal.handle(Signal.TSTP, this::suspend);
Attributes attributes = terminal.enterRawMode();
terminal.puts(Capability.enter_ca_mode);
terminal.flush();
terminal.setAttributes(attributes);
terminal.handle(Signal.WINCH, prevWinchHandler);
terminal.handle(Signal.INT, prevIntHandler);
terminal.handle(Signal.TSTP, prevSuspHandler);
代码示例来源:origin: org.jline/jline-builtins
Terminal.SignalHandler prevHandler = terminal.handle(Terminal.Signal.WINCH, this::handle);
Attributes attr = terminal.enterRawMode();
try {
terminal.setAttributes(attr);
if (prevHandler != null) {
terminal.handle(Terminal.Signal.WINCH, prevHandler);
代码示例来源:origin: org.jline/jline
Terminal.SignalHandler prevHandler = terminal.handle(Terminal.Signal.WINCH, this::handle);
Attributes attr = terminal.enterRawMode();
try {
terminal.setAttributes(attr);
if (prevHandler != null) {
terminal.handle(Terminal.Signal.WINCH, prevHandler);
代码示例来源:origin: batfish/batfish
_reader
.getTerminal()
.handle(org.jline.terminal.Terminal.Signal.INT, signal -> handleSigInt());
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core
jlineTerminal.handle(Signal.TSTP, s -> {
Job current = session.foregroundJob();
if (current != null) {
jlineTerminal.handle(Signal.INT, s -> {
Job current = session.foregroundJob();
if (current != null) {
代码示例来源:origin: apache/karaf
jlineTerminal.handle(Signal.TSTP, s -> {
Job current = session.foregroundJob();
if (current != null) {
jlineTerminal.handle(Signal.INT, s -> {
Job current = session.foregroundJob();
if (current != null) {
代码示例来源:origin: apache/felix
SignalHandler intHandler = terminal.handle(Signal.INT, s -> {
Job current = session.foregroundJob();
if (current != null) {
SignalHandler suspHandler = terminal.handle(Signal.TSTP, s -> {
Job current = session.foregroundJob();
if (current != null) {
terminal.handle(Signal.INT, intHandler);
terminal.handle(Signal.TSTP, suspHandler);
代码示例来源:origin: org.jline/jline
display.reset();
display.resize(size.getRows(), size.getColumns());
prevHandler = terminal.handle(Signal.WINCH, this::handle);
terminal.flush();
terminal.setAttributes(attributes);
terminal.handle(Signal.WINCH, prevHandler);
内容来源于网络,如有侵权,请联系作者删除!