diff --git a/notes b/notes index f17dc0788..7d36752e2 100644 --- a/notes +++ b/notes @@ -1,3 +1,9 @@ +Added: +1. prefix continuous compilation with run number +2. Added pomRepositoryFilter(repo: MavenRepository): Boolean that excludes local repositories by default +3. Added pomPostProcess(pom: Node): Node to make advanced manipulation of the default pom easier (pomExtra covers basic cases) +4. Added 'reset' command to reset JLine terminal. This needs to be run after suspending and then resuming sbt. + - script tasks (in 'scripts' branch). To use: 1) add implementation of jsr223 to project/build/lib, declare in project/plugins, or add to sbt startup classpath diff --git a/sbt/src/main/scala/sbt/LineReader.scala b/sbt/src/main/scala/sbt/LineReader.scala index 174a4ab23..23c5bde81 100644 --- a/sbt/src/main/scala/sbt/LineReader.scala +++ b/sbt/src/main/scala/sbt/LineReader.scala @@ -40,24 +40,32 @@ abstract class JLine extends LineReader private object JLine { def terminal = jline.Terminal.getTerminal - def createReader() = - terminal.synchronized + def resetTerminal() = withTerminal { _ => jline.Terminal.resetTerminal } + private def withTerminal[T](f: jline.Terminal => T): T = + synchronized { - val cr = new ConsoleReader - terminal.enableEcho() - cr.setBellEnabled(false) - cr + val t = terminal + t.synchronized { f(t) } + } + def createReader() = + withTerminal { t => + t.synchronized + { + val cr = new ConsoleReader + t.enableEcho() + cr.setBellEnabled(false) + cr + } } def withJLine[T](action: => T): T = - { - val t = terminal - t.synchronized - { - t.disableEcho() - try { action } - finally { t.enableEcho() } + withTerminal { t => + t.synchronized + { + t.disableEcho() + try { action } + finally { t.enableEcho() } + } } - } } object SimpleReader extends JLine { diff --git a/sbt/src/main/scala/sbt/Main.scala b/sbt/src/main/scala/sbt/Main.scala index ca094d6b2..7d26cf869 100755 --- a/sbt/src/main/scala/sbt/Main.scala +++ b/sbt/src/main/scala/sbt/Main.scala @@ -157,6 +157,7 @@ class xMain extends xsbti.AppMain arguments match { case "" :: tail => continue(project, tail, failAction) + case ResetCommand :: tail => JLine.resetTerminal(); continue(project, tail, failAction) case x :: tail if x.startsWith(";") => continue(project, x.split("""\s*;\s*""").toList ::: tail, failAction) case (ExitCommand | QuitCommand) :: _ => result( Exit(NormalExitCode) ) case RebootCommand :: tail => reload( tail ) @@ -366,7 +367,11 @@ class xMain extends xsbti.AppMain val ShowProjectsAction = "projects" val ExitCommand = "exit" val QuitCommand = "quit" + /** The name of the command that resets JLine. This is necessary when resuming from suspension.*/ + val ResetCommand = "reset" + /** The name of the command that switches to the builder project.*/ val BuilderCommand = "builder" + /** The name of the command that loads the interactive shell.*/ val InteractiveCommand = "shell" /** The list of lowercase command names that may be used to terminate the program.*/ val TerminateActions: Iterable[String] = ExitCommand :: QuitCommand :: Nil @@ -721,10 +726,12 @@ class xMain extends xsbti.AppMain val actionValid = checkAction(project, action) if(actionValid) { + var count = 0 SourceModificationWatch.watchUntil(project, ContinuousCompilePollDelaySeconds)(shouldTerminate) { + count += 1 handleAction(project, action) - Console.println("Waiting for source changes... (press enter to interrupt)") + Console.println(count + ". Waiting for source changes... (press enter to interrupt)") } while (System.in.available() > 0) System.in.read() }