本文整理汇总了Golang中github.com/deweerdt/gocui.Gui.SetKeybinding方法的典型用法代码示例。如果您正苦于以下问题:Golang Gui.SetKeybinding方法的具体用法?Golang Gui.SetKeybinding怎么用?Golang Gui.SetKeybinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/deweerdt/gocui.Gui
的用法示例。
在下文中一共展示了Gui.SetKeybinding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: keybindings
//.........这里部分代码省略.........
}
replyMessage := reply(false)
groupReplyMessage := reply(true)
pipeMessage := func(g *gocui.Gui, v *gocui.View) error {
m := amua.curMessage()
cmd := exec.Command(amua.ExtEditor(), m.path)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
setStatus("")
switchToMode(amua, g, MaildirMode)
err := g.Sync()
if err != nil {
log.Fatal(err)
}
/* exec a command, pipe the message there */
return nil
}
type keybinding struct {
key interface{}
fn gocui.KeybindingHandler
mod bool
}
bindings := map[string][]keybinding{
MAILDIR_VIEW: {
{gocui.KeyEnter, switchToModeInt(MessageMode), false},
{'c', switchToModeInt(KnownMaildirsMode), false},
{'v', switchToModeInt(MessageMimeMode), false},
{'q', quit, false},
{'d', deleteMessage, false},
{'u', undeleteMessage, false},
{'G', maildirAllDown(), false},
{'k', maildirMove(-1), false},
{gocui.KeyArrowUp, maildirMove(-1), false},
{'j', maildirMove(1), false},
{'n', search(true), false},
{'N', search(false), false},
{'$', syncMaildir, false},
{'F', toggleFlagged, false},
{gocui.KeyCtrlR, readMessage, false},
{gocui.KeyCtrlN, unreadMessage, false},
{gocui.KeyArrowDown, maildirMove(1), false},
{gocui.KeyCtrlF, maildirMove(10), false},
{gocui.KeyPgdn, maildirMove(10), false},
{gocui.KeyCtrlB, maildirMove(-10), false},
{gocui.KeyPgup, maildirMove(-10), false},
{'/', switchToModeInt(CommandSearchMode), false},
{'m', switchToModeInt(CommandNewMailMode), false},
{'r', replyMessage, false},
{'g', groupReplyMessage, false},
{'|', pipeMessage, false},
},
MESSAGE_VIEW: {
{'q', switchToModeInt(MaildirMode), false},
{'v', messageModeToggle, false},
{gocui.KeyPgup, scrollMessageView(-10), false},
{gocui.KeyPgdn, scrollMessageView(10), false},
{gocui.KeySpace, scrollMessageView(10), false},
{'j', scrollMessageView(1), false},
{'k', scrollMessageView(-1), false},
{'r', replyMessage, false},
{'g', groupReplyMessage, false},
{'|', pipeMessage, false},
},
SEND_MAIL_VIEW: {
{'q', switchToModeInt(MaildirMode), false},
{'t', switchToModeInt(CommandMailModeTo), false},
{'c', switchToModeInt(CommandMailModeCc), false},
{'b', switchToModeInt(CommandMailModeBcc), false},
{'y', sendMail, false},
{gocui.KeyCtrlG, switchToModeInt(MaildirMode), false},
},
STATUS_VIEW: {
{gocui.KeyEnter, commandEnter, false},
{gocui.KeyCtrlG, cancelSearch, false},
},
SIDE_VIEW: {
{'j', scrollSideView(amua, 1), false},
{gocui.KeyArrowDown, scrollSideView(amua, 1), false},
{'k', scrollSideView(amua, -1), false},
{gocui.KeyArrowUp, scrollSideView(amua, 1), false},
{gocui.KeyEnter, selectNewMaildir(amua), false},
},
"": {
{gocui.KeyCtrlC, quit, false},
},
}
for vn, binds := range bindings {
for _, b := range binds {
err := g.SetKeybinding(vn, b.key, gocui.ModNone, b.fn)
if err != nil {
return err
}
}
}
return nil
}