forked from gizak/termui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paragraph.go
53 lines (43 loc) · 1.04 KB
/
paragraph.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
// +build ignore
package main
import ui "github.com/JBToula/termui"
func main() {
err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close()
p0 := ui.NewParagraph("Borderless Text")
p0.Height = 1
p0.Width = 20
p0.Y = 1
p0.Border = false
p1 := ui.NewParagraph("你好,世界。")
p1.Height = 3
p1.Width = 17
p1.X = 20
p1.BorderLabel = "标签"
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
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"
ui.Render(p0, p1, p2, p3)
uiEvents := ui.PollEvents()
for {
e := <-uiEvents
switch e.ID {
case "q", "<C-c>":
return
}
}
}