The Great Rewrite

This commit is contained in:
Caleb Bassi
2019-01-23 20:12:10 -08:00
parent b3075f7313
commit 958a28575d
95 changed files with 2626 additions and 4974 deletions

View File

@@ -6,41 +6,47 @@
package main
import ui "github.com/gizak/termui"
import (
"log"
ui "github.com/gizak/termui"
"github.com/gizak/termui/widgets"
)
func main() {
err := ui.Init()
if err != nil {
panic(err)
if err := ui.Init(); err != nil {
log.Fatalf("failed to initialize termui: %v", err)
}
defer ui.Close()
p0 := ui.NewParagraph("Borderless Text")
p0.Height = 1
p0.Width = 20
p0.Y = 1
p0 := widgets.NewParagraph()
p0.Text = "Borderless Text"
p0.SetRect(0, 0, 20, 5)
p0.Border = false
p1 := ui.NewParagraph("你好,世界。")
p1.Height = 3
p1.Width = 17
p1.X = 20
p1.BorderLabel = "标签"
p1 := widgets.NewParagraph()
p1.Title = "标签"
p1.Text = "你好,世界。"
p1.SetRect(20, 0, 35, 5)
p2 := ui.NewParagraph("Simple colored text\nwith label. It [can be](fg-red) multilined with \\n or [break automatically](fg-red,fg-bold)")
p2.Height = 5
p2.Width = 37
p2.Y = 4
p2.BorderLabel = "Multiline"
p2.BorderFg = ui.ColorYellow
p2 := widgets.NewParagraph()
p2.Title = "Multiline"
p2.Text = "Simple colored text\nwith label. It [can be](fg:red) multilined with \\n or [break automatically](fg:red,fg:bold)"
p2.SetRect(0, 5, 35, 10)
p2.BorderStyle.Fg = ui.ColorYellow
p3 := ui.NewParagraph("Long text with label and it is auto trimmed.")
p3.Height = 3
p3.Width = 37
p3.Y = 9
p3.BorderLabel = "Auto Trim"
p3 := widgets.NewParagraph()
p3.Title = "Auto Trim"
p3.Text = "Long text with label and it is auto trimmed."
p3.SetRect(0, 10, 40, 15)
ui.Render(p0, p1, p2, p3)
p4 := widgets.NewParagraph()
p4.Title = "Text Box with Wrapping"
p4.Text = "Press q to QUIT THE DEMO. [There](fg:blue,mod:bold) are other things [that](fg:red) are going to fit in here I think. What do you think? Now is the time for all good [men to](bg:blue) come to the aid of their country. [This is going to be one really really really long line](fg:green) that is going to go together and stuffs and things. Let's see how this thing renders out.\n Here is a new paragraph and stuffs and things. There should be a tab indent at the beginning of the paragraph. Let's see if that worked as well."
p4.SetRect(40, 0, 70, 20)
p4.BorderStyle.Fg = ui.ColorBlue
ui.Render(p0, p1, p2, p3, p4)
uiEvents := ui.PollEvents()
for {