Closed imwaddy closed 5 years ago
err := termui.Init() if err != nil { panic(err) } defer termui.Close()
lsss := time.Now().Format(time.RFC1123)
strs := []string{
"",
"",
"",
" ",
"",
"",
"",
" ",
"",
"",
" Current Time is : " + lsss,
"",
}
ls := termui.NewList()
ls.Items = strs
ls.ItemFgColor = termui.ColorYellow
// ls.BorderLabel = borderLabel
ls.Height = 15
ls.Width = 80
ls.Border = false
ls.Y = 10
termui.Render(ls)
termui.Handle("/timer/1s", func(e termui.Event) {
strs = []string{
"",
"",
"",
" ",
"",
"",
"",
"",
" Current Time is : " + time.Now().Format(time.RFC1123),
"",
}
ls.Items = strs
termui.Render(ls)
})
termui.Handle("q", func(termui.Event) {
termui.StopLoop()
})
termui.Loop()
this is freezing the time but in windows it continuously showing current time.
I thought that I was doing something wrong, it does not work for me either
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
Is there any other way to update a widget?
As a workaround:
go func() {
update := time.NewTicker(time.Second)
for {
<-update.C
ls.Items = strs
ui.Render(ls)
}
}()
@bgadrian I was also thought that I was doing something wrong too. Finally put this into issue so I can be get little help by authors.
My apologies for not updating the documentation, the termui timers were removed on the master branch in favor of Go's built in timers. Most of the event logic in termui has actually been reworked on master. I'll make sure to update the documentation this week with the updates. The v2.3.0
release should still have all the functionality as documented however.
To switch to Go's built in timers, I would recommend either @bgadrian's example, the example from go by example, or using a select statement to choose between timer events and termui events.
@cjbassi thanks for your reply. Keyboard events (combination keys as 'C-c' ) is not working but working in windows. Does this also removed?
The key identifiers were also changed on master, so you would have to do <C-c>
now. The available keycodes are listed here. Let me know if you still get issues with it.
Thank you so much for help...Please update documention as early as possible..Thanks for awesome library..š
@cjbassi I used key identifier(
And while second time it's clear whole console screen.
I tested on windows 7 but not on Ubuntu...Once I'm done I'll let you know.
Hii @cjbassi, I have tested same with ubuntu but it's exactly opposite of windows behaviour. On second run it will freezing window and nothing happend with keys. But first time it works totally fine in my case.
Hi, I just updated the documentation. You can check godoc for code documentation and also the wiki for general info now. I also reworked the events (again) and changed the names of a few things so there's some breaking changes that are documented in the CHANGELOG. Let me know if anyone has any suggestions about anything.
@imwaddy Let me know if you're still having issues with the latest version.
@cjbassi I have updated the package and now it's working fine in both cases....I've not seen documentation yet but soon I'll inform you. Thanks!
Closing this but let me know if you have any more issues/suggestions!
I used the function which is correctly working with windows(windows 7 & 8) but it is not working on Ubuntu 18.04