Skip to content

Commit

Permalink
Simultaneous input and output example, #75
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Dec 21, 2016
1 parent 83db9a0 commit b14eb5e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/java/org/jline/example/Example.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

import org.jline.keymap.KeyMap;
import org.jline.reader.*;
Expand Down Expand Up @@ -63,6 +65,7 @@ public static void main(String[] args) throws IOException {
Character mask = null;
String trigger = null;
boolean color = false;
boolean timer = false;

TerminalBuilder builder = TerminalBuilder.builder();

Expand Down Expand Up @@ -97,6 +100,10 @@ public static void main(String[] args) throws IOException {
index++;
break;
*/
case "timer":
timer = true;
index++;
break;
case "-system":
builder.system(false);
index++;
Expand Down Expand Up @@ -188,6 +195,17 @@ public static void main(String[] args) throws IOException {
.parser(parser)
.build();

if (timer) {
Executors.newScheduledThreadPool(1)
.scheduleAtFixedRate(() -> {
reader.getTerminal().puts(Capability.carriage_return);
reader.getTerminal().writer().println("Hello world!");
reader.callWidget(LineReader.REDRAW_LINE);
reader.callWidget(LineReader.REDISPLAY);
reader.getTerminal().writer().flush();
}, 1, 1, TimeUnit.SECONDS);
}

while (true) {
String line = null;
try {
Expand Down

0 comments on commit b14eb5e

Please sign in to comment.