https://github.com/achannarasappa/term-grid
Position text and visuals in a grid layout for terminal UIs (TUIs) with familiar web semantics
https://github.com/achannarasappa/term-grid
Last synced: 5 months ago
JSON representation
Position text and visuals in a grid layout for terminal UIs (TUIs) with familiar web semantics
- Host: GitHub
- URL: https://github.com/achannarasappa/term-grid
- Owner: achannarasappa
- License: mit
- Created: 2021-02-27T21:07:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-15T22:15:45.000Z (over 4 years ago)
- Last Synced: 2024-06-19T00:27:01.802Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 20
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# term-grid
Position text and visuals in a grid layout for terminal UIs (TUIs) with familiar web semantics
## Features
* **Flex Layout** - dynamically resize cells to use available space
* **Responsive** - show or hide cells dynamically based on grid size
* **Alignment** - align text to the right of left of a cell
* **Overflow/Wrap** - set whether text should be hidden, wrap on word, or wrap unconditionally when width exceeds the cell width
* **Margins** - set width vertically and horizontally between cells## Install
```sh
go get github.com/achannarasappa/term-grid
```## Quick Start
```go
// main.go
package mainimport (
"fmt"
. "github.com/achannarasappa/term-grid"
)func main() {
out := Render(
Grid{
GutterVertical: 2,
GutterHorizontal: 5,
Rows: []Row{
{
Width: 100,
Cells: []Cell{
{Width: 10, Text: "term-grid is awesome!", Overflow: WrapWord},
{Width: 10, Text: "everything to the right", Overflow: Wrap, Align: Right},
{Width: 20, Text: "To Do:\n- take out trash\n- book my flight\n- workout", Overflow: WrapWord},
{Text: "I'm baby pitchfork iPhone tilde umami man braid"},
},
},
},
})fmt.Print(out)
}
``````sh
$ go run main.go
term-grid everything To Do: I'm baby pitchfork iPhone tilde umami man bra
is to the rig - take out trash
awesome! ht - book my flight
- workout
```