本文整理匯總了Golang中github.com/jroimartin/gocui.Gui.Flush方法的典型用法代碼示例。如果您正苦於以下問題:Golang Gui.Flush方法的具體用法?Golang Gui.Flush怎麽用?Golang Gui.Flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/jroimartin/gocui.Gui
的用法示例。
在下文中一共展示了Gui.Flush方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setContacts
func setContacts(g *gocui.Gui, contacts map[string]*contact) error {
if jidBuffs == nil {
jidBuffs = make(map[string][]byte)
}
g.View("contacts").Clear()
viewJids = make([]string, 1)
viewJids[0] = "Home"
for _, c := range contacts {
if !c.HasAxo() {
continue
}
viewJids = append(viewJids, c.String())
}
sort.Strings(viewJids[1:])
for _, c := range viewJids {
fmt.Fprintln(g.View("contacts"), c)
}
// Cleanup buffers
for k, _ := range jidBuffs {
if _, ok := contacts[k]; !ok {
delete(jidBuffs, k)
}
}
g.Flush()
return nil
}
示例2: updateMainView
func updateMainView(g *gocui.Gui) {
main_view, _ := g.View("main")
for i := range main_output {
main_view.Clear()
fmt.Fprintln(main_view, i)
g.Flush()
}
}
示例3: updateAveragesView
func updateAveragesView(g *gocui.Gui) {
averages_view, _ := g.View("averages")
for i := range averages_output {
averages_view.Clear()
fmt.Fprintln(averages_view, i)
g.Flush()
}
}
示例4: updateSparksView
func updateSparksView(g *gocui.Gui) {
sparks_view, _ := g.View("sparks")
for i := range sparks_output {
sparks_view.Clear()
fmt.Fprintln(sparks_view, i)
g.Flush()
}
}
示例5: updateStatusView
// the UI could be a lot smoother if there was less Clear()
// and Flush() .. Flush() could run on an interval instead of
// inside these update*View functions
func updateStatusView(g *gocui.Gui) {
status_view, _ := g.View("status")
for i := range status_output {
status_view.Clear()
fmt.Fprintln(status_view, i)
g.Flush()
}
}
示例6: updateTimeView
func updateTimeView(g *gocui.Gui) {
for {
time.Sleep(1 * time.Second)
time_view, _ := g.View("time")
time_view.Clear()
fmt.Fprintln(time_view, "", time.Now().Local())
if err := g.Flush(); err != nil {
return
}
}
}
示例7: delProj
func delProj(g *gocui.Gui, v *gocui.View) error {
if l := current_name; l != "" {
delete(projects, l)
}
g.ShowCursor = false
delView(g, "del_proj")
delView(g, "list")
g.Flush()
setView(g, "list")
return nil
}
示例8: updateLogDumpView
func updateLogDumpView(g *gocui.Gui) {
logdump_view, _ := g.View("logdump_view")
flush := time.Tick(update_logdump_frequency * time.Millisecond)
for {
select {
case log_data := <-logdump_output:
fmt.Fprintln(logdump_view, log_data)
case <-flush:
g.Flush()
}
}
}
示例9: saveProj
func saveProj(g *gocui.Gui, v *gocui.View) error {
if l := strings.TrimSpace(v.Buffer()); l != "" {
init_t, _ := time.ParseDuration("0s")
init_d, _ := time.ParseDuration("0s")
projects[l] = Project{time.Now(), &init_d, &init_t}
}
g.ShowCursor = false
delView(g, "save_proj")
delView(g, "list")
g.Flush()
setView(g, "list")
updateProjInfo(g, v)
return nil
}
示例10: updateAlertsView
func updateAlertsView(g *gocui.Gui) {
alerts_view, _ := g.View("alerts")
for {
select {
case alert_text := <-alerts_output:
fmt.Fprintln(alerts_view, alert_text)
g.Flush()
case alert_state := <-alert_state_chan:
if alert_state {
alerts_view.BgColor = gocui.ColorRed
} else {
alerts_view.BgColor = gocui.ColorDefault
}
g.Flush()
}
}
}
示例11: display
func display(g *gocui.Gui, to, message string) error {
// Write in buffer
buf, ok := jidBuffs[to]
if !ok {
jidBuffs[to] = make([]byte, 0)
buf = jidBuffs[to]
}
buf = append(buf, message...)
jidBuffs[to] = buf
// Is it the current view ?
contacts := g.View("contacts")
_, cy := contacts.Cursor()
contact, err := contacts.Line(cy)
if err != nil {
return err
}
// If yes, write message in main view
if to == contact {
fmt.Fprint(g.View("main"), message)
}
return g.Flush()
}
示例12: updateViews
func updateViews(g *gocui.Gui) {
for {
time.Sleep(1000 * time.Millisecond)
if sv := g.View("status"); sv != nil {
sv.Clear()
fmt.Fprintln(sv, time.Now().Local())
}
if sv := g.View("counters"); sv != nil {
sv.Clear()
indexedSlice := make([]string, len(counters))
i := 0
for k, _ := range counters {
indexedSlice[i] = k
i++
}
sort.Strings(indexedSlice)
for _, value := range indexedSlice {
fmt.Fprintf(sv, "%s =\t%d\n", value, counters[value].value)
var duration time.Duration = time.Now().Sub(counters[value].received)
if duration.Seconds() > float64(*flushInterval) {
delete(counters, value)
}
}
}
if sv := g.View("gauges"); sv != nil {
sv.Clear()
indexedSlice := make([]string, len(gauges))
i := 0
for k, _ := range gauges {
indexedSlice[i] = k
i++
}
sort.Strings(indexedSlice)
for _, value := range indexedSlice {
fmt.Fprintf(sv, "%s =\t%d\n", value, gauges[value])
}
}
if sv := g.View("timers"); sv != nil {
sv.Clear()
indexedSlice := make([]string, len(timers))
i := 0
for k, _ := range timers {
indexedSlice[i] = k
i++
}
sort.Strings(indexedSlice)
for _, value := range indexedSlice {
calculateAverageTime(sv, value, timers[value])
}
}
if err := g.Flush(); err != nil {
return
}
}
}
示例13: debug
func debug(g *gocui.Gui, str string) error {
fmt.Fprintln(g.View("main"), str)
g.Flush()
return nil
}
示例14: debugf
func debugf(g *gocui.Gui, format string, args ...interface{}) error {
fmt.Fprintf(g.View("main"), format, args)
g.Flush()
return nil
}