コード例 #1
0
ファイル: main.go プロジェクト: plumbum/go-samples
func main() {

	err := ui.Init()
	if err != nil {
		panic(err)
	}
	defer ui.Close()

	w11 := ui.NewPar("Hello world")
	w11.Height = 10
	w11.Border.Label = "Hello"
	w11.Border.LabelFgColor = ui.ColorGreen

	w12 := ui.NewPar("first")
	w12.Height = 20

	w2 := ui.NewPar("second")
	w2.Height = 20

	ui.Body.AddRows(
		ui.NewRow(
			ui.NewCol(6, 0, w11),
			ui.NewCol(6, 0, w12)),
		ui.NewRow(
			ui.NewCol(12, 0, w2)))

	ui.Body.Align()

	ui.Render(ui.Body)

	<-ui.EventCh()

}
コード例 #2
0
ファイル: view.go プロジェクト: byrnedo/dockdash
func NewView() *View {

	var view = View{}

	view.Header = ui.NewPar("Containers")
	view.Header.Border = false
	view.Header.Text = " Dockdash - Interactive realtime container inspector"
	view.Header.Height = 2

	view.InfoBar = ui.NewPar("InfoBar")
	view.InfoBar.Border = false
	view.InfoBar.Text = ""
	view.InfoBar.Height = 2

	view.NameList = createContainerList()
	view.NameList.BorderLabel = "Name"

	view.InfoList = createContainerList()
	view.InfoList.BorderLabel = "Image"

	view.CpuChart = ui.NewBarChart()
	view.CpuChart.Border = true
	view.CpuChart.BorderLabel = "%CPU"
	view.CpuChart.BorderFg = ui.ColorBlack
	view.CpuChart.Height = 8

	view.MemChart = ui.NewBarChart()
	view.MemChart.Border = true
	view.MemChart.BorderLabel = "%MEM"
	view.MemChart.BorderFg = ui.ColorBlack
	view.MemChart.Height = 8
	return &view
}
コード例 #3
0
ファイル: editui.go プロジェクト: sqp/godock
// New creates a new edit info console GUI.
//
func New(log cdtype.Logger, packs packages.AppletPackages) *Editor {
	ed := &Editor{
		applets: termui.NewList(),
		fields:  termui.NewList(),
		appinfo: termui.NewList(),
		locked:  termui.NewPar(""),
		desc:    termui.NewPar(""),
		title:   termui.NewPar(infoText),
		packs:   packs,
		log:     log,
	}

	ed.applets.ItemFgColor = termui.ColorYellow
	ed.applets.BorderLabel = "[ Applets ]"
	ed.applets.Width = 20 // TODO autodetect.
	ed.applets.BorderBottom = false
	ed.applets.BorderFg = termui.ColorCyan

	ed.fields.BorderLabel = "[ Fields ]"
	ed.fields.X = ed.applets.Width
	ed.fields.Height = 6 + 2 + 2 // last 2 for blank lines around text
	ed.fields.Width = len(fields[1]) + 2
	ed.fields.BorderLeft = false
	ed.fields.BorderBottom = false
	ed.fields.BorderFg = termui.ColorCyan

	ed.appinfo.BorderLabel = "[ Value ]"
	ed.appinfo.X = ed.fields.X + ed.fields.Width
	ed.appinfo.Height = 6 + 2 + 2 // last 2 for blank lines around text
	ed.appinfo.BorderLeft = false
	ed.appinfo.BorderRight = false
	ed.appinfo.BorderBottom = false
	ed.appinfo.BorderFg = termui.ColorCyan

	ed.locked.BorderLabel = "[ Details ]"
	ed.locked.X = ed.applets.Width
	ed.locked.Y = ed.fields.Height - 1 // offset 1 for border
	ed.locked.Height = 6
	ed.locked.BorderBottom = false
	ed.locked.BorderLeft = false
	ed.locked.BorderRight = false
	ed.locked.BorderFg = termui.ColorCyan

	ed.desc.BorderLabel = "[ Description ]"
	ed.desc.X = ed.applets.Width
	ed.desc.BorderBottom = false
	ed.desc.BorderLeft = false
	ed.desc.BorderRight = false
	ed.desc.BorderFg = termui.ColorCyan

	ed.title.BorderLabel = "[ Edit applet info ]"
	ed.title.Height = 2
	ed.title.TextFgColor = termui.ColorWhite
	ed.title.BorderBottom = false
	ed.title.BorderLeft = false
	ed.title.BorderRight = false
	ed.title.BorderFg = termui.ColorCyan

	return ed
}
コード例 #4
0
ファイル: ui.go プロジェクト: bigwhoop/podcastd
func NewUi() Ui {
	headerWidget := termui.NewPar(fmt.Sprintf("podcastd v%s\nCopyright 2015 Philippe Gerber\nhttps://github.com/bigwhoop/podcastd", VERSION))
	headerWidget.Height = 5
	headerWidget.HasBorder = false
	headerWidget.PaddingTop = 1
	headerWidget.PaddingBottom = 1
	headerWidget.PaddingLeft = 1

	infoWidget := termui.NewPar("")
	infoWidget.HasBorder = false
	infoWidget.Text = fmt.Sprintf("Press 'q' to quit")

	feedsWidget := termui.NewList()
	feedsWidget.Border.Label = "Feeds"

	return Ui{
		termui.TermWidth(),
		headerWidget,
		infoWidget,
		feedsWidget,
		make(map[string]bool, 0),
		make([]*termui.Gauge, 0),
		make(map[string]curl.ProgressStatus, 0),
	}
}
コード例 #5
0
ファイル: ui_single.go プロジェクト: nordicdyno/twemon
// Init creates widgets, sets sizes and labels.
func (t *TermUISingle) Init(data UIData) error {
	err := termui.Init()
	if err != nil {
		return err
	}

	t.Sparklines = make(map[VarName]*termui.Sparkline)

	termui.UseTheme("helloworld")

	t.Title = func() *termui.Par {
		p := termui.NewPar("")
		p.Height = 3
		p.TextFgColor = termui.ColorWhite
		p.Border.Label = "Services Monitor"
		p.Border.FgColor = termui.ColorCyan
		return p
	}()
	t.Status = func() *termui.Par {
		p := termui.NewPar("")
		p.Height = 3
		p.TextFgColor = termui.ColorWhite
		p.Border.Label = "Status"
		p.Border.FgColor = termui.ColorCyan
		return p
	}()

	t.Pars = make([]*termui.Par, len(data.Vars))
	for i, name := range data.Vars {
		par := termui.NewPar("")
		par.TextFgColor = colorByKind(name.Kind())
		par.Border.Label = name.Short()
		par.Border.LabelFgColor = termui.ColorGreen
		par.Height = 3
		t.Pars[i] = par
	}

	var sparklines []termui.Sparkline
	for _, name := range data.Vars {
		spl := termui.NewSparkline()
		spl.Height = 1
		spl.TitleColor = colorByKind(name.Kind())
		spl.LineColor = colorByKind(name.Kind())
		spl.Title = name.Long()
		sparklines = append(sparklines, spl)
	}

	t.Sparkline = func() *termui.Sparklines {
		s := termui.NewSparklines(sparklines...)
		s.Height = 2*len(sparklines) + 2
		s.HasBorder = true
		s.Border.Label = fmt.Sprintf("Monitoring")
		return s
	}()

	t.Relayout()

	return nil
}
コード例 #6
0
func newTerminalUI(appName string) error {
	if err := ui.Init(); err != nil {
		return err
	}
	ui.UseTheme("helloworld")

	// usage text
	usageText := fmt.Sprintf(`Show live statistics for [%s]

:Press 'q' or 'ctrl-c' to exit
:Press 'PageUp' to increase app instances
:Press 'PageDown' to decrease app instances`, appName)
	usage := ui.NewPar(usageText)
	usage.Height = 12
	usage.TextFgColor = ui.ColorWhite
	usage.Border.Label = "Usage"
	usage.Border.FgColor = ui.ColorCyan

	// summary text
	summary := ui.NewPar("")
	summary.Height = 12
	summary.TextFgColor = ui.ColorRed
	summary.Border.Label = "Summary"
	summary.Border.FgColor = ui.ColorCyan

	// cpu sparklines
	data := [400]int{}
	line := ui.NewSparkline()
	line.Data = data[:]
	line.Height = 4
	line.LineColor = colors[0]
	cpu := ui.NewSparklines(line)
	cpu.Height = 7
	cpu.Border.Label = "CPU Usage"

	// memory gauges
	mem := make([]*ui.Gauge, 1)
	for i := range mem {
		mem[i] = ui.NewGauge()
		mem[i].Percent = 0
		mem[i].Height = 5
	}

	// disk bars
	disk := ui.NewBarChart()
	disk.Border.Label = "Disk Usage (in MB)"
	disk.Data = []int{0, 0, 0, 0, 0, 0, 0, 0}
	disk.Height = 12
	disk.BarWidth = 10
	disk.DataLabels = []string{"I: 0", "I: 1", "I: 2", "I: 3", "I: 4", "I: 5", "I: 6", "I: 7"}
	disk.TextColor = ui.ColorWhite
	disk.BarColor = ui.ColorYellow
	disk.NumColor = ui.ColorWhite

	term = &TerminalUI{ui.Body, usage, summary, cpu, mem, disk}
	return nil
}
コード例 #7
0
// TODO make new widget traffic light
// Waiting for canvas from termui
func initWidgets() (*ui.List, *ui.Par, *ui.Par, *ui.Par, *ui.Par) {
	ui.UseTheme("Jenkins Term UI")

	title := "q to quit - " + *jenkinsUrl
	if *filter != "" {
		title += " filter on " + *filter
	}
	p := ui.NewPar(title)
	_, h := tm.Size()
	p.Height = 3
	p.TextFgColor = ui.ColorWhite
	p.Border.Label = "Go Jenkins Dashboard"
	p.Border.FgColor = ui.ColorCyan

	info := ui.NewPar("")
	info.Height = 3
	info.Y = h - 3
	info.TextFgColor = ui.ColorWhite
	info.Border.FgColor = ui.ColorWhite

	ls := ui.NewList()
	ls.ItemFgColor = ui.ColorYellow
	ls.Border.Label = "Jobs"
	ls.Y = 3
	ls.Height = h - 6

	width, height := 4, 5
	redbox, yellowbox, greenbox := ui.NewPar(""), ui.NewPar(""), ui.NewPar("")
	redbox.HasBorder, yellowbox.HasBorder, greenbox.HasBorder = false, false, false
	redbox.Height, yellowbox.Height, greenbox.Height = height, height, height
	redbox.Width, yellowbox.Width, greenbox.Width = width, width, width
	redbox.BgColor = ui.ColorRed
	yellowbox.BgColor = ui.ColorYellow
	greenbox.BgColor = ui.ColorGreen

	ui.Body.AddRows(
		ui.NewRow(
			ui.NewCol(12, 0, p),
		),
		ui.NewRow(
			ui.NewCol(10, 0, ls),
			ui.NewCol(2, 0, redbox, yellowbox, greenbox),
		),
		ui.NewRow(
			ui.NewCol(12, 0, info),
		),
	)
	ui.Body.Align()
	ui.Render(ui.Body)
	return ls, info, redbox, yellowbox, greenbox
}
コード例 #8
0
ファイル: ui.go プロジェクト: marktai/T9-Terminal
func setupBody() {

	height := termui.TermHeight() - 23

	prompt := termui.NewPar("")
	prompt.Height = 1
	prompt.Border = false
	parMap["prompt"] = prompt

	input := termui.NewPar("")
	input.Height = 3
	input.BorderLabel = "Input"
	input.BorderFg = termui.ColorYellow
	parMap["input"] = input

	moveHistory := termui.NewPar("")
	moveHistory.Height = height - 4
	moveHistory.BorderLabel = "Move History"
	moveHistory.BorderFg = termui.ColorBlue
	parMap["moveHistory"] = moveHistory
	linesMap["moveHistory"] = NewLines()

	output := termui.NewPar("")
	output.Height = height
	output.BorderLabel = "Output"
	output.BorderFg = termui.ColorGreen
	parMap["output"] = output
	linesMap["output"] = NewLines()

	board := termui.NewPar("")
	board.Height = 23
	board.Width = 37
	board.BorderLabel = "Board"
	board.BorderFg = termui.ColorRed
	parMap["board"] = board

	// build layout
	termui.Body.AddRows(
		termui.NewRow(
			termui.NewCol(6, 0, parMap["prompt"], parMap["input"], parMap["moveHistory"]),
			termui.NewCol(6, 0, parMap["output"]),
		),
		termui.NewRow(
			termui.NewCol(12, 0, parMap["board"]),
		),
	)
	changeState(0)
}
コード例 #9
0
ファイル: main.go プロジェクト: ringtail/pug
func main() {
	err := ui.Init()
	if err != nil {
		panic(err)
	}
	defer ui.Close()

	p := ui.NewPar(":PRESS q TO QUIT DEMO")
	p.Height = 3
	p.Width = 50
	p.TextFgColor = ui.ColorWhite
	p.BorderLabel = "Text Box"
	p.BorderFg = ui.ColorCyan

	g := ui.NewGauge()
	g.Percent = 50
	g.Width = 50
	g.Height = 3
	g.Y = 11
	g.BorderLabel = "Gauge"
	g.BarColor = ui.ColorRed
	g.BorderFg = ui.ColorWhite
	g.BorderLabelFg = ui.ColorCyan

	ui.Render(p, g) // feel free to call Render, it's async and non-block
}
コード例 #10
0
ファイル: migration.go プロジェクト: rzh/montu
func (w *MigrationWidget) Init() {
	w.G = gen.ChunkMigration()

	par3 := termui.NewPar("")
	par3.Height = LINE + 2
	par3.Width = 137
	par3.Y = 9
	par3.Border.Label = "> Migrations <"

	par3.Text = ""

	w.bc = par3

	go func() {
		for {
			time.Sleep(1 * time.Second)

			// request data
			w.G.C <- [3]int64{1, 1, 1}
			a := <-w.G.C
			m := fmt.Sprintf(" %d: %d --> %d", a[0], a[1], a[2])

			if len(w.msg) == LINE {
				w.msg = append(w.msg[1:LINE], m)
			} else {
				w.msg = append(w.msg, m)
			}

			text := strings.Join(w.msg, "\n ")
			w.bc.Text = " " + text
		}
	}()
}
コード例 #11
0
ファイル: ui.go プロジェクト: ovh/tatcli
func (ui *tatui) initLastRefresh() {
	p := termui.NewPar("")
	p.Height = uiHeightTop
	p.TextFgColor = termui.ColorWhite
	p.BorderTop, p.BorderLeft, p.BorderRight, p.BorderBottom = false, false, false, false
	ui.lastRefresh = p
}
コード例 #12
0
ファイル: ui.go プロジェクト: ovh/tatcli
func (ui *tatui) initHeader() {
	p := termui.NewPar("TAT ➠ topics: (f)avorites - un(r)ead - (a)ll | (h)ome | (q)uit")
	p.Height = uiHeightTop
	p.TextFgColor = termui.ColorWhite
	p.Border = false
	ui.header = p
}
コード例 #13
0
ファイル: Monitor.go プロジェクト: fasmide/lagpipe
func (m *Monitor) Start(conn *net.Conn) {
	if err := ui.Init(); err != nil {
		panic(err)
	}
	defer ui.Close()

	help := ui.NewPar(":PRESS q TO QUIT")
	help.Height = 3
	help.Width = 50
	help.TextFgColor = ui.ColorWhite
	help.BorderLabel = "Help"
	help.BorderFg = ui.ColorCyan

	// build
	ui.Body.AddRows(
		ui.NewRow(
			ui.NewCol(6, 0, help),
		),
	)

	draw := func(t int) {
		ui.Body.Align()
		ui.Render(ui.Body)
	}

	draw(0)
	ui.Handle("/sys/kbd/q", func(ui.Event) {
		ui.StopLoop()
	})
	ui.Handle("/timer/1s", func(e ui.Event) {
		t := e.Data.(ui.EvtTimer)
		draw(int(t.Count))
	})
	ui.Loop()
}
コード例 #14
0
ファイル: wrappar.go プロジェクト: jmptrader/termui
func main() {

	err := ui.Init()
	if err != nil {
		panic(err)
	}
	defer ui.Close()

	p := ui.NewPar("Press q to QUIT THE DEMO. [There](fg-blue) are other things [that](fg-red) are going to fit in here I think. What do you think? Now is the time for all good [men to](bg-blue) come to the aid of their country. [This is going to be one really really really long line](fg-green) that is going to go together and stuffs and things. Let's see how this thing renders out.\n    Here is a new paragraph and stuffs and things. There should be a tab indent at the beginning of the paragraph. Let's see if that worked as well.")
	p.WrapLength = 48 // this should be at least p.Width - 2
	p.Height = 20
	p.Width = 50
	p.Y = 2
	p.X = 20
	p.TextFgColor = ui.ColorWhite
	p.BorderLabel = "Text Box with Wrapping"
	p.BorderFg = ui.ColorCyan
	//p.Border = false

	ui.Render(p)

	ui.Handle("/sys/kbd/q", func(ui.Event) {
		ui.StopLoop()
	})

	ui.Loop()
}
コード例 #15
0
ファイル: widgets.go プロジェクト: avadhutp/lazarus
// quitWidget Displays the key required to quit
func quitWidget() *termui.Par {
	q := termui.NewPar("Press q to quit Lazarus; s to skip a song.")
	q.TextFgColor = termui.ColorRed
	q.Height = 1
	q.Border = false

	return q
}
コード例 #16
0
ファイル: send_box.go プロジェクト: mhoc/river
func CreateSendBox() *ui.Par {
	p := ui.NewPar("")
	p.Height = SendBoxHeight
	p.TextFgColor = ui.ColorWhite
	p.BorderLabel = "Send"
	p.BorderFg = ui.ColorCyan
	SendBoxEvents(p)
	return p
}
コード例 #17
0
ファイル: receive_box.go プロジェクト: mhoc/river
func CreateReceiveBox() *ui.Par {
  p := ui.NewPar("")
  // p.Height = ui.TermHeight() - SendBoxHeight
  p.Height = ReceiveBoxHeight
  p.TextFgColor = ui.ColorWhite
  p.BorderFg = ui.ColorCyan
  go ReadReceives(p)
  return p
}
コード例 #18
0
ファイル: home.go プロジェクト: ovh/tatcli
func (ui *tatui) initHomeLeft() {

	textURL := viper.GetString("url")
	if textURL == "" {
		textURL = "[Invalid URL, please check your config file](fg-red)"
	}

	p := termui.NewPar(`                            TEXT AND TAGS
            ----------------------------------------------
            ----------------------------------------------
                     |||                     |||
                     |||                     |||
                     |||         |||         |||
                     |||         |||         |||
                     |||                     |||
                     |||         |||         |||
                     |||         |||         |||
                     |||                     |||
                     |||                     |||

                       Tatcli Version: ` + internal.VERSION + `
                    https://github.com/ovh/tatcli
                TAT Engine: https://github.com/ovh/tat
								Current Tat Engine: ` + textURL + `
								Current config file: ` + internal.ConfigFile + `
 Shortcuts:
 - Ctrl + a to view all topics. Cmd /topics in send box
 - Ctrl + b to go back to messsages list, after selected a message
 - Ctrl + c clears filters and UI on current messages list
 - Ctrl + f to view favorites topics. Cmd /favorites
 - Ctrl + h to go back home. Cmd /home or /help
 - Ctrl + t hide or show top menu. Cmd /toggle-top
 - Ctrl + y hide or show actionbox menu. Cmd /toggle-bottom
 - Ctrl + o open current message on tatwebui with a browser. Cmd /open
	          Use option tatwebui-url in config file. See /set-tatwebui-url
 - Ctrl + p open links in current message with a browser. Cmd /open-links
 - Ctrl + j / Ctrl + k (for reverse action):
	    if mode run is enabled, set a msg from open to doing,
	        from doing to done from done to open.
	    if mode monitoring is enabled, set a msg from UP to AL,
	        from AL to UP.
 - Ctrl + q to quit. Cmd /quit
 - Ctrl + r to view unread topics. Cmd /unread
 - Ctrl + u display/hide usernames in messages list. Cmd /toggle-usernames
 - UP / Down to move into topics & messages list
 - UP / Down to navigate through history of action box
 - <tab> to go to next section on screen`)

	p.Height = termui.TermHeight() - uiHeightTop - uiHeightSend
	p.TextFgColor = termui.ColorWhite
	p.BorderTop = true
	p.BorderLeft = false
	p.BorderBottom = false
	ui.homeLeft = p
}
コード例 #19
0
ファイル: readmail.go プロジェクト: llvtt/gomail
func readMessage(message *imap.MessageInfo) {
	set := new(imap.SeqSet)
	set.AddNum(message.Seq)
	cmd, err := imap.Wait(c.Fetch(set, BODY_PART_NAME))
	panicMaybe(err)

	reader, err := messageReader(cmd.Data[0].MessageInfo())
	panicMaybe(err)

	scanner := bufio.NewScanner(reader)
	var lines []string
	for scanner.Scan() {
		lines = append(lines, scanner.Text())
	}
	messageBodyStr := strings.Join(lines[:min(len(lines), ui.TermHeight()-2)], "\n")

	if len(messageBodyStr) <= 0 {
		LOG.Printf("Message body was empty or could not be retrieved: +%v\n", err)
		return
	}

	msgBox := ui.NewPar(messageBodyStr)
	msgBox.Border.Label = "Reading Message"
	msgBox.Height = ui.TermHeight()
	msgBox.Width = ui.TermWidth()
	msgBox.Y = 0
	ui.Render(msgBox)

	topLineIndex := 0

	redraw := make(chan bool)

	for {
		select {
		case e := <-ui.EventCh():
			switch e.Key {
			case ui.KeyArrowDown:
				topLineIndex = max(0, min(
					len(lines)-msgBox.Height/2,
					topLineIndex+1))
				go func() { redraw <- true }()
			case ui.KeyArrowUp:
				topLineIndex = max(0, topLineIndex-1)
				go func() { redraw <- true }()
			case ui.KeyEsc:
				// back to "list messages"
				return
			}
		case <-redraw:
			messageBodyStr = strings.Join(lines[topLineIndex+1:], "\n")
			msgBox.Text = messageBodyStr
			ui.Render(msgBox)
		}
	}
}
コード例 #20
0
ファイル: main.go プロジェクト: VonC/hello-world-go
func main() {

	err := termui.Init()
	if err != nil {
		panic(err)
	}
	defer termui.Close()

	sinps := (func() []float64 {
		n := 220
		ps := make([]float64, n)
		for i := range ps {
			ps[i] = 1 + math.Sin(float64(i)/5)
		}
		return ps
	})()

	p := termui.NewPar(":PRESS q or Esc TO QUIT DEMO Hello World")
	p.Height = 3
	p.Width = 50
	p.TextFgColor = termui.ColorWhite
	p.BorderLabel = "Hello-World"
	p.BorderFg = termui.ColorCyan

	lc1 := termui.NewLineChart()
	lc1.BorderLabel = "dot-mode Line Chart"
	lc1.Mode = "dot"
	lc1.Data = sinps
	lc1.Width = 26
	lc1.Height = 12
	lc1.X = 51
	lc1.DotStyle = '+'
	lc1.AxesColor = termui.ColorWhite
	lc1.LineColor = termui.ColorYellow | termui.AttrBold

	g0 := termui.NewGauge()
	g0.Percent = 40
	g0.Width = 50
	g0.Height = 3
	g0.Y = 3
	g0.BorderLabel = "Slim Gauge"
	g0.BarColor = termui.ColorRed
	g0.BorderFg = termui.ColorWhite
	g0.BorderLabelFg = termui.ColorCyan

	termui.Render(p, g0, lc1)

	termui.Handle("/sys", func(e termui.Event) {
		k, ok := e.Data.(termui.EvtKbd)
		if ok && (k.KeyStr == "q" || k.KeyStr == "<escape>") {
			termui.StopLoop()
		}
	})
	termui.Loop()
}
コード例 #21
0
ファイル: par.go プロジェクト: missingdays/termui
func main() {
	err := termui.Init()
	if err != nil {
		panic(err)
	}
	defer termui.Close()

	//termui.UseTheme("helloworld")

	par0 := termui.NewPar("Borderless Text")
	par0.Height = 1
	par0.Width = 20
	par0.Y = 1
	par0.Border = false

	par1 := termui.NewPar("你好,世界。")
	par1.Height = 3
	par1.Width = 17
	par1.X = 20
	par1.BorderLabel = "标签"

	par2 := termui.NewPar("Simple colored text\nwith label. It [can be](fg-red) multilined with \\n or [break automatically](fg-red,fg-bold)")
	par2.Height = 5
	par2.Width = 37
	par2.Y = 4
	par2.BorderLabel = "Multiline"
	par2.BorderFg = termui.ColorYellow

	par3 := termui.NewPar("Long text with label and it is auto trimmed.")
	par3.Height = 3
	par3.Width = 37
	par3.Y = 9
	par3.BorderLabel = "Auto Trim"

	termui.Render(par0, par1, par2, par3)

	termui.Handle("/sys/kbd/q", func(termui.Event) {
		termui.StopLoop()
	})
	termui.Loop()

}
コード例 #22
0
ファイル: send.go プロジェクト: ovh/tatcli
func (ui *tatui) initSend() {
	p := termui.NewPar("")
	p.Height = uiHeightSend
	p.BorderLeft = false
	p.BorderRight = false
	p.BorderTop = true
	p.BorderBottom = false
	p.TextFgColor = termui.ColorWhite
	p.BorderFg = termui.ColorCyan
	p.BorderLabel = " ✎ Action "
	ui.send = p
}
コード例 #23
0
ファイル: notes.go プロジェクト: wfernandes/firehose-stats
func (m *NotesChart) Init() {
	m.sentByIP = make(map[string]int)
	m.receivedByIP = make(map[string]int)

	m.graph = termui.NewPar("Firehose Statistics Plugin\nPivotal Hackday Project Dec 18, 2015\nAuthors: Warren Fernandes & Tom Chen\n\n[Press q](fg-red) to exit.")

	//	m.graph.Width = 50
	m.graph.Height = 8
	m.graph.BorderLabel = "Notes"
	m.graph.BorderFg = termui.ColorYellow

}
コード例 #24
0
ファイル: gom.go プロジェクト: ZhiqinYang/gom
func draw() {
	display = ui.NewPar("")
	display.Height = 1
	display.Border = false

	prompt = ui.NewPar(promptMsg)
	prompt.Height = 1
	prompt.Border = false

	help := ui.NewPar(`:c, :h for profiles; :f to filter; ↓ and ↑ to paginate`)
	help.Height = 1
	help.Border = false
	help.TextBgColor = ui.ColorBlue
	help.Bg = ui.ColorBlue
	help.TextFgColor = ui.ColorWhite

	gs := ui.Sparkline{}
	gs.Title = "goroutines"
	gs.Height = 4
	gs.LineColor = ui.ColorCyan

	ts := ui.Sparkline{}
	ts.Title = "threads"
	ts.Height = 4
	ts.LineColor = ui.ColorCyan

	sp = ui.NewSparklines(gs, ts)
	sp.Height = 10
	sp.Border = false

	ls = ui.NewList()
	ls.Border = false
	ui.Body.AddRows(
		ui.NewRow(ui.NewCol(4, 0, prompt), ui.NewCol(8, 0, help)),
		ui.NewRow(ui.NewCol(12, 0, sp)),
		ui.NewRow(ui.NewCol(12, 0, display)),
		ui.NewRow(ui.NewCol(12, 0, ls)),
	)
}
コード例 #25
0
ファイル: main.go プロジェクト: andyleap/GoBoy
func DisplayDiscovering() {
	p := ui.NewPar("Discovering Pip-Boys")
	p.Width = 22
	p.Height = 3
	discoverUi := ui.NewGrid(
		ui.NewRow(
			ui.NewCol(4, 4, p),
		),
	)
	discoverUi.Width = ui.Body.Width
	discoverUi.Align()
	ui.Render(discoverUi)
}
コード例 #26
0
ファイル: par.go プロジェクト: sguiheux/termui
func main() {
	err := termui.Init()
	if err != nil {
		panic(err)
	}
	defer termui.Close()

	termui.UseTheme("helloworld")

	par0 := termui.NewPar("Borderless Text")
	par0.Height = 1
	par0.Width = 20
	par0.Y = 1
	par0.HasBorder = false

	par1 := termui.NewPar("你好,世界。")
	par1.Height = 3
	par1.Width = 17
	par1.X = 20
	par1.Border.Label = "标签"

	par2 := termui.NewPar("Simple colored text\nwith label. It [can be](RED) multilined with \\n or [break automatically](GREEN, BOLD)")
	par2.RendererFactory = termui.MarkdownTextRendererFactory{}
	par2.Height = 5
	par2.Width = 37
	par2.Y = 4
	par2.Border.Label = "Multiline"
	par2.Border.FgColor = termui.ColorYellow

	par3 := termui.NewPar("Long text with label and it is auto trimmed.")
	par3.Height = 3
	par3.Width = 37
	par3.Y = 9
	par3.Border.Label = "Auto Trim"

	termui.Render(par0, par1, par2, par3)

	<-termui.EventCh()
}
コード例 #27
0
ファイル: home.go プロジェクト: ovh/tatcli
func (ui *tatui) initHomeRight() {
	p := termui.NewPar(`Action Box

  Keywords:
   - /help display this page
   - /me show information about you
   - /version to show tatcli and engine version

  On messages list:
   - /label eeeeee yourLabel to add a label on selected message
   - /unlabel yourLabel to remove label "yourLabel" on selected message
   - /voteup, /votedown, /unvoteup, /unvotedown to vote up or down, or remove vote
   - /task, /untask to add or remove selected message as a personal task
   - /like, /unlike to add or remove like on selected message
   - /filter label:labelA,labelB andtag:tag,tagb
   - /mode (run|monitoring): enable Ctrl + l shortcut, see on left side for help
   - /codereview splits screen into fours panes:
     label:OPENED label:APPROVED label:MERGED label:DECLINED
   - /monitoring splits screen into three panes: label:UP, label:AL, notlabel:AL,UP
     This is the same as two commands:
      - /split label:UP label:AL notlabel:AL,UP
      - /mode monitoring
   - /run <tag> splits screen into three panes: label:open, label:doing, label:done
     /run AA,BB is the same as two commands:
      - /split tag:AA,BB;label:open tag:AA,BB;label:doing tag:AA,BB;label:done
      - /mode run
   - /set-tatwebui-url <urlOfTatWebUI> sets tatwebui-url in tatcli config file. This
      url is used by Ctrl + o shortcut to open message with a tatwebui instance.
   - /split <criteria> splits screen with one section per criteria delimited by space, ex:
      /split label:labelA label:labelB label:labelC
      /split label:labelA,labelB andtag:tag,tagb
      /split tag:myTag;label:labelA,labelB andtag:tag,tagb;label:labelC
   - /save saves current filters in tatcli config file
   - /toggle-usernames displays or hides username in messages list

  For /split and /filter, see all parameters on https://github.com/ovh/tat#parameters

  On topics list, ex:
   - /filter topic:/Private/firstname.lastname
  			see all parameters on https://github.com/ovh/tat#parameters-4

`)

	p.Height = termui.TermHeight() - uiHeightTop - uiHeightSend
	p.TextFgColor = termui.ColorWhite
	p.BorderTop = true
	p.BorderLeft = false
	p.BorderRight = false
	p.BorderBottom = false
	ui.homeRight = p
}
コード例 #28
0
ファイル: par.go プロジェクト: 4honor/termui
func main() {
	err := termui.Init()
	if err != nil {
		panic(err)
	}
	defer termui.Close()

	termui.UseTheme("helloworld")

	par0 := termui.NewPar("Borderless Text")
	par0.Height = 1
	par0.Width = 20
	par0.Y = 1
	par0.HasBorder = false

	par1 := termui.NewPar("你好,世界。")
	par1.Height = 3
	par1.Width = 17
	par1.X = 20
	par1.Border.Label = "标签"

	par2 := termui.NewPar("Simple text\nwith label. It can be multilined with \\n or break automatically")
	par2.Height = 5
	par2.Width = 37
	par2.Y = 4
	par2.Border.Label = "Multiline"
	par2.Border.FgColor = termui.ColorYellow

	par3 := termui.NewPar("Long text with label and it is auto trimmed.")
	par3.Height = 3
	par3.Width = 37
	par3.Y = 9
	par3.Border.Label = "Auto Trim"

	termui.Render(par0, par1, par2, par3)

	termbox.PollEvent()
}
コード例 #29
0
func (t *TerminalUI) ScaleApp(appName string, instances int) {
	// scaling text
	scaling := ui.NewPar(fmt.Sprintf("\nSCALING [%s] TO [%d] INSTANCES...\n", appName, instances))
	scaling.Height = 5
	scaling.TextFgColor = ui.ColorYellow
	scaling.Border.Label = "Scale"
	scaling.Border.FgColor = ui.ColorRed
	scaling.Border.LabelFgColor = ui.ColorWhite
	scaling.Border.LabelBgColor = ui.ColorRed

	ui.Body.Rows = []*ui.Row{ui.NewRow(
		ui.NewCol(8, 2, scaling),
	)}

	term.Render()
}
コード例 #30
0
ファイル: main.go プロジェクト: nindalf/gotop
func main() {
	err := ui.Init()
	fmt.Println(daemon.UpSince())
	if err != nil {
		fmt.Println("Could not initialise UI")
	}
	defer ui.Close()

	ut, _ := daemon.Uptime()
	p := ui.NewPar(ut.String())
	p.Height = 3
	p.Width = 50
	p.TextFgColor = ui.ColorWhite
	p.Border.Label = "Uptime"
	p.Border.FgColor = ui.ColorCyan

	g0 := ui.NewGauge()
	g0.Percent = 40
	g0.Width = 50
	g0.Height = 3
	g0.Border.Label = "Memory"
	g0.BarColor = ui.ColorRed
	g0.Border.FgColor = ui.ColorWhite
	g0.Border.LabelFgColor = ui.ColorCyan

	g2 := ui.NewGauge()
	g2.Percent = 60
	g2.Width = 50
	g2.Height = 3
	g2.PercentColor = ui.ColorBlue
	g2.Y = 3
	g2.Border.Label = "CPU"
	g2.BarColor = ui.ColorYellow
	g2.Border.FgColor = ui.ColorWhite

	ui.Body.AddRows(ui.NewRow(ui.NewCol(6, 0, g0), ui.NewCol(6, 0, p)),
		ui.NewRow(ui.NewCol(6, 0, g2)))
	ui.Body.Align()
	ui.Render(ui.Body)
	go updateMemCPU(g2, g0)
	go updateUptime(p)
	<-ui.EventCh()
}