I have a simple, console-based application that has a command/repsonse interface that uses jline. My code looks like this:
<blockquote>
code:
<pre name="code" class="core">
import jline.*
ConsoleReader reader = new ConsoleReader();
String response1 = reader.readLine("enter first response").trim();
String response2 = reader.readLine("enter second response").trim();</pre>
</blockquote>
Pretty easy stuff. The problem is that I would like to be able to send a kill message to my script using the "CTRL+C" key combination. Jline "swallows" this virtual key, and doesn't act on it unless you tell it to do so.
I therefore threw together some
test code that does that:
<blockquote>
code:
<pre name="code" class="core">
ConsoleReader reader = new ConsoleReader();
char ctrlC = reader.readVirtualKey();
if (ctrlC == ConsoleOperations.CTRL_C) { System.exit(1); }</pre>
</blockquote>
The problem is that I don't know how to "merge" these two code snippets together. Has anyone done something like this before? If so, how did you do it?
Thanks in advance!