at=info method=GET path=/ host=mutelight.org fwd="124.133.52.161"
dyno=web.2 connect=4ms service=8ms status=200 bytes=1653
scala-reflect
. Not really hard to fix, but it's annoying. Is there a way to make it a transitive dependency, so I don't need to add it manually on the build.sbt?
Boy this room doesn't get much action :D
I'm doing something for mdoc and playing with width and height values gives me surprising results:
@ import $ivy.`com.lihaoyi::pprint:0.5.4`
import $ivy.$
@ val x = List.fill(15)("helloasdasdasdasdasdasdasdasd!")
x: List[String] = List(
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
...
@ pprint.PPrinter.BlackWhite.tokenize(x, height=5, width=10, initialOffset=0).foreach(print)
List(
"helloasdasdasdasdasdasdasda...
@ pprint.PPrinter.BlackWhite.tokenize(x, height=2, width=10, initialOffset=0).foreach(print)
List(
...
@ pprint.PPrinter.BlackWhite.tokenize(x, height=8, width=10, initialOffset=0).foreach(print)
List(
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasd...
Are those values expressed in characters or tokens? and if it's tokens - how is height interpreted?
➜ pprint git:(master) amm
Loading...
Welcome to the Ammonite Repl 2.2.0-4-4bd225e (Scala 2.13.3 Java 1.8.0_252)
@ import $ivy.`com.lihaoyi::pprint:0.6.0`
import $ivy.$
@ val x = List.fill(15)("helloasdasdasdasdasdasdasdasd!")
x: List[String] = List(
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasdasdasdasdasd!",
...
@ pprint.PPrinter.BlackWhite.tokenize(x, height=5, width=10, initialOffset=0).foreach(print)
List(
"helloasdasdasdasdasdasdasda...
@ pprint.PPrinter.BlackWhite.tokenize(x, height=2, width=10, initialOffset=0).foreach(print)
List(
...
@ pprint.PPrinter.BlackWhite.tokenize(x, height=8, width=10, initialOffset=0).foreach(print)
List(
"helloasdasdasdasdasdasdasdasd!",
"helloasdasdasdasd...
I'm also looking at one of the tests (I might be reading it wrong, I've only now imported pprint)
test{
val Check = new Check(width = 60, height = 5)
Check(
"a" * 1000,
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"..."
)
}
It seems like it expects the width to be 60, but it checks that the string is truncated to roughly ~480 characters?
so if you lay out the string
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"..."
And wrap it every 60 characters, it gets truncated with ...
when consuming a total of 5 vertical lines of space
I see, and from the examples above does the height truncation look right to you?
And with regards to width - if pprint is being run outside of a terminal (i.e. in mdoc it's used for markdown generation), it would default to the values it has, right? I guess pprint actually doesn't interact with terminal directly
➜ pprint git:(master) ✗ cat test.sc
import $ivy.`com.lihaoyi::pprint:0.6.0`
val x = List.fill(sys.env("LIST_LENGTH").toInt)("a")
pprint.PPrinter.BlackWhite
.tokenize(x,
height=sys.env("HEIGHT").toInt,
width=sys.env("WIDTH").toInt,
initialOffset=0)
.foreach(print)
➜ pprint git:(master) ✗ LIST_LENGTH=30 HEIGHT=15 WIDTH=2 amm test.sc
List(
"a",
"a",
"a",
"a"...#
➜ pprint git:(master) ✗ LIST_LENGTH=30 HEIGHT=15 WIDTH=10 amm test.sc
List(
"a",
"a",
"a",
"a",
"a",
"a",
"a",
"a",
"a",
"a",
"a",
"a",
"a",
.
width
, it should be height
lines tall (including the ...
)