dialog

package
v0.0.0-...-ab63aab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2017 License: GPL-3.0 Imports: 7 Imported by: 3

Documentation

Overview

Package that contains variety of dialogs

Example of using InputDialog

input := make(chan string)
//Prevents nested dialogs and other glitches (like double handler call)
for _, view := range gui.Views() {
	gui.DeleteKeybindings(view.Name())
}
utils.ErrCheck(
	mngr.SelectView(
		gui,
		dialog.InputDialog("Are you sure? [y/n]", "", "", gui, input).Name()))
go func() {
	if userInput, ok := <-input; ok {
		log.Print(userInput)
	}
	SetKeyBindings(gui, mngr)
}()

Similar example for ConfirmDialog

option := make(chan bool)
previousView := gui.CurrentView()
log.Println("callback: ", previousView.Name())
//Prevents nested dialogs and other glitches (like double handler call)
for _, view := range gui.Views() {
	gui.DeleteKeybindings(view.Name())
}
utils.ErrCheck(
	mngr.SelectView(
		gui,
		dialog.ConfirmDialog("message", "title", gui, option).Name()))

go func() {
	if choice, ok = <-option; ok {
		log.Printf("Choosen option: %v", choice)
	}

	mngr.currView = previousView
	log.Println("thread: ", mngr.currView.Name(), previousView.Name())
	SetKeyBindings(gui, mngr)
}()

Remember! When user chooses an option, it deletes returned view, so make sure to handle it properly. If you don't, it may cause Unknown view error

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfirmDialog

func ConfirmDialog(msg, title string, gui *gocui.Gui, choice chan bool) (view *gocui.View)

Provides option dialog. User can make decision with 'y' and 'n' key.

func DeleteDialog

func DeleteDialog(gui *gocui.Gui, dialogViews ...*gocui.View) error

func InputDialog

func InputDialog(msg, title, initValue string, gui *gocui.Gui, input chan string) [2]*gocui.View

Provides dialog with an input field

func LabelDialog

func LabelDialog(gui *gocui.Gui, labelChan chan [2]string) gocui.Manager

func SelectDialog

func SelectDialog(title string, gui *gocui.Gui, selIdxC chan int, values []string) *gocui.View

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL