• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang gocui.Gui类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/deweerdt/gocui.Gui的典型用法代码示例。如果您正苦于以下问题:Golang Gui类的具体用法?Golang Gui怎么用?Golang Gui使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Gui类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: switchToMode

func switchToMode(amua *Amua, g *gocui.Gui, mode Mode) error {
	/* highlight off */
	if amua.mode.IsHighlighted() {
		v := modeToView(g, amua.mode)
		v.Highlight = false
	}
	amua.prevMode = amua.mode
	amua.mode = mode
	curview := modeToViewStr(amua.mode)
	var err error
	switch amua.mode {
	case MessageMode:
		m := amua.curMessage()
		m.Flags |= Seen
		err = m.Draw(amua, g)
	case MessageMimeMode:
		m := amua.curMessage()
		err = (*MessageAsMimeTree)(m).Draw(amua, g)
	case MaildirMode:
		v, _ := g.View(curview)
		err = amua.curMaildirView.Draw(v)
	case SendMailMode:
		v, _ := g.View(curview)
		err = amua.sendMailDraw(v)
	case CommandNewMailMode:
		tos := util.ConcatAddresses(amua.newMail.to)
		amua.newMail.to = []*mail.Address{}
		displayPromptWithPrefill(TO_PROMPT, tos)
	case CommandMailModeTo:
		displayPromptWithPrefill(TO_PROMPT, util.ConcatAddresses(amua.newMail.to))
	case CommandMailModeCc:
		displayPromptWithPrefill(CC_PROMPT, util.ConcatAddresses(amua.newMail.cc))
	case CommandMailModeBcc:
		displayPromptWithPrefill(BCC_PROMPT, util.ConcatAddresses(amua.newMail.bcc))
	case CommandSearchMode:
		displayPrompt(SEARCH_PROMPT)
	}

	if err != nil {
		v, _ := g.View(curview)
		if v != nil {
			fmt.Fprintf(v, err.Error())
		}
		/* we printed the error, fallback */
	}
	_, err = g.SetViewOnTop(curview)
	if err != nil {
		return err
	}
	err = g.SetCurrentView(curview)
	if err != nil {
		return err
	}
	/* highlight back */
	if amua.mode.IsHighlighted() {
		v := modeToView(g, amua.mode)
		v.Highlight = true
	}
	return nil
}
开发者ID:deweerdt,项目名称:amua,代码行数:60,代码来源:amua.go


示例2: Draw

func (m *MessageAsText) Draw(amua *Amua, g *gocui.Gui) error {
	v, err := g.View(MESSAGE_VIEW)
	if err != nil {
		return err
	}
	v.Clear()
	v.Wrap = true
	v.SetOrigin(0, 0)

	_, err = io.Copy(v, m)
	if err != nil {
		return err
	}
	return nil

}
开发者ID:deweerdt,项目名称:amua,代码行数:16,代码来源:message.go


示例3: Draw

func (m *Message) Draw(amua *Amua, g *gocui.Gui) error {
	v, err := g.View(MESSAGE_VIEW)
	if err != nil {
		return err
	}
	v.Clear()
	v.Wrap = true
	v.SetOrigin(0, 0)

	colorstring.Fprintf(v, "[green]Subject: %s\n", m.Subject)
	colorstring.Fprintf(v, "[red]From: %s\n", m.From)
	colorstring.Fprintf(v, "[red]To: %s\n", m.To)
	colorstring.Fprintf(v, "[green]Date: %s\n", m.Date.Format("Mon, 2 Jan 2006 15:04:05 -0700"))
	fmt.Fprintf(v, "\n")
	_, err = io.Copy(v, m)
	if err != nil {
		return err
	}
	return nil

}
开发者ID:deweerdt,项目名称:amua,代码行数:21,代码来源:amua.go


示例4: drawSlider

func drawSlider(amua *Amua, g *gocui.Gui) {
	v, err := g.View(SLIDER_VIEW)
	if err != nil {
		return
	}
	v.Clear()
	_, h := v.Size()
	sliderH := 1
	whites := h - 1
	if len(amua.curMaildirView.md.messages) > 0 {
		sliderH = h * h / len(amua.curMaildirView.md.messages)
		whites = amua.curMaildirView.curTop * h / len(amua.curMaildirView.md.messages)
	}
	if sliderH <= 0 {
		sliderH = 1
	}
	for i := 0; i < whites; i++ {
		fmt.Fprintln(v, " ")
	}
	for i := 0; i < sliderH; i++ {
		fmt.Fprintln(v, "\u2588")
	}
}
开发者ID:deweerdt,项目名称:amua,代码行数:23,代码来源:amua.go


