本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}