本文整理了Java中org.jline.terminal.Terminal.reader()
方法的一些代码示例,展示了Terminal.reader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Terminal.reader()
方法的具体详情如下:
包路径:org.jline.terminal.Terminal
类名称:Terminal
方法名:reader
[英]Retrieve the Reader
for this terminal. This is the standard way to read input from this terminal. The reader is non blocking.
[中]检索此终端的Reader
。这是从该终端读取输入的标准方式。读卡器是非阻塞的。
代码示例来源:origin: apache/flink
public CliView(CliClient client) {
this.client = client;
keyReader = new BindingReader(client.getTerminal().reader());
}
代码示例来源:origin: apache/karaf
@Override
public NonBlockingReader reader() {
return terminal.reader();
}
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core
@Override
public NonBlockingReader reader() {
return terminal.reader();
}
代码示例来源:origin: com.github.fonimus/ssh-shell-starter
@Override
public NonBlockingReader reader() {
return delegate().reader();
}
代码示例来源:origin: com.github.fonimus/spring-boot-ssh-shell-starter
@Override
public NonBlockingReader reader() {
return delegate().reader();
}
代码示例来源:origin: GoMint/GoMint
/**
* Close the jLine terminal when needed
*
* @throws IOException when closing failed
*/
public static void close() throws IOException {
if (terminal != null) {
terminal.reader().shutdown();
/*try {
terminal.close();
} finally {
terminal = null;
}*/
}
}
代码示例来源:origin: org.jline/jline-builtins
public Less(Terminal terminal) {
this.terminal = terminal;
this.display = new Display(terminal, true);
this.bindingReader = new BindingReader(terminal.reader());
}
代码示例来源:origin: julianhyde/sqlline
private int getUserAnswer(String question, int... allowedAnswers)
throws IOException {
final Set<Integer> allowedAnswerSet =
IntStream.of(allowedAnswers).boxed().collect(Collectors.toSet());
final Terminal terminal = sqlLine.getLineReader().getTerminal();
final PrintWriter writer = terminal.writer();
writer.write(question);
int c;
// The logic to prevent reaction of SqlLineParser here
do {
c = terminal.reader().read(100);
} while (c != -1 && !allowedAnswerSet.contains(c));
return c;
}
代码示例来源:origin: org.jline/jline
public Less(Terminal terminal) {
this.terminal = terminal;
this.display = new Display(terminal, true);
this.bindingReader = new BindingReader(terminal.reader());
}
代码示例来源:origin: org.jline/jline
public LineReaderImpl(Terminal terminal, String appName, Map<String, Object> variables) {
Objects.requireNonNull(terminal, "terminal can not be null");
this.terminal = terminal;
if (appName == null) {
appName = "JLine";
}
this.appName = appName;
if (variables != null) {
this.variables = variables;
} else {
this.variables = new HashMap<>();
}
this.keyMaps = defaultKeyMaps();
builtinWidgets = builtinWidgets();
widgets = new HashMap<>(builtinWidgets);
bindingReader = new BindingReader(terminal.reader());
}
代码示例来源:origin: org.jline/jline-builtins
public Nano(Terminal terminal, Path root) {
this.terminal = terminal;
this.root = root;
this.display = new Display(terminal, true);
this.bindingReader = new BindingReader(terminal.reader());
this.size = new Size();
bindKeys();
}
代码示例来源:origin: org.jline/jline
public Nano(Terminal terminal, Path root) {
this.terminal = terminal;
this.root = root;
this.display = new Display(terminal, true);
this.bindingReader = new BindingReader(terminal.reader());
this.size = new Size();
bindKeys();
}
代码示例来源: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
keyReader = new BindingReader(terminal.reader());
inputThread = new InputThread();
inputThread.start();
代码示例来源:origin: sqlline/sqlline
private void sillyLess(InputStream in) throws IOException {
BufferedReader breader =
new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
String man;
int index = 0;
while ((man = breader.readLine()) != null) {
index++;
sqlLine.output(man);
// silly little pager
if (index % (sqlLine.getOpts().getMaxHeight() - 1) == 0) {
String prompt = sqlLine.loc("enter-for-more");
sqlLine.getLineReader().getTerminal().writer().write(prompt);
int c;
// The logic to prevent reaction of SqlLineParser here
do {
c = sqlLine.getLineReader().getTerminal().reader().read(100);
} while (c != -1 && c != 13 && c != 'q');
if (c == -1 || c == 'q') {
sqlLine.getLineReader().getTerminal().writer().write('\n');
break;
}
}
}
breader.close();
}
代码示例来源:origin: org.jline/jline
private static int readExt(Terminal terminal) {
try {
// The coordinates are encoded in UTF-8, so if that's not the input encoding,
// we need to get around
int c;
if (terminal.encoding() != StandardCharsets.UTF_8) {
c = new InputStreamReader(terminal.input(), StandardCharsets.UTF_8).read();
} else {
c = terminal.reader().read();
}
if (c < 0) {
throw new EOFException();
}
return c;
} catch (IOException e) {
throw new IOError(e);
}
}
代码示例来源:origin: apache/felix
executorService.scheduleAtFixedRate(task, 0, interval, TimeUnit.SECONDS);
Attributes attr = terminal.enterRawMode();
terminal.reader().read();
terminal.setAttributes(attr);
} finally {
代码示例来源:origin: org.jline/jline
public TTop(Terminal terminal) {
this.terminal = terminal;
this.display = new Display(terminal, true);
this.bindingReader = new BindingReader(terminal.reader());
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator('.');
DecimalFormat perc = new DecimalFormat("0.00%", dfs);
register(STAT_TID, Right, "TID", o -> String.format("%3d", (Long) o));
register(STAT_NAME, Left, "NAME", padcut(40));
register(STAT_STATE, Left, "STATE", o -> o.toString().toLowerCase());
register(STAT_BLOCKED_TIME, Right, "T-BLOCKED", o -> millis((Long) o));
register(STAT_BLOCKED_COUNT, Right, "#-BLOCKED", Object::toString);
register(STAT_WAITED_TIME, Right, "T-WAITED", o -> millis((Long) o));
register(STAT_WAITED_COUNT, Right, "#-WAITED", Object::toString);
register(STAT_LOCK_NAME, Left, "LOCK-NAME", Object::toString);
register(STAT_LOCK_OWNER_ID, Right, "LOCK-OWNER-ID", id -> ((Long) id) >= 0 ? id.toString() : "");
register(STAT_LOCK_OWNER_NAME, Left, "LOCK-OWNER-NAME", name -> name != null ? name.toString() : "");
register(STAT_USER_TIME, Right, "T-USR", o -> nanos((Long) o));
register(STAT_CPU_TIME, Right, "T-CPU", o -> nanos((Long) o));
register(STAT_USER_TIME_PERC, Right, "%-USR", perc::format);
register(STAT_CPU_TIME_PERC, Right, "%-CPU", perc::format);
keys = new KeyMap<>();
bindKeys(keys);
}
代码示例来源:origin: org.jline/jline-builtins
public TTop(Terminal terminal) {
this.terminal = terminal;
this.display = new Display(terminal, true);
this.bindingReader = new BindingReader(terminal.reader());
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setDecimalSeparator('.');
DecimalFormat perc = new DecimalFormat("0.00%", dfs);
register(STAT_TID, Right, "TID", o -> String.format("%3d", (Long) o));
register(STAT_NAME, Left, "NAME", padcut(40));
register(STAT_STATE, Left, "STATE", o -> o.toString().toLowerCase());
register(STAT_BLOCKED_TIME, Right, "T-BLOCKED", o -> millis((Long) o));
register(STAT_BLOCKED_COUNT, Right, "#-BLOCKED", Object::toString);
register(STAT_WAITED_TIME, Right, "T-WAITED", o -> millis((Long) o));
register(STAT_WAITED_COUNT, Right, "#-WAITED", Object::toString);
register(STAT_LOCK_NAME, Left, "LOCK-NAME", Object::toString);
register(STAT_LOCK_OWNER_ID, Right, "LOCK-OWNER-ID", id -> ((Long) id) >= 0 ? id.toString() : "");
register(STAT_LOCK_OWNER_NAME, Left, "LOCK-OWNER-NAME", name -> name != null ? name.toString() : "");
register(STAT_USER_TIME, Right, "T-USR", o -> nanos((Long) o));
register(STAT_CPU_TIME, Right, "T-CPU", o -> nanos((Long) o));
register(STAT_USER_TIME_PERC, Right, "%-USR", perc::format);
register(STAT_CPU_TIME_PERC, Right, "%-CPU", perc::format);
keys = new KeyMap<>();
bindKeys(keys);
}
内容来源于网络,如有侵权,请联系作者删除!