本文整理了Java中org.jline.terminal.Terminal.getCursorPosition()
方法的一些代码示例,展示了Terminal.getCursorPosition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Terminal.getCursorPosition()
方法的具体详情如下:
包路径:org.jline.terminal.Terminal
类名称:Terminal
方法名:getCursorPosition
[英]Query the terminal to report the cursor position. As the response is read from the input stream, some characters may be read before the cursor position is actually read. Those characters can be given back using org.jline.keymap.BindingReader#runMacro(String)
[中]查询终端以报告光标位置。当从输入流读取响应时,可能会在实际读取光标位置之前读取一些字符。这些字符可以使用org.jline.keymap.BindingReader#runMacro(String)
返回
代码示例来源:origin: org.apache.karaf.shell/org.apache.karaf.shell.core
@Override
public Cursor getCursorPosition(IntConsumer discarded) {
return terminal.getCursorPosition(discarded);
}
代码示例来源:origin: apache/karaf
@Override
public Cursor getCursorPosition(IntConsumer discarded) {
return terminal.getCursorPosition(discarded);
}
代码示例来源:origin: com.github.fonimus/spring-boot-ssh-shell-starter
@Override
public Cursor getCursorPosition(IntConsumer intConsumer) {
return delegate().getCursorPosition(intConsumer);
}
代码示例来源:origin: com.github.fonimus/ssh-shell-starter
@Override
public Cursor getCursorPosition(IntConsumer intConsumer) {
return delegate().getCursorPosition(intConsumer);
}
代码示例来源:origin: org.jline/jline
public boolean mouse() {
MouseEvent event = readMouseEvent();
if (event.getType() == MouseEvent.Type.Released
&& event.getButton() == MouseEvent.Button.Button1) {
StringBuilder tsb = new StringBuilder();
Cursor cursor = terminal.getCursorPosition(c -> tsb.append((char) c));
bindingReader.runMacro(tsb.toString());
List<AttributedString> secondaryPrompts = new ArrayList<>();
getDisplayedBufferWithPrompts(secondaryPrompts);
AttributedStringBuilder sb = new AttributedStringBuilder().tabs(TAB_WIDTH);
sb.append(prompt);
sb.append(insertSecondaryPrompts(new AttributedString(buf.upToCursor()), secondaryPrompts, false));
List<AttributedString> promptLines = sb.columnSplitLength(size.getColumns(), false, display.delayLineWrap());
int currentLine = promptLines.size() - 1;
int wantedLine = Math.max(0, Math.min(currentLine + event.getY() - cursor.getY(), secondaryPrompts.size()));
int pl0 = currentLine == 0 ? prompt.columnLength() : secondaryPrompts.get(currentLine - 1).columnLength();
int pl1 = wantedLine == 0 ? prompt.columnLength() : secondaryPrompts.get(wantedLine - 1).columnLength();
int adjust = pl1 - pl0;
buf.moveXY(event.getX() - cursor.getX() - adjust, event.getY() - cursor.getY());
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!