-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve REPL output filtering for color escapes
- Loading branch information
Showing
7 changed files
with
206 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 6a 61 76 61 2e |scala> .[0mjava.| | ||
00000010 6e 69 6f 2e 43 68 61 72 42 75 66 66 65 72 2e 61 |nio.CharBuffer.a| | ||
00000020 6c 6c 6f 63 61 74 65 28 35 29 |llocate(5)| | ||
|
||
00000000 76 61 6c 20 1b 5b 31 6d 1b 5b 33 34 6d 72 65 73 |val .[1m.[34mres| | ||
00000010 30 1b 5b 30 6d 3a 20 1b 5b 31 6d 1b 5b 33 32 6d |0.[0m: .[1m.[32m| | ||
00000020 6a 61 76 61 2e 6e 69 6f 2e 43 68 61 72 42 75 66 |java.nio.CharBuf| | ||
00000030 66 65 72 1b 5b 30 6d 20 3d 20 3f 3f 3f 3f 3f |fer.[0m = ?????| | ||
|
||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 6a 61 76 61 2e |scala> .[0mjava.| | ||
00000010 6e 69 6f 2e 43 68 61 72 42 75 66 66 65 72 2e 61 |nio.CharBuffer.a| | ||
00000020 6c 6c 6f 63 61 74 65 28 36 29 |llocate(6)| | ||
|
||
00000000 76 61 6c 20 1b 5b 31 6d 1b 5b 33 34 6d 72 65 73 |val .[1m.[34mres| | ||
00000010 31 1b 5b 30 6d 3a 20 1b 5b 31 6d 1b 5b 33 32 6d |1.[0m: .[1m.[32m| | ||
00000020 6a 61 76 61 2e 6e 69 6f 2e 43 68 61 72 42 75 66 |java.nio.CharBuf| | ||
00000030 66 65 72 1b 5b 30 6d 20 3d 20 3f 3f 3f 3f 3f 3f |fer.[0m = ??????| | ||
|
||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 63 6c 61 73 73 |scala> .[0mclass| | ||
00000010 20 43 | C| | ||
|
||
00000000 63 6c 61 73 73 20 43 |class C| | ||
|
||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 63 6c 61 73 73 |scala> .[0mclass| | ||
00000010 4f 66 5b 43 5d |Of[C]| | ||
|
||
00000000 76 61 6c 20 1b 5b 31 6d 1b 5b 33 34 6d 72 65 73 |val .[1m.[34mres| | ||
00000010 32 1b 5b 30 6d 3a 20 1b 5b 31 6d 1b 5b 33 32 6d |2.[0m: .[1m.[32m| | ||
00000020 43 6c 61 73 73 5b 43 5d 1b 5b 30 6d 20 3d 20 63 |Class[C].[0m = c| | ||
00000030 6c 61 73 73 20 43 |lass C| | ||
|
||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 76 61 6c 20 65 |scala> .[0mval e| | ||
00000010 73 63 20 3d 20 30 78 31 62 2e 74 6f 43 68 61 72 |sc = 0x1b.toChar| | ||
|
||
00000000 76 61 6c 20 1b 5b 31 6d 1b 5b 33 34 6d 65 73 63 |val .[1m.[34mesc| | ||
00000010 1b 5b 30 6d 3a 20 1b 5b 31 6d 1b 5b 33 32 6d 43 |.[0m: .[1m.[32mC| | ||
00000020 68 61 72 1b 5b 30 6d 20 3d 20 3f |har.[0m = ?| | ||
|
||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 63 6c 61 73 73 |scala> .[0mclass| | ||
00000010 4f 66 5b 43 5d 2e 74 6f 53 74 72 69 6e 67 20 2b |Of[C].toString +| | ||
00000020 20 65 73 63 20 2b 20 22 5b 33 7a 22 | esc + "[3z"| | ||
|
||
00000000 76 61 6c 20 1b 5b 31 6d 1b 5b 33 34 6d 72 65 73 |val .[1m.[34mres| | ||
00000010 33 1b 5b 30 6d 3a 20 1b 5b 31 6d 1b 5b 33 32 6d |3.[0m: .[1m.[32m| | ||
00000020 53 74 72 69 6e 67 1b 5b 30 6d 20 3d 20 63 6c 61 |String.[0m = cla| | ||
00000030 73 73 20 43 3f 3f 3f 3f |ss C????| | ||
|
||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 63 6c 61 73 73 |scala> .[0mclass| | ||
00000010 4f 66 5b 43 5d 2e 74 6f 53 74 72 69 6e 67 20 2b |Of[C].toString +| | ||
00000020 20 65 73 63 20 2b 20 22 5b 33 21 22 | esc + "[3!"| | ||
|
||
00000000 76 61 6c 20 1b 5b 31 6d 1b 5b 33 34 6d 72 65 73 |val .[1m.[34mres| | ||
00000010 34 1b 5b 30 6d 3a 20 1b 5b 31 6d 1b 5b 33 32 6d |4.[0m: .[1m.[32m| | ||
00000020 53 74 72 69 6e 67 1b 5b 30 6d 20 3d 20 63 6c 61 |String.[0m = cla| | ||
00000030 73 73 20 43 3f 5b 33 21 |ss C?[3!| | ||
|
||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 63 6c 61 73 73 |scala> .[0mclass| | ||
00000010 4f 66 5b 43 5d 2e 74 6f 53 74 72 69 6e 67 20 2b |Of[C].toString +| | ||
00000020 20 73 63 61 6c 61 2e 69 6f 2e 41 6e 73 69 43 6f | scala.io.AnsiCo| | ||
00000030 6c 6f 72 2e 59 45 4c 4c 4f 57 |lor.YELLOW| | ||
|
||
00000000 76 61 6c 20 1b 5b 31 6d 1b 5b 33 34 6d 72 65 73 |val .[1m.[34mres| | ||
00000010 35 1b 5b 30 6d 3a 20 1b 5b 31 6d 1b 5b 33 32 6d |5.[0m: .[1m.[32m| | ||
00000020 53 74 72 69 6e 67 1b 5b 30 6d 20 3d 20 63 6c 61 |String.[0m = cla| | ||
00000030 73 73 20 43 1b 5b 33 33 6d |ss C.[33m| | ||
|
||
00000000 1b 5b 33 35 6d |.[35m| | ||
|
||
00000000 73 63 61 6c 61 3e 20 1b 5b 30 6d 3a 71 75 69 74 |scala> .[0m:quit| | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import scala.tools.nsc.Settings | ||
import scala.tools.nsc.interpreter.shell.{ILoop, ShellConfig} | ||
import scala.tools.partest.{hexdump, ReplTest} | ||
|
||
object Test extends ReplTest { | ||
def code = """ | ||
|java.nio.CharBuffer.allocate(5) | ||
|java.nio.CharBuffer.allocate(6) | ||
|class C | ||
|classOf[C] | ||
|val esc = 0x1b.toChar | ||
|classOf[C].toString + esc + "[3z" | ||
|classOf[C].toString + esc + "[3!" | ||
|classOf[C].toString + scala.io.AnsiColor.YELLOW | ||
|""".stripMargin | ||
|
||
override protected def shellConfig(testSettings: Settings) = | ||
new ILoop.TestConfig(ShellConfig(testSettings)) { | ||
override val colorOk = true | ||
} | ||
override def normalize(s: String) = hexdump(s).mkString("", "\n", "\n") | ||
} |