You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
5.3 KiB
108 lines
5.3 KiB
diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala b/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
|
|
index 10f9724..2970276 100644
|
|
--- a/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
|
|
+++ b/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
|
|
@@ -42,7 +42,7 @@ class JLineReader(_completion: => Completion) extends InteractiveReader {
|
|
def readOneKey(prompt: String) = {
|
|
this.print(prompt)
|
|
this.flush()
|
|
- this.readVirtualKey()
|
|
+ this.readCharacter()
|
|
}
|
|
def eraseLine() = consoleReader.resetPromptLine("", "", 0)
|
|
def redrawLineAndFlush(): Unit = { flush() ; drawLine() ; flush() }
|
|
diff --git a/src/compiler/scala/tools/nsc/interpreter/session/FileBackedHistory.scala b/src/compiler/scala/tools/nsc/interpreter/session/FileBackedHistory.scala
|
|
index dddfb1b..e598ac5 100644
|
|
--- a/src/compiler/scala/tools/nsc/interpreter/session/FileBackedHistory.scala
|
|
+++ b/src/compiler/scala/tools/nsc/interpreter/session/FileBackedHistory.scala
|
|
@@ -13,7 +13,7 @@ import FileBackedHistory._
|
|
/** TODO: file locking.
|
|
*/
|
|
trait FileBackedHistory extends JLineHistory with JPersistentHistory {
|
|
- def maxSize: Int
|
|
+ def maxSize: Int = 2500
|
|
protected lazy val historyFile: File = defaultFile
|
|
private var isPersistent = true
|
|
|
|
diff --git a/src/compiler/scala/tools/nsc/interpreter/session/JLineHistory.scala b/src/compiler/scala/tools/nsc/interpreter/session/JLineHistory.scala
|
|
index 18e0ee7..fc33192 100644
|
|
--- a/src/compiler/scala/tools/nsc/interpreter/session/JLineHistory.scala
|
|
+++ b/src/compiler/scala/tools/nsc/interpreter/session/JLineHistory.scala
|
|
@@ -13,7 +13,6 @@ package session
|
|
trait JLineHistory extends JHistory with History {
|
|
def size: Int
|
|
def isEmpty: Boolean
|
|
- def index: Int
|
|
def clear(): Unit
|
|
def get(index: Int): CharSequence
|
|
def add(line: CharSequence): Unit
|
|
@@ -42,7 +41,8 @@ object JLineHistory {
|
|
addLineToFile(item)
|
|
}
|
|
}
|
|
- override def toString = "History(size = " + size + ", index = " + index + ")"
|
|
+ override def toString = "History(size = " + size + ", _index = " + index + ")"
|
|
+ override def maxSize: Int = 2500
|
|
}
|
|
|
|
def apply(): JLineHistory = try new JLineFileHistory catch { case x: Exception => new SimpleHistory() }
|
|
diff --git a/src/compiler/scala/tools/nsc/interpreter/session/SimpleHistory.scala b/src/compiler/scala/tools/nsc/interpreter/session/SimpleHistory.scala
|
|
index 9f4e2b9..8933849 100644
|
|
--- a/src/compiler/scala/tools/nsc/interpreter/session/SimpleHistory.scala
|
|
+++ b/src/compiler/scala/tools/nsc/interpreter/session/SimpleHistory.scala
|
|
@@ -10,7 +10,7 @@ package session
|
|
import scala.collection.mutable.{ Buffer, ListBuffer }
|
|
import scala.collection.JavaConverters._
|
|
|
|
-class SimpleHistory extends JLineHistory {
|
|
+class SimpleHistory extends JMemoryHistory with JLineHistory {
|
|
private var _index: Int = 0
|
|
private val buf: Buffer[String] = new ListBuffer[String]
|
|
private def toEntries(): Seq[JEntry] = buf.zipWithIndex map { case (x, i) => Entry(i, x) }
|
|
@@ -32,27 +32,27 @@ class SimpleHistory extends JLineHistory {
|
|
def maxSize: Int = 2500
|
|
def last = if (isEmpty) fail("last") else buf.last
|
|
|
|
- def size = buf.size
|
|
- def index = _index
|
|
- def isEmpty = buf.isEmpty
|
|
- def clear() = buf.clear()
|
|
- def get(idx: Int): CharSequence = buf(idx)
|
|
- def add(item: CharSequence): Unit = buf += item
|
|
- def replace(item: CharSequence): Unit = {
|
|
+ override def size = buf.size
|
|
+ override def index = _index
|
|
+ override def isEmpty = buf.isEmpty
|
|
+ override def clear() = buf.clear()
|
|
+ override def get(idx: Int): CharSequence = buf(idx)
|
|
+ override def add(item: CharSequence): Unit = buf += item
|
|
+ override def replace(item: CharSequence): Unit = {
|
|
buf trimEnd 1
|
|
add(item)
|
|
}
|
|
- def entries(idx: Int): JListIterator[JEntry] = toEntries().asJava.listIterator(idx)
|
|
- def entries(): JListIterator[JEntry] = toEntries().asJava.listIterator()
|
|
- def iterator: JIterator[JEntry] = toEntries().iterator.asJava
|
|
-
|
|
- def current() = if (index >= 0 && index < buf.size) buf(index) else fail("current()")
|
|
- def previous() = (index > 0) && minusOne
|
|
- def next() = (index <= lastIndex) && plusOne
|
|
- def moveToFirst() = (size > 0) && (index != 0) && setTo(0)
|
|
- def moveToLast() = (size > 0) && (index < lastIndex) && setTo(lastIndex)
|
|
- def moveTo(idx: Int) = (idx > 0) && (idx <= lastIndex) && setTo(idx)
|
|
- def moveToEnd(): Unit = setTo(size)
|
|
+ override def entries(idx: Int): JListIterator[JEntry] = toEntries().asJava.listIterator(idx)
|
|
+ override def entries(): JListIterator[JEntry] = toEntries().asJava.listIterator()
|
|
+ override def iterator: JIterator[JEntry] = toEntries().iterator.asJava
|
|
+
|
|
+ override def current() = if (index >= 0 && index < buf.size) buf(index) else fail("current()")
|
|
+ override def previous() = (index > 0) && minusOne
|
|
+ override def next() = (index <= lastIndex) && plusOne
|
|
+ override def moveToFirst() = (size > 0) && (index != 0) && setTo(0)
|
|
+ override def moveToLast() = (size > 0) && (index < lastIndex) && setTo(lastIndex)
|
|
+ override def moveTo(idx: Int) = (idx > 0) && (idx <= lastIndex) && setTo(idx)
|
|
+ override def moveToEnd(): Unit = setTo(size)
|
|
|
|
// scala legacy interface
|
|
def asList: List[JEntry] = toEntries().toList
|