blob: 2fe436fd2f283b7fdd6b0a3ae0395255ba2e6a56 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/* NSC -- new Scala compiler
* Copyright 2005-2010 LAMP/EPFL
* @author Stepan Koltsov
*/
package scala.tools.nsc
package interpreter
import java.io.File
import jline.{ ConsoleReader, ArgumentCompletor, History => JHistory }
import scala.tools.util.SignalManager
/** Reads from the console using JLine */
class JLineReader(interpreter: Interpreter) extends InteractiveReader {
def this() = this(null)
override lazy val history = Some(History(consoleReader))
override lazy val completion = Option(interpreter) map (x => new Completion(x))
override def init() = consoleReader.getTerminal().initializeTerminal()
/** Requires two interrupt signals within three seconds
* of one another to initiate exit.
*/
SignalManager.requireInterval(3, SignalManager.INT) {
case true => Console.println("\nPress ctrl-C again to exit.")
case false => System.exit(1)
}
val consoleReader = {
val r = new jline.ConsoleReader()
r setHistory (History().jhistory)
r setBellEnabled false
completion foreach { c =>
r addCompletor c.jline
r setAutoprintThreshhold 250
}
r
}
def readOneLine(prompt: String) = consoleReader readLine prompt
val interactive = true
}
|