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


Golang View.Line方法代码示例

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


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

示例1: 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

示例2: getLine

func getLine(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 = ""
	}

	maxX, maxY := g.Size()
	length := 10 + len(current_name)
	if l != "" {
		current_name = l
		if v, err := g.SetView("msg", maxX/2-length/2, maxY/2-3, maxX/2+length/2, maxY/2+3); err != nil {
			v.BgColor = gocui.ColorGreen
			v.FgColor = gocui.ColorBlack
			if err != gocui.ErrorUnkView {
				return err
			}
			current_proj = projects[current_name]
			current_proj.start()
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, strings.Repeat(" ", (length-15)/2), "Active Project")
			fmt.Fprintln(v, "")
			fmt.Fprintln(v, strings.Repeat(" ", 5), current_name)
			fmt.Fprintln(v, "")
			setView(g, "msg")
		}
	}
	return nil
}
开发者ID:mkrapp,项目名称:go-watch,代码行数:34,代码来源:go-watch.go

示例3: 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

示例4: getLine

func getLine(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

	_, cy := v.Cursor()
	if l, err = v.Line(cy); err != nil {
		l = ""
	}

	maxX, maxY := g.Size()
	if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		fmt.Fprintln(v, l)
		if err := g.SetCurrentView("msg"); err != nil {
			return err
		}
	}

	if v, err := g.View("main"); err != nil {
		if err != gocui.ErrorUnkView {
			return err
		}
		f := proj.GetFile(l)
		if f != nil {
			v.Clear()
			fmt.Fprintf(v, "%s", f.GetBody())
		}
		v.Editable = true
		v.Wrap = true
	}
	return nil
}
开发者ID:YouROK,项目名称:GoProjectManager,代码行数:34,代码来源:edit.go

示例5: getSelected

func (gui *Gui) getSelected(v *gocui.View) (string, error) {
	var l string
	var err error

	_, cy := v.Cursor()
	if l, err = v.Line(cy); err != nil {
		l = ""
	}

	return l, err
}
开发者ID:rdbrdd,项目名称:sconsify,代码行数:11,代码来源:cui.go

示例6: selectChannel

func selectChannel(g *gocui.Gui, v *gocui.View, token string, getChannelIdChan chan<- ChannelIdRequest, getUserNameChan chan<- UserNameRequest, getMessagesChan chan<- MessageRequest) error {
	log.Println("selectChannel called")
	_, cy := v.Cursor()
	channel, err := v.Line(cy)
	if err != nil {
		log.Println("selectChannel returning err")
		return err
	}
	log.Println("selectChannel calling getChannelId with " + channel)
	channelId := GetChannelId(channel, getChannelIdChan)
	log.Println("selectChannel calling populateMessages")
	err = populateMessages(g, token, channelId, getUserNameChan, getMessagesChan)
	log.Println("selectChannel returning")
	return err
}
开发者ID:robert-butts,项目名称:slackterm,代码行数:15,代码来源:gui.go

示例7: 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

示例8: readLine

func (gc *GuiClient) readLine(_ *gocui.Gui, v *gocui.View) error {
	// HACK: pressing enter on startup causes panic
	if len(v.Buffer()) == 0 {
		return nil
	}
	_, cy := v.Cursor()
	line, err := v.Line(cy - 1)
	if err != nil {
		return err
	}
	if line == "" {
		return nil
	}
	v.Clear()

	return gc.handleLine(line)
}
开发者ID:ak-67,项目名称:vuvuzela,代码行数:17,代码来源:gui.go

示例9: getLine

func getLine(g *gocui.Gui, v *gocui.View) error {
	var line string
	var err error

	_, cy := v.Cursor()
	if line, err = v.Line(cy); err != nil {
		line = ""
	}
	switch v.Name() {
	case vPlatforms:
		opt.platform = line
	case vTranscripts:
		opt.transcript = line
	case vDestinations:
		opt.destination = line
	}
	return err
}
开发者ID:metalogic-software,项目名称:go-examples,代码行数:18,代码来源:main.go

示例10: cursorDown

func cursorDown(g *gocui.Gui, v *gocui.View) error {
	var err error
	if v != nil {
		cx, cy := v.Cursor()
		if current_name, err = v.Line(cy + 1); err != nil {
			current_name = ""
		}
		if l, err := v.Line(cy + 2); err != nil && l == "" {
		} else {
			if err := v.SetCursor(cx, cy+1); err != nil {
				ox, oy := v.Origin()
				if err := v.SetOrigin(ox, oy+1); err != nil {
					return err
				}
			}
			updateProjInfo(g, v)
		}
	}
	return nil
}
开发者ID:mkrapp,项目名称:go-watch,代码行数:20,代码来源:go-watch.go

示例11: getLine

func getLine(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

	_, cy := v.Cursor()
	if l, err = v.Line(cy); err != nil {
		l = ""
	}

	maxX, maxY := g.Size()
	if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		fmt.Fprintln(v, l)
		if _, err := g.SetCurrentView("msg"); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:jroimartin,项目名称:gocui,代码行数:21,代码来源:demo.go

示例12: cursorDown

func cursorDown(g *gocui.Gui, v *gocui.View) error {
	if v == nil {
		return nil
	}
	cx, cy := v.Cursor()

	nextLine, err := v.Line(cy + 1)
	if err != nil {
		return err
	}
	if nextLine == "" {
		return nil
	}

	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:robert-butts,项目名称:slackterm,代码行数:22,代码来源:gui.go

示例13: showMsg

func showMsg(g *gocui.Gui, v *gocui.View) error {
	var l string
	var err error

	if err := g.SetCurrentView(v.Name()); err != nil {
		return err
	}

	_, cy := v.Cursor()
	if l, err = v.Line(cy); err != nil {
		l = ""
	}

	maxX, maxY := g.Size()
	if v, err := g.SetView("msg", maxX/2-10, maxY/2, maxX/2+10, maxY/2+2); err != nil {
		if err != gocui.ErrUnknownView {
			return err
		}
		fmt.Fprintln(v, l)
	}
	return nil
}
开发者ID:grafov,项目名称:gocui,代码行数:22,代码来源:mouse.go


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