diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-12-26 18:41:29 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-12-27 00:25:49 +0100 |
commit | d83517f67ba638abed1d76541068413e60142194 (patch) | |
tree | c4223f0e28d3f21e8247aa0fe3330782977a611d /terminal.go | |
parent | 4f2c2dc8daeb5474fbfc4bd6071987b2797f5eba (diff) | |
download | acid-d83517f67ba638abed1d76541068413e60142194.tar.gz acid-d83517f67ba638abed1d76541068413e60142194.tar.xz acid-d83517f67ba638abed1d76541068413e60142194.zip |
Refresh task view dynamically with Javascript
This is more efficient, responsive, and user friendly.
Diffstat (limited to 'terminal.go')
-rw-r--r-- | terminal.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/terminal.go b/terminal.go index 4660c1b..55eabb5 100644 --- a/terminal.go +++ b/terminal.go @@ -47,6 +47,16 @@ func (tw *terminalWriter) log(format string, v ...interface{}) { } } +// SerializeUpdates returns an update block for a client with a given last line, +// and the index of the first line in the update block. +func (tw *terminalWriter) SerializeUpdates(last int) (string, int) { + if last < 0 || last >= len(tw.lines) { + return "", last + } + top := tw.lines[last].updateGroup + return string(tw.Serialize(top)), top +} + func (tw *terminalWriter) Serialize(top int) []byte { var b bytes.Buffer for i := top; i < len(tw.lines); i++ { @@ -104,7 +114,7 @@ func (tw *terminalWriter) processPrint(r rune) { // Refresh update trackers, if necessary. if tw.lines[len(tw.lines)-1].updateGroup > tw.line { for i := tw.line; i < len(tw.lines); i++ { - tw.lines[i].updateGroup = tw.line + tw.lines[i].updateGroup = min(tw.lines[i].updateGroup, tw.line) } } |