Пример #1
0
func NewAuthPanel(app *App, server string) *AuthPanel {
	apanel := &AuthPanel{}
	apanel.Panel.Init(app)

	st := tcell.StyleDefault.
		Foreground(tcell.ColorSilver).
		Background(tcell.ColorBlack)

	apanel.username = make([]rune, 0, 128)
	apanel.password = make([]rune, 0, 128)

	apanel.hlayout = views.NewBoxLayout(views.Horizontal)
	apanel.left = views.NewBoxLayout(views.Vertical)
	apanel.right = views.NewBoxLayout(views.Vertical)
	apanel.uprompt = views.NewText()
	apanel.pprompt = views.NewText()
	apanel.ufield = views.NewText()
	apanel.pfield = views.NewText()
	apanel.ufield.SetText("                ")
	apanel.pfield.SetText("                ")
	apanel.uprompt.SetText("Username: "******"Password: "******"Authentication Required")
	apanel.SetKeys([]string{"[ESC] Quit"})
	apanel.SetContent(apanel.hlayout)

	return apanel
}
Пример #2
0
func main() {

	title := &views.TextBar{}
	title.SetStyle(tcell.StyleDefault.
		Background(tcell.ColorYellow).
		Foreground(tcell.ColorBlack))
	title.SetCenter("Horizontal Boxes", tcell.StyleDefault)
	title.SetLeft("ESC to exit", tcell.StyleDefault.
		Background(tcell.ColorBlue).
		Foreground(tcell.ColorWhite))
	title.SetRight("==>X", tcell.StyleDefault)

	inner := views.NewBoxLayout(views.Horizontal)

	l := views.NewText()
	m := views.NewText()
	r := views.NewText()

	l.SetText("Left (0.0)")
	m.SetText("Middle (0.7)")
	r.SetText("Right (0.3)")
	l.SetStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).
		Background(tcell.ColorRed))
	m.SetStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).
		Background(tcell.ColorLime))
	r.SetStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).
		Background(tcell.ColorBlue))
	l.SetAlignment(views.AlignBegin)
	m.SetAlignment(views.AlignMiddle)
	r.SetAlignment(views.AlignEnd)

	inner.AddWidget(l, 0)
	inner.AddWidget(m, 0.7)
	inner.AddWidget(r, 0.3)

	box.SetOrientation(views.Vertical)
	box.AddWidget(title, 0)
	box.AddWidget(inner, 1)
	app.SetRootWidget(box)
	if e := app.Run(); e != nil {
		fmt.Fprintln(os.Stderr, e.Error())
		os.Exit(1)
	}
}