本文整理汇总了Golang中github.com/gizak/termui.TermHeight函数的典型用法代码示例。如果您正苦于以下问题:Golang TermHeight函数的具体用法?Golang TermHeight怎么用?Golang TermHeight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TermHeight函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: doLiveGraph
//doLiveGraph builds a graph in the terminal window that
//updates every graphUpdate seconds
//It will build up to maxGraphs graphs with one time-series
//per graph
func doLiveGraph(res *wavefront.QueryResponse, query *wavefront.Querying, period int64) {
err := ui.Init()
if err != nil {
log.Fatal(err)
}
defer ui.Close()
if maxGraphs > len(res.TimeSeries) {
maxGraphs = len(res.TimeSeries)
}
var wDivisor, hDivisor int
switch maxGraphs {
case 1:
wDivisor = 1
hDivisor = 1
case 2:
wDivisor = 2
hDivisor = 1
case 3, 4:
wDivisor = 2
hDivisor = 2
}
height := ui.TermHeight() / hDivisor
width := ui.TermWidth() / wDivisor
xVals, yVals := calculateCoords(maxGraphs, ui.TermWidth()/wDivisor, ui.TermHeight()/hDivisor)
graphs := buildGraphs(res, height, width, xVals, yVals)
ui.Render(graphs...)
ui.Handle("/sys/kbd/q", func(ui.Event) {
// press q to quit
ui.StopLoop()
})
ui.Handle("/sys/kbd/C-c", func(ui.Event) {
// handle Ctrl + c combination
ui.StopLoop()
})
ui.Handle("/timer/1s", func(e ui.Event) {
query.SetEndTime(time.Now())
query.SetStartTime(period)
res, err := query.Execute()
if err != nil {
log.Fatal(err)
}
graphs := buildGraphs(res, height, width, xVals, yVals)
ui.Render(graphs...)
})
ui.Loop()
}
示例2: readMessage
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)
}
}
}
示例3: Create
func (p *LabelListPage) Create() {
ui.Clear()
ls := ui.NewList()
p.uiList = ls
if p.statusBar == nil {
p.statusBar = new(StatusBar)
}
if p.commandBar == nil {
p.commandBar = commandBar
}
queryName := p.ActiveQuery.Name
queryJQL := p.ActiveQuery.JQL
p.labelCounts = countLabelsFromQuery(queryJQL)
p.cachedResults = p.labelsAsSortedList()
p.isPopulated = true
p.displayLines = make([]string, len(p.cachedResults))
ls.ItemFgColor = ui.ColorYellow
ls.BorderLabel = fmt.Sprintf("Label view -- %s: %s", queryName, queryJQL)
ls.Height = ui.TermHeight() - 2
ls.Width = ui.TermWidth()
ls.Y = 0
p.statusBar.Create()
p.commandBar.Create()
p.Update()
}
示例4: BuildUI
func BuildUI() {
ui.Init()
defer ui.Close()
receiveBox := CreateReceiveBox()
sendBox := CreateSendBox()
ui.Body.AddRows(
ui.NewRow(ui.NewCol(12, 0, receiveBox)),
ui.NewRow(ui.NewCol(12, 0, sendBox)),
)
ui.Body.Align()
ui.Render(ui.Body)
ui.Handle("/sys/kbd/C-x", func(e ui.Event) {
ui.StopLoop()
})
ui.Handle("/timer/1s", func(e ui.Event) {
ReceiveBoxHeight = ui.TermHeight() - SendBoxHeight
receiveBox.Height = ReceiveBoxHeight
ui.Body.Align()
ui.Render(ui.Body)
})
// Leaving this commented out for now
// I'd like to get this method of screen refreshing working instead of the 1s method,
// but this crashes on resize.
// ui.Handle("/sys/wnd/resize", func(e ui.Event) {
// ui.Body.Align()
// ui.Render(ui.Body)
// })
ui.Loop()
}
示例5: Create
func (p *TicketListPage) Create() {
log.Debugf("TicketListPage.Create(): self: %s (%p)", p.Id(), p)
log.Debugf("TicketListPage.Create(): currentPage: %s (%p)", currentPage.Id(), currentPage)
ui.Clear()
ls := ui.NewList()
p.uiList = ls
if p.statusBar == nil {
p.statusBar = new(StatusBar)
}
if p.commandBar == nil {
p.commandBar = commandBar
}
query := p.ActiveQuery.JQL
if sort := p.ActiveSort.JQL; sort != "" {
re := regexp.MustCompile(`(?i)\s+ORDER\s+BY.+$`)
query = re.ReplaceAllString(query, ``) + " " + sort
}
if len(p.cachedResults) == 0 {
p.cachedResults = JiraQueryAsStrings(query, p.ActiveQuery.Template)
}
if p.selectedLine >= len(p.cachedResults) {
p.selectedLine = len(p.cachedResults) - 1
}
p.displayLines = make([]string, len(p.cachedResults))
ls.ItemFgColor = ui.ColorYellow
ls.BorderLabel = fmt.Sprintf("%s: %s", p.ActiveQuery.Name, p.ActiveQuery.JQL)
ls.Height = ui.TermHeight() - 2
ls.Width = ui.TermWidth()
ls.Y = 0
p.statusBar.Create()
p.commandBar.Create()
p.Update()
}
示例6: resize
func (ed *Editor) resize() {
termui.Body.Width = termui.TermWidth()
ed.applets.Height = termui.TermHeight() - 2 + 1 // offset 1 for border
ed.desc.Y = ed.locked.Y + ed.locked.Height - 1 // offset 1 for border
ed.desc.Height = termui.TermHeight() - ed.desc.Y - 2
ed.title.Y = termui.TermHeight() - 2
ed.title.Width = termui.TermWidth() + 1 // offset 1 for border
ed.appinfo.Width = termui.TermWidth() - ed.appinfo.X + 1 // offset 1 for border
ed.locked.Width = termui.TermWidth() - ed.applets.Width + 1 // offset 1 for border
ed.desc.Width = termui.TermWidth() - ed.applets.Width + 1 // offset 1 for border
ed.desc.WrapLength = ed.desc.Width
termui.Render(ed.applets, ed.fields, ed.appinfo, ed.locked, ed.desc, ed.title)
}
示例7: initHomeLeft
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
}
示例8: Create
func (p *CommandBar) Create() {
ls := ui.NewList()
p.uiList = ls
ls.ItemFgColor = ui.ColorGreen
ls.Border = false
ls.Height = 1
ls.Width = ui.TermWidth()
ls.X = 0
ls.Y = ui.TermHeight() - 1
p.Update()
}
示例9: adjustDimensions
func adjustDimensions() {
termui.Body.Width = termui.TermWidth()
height := termui.TermHeight()
parMap["moveHistory"].Height = height - 23 - 4
parMap["output"].Height = height - 23
if height < 31 {
parMap["board"].Height = height - 8
parMap["moveHistory"].Height = 2
parMap["output"].Height = 6
}
}
示例10: Create
func (p *TicketShowPage) Create() {
log.Debugf("TicketShowPage.Create(): self: %s (%p)", p.Id(), p)
log.Debugf("TicketShowPage.Create(): currentPage: %s (%p)", currentPage.Id(), currentPage)
p.opts = getJiraOpts()
if p.TicketId == "" {
p.TicketId = ticketListPage.GetSelectedTicketId()
}
if p.MaxWrapWidth == 0 {
if m := p.opts["max_wrap"]; m != nil {
p.MaxWrapWidth = uint(m.(int64))
} else {
p.MaxWrapWidth = defaultMaxWrapWidth
}
}
ui.Clear()
ls := ui.NewList()
if p.statusBar == nil {
p.statusBar = new(StatusBar)
}
if p.commandBar == nil {
p.commandBar = commandBar
}
p.uiList = ls
if p.Template == "" {
if templateOpt := p.opts["template"]; templateOpt == nil {
p.Template = "jira_ui_view"
} else {
p.Template = templateOpt.(string)
}
}
innerWidth := uint(ui.TermWidth()) - 3
if innerWidth < p.MaxWrapWidth {
p.WrapWidth = innerWidth
} else {
p.WrapWidth = p.MaxWrapWidth
}
if p.apiBody == nil {
p.apiBody, _ = FetchJiraTicket(p.TicketId)
}
p.cachedResults = WrapText(JiraTicketAsStrings(p.apiBody, p.Template), p.WrapWidth)
p.displayLines = make([]string, len(p.cachedResults))
if p.selectedLine >= len(p.cachedResults) {
p.selectedLine = len(p.cachedResults) - 1
}
ls.ItemFgColor = ui.ColorYellow
ls.Height = ui.TermHeight() - 2
ls.Width = ui.TermWidth()
ls.Border = true
ls.BorderLabel = fmt.Sprintf("%s %s", p.TicketId, p.ticketTrailAsString())
ls.Y = 0
p.statusBar.Create()
p.commandBar.Create()
p.Update()
}
示例11: Create
func (p *StatusBar) Create() {
ls := ui.NewList()
p.uiList = ls
ls.ItemFgColor = ui.ColorWhite
ls.ItemBgColor = ui.ColorRed
ls.Bg = ui.ColorRed
ls.Border = false
ls.Height = 1
ls.Width = ui.TermWidth()
ls.X = 0
ls.Y = ui.TermHeight() - 2
p.Update()
}
示例12: Create
func (p *BaseListPage) Create() {
ui.Clear()
ls := ui.NewList()
p.uiList = ls
p.cachedResults = make([]string, 0)
p.displayLines = make([]string, len(p.cachedResults))
ls.ItemFgColor = ui.ColorYellow
ls.BorderLabel = "Updating, please wait"
ls.Height = ui.TermHeight()
ls.Width = ui.TermWidth()
ls.Y = 0
p.Update()
}
示例13: initHomeRight
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
}
示例14: Create
func (p *BaseInputBox) Create() {
ls := ui.NewList()
var strs []string
p.uiList = ls
ls.Items = strs
ls.ItemFgColor = ui.ColorGreen
ls.BorderFg = ui.ColorRed
ls.Height = 1
ls.Width = 30
ls.Overflow = "wrap"
ls.X = ui.TermWidth()/2 - ls.Width/2
ls.Y = ui.TermHeight()/2 - ls.Height/2
p.Update()
}
示例15: Create
func (p *PasswordInputBox) Create() {
ls := ui.NewList()
p.uiList = ls
var strs []string
ls.Items = strs
ls.ItemFgColor = ui.ColorGreen
ls.BorderLabel = "Enter Password:"
ls.BorderFg = ui.ColorRed
ls.Height = 3
ls.Width = 30
ls.X = ui.TermWidth()/2 - ls.Width/2
ls.Y = ui.TermHeight()/2 - ls.Height/2
p.Update()
}