blob: 941b70101f04e27a2438d1711c96ed8727988c32 (
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
|
/* NSC -- new Scala compiler
* Copyright 2005-2010 LAMP/EPFL
* @author Stepan Koltsov
*/
package scala.tools.nsc
package interpreter
import java.io.File
import jline.console.ConsoleReader
import jline.console.completer._
/** Reads from the console using JLine */
class JLineReader(interpreter: Interpreter) extends InteractiveReader {
def this() = this(null)
override lazy val history = Some(History())
override lazy val completion = Option(interpreter) map (x => new Completion(x))
override def reset() = consoleReader.getTerminal().reset()
override def init() = consoleReader.getTerminal().init()
override def redrawLine() = {
consoleReader.flush()
consoleReader.drawLine()
consoleReader.flush()
}
val consoleReader = {
val r = new ConsoleReader()
r setBellEnabled false
history foreach { r setHistory _.jhistory }
completion foreach { c =>
r addCompleter c.jline
r setAutoprintThreshold 250 // max completion candidates without warning
}
r
}
override def currentLine: String = consoleReader.getCursorBuffer.buffer.toString
def readOneLine(prompt: String) = consoleReader readLine prompt
val interactive = true
}
|