Exemplo n.º 1
0
func newPrompts() AllPrompts {
	cycleConfig := prompt.CycleConfig{
		Grab:       true,
		CancelKey:  Config.CancelKey,
		ConfirmKey: Config.ConfirmKey,
	}
	selectConfig := prompt.SelectConfig{
		CancelKey:    Config.CancelKey,
		BackspaceKey: Config.BackspaceKey,
		ConfirmKey:   Config.ConfirmKey,
		TabKey:       Config.TabKey,
	}
	inputConfig := prompt.InputConfig{
		CancelKey:    Config.CancelKey,
		BackspaceKey: Config.BackspaceKey,
		ConfirmKey:   Config.ConfirmKey,
	}
	msgConfig := prompt.MessageConfig{
		CancelKey:  Config.CancelKey,
		ConfirmKey: Config.ConfirmKey,
	}
	ps := AllPrompts{
		Cycle:   prompt.NewCycle(X, Theme.Prompt.CycleTheme(), cycleConfig),
		Slct:    prompt.NewSelect(X, Theme.Prompt.SelectTheme(), selectConfig),
		Input:   prompt.NewInput(X, Theme.Prompt.InputTheme(), inputConfig),
		Message: prompt.NewMessage(X, Theme.Prompt.MessageTheme(), msgConfig),
	}
	ps.slctVisible = ps.Slct.AddGroup(ps.Slct.NewStaticGroup("Visible"))
	ps.slctHidden = ps.Slct.AddGroup(ps.Slct.NewStaticGroup("Hidden"))
	return ps
}
Exemplo n.º 2
0
func main() {
	X, err := xgbutil.NewConn()
	if err != nil {
		log.Fatalln(err)
	}

	// The input box uses the keybind module, so we must initialize it.
	keybind.Initialize(X)

	// Creating a new input prompt is as simple as supply an X connection,
	// a theme and a configuration. We use built in defaults here.
	inpPrompt := prompt.NewInput(X,
		prompt.DefaultInputTheme, prompt.DefaultInputConfig)

	// Show maps the input prompt window and sets the focus. It returns
	// immediately, and the main X event loop is started.
	// Also, we use the root window geometry to make sure the prompt is
	// centered in the middle of the screen. 'response' and 'canceled' are
	// callback functions. See their respective commends for more details.
	inpPrompt.Show(xwindow.RootGeometry(X),
		"What is your name?", response, canceled)

	xevent.Main(X)
}