1
0
mirror of https://github.com/gizak/termui.git synced 2025-04-24 13:48:50 +08:00
termui/_examples/canvas.go
Caleb Bassi 08e68490f3 Add TextBox widget
- TextBox is a superset of Paragraph, so Paragraph is deprecated
- adds support for a cursor, which can be moved
- the `Text` field is now private, replaced with `SetText`, `InsertText`, and `ClearText` methods

TODO:

- adding focusable widgets support to termui might clean up the API since we could potentially move the event handling from client side to library side
- add support for scrolling the TextBox view
- fix the cursor position on linewrap
- fix linewrapping
- add line number support
2019-03-15 22:40:01 -07:00

31 lines
481 B
Go

// +build ignore
package main
import (
"image"
"log"
ui "github.com/gizak/termui/v3"
)
// TODO make example interactive so you can draw lines
func main() {
if err := ui.Init(); err != nil {
log.Fatalf("failed to initialize termui: %v", err)
}
defer ui.Close()
c := ui.NewCanvas()
c.SetRect(0, 0, 50, 50)
c.SetLine(image.Pt(0, 0), image.Pt(10, 20), ui.ColorWhite)
ui.Render(c)
for e := range ui.PollEvents() {
if e.Type == ui.KeyboardEvent {
break
}
}
}