本文整理汇总了Golang中github.com/jroimartin/gocui.View类的典型用法代码示例。如果您正苦于以下问题:Golang View类的具体用法?Golang View怎么用?Golang View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了View类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: removeProject
func removeProject(g *gocui.Gui, v *gocui.View) error {
var l string
var err error
g.ShowCursor = false
_, cy := v.Cursor()
if l, err = v.Line(cy); err != nil {
l = ""
}
current_name = l
maxX, maxY := g.Size()
length := 20
if l != "" {
if v, err := g.SetView("del_proj", maxX/2-length/2, maxY/2, maxX/2+length/2, maxY/2+2); err != nil {
v.BgColor = gocui.ColorRed
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(v, "Press 'd' to delete")
setView(g, "del_proj")
}
}
return nil
}
开发者ID:mkrapp,项目名称:go-watch,代码行数:26,代码来源:go-watch.go
示例2: changeHost
func changeHost(g *gocui.Gui, v *gocui.View) error {
if err := g.DeleteView("summary"); err != nil {
return err
}
if err := g.DeleteView("detail"); err != nil {
return err
}
_, cy := v.Cursor()
l, err := v.Line(cy)
if err != nil {
return err
}
serverName := strings.TrimSpace(l)
for _, r := range scanHistory.ScanResults {
if serverName == strings.TrimSpace(r.ServerInfoTui()) {
currentScanResult = r
break
}
}
if err := setSummaryLayout(g); err != nil {
return err
}
if err := setDetailLayout(g); err != nil {
return err
}
return nil
}
开发者ID:Rompei,项目名称:vuls,代码行数:31,代码来源:tui.go
示例3: Handle
func Handle(
stdHandler *std.StdHandler,
travianHandler *travian.TravianHandler,
trav *travian.Game,
ui *console.GUI,
v *gocui.View) error {
command := strings.Trim(v.Buffer(), "\n\r ")
parsedCmd, _ := shellwords.Parse(command)
if len(command) == 0 {
return nil
}
if exists := stdHandler.Handle(parsedCmd, ui); exists {
} else if exists := travianHandler.Handle(parsedCmd, trav, ui); exists {
} else {
ui.Println("Command not found")
}
v.Clear() // clears input view's input buffer
return nil
}
开发者ID:hojgr,项目名称:cook,代码行数:27,代码来源:handler.go
示例4: saveMain
func saveMain(g *gocui.Gui, v *gocui.View) error {
f, err := ioutil.TempFile("", "gocui_demo_")
if err != nil {
return err
}
defer f.Close()
p := make([]byte, 5)
v.Rewind()
for {
n, err := v.Read(p)
if n > 0 {
if _, err := f.Write(p[:n]); err != nil {
return err
}
}
if err == io.EOF {
break
}
if err != nil {
return err
}
}
return nil
}
开发者ID:jroimartin,项目名称:gocui,代码行数:25,代码来源:demo.go
示例5: removeTrackCommand
func removeTrackCommand(g *gocui.Gui, v *gocui.View) error {
switch v.Name() {
case VIEW_PLAYLISTS:
if playlist := gui.getSelectedPlaylist(); playlist != nil {
playlists.Remove(playlist.Name())
gui.updatePlaylistsView()
gui.updateTracksView()
}
case VIEW_TRACKS:
if playlist, index := gui.getSelectedPlaylistAndTrack(); index > -1 {
for i := 1; i <= getOffsetFromTypedNumbers(); i++ {
playlist.RemoveTrack(index)
}
gui.updateTracksView()
goTo(g, v, index+1)
}
case VIEW_QUEUE:
if index := gui.getQueueSelectedTrackIndex(); index > -1 {
for i := 1; i <= getOffsetFromTypedNumbers(); i++ {
if queue.Remove(index) != nil {
continue
}
}
gui.updateQueueView()
}
}
return nil
}
开发者ID:ialbors,项目名称:sconsify,代码行数:28,代码来源:cui_actions.go
示例6: codeComplete
func codeComplete(g *gocui.Gui, v *gocui.View) error {
if v != nil {
ox, oy := v.Origin()
cx, cy := v.Cursor()
x, y := ox+cx, oy+cy
f := proj.GetFile("test.go")
off := f.GetOffset(x, y)
cands := codecomplete.Complete(proj, f, off)
maxX, maxY := g.Size()
maxY = maxY/2 - (len(cands) / 2)
if v, err := g.SetView("msg", maxX/2-30, maxY, maxX/2+30, maxY+len(cands)+2); err != nil {
if err != gocui.ErrorUnkView {
return err
}
fmt.Fprintln(v, x, y, off)
for _, c := range cands {
fmt.Fprintln(v, c.Name, c.Perc)
}
if err := g.SetCurrentView("msg"); err != nil {
return err
}
}
}
return nil
}
开发者ID:YouROK,项目名称:GoProjectManager,代码行数:29,代码来源:edit.go
示例7: PrintTubeList
func PrintTubeList(v *gocui.View) {
line := fmt.Sprintf("%-35s %-22s %-22s", "Tube", "ready/delayed/buried", "waiting/watching/using")
fmt.Fprintln(v, line)
//Reload the tube stats - will detect new tubes and drop removed tubes
cTubes.UseAll()
//Calculate the size for paging
_, vy := v.Size()
cTubes.Pages = int(math.Ceil(float64(len(cTubes.Conns)) / float64(vy-1)))
offset := vy * (cTubes.Page - 1)
limit := vy * cTubes.Page
if limit > len(cTubes.Conns) {
limit = len(cTubes.Conns)
}
displayed := cTubes.Conns[offset:limit]
for _, tube := range displayed {
stats, _ := tube.Stats()
jobStats := stats["current-jobs-ready"] + " / " + stats["current-jobs-delayed"] + " / " + stats["current-jobs-buried"]
workerStats := stats["current-waiting"] + " / " + stats["current-watching"] + " / " + stats["current-using"]
line := fmt.Sprintf("%-35s %-22s %-22s", tube.Name, jobStats, workerStats)
fmt.Fprintln(v, line)
}
}
开发者ID:george-infinity,项目名称:bsw,代码行数:25,代码来源:views.go
示例8: nextView
func nextView(g *gocui.Gui, v *gocui.View) error {
if v == nil {
return g.SetCurrentView(vPlatforms)
}
getLine(g, v)
switch v.Name() {
case vPlatforms:
return g.SetCurrentView(vTranscripts)
case vTranscripts:
return g.SetCurrentView(vDestinations)
case vDestinations:
if x, err := g.View(vTop); err == nil {
x.Clear()
fmt.Fprintf(x, "Hit enter to submit selections")
}
return g.SetCurrentView(vSubmit)
case vSubmit:
return g.SetCurrentView(vText)
case vText:
return g.SetCurrentView(vPlatforms)
}
return g.SetCurrentView(vPlatforms)
}
开发者ID:metalogic-software,项目名称:go-examples,代码行数:25,代码来源:main.go
示例9: CreateViews
func (c *column) CreateViews(g *gocui.Gui, colv *gocui.View) error {
if c.isActive {
colv.FgColor = gocui.ColorCyan | gocui.AttrBold
} else {
colv.FgColor = gocui.ColorDefault
}
x, y, maxX, maxY, err := g.ViewPosition(colv.Name())
y = y + 2
if err != nil {
return err
}
maxIssues := maxY / LinesPerEntry
c.maxIssues = maxIssues
for i := 0; i < maxIssues; i++ {
v, err := g.SetView(fmt.Sprintf("col-%s-%d", c.name, i),
x, y+(i*LinesPerEntry), maxX, y+((i+1)*LinesPerEntry))
if err != nil {
if err != gocui.ErrorUnkView {
return err
}
}
v.SelBgColor = gocui.ColorRed
v.Frame = false
v.Wrap = true
}
return c.redraw(g)
}
开发者ID:pombredanne,项目名称:stroop,代码行数:27,代码来源:column.go
示例10: draw
func (self *stack) draw(v *gocui.View, refresh bool) {
if refresh {
self.written = false
}
if self.written {
return
}
v.Clear()
self.sx, self.sy = v.Size()
blob := self.contents[self.bump:]
for off, b := range blob {
cur := self.lastaddr + uint16(off) + uint16(self.bump)
if off%2 == 0 {
if cur == self.lastsp {
fmt.Fprintf(v, "%0.4x:>> ", cur)
} else {
fmt.Fprintf(v, "%0.4x: ", cur)
}
fmt.Fprintf(v, "%0.2x", b)
} else {
fmt.Fprintf(v, "%0.2x\n", b)
}
}
self.written = true
}
开发者ID:ketchupsalt,项目名称:debugger,代码行数:32,代码来源:stack.go
示例11: 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
示例12: cursorMoveTop
func cursorMoveTop(g *gocui.Gui, v *gocui.View) error {
if v != nil {
cx, _ := v.Cursor()
v.SetCursor(cx, 0)
}
onMovingCursorRedrawView(g, v)
return nil
}
开发者ID:Rompei,项目名称:vuls,代码行数:8,代码来源:tui.go
示例13: toggleButton
func toggleButton(g *gocui.Gui, v *gocui.View) error {
nextview := "butdown"
if v != nil && v.Name() == "butdown" {
nextview = "butup"
}
_, err := g.SetCurrentView(nextview)
return err
}
开发者ID:jroimartin,项目名称:gocui,代码行数:8,代码来源:widgets.go
示例14: nextView
func nextView(g *gocui.Gui, v *gocui.View) error {
if v == nil || v.Name() == "side" {
_, err := g.SetCurrentView("main")
return err
}
_, err := g.SetCurrentView("side")
return err
}
开发者ID:jroimartin,项目名称:gocui,代码行数:8,代码来源:demo.go
示例15: confirmStringDetail
func (runner *appRunner) confirmStringDetail(gui *gocui.Gui, view *gocui.View) error {
text := strings.TrimSpace(view.Buffer())
runner.activeStringDetailController.Confirm(text)
runner.restoreMainView()
runner.gui.DeleteView(view.Name())
return nil
}
开发者ID:inkyblackness,项目名称:shocked-client,代码行数:8,代码来源:Run.go
示例16: platformsMenuDown
func platformsMenuDown(g *gocui.Gui, v *gocui.View) error {
length := 3
_, cy := v.Cursor()
_, oy := v.Origin()
if cy+oy < length-1 {
return menuDown(g, v)
}
return nil
}
开发者ID:metalogic-software,项目名称:go-examples,代码行数:9,代码来源:main.go
示例17: transcriptsMenuDown
func transcriptsMenuDown(g *gocui.Gui, v *gocui.View) error {
length := 5
_, cy := v.Cursor()
_, oy := v.Origin()
if cy+oy < length-1 {
return menuDown(g, v)
}
return nil
}
开发者ID:metalogic-software,项目名称:go-examples,代码行数:9,代码来源:main.go
示例18: destinationsMenuDown
func destinationsMenuDown(g *gocui.Gui, v *gocui.View) error {
length := 9
_, cy := v.Cursor()
_, oy := v.Origin()
if cy+oy < length-1 {
return menuDown(g, v)
}
return nil
}
开发者ID:metalogic-software,项目名称:go-examples,代码行数:9,代码来源:main.go
示例19: next
func next(g *ui.Gui, v *ui.View) error {
cx, cy := v.Cursor()
if cy+1 >= len(cli.Nodes) {
return nil
}
err := v.SetCursor(cx, cy+1)
printNodes()
printNode(g)
return err
}
开发者ID:cswank,项目名称:quimby,代码行数:10,代码来源:main.go
示例20: FocusInputView
func FocusInputView(g *gocui.Gui, v *gocui.View) error {
v.SetCursor(len(v.Buffer()+"")-1, 0)
if _, err := g.SetCurrentView("input"); err != nil {
return err
}
return nil
}
开发者ID:mephux,项目名称:komanda-cli,代码行数:10,代码来源:util.go
注:本文中的github.com/jroimartin/gocui.View类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论