當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。