Beispiel #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
}
Beispiel #2
0
func main() {
	X, err := xgbutil.NewConn()
	if err != nil {
		log.Fatalln(err)
	}

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

	// Creating a new message prompt is as simple as supply an X connection,
	// a theme and a configuration. We use built in defaults here.
	msgPrompt := prompt.NewMessage(X,
		prompt.DefaultMessageTheme, prompt.DefaultMessageConfig)

	// Show maps the message prompt window.
	// If a duration is specified, the window does NOT acquire focus and
	// automatically disappears after the specified time.
	// If a duration is not specified (i.e., '0'), then the window is mapped,
	// and acquires focus. It does not disappear until it loses focus or when
	// the user hits the "confirm" or "cancel" keys (usually "enter" and
	// "escape").
	timeout := 2 * time.Second // or "0" for no timeout.
	msgPrompt.Show(xwindow.RootGeometry(X), "Hello, world!", timeout, hidden)

	xevent.Main(X)
}