Ahnfelt / TextTable
Simple plaintext (ASCII art-like) table formatting. It can wrap tables that are too wide. It is written in Haxe.
$ hg clone http://bitbucket.org/Ahnfelt/texttable
Text table formatting
Because roller coasters are awesome (data from Google Squared).
Gives the result (notice the wrapping):
.----------------------.----------------------.----------------------. | Name | Location | Description | |----------------------|----------------------|----------------------| | Six Flags Great Ad...| Jackson Township, ...| Great Adventure & ...| | Viper | Wien | Viper is the world...| '----------------------'----------------------'----------------------' .----------.-------.------------. | Capacity | Speed | Model | |----------|-------|------------| |//////////| 70 |////////////| | 12.8 | 50 | Viper 3A-1 | '----------'-------'------------'
The two last parameters (20 and 75) are the maximum characters shown from a value and the maximum total table width (in characters). There are two additional arguments, maximum shown rows and row offset, which are not used in this example.
The tables are unambiguous: you can distinguish null from strings like "//////" because there is no margin around the //// that indicate null; and when dots ... indicate that there's more data than can be displayed, there is no margin on the right of the dots, so it can be distinguished from strings like "...".
You can customize borders (and null-character) by passing it to the constructor:
Get it from haxelib install TextTable and then haxe -lib TextTable -x MyClass. Remember to import text.TextTable.
This revision is from 2010-02-13 13:29
