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


Golang View.SetOrigin方法代码示例

本文整理汇总了Golang中github.com/jroimartin/gocui.View.SetOrigin方法的典型用法代码示例。如果您正苦于以下问题:Golang View.SetOrigin方法的具体用法?Golang View.SetOrigin怎么用?Golang View.SetOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/jroimartin/gocui.View的用法示例。


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

示例1: textUp

func textUp(g *gocui.Gui, v *gocui.View) error {
	if v, err := g.View(vText); err == nil {
		ox, oy := v.Origin()
		oy = oy - 10
		v.SetOrigin(ox, oy)
	}
	return nil
}
开发者ID:metalogic-software,项目名称:go-examples,代码行数:8,代码来源:main.go

示例2: cursorHome

func cursorHome(g *gocui.Gui, v *gocui.View) error {
	ox, _ := v.Origin()
	cx, _ := v.Cursor()
	v.SetCursor(cx, 0)
	v.SetOrigin(ox, 0)

	updateTracksView(g, v)
	return nil
}
开发者ID:simonwoerpel,项目名称:sconsify,代码行数:9,代码来源:cui_navigation.go

示例3: scrollView

func scrollView(v *gocui.View, dy int) error {
	if v != nil {
		v.Autoscroll = false
		ox, oy := v.Origin()
		if err := v.SetOrigin(ox, oy+dy); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:jmptrader,项目名称:gocui,代码行数:10,代码来源:stdin.go

示例4: moveRight

func moveRight(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx+1, cy); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox+1, oy); err != nil {
				return err
			}
		}
	}
	return nil
}
开发者ID:thorncp,项目名称:hello-go,代码行数:12,代码来源:main.go

示例5: cursorLeft

func cursorLeft(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx-1, cy); err != nil && ox > 0 {
			if err := v.SetOrigin(ox-1, oy); err != nil {
				return err
			}
		}
	}
	return nil
}
开发者ID:balu-,项目名称:gocui,代码行数:12,代码来源:demo2.go

示例6: cursorDown

func cursorDown(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy+1); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+1); err != nil {
				return err
			}
		}
	}
	return nil
}
开发者ID:jroimartin,项目名称:gocui,代码行数:12,代码来源:demo.go

示例7: cursorUp

func cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
	}
	return nil
}
开发者ID:jroimartin,项目名称:gocui,代码行数:12,代码来源:demo.go

示例8: cursorUp

func cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && 0 < oy {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
	}
	onMovingCursorRedrawView(g, v)
	return nil
}
开发者ID:ymomoi,项目名称:vuls,代码行数:13,代码来源:tui.go

示例9: cursorUp

func (runner *appRunner) cursorUp(g *gocui.Gui, v *gocui.View) error {
	if v != nil {
		ox, oy := v.Origin()
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy-1); err != nil && oy > 0 {
			if err := v.SetOrigin(ox, oy-1); err != nil {
				return err
			}
		}
		runner.layout(g)
	}
	return nil
}
开发者ID:inkyblackness,项目名称:shocked-client,代码行数:13,代码来源:Run.go

示例10: cursorPageUp

func cursorPageUp(g *gocui.Gui, v *gocui.View) error {
	jump := pageUpDownJumpCount(v)
	if v != nil {
		cx, _ := v.Cursor()
		ox, oy := v.Origin()
		if err := v.SetOrigin(ox, oy-jump); err != nil {
			v.SetOrigin(ox, 0)
			v.SetCursor(cx, 0)

		}
		onMovingCursorRedrawView(g, v)
	}
	return nil
}
开发者ID:Rompei,项目名称:vuls,代码行数:14,代码来源:tui.go

示例11: moveDown

func moveDown(g *gocui.Gui, v *gocui.View) error {
	fmt.Println("yo")
	if v != nil {
		fmt.Println("hey")
		cx, cy := v.Cursor()
		if err := v.SetCursor(cx, cy+1); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+1); err != nil {
				return err
			}
		}
	}
	return nil
}
开发者ID:thorncp,项目名称:hello-go,代码行数:14,代码来源:main.go

示例12: cursorUp

func cursorUp(g *gocui.Gui, v *gocui.View) error {
	offset := getOffsetFromTypedNumbers()
	ox, oy := v.Origin()
	cx, cy := v.Cursor()
	if err := v.SetCursor(cx, cy-offset); err != nil && oy > 0 {
		if err := v.SetOrigin(ox, oy-offset); err != nil {
			return err
		}
	}
	if v == gui.playlistsView {
		gui.updateTracksView()
	}
	return nil
}
开发者ID:simonwoerpel,项目名称:sconsify,代码行数:14,代码来源:cui_navigation.go

示例13: cursorDown

func cursorDown(g *gocui.Gui, v *gocui.View) error {
	offset := getOffsetFromTypedNumbers()
	if cx, cy := v.Cursor(); canGoToNewPosition(cy + offset) {
		if err := v.SetCursor(cx, cy+offset); err != nil {
			ox, oy := v.Origin()
			if err := v.SetOrigin(ox, oy+offset); err != nil {
				return err
			}
		}
		if v == gui.playlistsView {
			gui.updateTracksView()
		}
	}
	return nil
}
开发者ID:simonwoerpel,项目名称:sconsify,代码行数:15,代码来源:cui_navigation.go

示例14: send

func send(g *gocui.Gui, v *gocui.View) error {
	v.SetOrigin(0, 0)
	message, err := v.Line(0)
	if err != nil {
		// We pressed enter and there's no text. Do nothing
		return nil
	}
	v.Clear()
	message = strings.Replace(message, string(0x00), "", -1) // Remove trailing 0x00
	if strings.TrimSpace(message) == "" {
		return nil
	}

	contacts := g.View("contacts")
	_, cy := contacts.Cursor()
	contact, err := contacts.Line(cy)
	if err != nil {
		return err
	}

	if message[0] == '/' {
		spl := strings.Split(message[1:], " ")
		if len(spl) == 0 {
			return nil
		}
		switch spl[0] {
		case "q":
			fallthrough
		case "quit":
			return gocui.ErrorQuit
		default:
			display(g, contact, fmt.Sprintf("! Unknown command: %#v", message))
		}
	} else {
		contacts := g.View("contacts")
		_, cy := contacts.Cursor()
		contact, err := contacts.Line(cy)
		if err != nil {
			return err
		}
		if contact != "Home" {
			displayTimestamped(g, contact, message)
			sendMessage(contact, message)
		}
	}

	return nil
}
开发者ID:garry415,项目名称:goax,代码行数:48,代码来源:ui.go

示例15: cursorPgup

func cursorPgup(g *gocui.Gui, v *gocui.View) error {
	ox, oy := v.Origin()
	cx, cy := v.Cursor()
	_, pageSizeY := v.Size()
	pageSizeY--

	if newOriginY := oy - pageSizeY; newOriginY > 0 {
		v.SetOrigin(ox, newOriginY)
		v.SetCursor(cx, cy)
	} else {
		v.SetOrigin(ox, 0)
		v.SetCursor(cx, cy)
	}
	updateTracksView(g, v)
	return nil
}
开发者ID:simonwoerpel,项目名称:sconsify,代码行数:16,代码来源:cui_navigation.go


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