Package protocols.apps.chat.ui
Class Console
java.lang.Object
protocols.apps.chat.ui.Console
A tiny mIRC-style terminal, built on JLine. The point of using JLine (rather
than plain
System.in/out) is the fixed input line: you
can keep typing at the bottom while incoming messages scroll in above, without
your half-typed line getting scrambled.
Two threads touch this:
- the reader thread (started by
start(java.util.function.Consumer<java.lang.String>, java.lang.Runnable)) blocks onLineReader.readLine()and hands each entered line to a callback; - any thread (typically Babel's protocol event loop) can call
printAbove(java.lang.String)to display a message — JLine redraws the prompt for us.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Console
- Throws:
IOException
-
-
Method Details
-
printAbove
Print a line above the input prompt (safe to call from any thread). -
start
Start the input loop on a daemon thread.onLineis called for every entered line;onQuitruns when the user hits Ctrl-C / Ctrl-D or the input stream ends. -
stop
public void stop()
-