本文整理汇总了Golang中github.com/jroimartin/gocui.View类的典型用法代码示例。如果您正苦于以下问题:Golang View类的具体用法?Golang View怎么用?Golang View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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)
}
}
示例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)
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}