diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala | 2 | ||||
-rw-r--r-- | src/library/scala/runtime/WorksheetSupport.scala | 18 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala index bd1869e1a4..f7b1c42fd6 100644 --- a/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala +++ b/src/compiler/scala/tools/nsc/interactive/ScratchPadMaker.scala @@ -46,7 +46,7 @@ trait ScratchPadMaker { self: Global => patches += Patch(stat.pos.start, ";$stop()") var end = stat.pos.end if (end > skipped) { - while (end < contents.length && !(isLineBreakChar(contents(end)))) end += 1 + while (end < contents.length && !isLineBreakChar(contents(end))) end += 1 patches += Patch(stat.pos.start, ";$skip("+(end-skipped)+"); ") skipped = end } diff --git a/src/library/scala/runtime/WorksheetSupport.scala b/src/library/scala/runtime/WorksheetSupport.scala index db6d6359a3..f9ffb9197b 100644 --- a/src/library/scala/runtime/WorksheetSupport.scala +++ b/src/library/scala/runtime/WorksheetSupport.scala @@ -14,9 +14,11 @@ object WorksheetSupport { * By default it is 30ms. */ private class FlushedOutputStream(out: OutputStream) extends OutputStream { + protected def flushInterval = 30000000L // interval between flushes, by default 30ms + protected def width = 80 // output width, by default 80 characters + protected def tabInc = 8 // tab increment, by default 8 characters private var lastFlush: Long = 0L - protected val flushInterval = 30000000L // 30ms - private var lastCh: Int = '\n' + private var col = 0 override def write(b: Array[Byte], off: Int, len: Int) = { for (idx <- off until (off + len min b.length)) writeOne(b(idx)) flush() @@ -33,14 +35,16 @@ object WorksheetSupport { } } def writeOne(c: Int) { - if (lastCh == '\n') { - lastCh = 0 + if (col == 0) write((currentOffset+" ").getBytes) - } out.write(c) - lastCh = c + col = + if (c == '\n') 0 + else if (c == '\t') (col / tabInc) * tabInc + tabInc + else col + 1 + if (col >= width) writeOne('\n') } - def ensureNewLine() = if (lastCh != '\n') writeOne('\n') + def ensureNewLine() = if (col != 0) writeOne('\n') } private val flushedOut = new FlushedOutputStream(System.out) |