keybindings

package
v1.0.253 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2019 License: MIT Imports: 15 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,
}

Theses 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",
}

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",
}
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,
}

Functions

func AddHandler

func AddHandler(hnd KeyHandler)

func Bind

func Bind(g *gocui.Gui) error

func BindWithFileOverrides

func BindWithFileOverrides(g *gocui.Gui, filePath string) error

func GetKeyBindingsAsStrings

func GetKeyBindingsAsStrings() map[string]string

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
}

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

func (GlobalHandler) Widget

func (h GlobalHandler) Widget() string

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
}

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

func (ItemHandler) Widget

func (h ItemHandler) Widget() string

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
}

The KeyHandler interface that all key handlers must implement

type KeyHandlerBase

type KeyHandlerBase struct {
	Index uint16
}

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

func (KeyHandlerBase) Id

func (h KeyHandlerBase) Id() string

type KeyMap

type KeyMap map[string]gocui.Key

func GetKeyBindings

func GetKeyBindings() KeyMap

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 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
}

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

func (ListHandler) Widget

func (h ListHandler) Widget() string

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 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