diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-04-28 11:01:33 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-04-29 10:42:02 +0200 |
commit | 29fc55a67349145cbb23edf3f0fc0307bf9d515e (patch) | |
tree | 64165416302e5f9f9c89f27e844e8b67c06e9061 /src/dotty/tools/dotc/repl/ammonite/FilterTools.scala | |
parent | 4fadce464b2ecf0d35f1d6ff00283d6ada2ff0be (diff) | |
download | dotty-29fc55a67349145cbb23edf3f0fc0307bf9d515e.tar.gz dotty-29fc55a67349145cbb23edf3f0fc0307bf9d515e.tar.bz2 dotty-29fc55a67349145cbb23edf3f0fc0307bf9d515e.zip |
Add Ammonite's MIT license
Diffstat (limited to 'src/dotty/tools/dotc/repl/ammonite/FilterTools.scala')
-rw-r--r-- | src/dotty/tools/dotc/repl/ammonite/FilterTools.scala | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/repl/ammonite/FilterTools.scala b/src/dotty/tools/dotc/repl/ammonite/FilterTools.scala index 4eed208b1..c18b6a927 100644 --- a/src/dotty/tools/dotc/repl/ammonite/FilterTools.scala +++ b/src/dotty/tools/dotc/repl/ammonite/FilterTools.scala @@ -2,6 +2,7 @@ package dotty.tools package dotc package repl package ammonite.terminal + /** * A collection of helpers that to simpify the common case of building filters */ @@ -12,8 +13,8 @@ object FilterTools { var splitIndex = 0 var length = 0 - while(length < in){ - ansiRegex.r.findPrefixOf(buffer.drop(splitIndex)) match{ + while(length < in) { + ansiRegex.r.findPrefixOf(buffer.drop(splitIndex)) match { case None => splitIndex += 1 length += 1 @@ -24,9 +25,6 @@ object FilterTools { splitIndex } - - - /** * Shorthand to construct a filter in the common case where you're * switching on the prefix of the input stream and want to run some @@ -58,12 +56,9 @@ object FilterTools { def identifier = "Case" } - /** - * Shorthand for pattern matching on [[TermState]] - */ + /** Shorthand for pattern matching on [[TermState]] */ val TS = TermState - def findChunks(b: Vector[Char], c: Int) = { val chunks = Terminal.splitBuffer(b) // The index of the first character in each chunk @@ -76,11 +71,10 @@ object FilterTools { (chunks, chunkStarts, chunkIndex) } - def firstRow(cursor: Int, buffer: Vector[Char], width: Int) = { + def firstRow(cursor: Int, buffer: Vector[Char], width: Int) = cursor < width && (buffer.indexOf('\n') >= cursor || buffer.indexOf('\n') == -1) - } - def lastRow(cursor: Int, buffer: Vector[Char], width: Int) = { + + def lastRow(cursor: Int, buffer: Vector[Char], width: Int) = (buffer.length - cursor) < width && (buffer.lastIndexOf('\n') < cursor || buffer.lastIndexOf('\n') == -1) - } } |