Simple and highly customizable library to display tables in the terminal.
- Choose from seven predefined styles
- Or create any custom style you want
- Tab support
- Unicode support
v install serkonda7.termtable
import serkonda7.termtable as tt
fn main() {
data := [
['Name', 'Age', 'Sex'],
['Max', '13', 'male'],
['Moritz', '12', 'male'],
['Lisa', '42', 'female'],
]
t := tt.Table{
data: data
// The following settings are optional and have these defaults:
style: .grid
header_style: .bold
align: .left
orientation: .row
padding: 1
tabsize: 4
}
println(t)
}
Supported values for style: ...
are:
- .grid
- .pretty
- .plain
- .simple
- .fancy_grid
- .md
- .rst
.grid
(default):
.pretty
:
.plain
:
.simple
:
.fancy_grid
:
.md
follows the conventions of Markdown. It does not add alignment colons though:
.rst
behaves like the reStructuredText simple table format:
// header_style: ...
.bold (default) |
.plain |
---|---|
// align: ...
| Max | 13 | male | // .left (default)
| Max | 13 | male | // .center
| Max | 13 | male | // .right
t := tt.Table{
data: [
['Name', 'Age'],
['Max', '13'],
['Moritz', '12'],
]
// orientation: ...
}
println(t)
.row (default) |
.column |
---|---|
Control the count of spaces between the cell border and the item.
// padding: ...
| Lisa | 42 | female | // 3
| Lisa | 42 | female | // 1 (default)
|Lisa|42|female| // 0
t := tt.Table{
data: [
['\tName', 'Sex'],
['1.\tMax', 'male\t'],
['2. \tMoritz', '\tmale'],
]
// tabsize: ...
}
println(t)
4 (default) |
2 |
8 |
---|---|---|
To create a custom style set the tables style property to style: .custom
and specify custom_style: tt.StyleConfig{...}
.
topline tt.Sepline{...}
headerline tt.Sepline{...}
middleline tt.Sepline{...}
bottomline tt.Sepline{...}
colsep string
fill_padding bool = true
left string
right string
cross string
sep string
- Images were made with carbon and optimized with image-actions
Licensed under the MIT License