textmatrix

Textmatrix in Elixir. Make working with 2D text a breeze.


License
MIT

Documentation

Textmatrix

Textmatrix is a thin wrapper around charlist to make working with two dimensional text a breeze. Once you're done, turn it into a multiline string.

Example

buffer =
  Textmatrix.new()

  # Draw top line
  |> Textmatrix.write(2, 2, "+---------------------+")

  # Draw left border
  |> Textmatrix.write_vertical(2, 3, "|||")

  # Draw right border
  |> Textmatrix.write_vertical(24, 3, "|||")

  # Draw text
  |> Textmatrix.write(7, 4, "Hello, world!")
  # Draw bottom line
  |> Textmatrix.write(2, 6, "+---------------------+")

IO.puts(buffer)

which will result in the example below being printed to stdout.



  +---------------------+
  |                     |
  |    Hello, world!    |
  |                     |
  +---------------------+

Installation

If available in Hex, the package can be installed by adding textmatrix to your list of dependencies in mix.exs:

def deps do
  [
    {:textmatrix, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/textmatrix.

License

MIT