blob: c0fe874a37a62ee493e0609d4dbbbac2fd3c2ac3 (
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
45
46
47
48
|
/* NSC -- new Scala compiler
* Copyright 2005-2010 LAMP/EPFL
* @author Stepan Koltsov
*/
// $Id$
package scala.tools.nsc
package interpreter
import java.io.File
import jline.{ ConsoleReader, ArgumentCompletor, History => JHistory }
/** Reads from the console using JLine */
class JLineReader(interpreter: Interpreter, intLoop: InterpreterLoop) extends InteractiveReader {
def this() = this(null, null)
def this(interpreter: Interpreter) = this(interpreter, null)
override def history = Some(new History(consoleReader.getHistory))
val consoleReader = {
val history =
try new JHistory(new File(System.getProperty("user.home"), ".scala_history"))
// do not store history if error
catch { case _: Exception => new JHistory() }
val r = new jline.ConsoleReader()
r setHistory history
r setBellEnabled false
if (interpreter != null) {
// have to specify all delimiters for completion to work nicely
val delims = new ArgumentCompletor.AbstractArgumentDelimiter {
val delimChars = "(){}[],`;'\" \t".toArray
def isDelimiterChar(s: String, pos: Int) = delimChars contains s.charAt(pos)
}
val comp = new ArgumentCompletor(new Completion(interpreter, intLoop), delims)
comp setStrict false
r addCompletor comp
// XXX make this use a setting
r setAutoprintThreshhold 250
}
r
}
def readOneLine(prompt: String) = consoleReader readLine prompt
val interactive = true
}
|