https://github.com/todesking/monolay
Monospace Text Layout Engine for Scala
https://github.com/todesking/monolay
Last synced: 2 months ago
JSON representation
Monospace Text Layout Engine for Scala
- Host: GitHub
- URL: https://github.com/todesking/monolay
- Owner: todesking
- License: mit
- Created: 2014-11-17T10:08:43.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-12-21T16:33:56.000Z (over 11 years ago)
- Last Synced: 2026-01-17T16:50:16.404Z (5 months ago)
- Language: Scala
- Size: 266 KB
- Stars: 1
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Monolay: Monospace Text Layout Engine for Scala
[](https://circleci.com/gh/todesking/monolay)
[](https://coveralls.io/r/todesking/monolay?branch=master)
Monolay is text layout engine.
This is useful to generate simple text format(like Markdown), or to build user-friendly console application.
```scala
val l = new com.todesking.monolay.Layout(40)
l.appendText("""Monolayは、Scalaで書かれた等幅テキストレイアウトエンジンです。コンソールアプリケーションの出力や、markdownのようなフ ォーマットの整形に適しています。""")
l.requireEmptyLines(1)
l.appendText("Monolay support automatic word-breaking, full-width characters, table layout.")
l.requireEmptyLines(1)
l.appendText("""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.""")
l.requireEmptyLines(1)
l.renderTable {t => t.setHeader(Seq("S", "V", "O")); t.addRow(Seq("It", "support", "tables")) }
l.withIndent(10) {
l.appendText("And indent control is supported.")
l.renderTable {t => t.addRow(Seq("Combination", "is", "OK"))}
}
println(l.toString)
```
```
Monolayは、Scalaで書かれた等幅テキストレ
イアウトエンジンです。コンソールアプリケ
ーションの出力や、markdownのようなフォー
マットの整形に適しています。
Monolay support automatic word-breaking,
full-width characters, table layout.
Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis
nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim
id est laborum.
+----+---------+--------+
| S | V | O |
+====+=========+========+
| It | support | tables |
+----+---------+--------+
And indent control is
supported.
+-------------+----+----+
| Combination | is | OK |
+-------------+----+----+
```
## Features
* Text layout engine
* Word breaking
* Text alignment control(currently, align left and equal spaced is supported)
* Vertical alignment control("require N empty lines above the content")
* Indentation
* Full-width characters(ambiwidth is not yet)
* Table layout engine
* Auto width calculation
* Omit text longer than column width
* Multi-line columns
## Current status
STATUS: Under construction.
## Related products
There's some table layout library for Java.
* [j-text-utils](https://code.google.com/p/j-text-utils/)
* [Java Text Table Formatter](http://texttablefmt.sourceforge.net/)
* [java-ascii-table](https://code.google.com/p/java-ascii-table/)
* [MultiColumnPrinter.java](http://www.java2s.com/Code/Java/Development-Class/Utilityclassforprintingalignedcolumnsoftext.htm)
* I don't know where the class come from...