diff options
author | Luke Shumaker <lukeshu@beefcake.parabola.nu> | 2018-05-19 12:25:39 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@beefcake.parabola.nu> | 2018-05-19 12:25:39 -0400 |
commit | 9110ae474a8ac9fd70b6e15aa3cfda368c5d1cb4 (patch) | |
tree | 2242712710f65b67cad2b527f5db98e31fc0c095 /go/src/lib/statusline/async.go | |
parent | 19eeecd2821a36fe647584026379645a8764735b (diff) |
statusline fanciness
Diffstat (limited to 'go/src/lib/statusline/async.go')
-rw-r--r-- | go/src/lib/statusline/async.go | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/go/src/lib/statusline/async.go b/go/src/lib/statusline/async.go deleted file mode 100644 index 5b509ac..0000000 --- a/go/src/lib/statusline/async.go +++ /dev/null @@ -1,57 +0,0 @@ -package statusline - -import ( - "io" - "time" -) - -type AsyncStatusLine struct { - lines chan string - end1 chan struct{} - end2 chan struct{} -} - -func NewAsyncStatusLine(out io.Writer, d time.Duration) *AsyncStatusLine { - ret := &AsyncStatusLine{ - lines: make(chan string), - end1: make(chan struct{}), - end2: make(chan struct{}), - } - go func() { - sl := NewStatusLine(out) - ticker := time.NewTicker(d) - var oldLine string - var newLine string - dirty := false - for { - select { - case <-ticker.C: - if dirty && newLine != oldLine { - sl.Put(newLine) - dirty = false - } - case l := <-ret.lines: - newLine = l - dirty = true - case <-ret.end1: - sl.End() - ticker.Stop() - end2 <- struct{}{} - close(end2) - return - } - } - }() - return ret -} - -func (sl *AsyncStatusLine) Put(line string) { - sl.lines <- line -} - -func (sl *AsyncStatusLine) End() { - sl.end1 <- struct{}{} - close(sl.lines) - close(sl.end) - <-sl.end2 -} |