1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 12:15:43 +03:00

Handle new lines arriving

We display the lines, but we also just freeze. Try "./moar.sh moar.sh"
and try to search and you'll see.
This commit is contained in:
Johan Walles 2019-07-11 18:52:20 +02:00
parent 106626388d
commit 447da01d49
2 changed files with 17 additions and 0 deletions

View File

@ -453,6 +453,21 @@ func (p *_Pager) StartPaging(logger *log.Logger, screen tcell.Screen) {
screen.Show()
p._Redraw(logger)
go func() {
for {
// Wait for new lines to appear
<-p.reader.moreLinesAdded
// Request refresh
//
// FIXME: What we want to do here really is request a refresh in
// 0.2s. If a refresh is already pending, do nothing. This way
// we'll be able to respond to more lines read, while not having
// to refresh the screen too many times for long files.
screen.PostEvent(tcell.NewEventInterrupt(nil))
}
}()
// Main loop
for !p.quit {
ev := screen.PollEvent()

View File

@ -18,6 +18,8 @@ import (
var versionString = "Should be set when building, please use build.sh to build"
func main() {
// FIXME: If we get a CTRL-C, get terminal back into a useful state before terminating
defer func() {
err := recover()
if err == nil {