keybindings

package
v1.1.104 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeys = map[string]gocui.Key{
	"quit":           gocui.KeyCtrlC,
	"copy":           gocui.KeyCtrlS,
	"listdelete":     gocui.KeyDelete,
	"fullscreen":     gocui.KeyCtrlF,
	"help":           gocui.KeyCtrlI,
	"itemback":       gocui.KeyBackspace2,
	"itemleft":       gocui.KeyArrowLeft,
	"listactions":    gocui.KeyCtrlA,
	"listback":       gocui.KeyBackspace2,
	"listbacklegacy": gocui.KeyBackspace,
	"listdown":       gocui.KeyArrowDown,
	"listup":         gocui.KeyArrowUp,
	"listright":      gocui.KeyArrowRight,
	"listedit":       gocui.KeyCtrlE,
	"listexpand":     gocui.KeyEnter,
	"listopen":       gocui.KeyCtrlO,
	"listrefresh":    gocui.KeyF5,
	"listupdate":     gocui.KeyCtrlU,
	"listpagedown":   gocui.KeyPgdn,
	"listpageup":     gocui.KeyPgup,
	"listend":        gocui.KeyEnd,
	"listhome":       gocui.KeyHome,
}

DefaultKeys are the default key bindings for each handler.

View Source
var HandlerIds = []string{
	"quit",
	"copy",
	"listdelete",
	"fullscreen",
	"help",
	"itemback",
	"itemleft",
	"listactions",
	"listback",
	"listbacklegacy",
	"listdown",
	"listup",
	"listright",
	"listedit",
	"listexpand",
	"listopen",
	"listrefresh",
	"listupdate",
	"listpagedown",
	"listpageup",
	"listend",
	"listhome",
}

HandlerIds A list of available handlers and their associated array index

View Source
var KeyToStr = map[gocui.Key]string{
	gocui.KeyArrowUp:        "up",
	gocui.KeyArrowDown:      "down",
	gocui.KeyArrowLeft:      "left",
	gocui.KeyArrowRight:     "right",
	gocui.KeyDelete:         "delete",
	gocui.KeyHome:           "home",
	gocui.KeyEnd:            "end",
	gocui.KeyPgup:           "pageup",
	gocui.KeyPgdn:           "pagedown",
	gocui.KeyInsert:         "insert",
	gocui.KeySpace:          "space",
	gocui.KeyCtrl2:          "ctrl+2 or ctrl+~ or ctrl+space",
	gocui.KeyCtrl4:          "ctrl+4",
	gocui.KeyCtrl6:          "ctrl+6",
	gocui.KeyCtrl8:          "ctrl+8 or backspace2",
	gocui.KeyCtrlLsqBracket: "ctrl+[ or esc or ctrl+3",
	gocui.KeyCtrlRsqBracket: "ctrl+] or ctrl+5",
	gocui.KeyCtrlUnderscore: "ctrl+_ or ctrl+7",
	gocui.KeyCtrlA:          "ctrl+a",
	gocui.KeyCtrlB:          "ctrl+b",
	gocui.KeyCtrlC:          "ctrl+c",
	gocui.KeyCtrlD:          "ctrl+d",
	gocui.KeyCtrlE:          "ctrl+e",
	gocui.KeyCtrlF:          "ctrl+f",
	gocui.KeyCtrlG:          "ctrl+g",
	gocui.KeyCtrlH:          "ctrl+h or ctrl+backspace",
	gocui.KeyCtrlI:          "ctrl+i or tab",
	gocui.KeyCtrlJ:          "ctrl+j",
	gocui.KeyCtrlK:          "ctrl+k",
	gocui.KeyCtrlL:          "ctrl+l",
	gocui.KeyCtrlM:          "enter or ctrl+m",
	gocui.KeyCtrlN:          "ctrl+n",
	gocui.KeyCtrlO:          "ctrl+o",
	gocui.KeyCtrlP:          "ctrl+p",
	gocui.KeyCtrlQ:          "ctrl+q",
	gocui.KeyCtrlR:          "ctrl+r",
	gocui.KeyCtrlS:          "ctrl+s",
	gocui.KeyCtrlT:          "ctrl+t",
	gocui.KeyCtrlU:          "ctrl+u",
	gocui.KeyCtrlV:          "ctrl+v",
	gocui.KeyCtrlW:          "ctrl+w",
	gocui.KeyCtrlX:          "ctrl+x",
	gocui.KeyCtrlY:          "ctrl+y",
	gocui.KeyCtrlZ:          "ctrl+z",
	gocui.KeyF1:             "f1",
	gocui.KeyF2:             "f2",
	gocui.KeyF3:             "f3",
	gocui.KeyF4:             "f4",
	gocui.KeyF5:             "f5",
	gocui.KeyF6:             "f6",
	gocui.KeyF7:             "f7",
	gocui.KeyF8:             "f8",
	gocui.KeyF9:             "f9",
	gocui.KeyF10:            "f10",
	gocui.KeyF11:            "f11",
	gocui.KeyF12:            "f12",
}

