Simple utility to create nice boxed strings
Add the following line to your build.sbt file:
libraryDependencies += "com.alejandrohdezma" %% "string-box" % "1.0.0"
Add the following import to unblock the syntax:
import com.alejandrohdezma.string.box._
And then use .boxed
method on any String
value you want to get wrapped in a box:
"\n" + "Hello,\nworld!".boxed
// res0: String = """
// ┌────────┐
// │ Hello, │
// │ world! │
// └────────┘"""
"\n" + "Hello,\nworld!\nI'm a very long string that should be wrapped in a box".boxed
// res1: String = """
// ┌────────────────────────────────────────────────────────┐
// │ Hello, │
// │ world! │
// │ I'm a very long string that should be wrapped in a box │
// └────────────────────────────────────────────────────────┘"""
boxed
takes ANSI colors (from scala.io.AnsiColor
) into account, so they're not counted when calculating the width of the box.
alejandrohdezma |