当前位置: 首页>>代码示例>>Golang>>正文


Golang Gui.SetKeybinding方法代码示例

本文整理汇总了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
}
开发者ID:deweerdt,项目名称:amua,代码行数:101,代码来源:amua.go


注:本文中的github.com/deweerdt/gocui.Gui.SetKeybinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。