Пример #1
0
func main() {
	err := termui.Init()
	if err != nil {
		panic(err)
	}
	defer termui.Close()

	WelcomeScreen()

	termui.Handle("/sys/wnd/resize", func(e termui.Event) {
		termui.Body.Width = termui.TermWidth()
		termui.Body.Align()
		termui.Render(termui.Body)
	})

	termui.Handle("/sys/kbd/<space>", func(e termui.Event) {
		Menu()
	})

	termui.Handle("/timer/1s/", func(e termui.Event) {
		Redraw()
	})

	termui.Loop()

}
Пример #2
0
func Menu() {

	txt := "Here is the placeholder for our menu:"

	tPar := termui.NewPar(txt)
	tPar.Height = 4

	termui.Body.Rows = termui.Body.Rows[:0]
	termui.Body.AddRows(
		termui.NewRow(
			termui.NewCol(4, 4, tPar)),
	)

	termui.Body.Align()
	termui.Render(termui.Body)

	termui.Handle("/sys/kbd/q", func(termui.Event) {
		//termui.StopLoop()
		WelcomeScreen()
	})
}
Пример #3
0
func WelcomeScreen() {

	title := "WELCOME TO GM HELPER"
	ver := "0.0.1"
	welcometxt := "Hit <space> to bring up the menu at any time except when entering text into a dialog box. Also, you can hit <q> to exit back to the welcome screen. This is a complete work in progress and will have better information here in the future."

	tPar := termui.NewPar(title)
	tPar.Height = 3
	tPar.BorderLabel = "GM HELPER"

	tVer := termui.NewPar(ver)
	tVer.Height = 3
	tVer.BorderLabel = "Version"

	tWelc := termui.NewPar(welcometxt)
	tWelc.Height = 9
	//tWelc.WrapLength = 30
	tWelc.BorderLabel = "Welcome"
	tmp := termui.TermWidth()
	tWelc.WrapLength = uint(tmp) - 4

	termui.Body.Rows = termui.Body.Rows[:0] // clears the rows
	termui.Body.AddRows(
		termui.NewRow(
			termui.NewCol(6, 0, tPar)),
		termui.NewRow(
			termui.NewCol(6, 0, tVer)),
		termui.NewRow(
			termui.NewCol(12, 0, tWelc)),
	)

	termui.Handle("/sys/kbd/q", func(termui.Event) {
		termui.StopLoop()
	})

	termui.Body.Align()
	termui.Render(termui.Body)
}
Пример #4
0
func Redraw() {
	termui.Body.Align()
	termui.Render(termui.Body)
}