diff --git a/lib/compile/jar/jansi-1.11.jar b/lib/compile/jar/jansi-1.12-SNAPSHOT.jar similarity index 74% rename from lib/compile/jar/jansi-1.11.jar rename to lib/compile/jar/jansi-1.12-SNAPSHOT.jar index 63284fd..63dce55 100644 Binary files a/lib/compile/jar/jansi-1.11.jar and b/lib/compile/jar/jansi-1.12-SNAPSHOT.jar differ diff --git a/lib/compile/jar/jdb-util-1.1.jar b/lib/compile/jar/jdb-util-1.1.jar deleted file mode 100644 index 94962af..0000000 Binary files a/lib/compile/jar/jdb-util-1.1.jar and /dev/null differ diff --git a/lib/compile/jar/jdb-util-1.11.2.jar b/lib/compile/jar/jdb-util-1.11.2.jar new file mode 100644 index 0000000..2ab56a1 Binary files /dev/null and b/lib/compile/jar/jdb-util-1.11.2.jar differ diff --git a/lib/compile/jar/jdb-util-1.8.2.jar b/lib/compile/jar/jdb-util-1.8.2.jar deleted file mode 100644 index 9164e7f..0000000 Binary files a/lib/compile/jar/jdb-util-1.8.2.jar and /dev/null differ diff --git a/lib/runtime/jar/jansi-1.11.jar b/lib/runtime/jar/jansi-1.12-SNAPSHOT.jar similarity index 74% rename from lib/runtime/jar/jansi-1.11.jar rename to lib/runtime/jar/jansi-1.12-SNAPSHOT.jar index 63284fd..63dce55 100644 Binary files a/lib/runtime/jar/jansi-1.11.jar and b/lib/runtime/jar/jansi-1.12-SNAPSHOT.jar differ diff --git a/lib/runtime/jar/jdb-util-1.1.jar b/lib/runtime/jar/jdb-util-1.1.jar deleted file mode 100644 index 94962af..0000000 Binary files a/lib/runtime/jar/jdb-util-1.1.jar and /dev/null differ diff --git a/lib/runtime/jar/jdb-util-1.11.2.jar b/lib/runtime/jar/jdb-util-1.11.2.jar new file mode 100644 index 0000000..2ab56a1 Binary files /dev/null and b/lib/runtime/jar/jdb-util-1.11.2.jar differ diff --git a/lib/runtime/jar/jdb-util-1.8.2.jar b/lib/runtime/jar/jdb-util-1.8.2.jar deleted file mode 100644 index 9164e7f..0000000 Binary files a/lib/runtime/jar/jdb-util-1.8.2.jar and /dev/null differ diff --git a/project.properties b/project.properties index f990fd0..5770013 100644 --- a/project.properties +++ b/project.properties @@ -1,5 +1,5 @@ -#Thu, 08 Aug 2013 19:52:35 -0500 +#Thu, 08 Aug 2013 23:12:38 -0500 lib.local=true name=timestamper-cli -version=0.1 -build.number=29 +version=0.2 +build.number=13 diff --git a/resources/main/logback.groovy b/resources/main/logback.groovy deleted file mode 100644 index e69de29..0000000 diff --git a/src/main/com/jdblabs/timestamper/cli/TimeStamperCLI.groovy b/src/main/com/jdblabs/timestamper/cli/TimeStamperCLI.groovy index 0629c1d..3ed1ffa 100644 --- a/src/main/com/jdblabs/timestamper/cli/TimeStamperCLI.groovy +++ b/src/main/com/jdblabs/timestamper/cli/TimeStamperCLI.groovy @@ -1,5 +1,6 @@ package com.jdblabs.timestamper.cli +import com.jdbernard.io.NonBlockingInputStreamReader import com.jdbernard.util.SmartConfig import com.jdbernard.util.LightOptionParser import com.jdblabs.timestamper.core.Timeline @@ -43,7 +44,7 @@ public class TimeStamperCLI { protected static doMain(TimeStamperCLI inst, String[] args, def sin, def out, def err) { - out = new PrintStream(AnsiConsole.wrapOutputStream(out)) + //out = new PrintStream(AnsiConsole.wrapOutputStream(out)) def opts = LightOptionParser.parseOptions(cli, args as List) File workingDir = new File(opts.d ?: '.') @@ -84,87 +85,110 @@ public class TimeStamperCLI { //out.println "" def currentMarker = timeline.getLastMarker(new Date()) - Reader reader = new InputStreamReader(sin) + def reader = new NonBlockingInputStreamReader(sin) + Thread readerThread = new Thread(reader) + readerThread.start() boolean running = true + def blockingReadLine = { + String line = null; + while (line == null && readerThread.isAlive()) { + line = reader.readLine() + + Thread.sleep(200) } + + return line } + def readNotes = { out.println(ansi().fg(YELLOW). a("Notes (end with EOF or a blank line):").reset()) + out.flush(); String notes = "" String line = null - line = reader.readLine() + line = blockingReadLine() while(line != "" && line != "EOF" && line != null) { notes += line + EOL - line = reader.readLine() } + line = blockingReadLine() } - return notes - } + return notes } + + def printPrompt = { + out.print(formatMarker(currentMarker) + EOL + + ansi().fg(YELLOW).a("> ").reset()) + out.flush() } String line = null - while (running) { + printPrompt() + while (running && readerThread.isAlive()) { - out.println formatMarker(currentMarker) - out.print(ansi().fg(YELLOW).a("> ").reset()) - out.flush(); - - // Handle user input + // Handle user input line = reader.readLine() - - switch (line) { + if (line != null) { + out.flush(); + switch (line) { + case ~/quit|exit|\u0004/: + running = false; + break - case null: - case ~/quit|exit|\u0004/: - running = false; - break + case ~/n|new/: - case ~/r|refresh|^$/: - out.print(ansi().eraseLine().cursorUp(2).eraseLine()) - break + // Read mark + out.println(ansi().fg(YELLOW).a("New timestamp:").reset()) + String mark = blockingReadLine() - case ~/n|new/: + // Read notes + String notes = readNotes(); - // Read mark - out.println(ansi().fg(YELLOW).a("New timestamp:").reset()) - String mark = reader.readLine() + // Create marker + currentMarker = new TimelineMarker(new Date(), mark, notes) + timeline.addMarker(currentMarker) + if (timelineProperties.persistOnUpdate) + timelineProperties.save() + break - // Read notes - String notes = readNotes(); + case ~/h|help/: + out.println(ansi().fg(RED). + a("Not yet implemented.").reset()); + break - // Create marker - currentMarker = new TimelineMarker(new Date(), mark, notes) - timeline.addMarker(currentMarker) - if (timelineProperties.persistOnUpdate) + case ~/l|list|history/: + out.println(ansi().fg(RED). + a("Not yet implemented.").reset()); + break + + case ~/s|save/: timelineProperties.save() - break + break - case ~/h|help/: - out.println(ansi().eraseLine(). - fg(RED).a("Not yet implemented.")); - break - - case ~/l|list|history/: - out.println(ansi().eraseLine(). - fg(RED).a("Not yet implemented.")); - break - - case ~/s|save/: - timelineProperties.save() - break - - default: - String notes = readNotes() - currentMarker = new TimelineMarker(new Date(), line, notes) - timeline.addMarker(currentMarker) - if (timelineProperties.persistOnUpdate) - timelineProperties.save() - break + default: + String notes = readNotes() + currentMarker = new TimelineMarker(new Date(), line, notes) + timeline.addMarker(currentMarker) + if (timelineProperties.persistOnUpdate) + timelineProperties.save() + break + } + printPrompt() + } else { + out.print(ansi().saveCursorPosition().cursorUpLine().eraseLine().toString() + + formatMarker(currentMarker) + + ansi().cursorDown(1).restorCursorPosition().toString()) + out.flush(); + + Thread.sleep(200) } } + if (readerThread.isAlive()) { + readerThread.interrupt(); + readerThread.join(500); + if (readerThread.isAlive()) readerThread.stop(); } + + out.println "" } protected static String formatMarker(TimelineMarker tm) {