示例5: keybindings

func keybindings(amua *Amua, g *gocui.Gui) error {
	switchToModeInt := func(mode Mode) func(g *gocui.Gui, v *gocui.View) error {
		return func(g *gocui.Gui, v *gocui.View) error {
			return switchToMode(amua, g, mode)
		}
	}

	maildirMove := func(dy int) func(g *gocui.Gui, v *gocui.View) error {
		return func(g *gocui.Gui, v *gocui.View) error {
			amua.curMaildirView.scroll(v, dy)
			drawSlider(amua, g)
			return nil
		}
	}
	maildirAllDown := func() func(g *gocui.Gui, v *gocui.View) error {
		return func(g *gocui.Gui, v *gocui.View) error {
			dy := len(amua.curMaildirView.md.messages) - amua.curMaildirView.cur - 1
			amua.curMaildirView.scroll(v, dy)
			drawSlider(amua, g)
			return nil
		}
	}
	messageModeToggle := func(g *gocui.Gui, v *gocui.View) error {
		switch amua.mode {
		case MessageMode:
			switchToMode(amua, g, MessageMimeMode)
		case MessageMimeMode:
			switchToMode(amua, g, MessageMode)
		}
		return nil
	}
	search := func(forward bool) func(g *gocui.Gui, v *gocui.View) error {
		return func(g *gocui.Gui, v *gocui.View) error {
			setStatus("Looking for: " + amua.searchPattern + " in " + amua.curMaildirView.md.path)
			found := false
			direction := 1
			if forward == false {
				direction = -1
			}
			for i := 0; i < len(amua.curMaildirView.md.messages); i++ {
				idx := ((direction * i) + amua.curMaildirView.cur + direction) % len(amua.curMaildirView.md.messages)
				if idx < 0 {
					idx = len(amua.curMaildirView.md.messages) + idx
				}
				if idx < 0 {
					panic(idx)
				}
				m := amua.getMessage(idx)
				if strings.Contains(m.Subject, amua.searchPattern) {
					setStatus("Found: " + amua.searchPattern + " in " + amua.curMaildirView.md.path)
					found = true
					amua.curMaildirView.curTop = idx
					amua.curMaildirView.cur = idx
					break
				}
			}
			if found {
				mv, err := g.View(MAILDIR_VIEW)
				if err != nil {
					return err
				}
				err = amua.curMaildirView.Draw(mv)
				if err != nil {
					setStatus(err.Error())
				}
			} else {
				setStatus(amua.searchPattern + " not found")
			}
			return nil
		}
	}
	enterSearch := func(forward bool) func(g *gocui.Gui, v *gocui.View) error {
		return func(g *gocui.Gui, v *gocui.View) error {
			v.Rewind()
			spbuf, err := ioutil.ReadAll(v)
			if err != nil {
				return err
			}
			prompt := amua.prompt
			amua.searchPattern = strings.TrimSpace(string(spbuf[len(prompt):]))
			switchToMode(amua, g, MaildirMode)
			search(forward)(g, v)
			return nil
		}
	}
	cancelSearch := func(g *gocui.Gui, v *gocui.View) error {
		setStatus("")
		return switchToMode(amua, g, amua.prevMode)
	}
	setFlag := func(flag MessageFlags) func(g *gocui.Gui, v *gocui.View) error {
		return func(g *gocui.Gui, v *gocui.View) error {
			m := amua.curMessage()
			m.Flags |= flag
			amua.curMaildirView.Draw(v)
			return nil
		}
	}
	unsetFlag := func(flag MessageFlags) func(g *gocui.Gui, v *gocui.View) error {
		return func(g *gocui.Gui, v *gocui.View) error {
			m := amua.curMessage()
//.........这里部分代码省略.........
开发者ID:deweerdt,项目名称:amua,代码行数:101,代码来源:amua.go


示例6: modeToView

func modeToView(g *gocui.Gui, mode Mode) *gocui.View {
	v, _ := g.View(modeToViewStr(mode))
	return v
}
开发者ID:deweerdt,项目名称:amua,代码行数:4,代码来源:amua.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang ctxh.ContextHandlerFunc函数代码示例发布时间:2022-05-23
下一篇:
Golang gatt.Peripheral类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap