alejandrohdezma / string-box   1.0.0

Apache License 2.0 GitHub

Simple utility to create nice boxed strings

Scala versions: 3.x 2.13

Simple utility to create nice boxed strings

Installation

Add the following line to your build.sbt file:

libraryDependencies += "com.alejandrohdezma" %% "string-box" % "1.0.0"

Usage

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.

Contributors to this project

alejandrohdezma
alejandrohdezma