Moved back to realtime update model.
* Using patched version of Jansi. * Raw ANSI controls always sent to play well with Nailgun.
This commit is contained in:
parent
f78cd57ec7
commit
e4a756baf5
Binary file not shown.
Binary file not shown.
BIN
lib/compile/jar/jdb-util-1.11.2.jar
Normal file
BIN
lib/compile/jar/jdb-util-1.11.2.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/runtime/jar/jdb-util-1.11.2.jar
Normal file
BIN
lib/runtime/jar/jdb-util-1.11.2.jar
Normal file
Binary file not shown.
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
#Thu, 08 Aug 2013 19:52:35 -0500
|
#Thu, 08 Aug 2013 23:12:38 -0500
|
||||||
lib.local=true
|
lib.local=true
|
||||||
name=timestamper-cli
|
name=timestamper-cli
|
||||||
version=0.1
|
version=0.2
|
||||||
build.number=29
|
build.number=13
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.jdblabs.timestamper.cli
|
package com.jdblabs.timestamper.cli
|
||||||
|
|
||||||
|
import com.jdbernard.io.NonBlockingInputStreamReader
|
||||||
import com.jdbernard.util.SmartConfig
|
import com.jdbernard.util.SmartConfig
|
||||||
import com.jdbernard.util.LightOptionParser
|
import com.jdbernard.util.LightOptionParser
|
||||||
import com.jdblabs.timestamper.core.Timeline
|
import com.jdblabs.timestamper.core.Timeline
|
||||||
@ -43,7 +44,7 @@ public class TimeStamperCLI {
|
|||||||
protected static doMain(TimeStamperCLI inst, String[] args,
|
protected static doMain(TimeStamperCLI inst, String[] args,
|
||||||
def sin, def out, def err) {
|
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)
|
def opts = LightOptionParser.parseOptions(cli, args as List)
|
||||||
|
|
||||||
File workingDir = new File(opts.d ?: '.')
|
File workingDir = new File(opts.d ?: '.')
|
||||||
@ -84,52 +85,60 @@ public class TimeStamperCLI {
|
|||||||
|
|
||||||
//out.println ""
|
//out.println ""
|
||||||
def currentMarker = timeline.getLastMarker(new Date())
|
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
|
boolean running = true
|
||||||
|
|
||||||
|
def blockingReadLine = {
|
||||||
|
String line = null;
|
||||||
|
while (line == null && readerThread.isAlive()) {
|
||||||
|
line = reader.readLine()
|
||||||
|
|
||||||
|
Thread.sleep(200) }
|
||||||
|
|
||||||
|
return line }
|
||||||
|
|
||||||
def readNotes = {
|
def readNotes = {
|
||||||
out.println(ansi().fg(YELLOW).
|
out.println(ansi().fg(YELLOW).
|
||||||
a("Notes (end with EOF or a blank line):").reset())
|
a("Notes (end with EOF or a blank line):").reset())
|
||||||
|
out.flush();
|
||||||
|
|
||||||
String notes = ""
|
String notes = ""
|
||||||
String line = null
|
String line = null
|
||||||
line = reader.readLine()
|
line = blockingReadLine()
|
||||||
|
|
||||||
while(line != "" && line != "EOF" && line != null) {
|
while(line != "" && line != "EOF" && line != null) {
|
||||||
notes += line + EOL
|
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
|
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()
|
line = reader.readLine()
|
||||||
|
if (line != null) {
|
||||||
|
out.flush();
|
||||||
switch (line) {
|
switch (line) {
|
||||||
|
|
||||||
case null:
|
|
||||||
case ~/quit|exit|\u0004/:
|
case ~/quit|exit|\u0004/:
|
||||||
running = false;
|
running = false;
|
||||||
break
|
break
|
||||||
|
|
||||||
case ~/r|refresh|^$/:
|
|
||||||
out.print(ansi().eraseLine().cursorUp(2).eraseLine())
|
|
||||||
break
|
|
||||||
|
|
||||||
case ~/n|new/:
|
case ~/n|new/:
|
||||||
|
|
||||||
// Read mark
|
// Read mark
|
||||||
out.println(ansi().fg(YELLOW).a("New timestamp:").reset())
|
out.println(ansi().fg(YELLOW).a("New timestamp:").reset())
|
||||||
String mark = reader.readLine()
|
String mark = blockingReadLine()
|
||||||
|
|
||||||
// Read notes
|
// Read notes
|
||||||
String notes = readNotes();
|
String notes = readNotes();
|
||||||
@ -142,13 +151,13 @@ public class TimeStamperCLI {
|
|||||||
break
|
break
|
||||||
|
|
||||||
case ~/h|help/:
|
case ~/h|help/:
|
||||||
out.println(ansi().eraseLine().
|
out.println(ansi().fg(RED).
|
||||||
fg(RED).a("Not yet implemented."));
|
a("Not yet implemented.").reset());
|
||||||
break
|
break
|
||||||
|
|
||||||
case ~/l|list|history/:
|
case ~/l|list|history/:
|
||||||
out.println(ansi().eraseLine().
|
out.println(ansi().fg(RED).
|
||||||
fg(RED).a("Not yet implemented."));
|
a("Not yet implemented.").reset());
|
||||||
break
|
break
|
||||||
|
|
||||||
case ~/s|save/:
|
case ~/s|save/:
|
||||||
@ -163,8 +172,23 @@ public class TimeStamperCLI {
|
|||||||
timelineProperties.save()
|
timelineProperties.save()
|
||||||
break
|
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) {
|
protected static String formatMarker(TimelineMarker tm) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user