forked from epiclabs-io/winman
/
main.go
34 lines (27 loc) · 1.07 KB
/
main.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
package main
import (
"github.com/r3ap3r2004/winman"
"github.com/rivo/tview"
)
func main() {
app := tview.NewApplication()
wm := winman.NewWindowManager()
content := tview.NewTextView().
SetText("Hello, world!"). // set content of the text view
SetTextAlign(tview.AlignCenter) // align text to the center of the text view
window := wm.NewWindow(). // create new window and add it to the window manager
Show(). // make window visible
SetRoot(content). // have the text view above be the content of the window
SetDraggable(true). // make window draggable around the screen
SetResizable(true). // make the window resizable
SetTitle("Hi!"). // set the window title
AddButton(&winman.Button{ // create a button with an X to close the application
Symbol: 'X',
OnClick: func() { app.Stop() }, // close the application
})
window.SetRect(5, 5, 30, 10) // place the window
// now, execute the application:
if err := app.SetRoot(wm, true).EnableMouse(true).Run(); err != nil {
panic(err)
}
}