KeyToStr maps a gocui key to a string

View Source
var StrToKey = map[string]gocui.Key{
	"up":         gocui.KeyArrowUp,
	"down":       gocui.KeyArrowDown,
	"left":       gocui.KeyArrowLeft,
	"right":      gocui.KeyArrowRight,
	"backspace":  gocui.KeyBackspace,
	"backspace2": gocui.KeyBackspace2,
	"delete":     gocui.KeyDelete,
	"home":       gocui.KeyHome,
	"end":        gocui.KeyEnd,
	"pageup":     gocui.KeyPgup,
	"pagedown":   gocui.KeyPgdn,
	"insert":     gocui.KeyInsert,
	"tab":        gocui.KeyTab,
	"space":      gocui.KeySpace,
	"ctrl+2":     gocui.KeyCtrl2,
	"ctrl+3":     gocui.KeyCtrl3,
	"ctrl+4":     gocui.KeyCtrl4,
	"ctrl+5":     gocui.KeyCtrl5,
	"ctrl+6":     gocui.KeyCtrl6,
	"ctrl+7":     gocui.KeyCtrl7,
	"ctrl+8":     gocui.KeyCtrl8,
	"ctrl+[":     gocui.KeyCtrlLsqBracket,
	"ctrl+]":     gocui.KeyCtrlRsqBracket,
	"ctrl+space": gocui.KeyCtrlSpace,
	"ctrl+_":     gocui.KeyCtrlUnderscore,
	"ctrl+~":     gocui.KeyCtrlTilde,
	"ctrl+a":     gocui.KeyCtrlA,
	"ctrl+b":     gocui.KeyCtrlB,
	"ctrl+c":     gocui.KeyCtrlC,
	"ctrl+d":     gocui.KeyCtrlD,
	"ctrl+e":     gocui.KeyCtrlE,
	"ctrl+f":     gocui.KeyCtrlF,
	"ctrl+g":     gocui.KeyCtrlG,
	"ctrl+h":     gocui.KeyCtrlH,
	"ctrl+i":     gocui.KeyCtrlI,
	"ctrl+j":     gocui.KeyCtrlJ,
	"ctrl+k":     gocui.KeyCtrlK,
	"ctrl+l":     gocui.KeyCtrlL,
	"ctrl+m":     gocui.KeyCtrlM,
	"ctrl+n":     gocui.KeyCtrlN,
	"ctrl+o":     gocui.KeyCtrlO,
	"ctrl+p":     gocui.KeyCtrlP,
	"ctrl+q":     gocui.KeyCtrlQ,
	"ctrl+r":     gocui.KeyCtrlR,
	"ctrl+s":     gocui.KeyCtrlS,
	"ctrl+t":     gocui.KeyCtrlT,
	"ctrl+u":     gocui.KeyCtrlU,
	"ctrl+v":     gocui.KeyCtrlV,
	"ctrl+w":     gocui.KeyCtrlW,
	"ctrl+x":     gocui.KeyCtrlX,
	"ctrl+y":     gocui.KeyCtrlY,
	"ctrl+z":     gocui.KeyCtrlZ,
	"esc":        gocui.KeyEsc,
	"f1":         gocui.KeyF1,
	"f2":         gocui.KeyF2,
	"f3":         gocui.KeyF3,
	"f4":         gocui.KeyF4,
	"f5":         gocui.KeyF5,
	"f6":         gocui.KeyF6,
	"f7":         gocui.KeyF7,
	"f8":         gocui.KeyF8,
	"f9":         gocui.KeyF9,
	"f10":        gocui.KeyF10,
	"f11":        gocui.KeyF11,
	"f12":        gocui.KeyF12,
	"enter":      gocui.KeyEnter,
}

StrToKey maps a string representing they key to a gocui key

Functions

func AddHandler

func AddHandler(hnd KeyHandler)

AddHandler Adds a keybinding handler for use in Bind

func Bind

func Bind(g *gocui.Gui) error

Bind sets up key bindings for AzBrowse

func GetKeyBindingsAsStrings

func GetKeyBindingsAsStrings() map[string]string

GetKeyBindingsAsStrings provides a map of Handler->Key in string format

Types

type CopyHandler

type CopyHandler struct {
	GlobalHandler
	Content   *views.ItemWidget
	StatusBar *views.StatusbarWidget
}

//////////////////////////////////////////////////////////////////

func NewCopyHandler

func NewCopyHandler(content *views.ItemWidget, statusbar *views.StatusbarWidget) *CopyHandler

func (CopyHandler) Fn

