마지막으로 알아 낸 내용은 ... 여기에 있습니다. 첫째,이 함수를 정의 :
private ConsoleReader console = ...;
private CursorBuffer stashed;
private void stashLine() {
this.stashed = this.console.getCursorBuffer().copy();
try {
this.console.getOutput().write("\u001b[1G\u001b[K");
this.console.flush();
} catch (IOException e) {
// ignore
}
}
private void unstashLine() {
try {
this.console.resetPromptLine(this.console.getPrompt(),
this.stashed.toString(), this.stashed.cursor);
} catch (IOException e) {
// ignore
}
}
을 그럼 당신은 출력 새로운 데이터로 할 때, 먼저 현재 콘솔 입력을 저장 stashLine()
를 호출 한 후 출력의 출력 어떤 새로운 라인을, 다음을 복원 할 unstashLine()
를 호출합니다.
라이브러리는 의도적으로 콘솔 입력을 처리하도록 설계되었습니다. 콘솔 출력을 처리하는 방법을 알지 못합니다. 문제는 콘솔 I/O 이벤트가 비동기 적이라는 것입니다 (사용자의 경우). 어쩌면 입력을 수행하는 동안 콘솔 출력을 임시 버퍼에 저장하고 입력이 완료되면 버퍼의 출력을 표시해야 할 수도 있습니다. –
Java http://sourceforge.net/projects/javacurses/, http://sourceforge.net/projects/enigma-shell/ 또는 http://www.javaworld.com/에 대한 Curses 라이브러리를 찾아야 할 수도 있습니다. 콘솔 입출력 커서의 위치를 바꿀 수있는 javaworld/javaqa/2002-12/02-qa-1220-console.html –