func (h CopyHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type FullscreenHandler

type FullscreenHandler struct {
	GlobalHandler
	List         *views.ListWidget
	IsFullscreen *bool
	Content      *views.ItemWidget
}

//////////////////////////////////////////////////////////////////

func NewFullscreenHandler

func NewFullscreenHandler(list *views.ListWidget, content *views.ItemWidget, isFullscreen *bool) *FullscreenHandler

func (FullscreenHandler) Fn

func (h FullscreenHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type GlobalHandler

type GlobalHandler struct {
	KeyHandlerBase
}

GlobalHandler is a parent struct for all key handlers not tied to a specific view.

func (GlobalHandler) Widget

func (h GlobalHandler) Widget() string

Widget returns the name of the widget this handler binds to

type HelpHandler

type HelpHandler struct {
	GlobalHandler
	ShowHelp *bool
}

//////////////////////////////////////////////////////////////////

func NewHelpHandler

func NewHelpHandler(showHelp *bool) *HelpHandler

func (HelpHandler) Fn

func (h HelpHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ItemBackHandler

type ItemBackHandler struct {
	ItemHandler
	List *views.ListWidget
}

//////////////////////////////////////////////////////////////////

func NewItemBackHandler

func NewItemBackHandler(list *views.ListWidget) *ItemBackHandler

func (ItemBackHandler) Fn

func (h ItemBackHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ItemHandler

type ItemHandler struct {
	KeyHandlerBase
}

ItemHandler is a parent struct for all key handlers tied to the item widget view

func (ItemHandler) Widget

func (h ItemHandler) Widget() string

Widget returns the name of the widget this handler binds to

type ItemLeftHandler

type ItemLeftHandler struct {
	ItemHandler
	EditModeEnabled *bool
}

//////////////////////////////////////////////////////////////////

func NewItemLeftHandler

func NewItemLeftHandler(editModeEnabled *bool) *ItemLeftHandler

func (ItemLeftHandler) Fn

func (h ItemLeftHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type KeyHandler

type KeyHandler interface {
	ID() string
	Fn() func(g *gocui.Gui, v *gocui.View) error
	Widget() string

	DefaultKey() gocui.Key
}

KeyHandler is an interface that all key handlers must implement

type KeyHandlerBase

type KeyHandlerBase struct {
	Index uint16
}

KeyHandlerBase A base structure that will return the associated handler id from the HandlersId array and a default key for the handler.

func (KeyHandlerBase) DefaultKey

func (h KeyHandlerBase) DefaultKey() gocui.Key

DefaultKey returns the default key mapped to the handler

func (KeyHandlerBase) ID added in v1.1.50

func (h KeyHandlerBase) ID() string

ID returns the name of this item for example "listup"

type KeyMap

type KeyMap map[string]gocui.Key

KeyMap reprsents the current mappings from Handler -> Key

type ListActionsHandler

type ListActionsHandler struct {
	ListHandler
	List    *views.ListWidget
	Context context.Context
}

//////////////////////////////////////////////////////////////////

func NewListActionsHandler

func NewListActionsHandler(list *views.ListWidget, context context.Context) *ListActionsHandler

func (ListActionsHandler) Fn

func (h ListActionsHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListBackHandler

type ListBackHandler struct {
	ListHandler
	List *views.ListWidget
}

//////////////////////////////////////////////////////////////////

func NewListBackHandler

func NewListBackHandler(list *views.ListWidget) *ListBackHandler

func (ListBackHandler) Fn

func (h ListBackHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListBackLegacyHandler

type ListBackLegacyHandler struct {
	ListHandler
	List *views.ListWidget
}

//////////////////////////////////////////////////////////////////

func NewListBackLegacyHandler

func NewListBackLegacyHandler(list *views.ListWidget) *ListBackLegacyHandler

func (ListBackLegacyHandler) Fn

func (h ListBackLegacyHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListDeleteHandler

type ListDeleteHandler struct {
	ListHandler
	DeleteConfirmItemID string
	DeleteConfirmCount  int
	StatusBar           *views.StatusbarWidget
	Content             *views.ItemWidget
	List                *views.ListWidget
	Context             context.Context
}

//////////////////////////////////////////////////////////////////

func NewListDeleteHandler

func NewListDeleteHandler(content *views.ItemWidget,
	statusbar *views.StatusbarWidget,
	list *views.ListWidget,
	deleteConfirmItemId string,
	deleteConfirmCount int,
	context context.Context) *ListDeleteHandler

func (ListDeleteHandler) Fn

func (h ListDeleteHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListDownHandler

type ListDownHandler struct {
	ListHandler
	List *views.ListWidget
}

//////////////////////////////////////////////////////////////////

func NewListDownHandler

func NewListDownHandler(list *views.ListWidget) *ListDownHandler

func (ListDownHandler) Fn

func (h ListDownHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListEditHandler

type ListEditHandler struct {
	ListHandler
	List            *views.ListWidget
	EditModeEnabled *bool
}

//////////////////////////////////////////////////////////////////

func NewListEditHandler

func NewListEditHandler(list *views.ListWidget, editModeEnabled *bool) *ListEditHandler

func (ListEditHandler) Fn

func (h ListEditHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListEndHandler added in v1.1.104

type ListEndHandler struct {
	ListHandler
	List *views.ListWidget
}

/////////////////////////////////////////////////////////////////

func NewListEndHandler added in v1.1.104

func NewListEndHandler(list *views.ListWidget) *ListEndHandler

func (ListEndHandler) Fn added in v1.1.104

func (h ListEndHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListExpandHandler

type ListExpandHandler struct {
	ListHandler
	List *views.ListWidget
}

//////////////////////////////////////////////////////////////////

func NewListExpandHandler

func NewListExpandHandler(list *views.ListWidget) *ListExpandHandler

func (ListExpandHandler) Fn

func (h ListExpandHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListHandler

type ListHandler struct {
	KeyHandlerBase
}

ListHandler is a parent struct for all key handlers tied to the list widget view

func (ListHandler) Widget

func (h ListHandler) Widget() string

Widget returns the name of the widget this handler binds to

type ListHomeHandler added in v1.1.104

type ListHomeHandler struct {
	ListHandler
	List *views.ListWidget
}

/////////////////////////////////////////////////////////////////

func NewListHomeHandler added in v1.1.104

func NewListHomeHandler(list *views.ListWidget) *ListHomeHandler

func (ListHomeHandler) Fn added in v1.1.104

func (h ListHomeHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListOpenHandler

type ListOpenHandler struct {
	ListHandler
	List    *views.ListWidget
	Context context.Context
}

//////////////////////////////////////////////////////////////////

func NewListOpenHandler

func NewListOpenHandler(list *views.ListWidget, context context.Context) *ListOpenHandler

func (ListOpenHandler) Fn

func (h ListOpenHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListPageDownHandler added in v1.1.104

type ListPageDownHandler struct {
	ListHandler
	List *views.ListWidget
}

/////////////////////////////////////////////////////////////////

func NewListPageDownHandler added in v1.1.104

func NewListPageDownHandler(list *views.ListWidget) *ListPageDownHandler

func (ListPageDownHandler) Fn added in v1.1.104

func (h ListPageDownHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListPageUpHandler added in v1.1.104

type ListPageUpHandler struct {
	ListHandler
	List *views.ListWidget
}

/////////////////////////////////////////////////////////////////

func NewListPageUpHandler added in v1.1.104

func NewListPageUpHandler(list *views.ListWidget) *ListPageUpHandler

func (ListPageUpHandler) Fn added in v1.1.104

func (h ListPageUpHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListRefreshHandler

type ListRefreshHandler struct {
	ListHandler
	List *views.ListWidget
}

//////////////////////////////////////////////////////////////////

func NewListRefreshHandler

func NewListRefreshHandler(list *views.ListWidget) *ListRefreshHandler

func (ListRefreshHandler) Fn

func (h ListRefreshHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListRightHandler

type ListRightHandler struct {
	ListHandler
	List            *views.ListWidget
	EditModeEnabled *bool
}

//////////////////////////////////////////////////////////////////

func NewListRightHandler

func NewListRightHandler(list *views.ListWidget, editModeEnabled *bool) *ListRightHandler

func (ListRightHandler) Fn

func (h ListRightHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListUpHandler

type ListUpHandler struct {
	ListHandler
	List *views.ListWidget
}

//////////////////////////////////////////////////////////////////

func NewListUpHandler

func NewListUpHandler(list *views.ListWidget) *ListUpHandler

func (ListUpHandler) Fn

func (h ListUpHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type ListUpdateHandler

type ListUpdateHandler struct {
	ListHandler
	List *views.ListWidget

	Context context.Context
	Content *views.ItemWidget
	// contains filtered or unexported fields
}

//////////////////////////////////////////////////////////////////

func NewListUpdateHandler

func NewListUpdateHandler(list *views.ListWidget, statusbar *views.StatusbarWidget, ctx context.Context, content *views.ItemWidget) *ListUpdateHandler

func (ListUpdateHandler) Fn

func (h ListUpdateHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

type QuitHandler

type QuitHandler struct {
	GlobalHandler
}

//////////////////////////////////////////////////////////////////

func NewQuitHandler

func NewQuitHandler() *QuitHandler

func (QuitHandler) Fn

func (h QuitHandler) Fn() func(g *gocui.Gui, v *gocui.View) error

Jump to

Keyboard shortcuts

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