Skip to content

feat(cli): clear only previous graph in realtime mode#79

Merged
guptarohit merged 2 commits into
guptarohit:masterfrom
zhengshui:fix/issue-44-realtime-graph-clearing
Jun 19, 2026
Merged

feat(cli): clear only previous graph in realtime mode#79
guptarohit merged 2 commits into
guptarohit:masterfrom
zhengshui:fix/issue-44-realtime-graph-clearing

Conversation

@zhengshui

@zhengshui zhengshui commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

Summary
Fixes #44 by clearing only the previous graph instead of wiping the whole terminal in realtime mode, removing flicker and preserving any output above the graph.

Changes

  • Add exported asciigraph.ClearLines(n) helper that erases the last n lines (cursor up + clear to end of screen) without touching content above them.
  • Realtime CLI now tracks the last graph height (lastGraphLines) and calls ClearLines instead of the full-screen Clear().

Verification

  • go test ./... (incl. new TestClearLines), go vet ./..., gofmt, and GOARCH=arm cross-compile all pass.
  • Manual: seq 1 100 | go run ./cmd/asciigraph -r redraws in place with no flicker; captured output contains zero full-screen \033[2J wipes.

Closes #44

zhengshui and others added 2 commits June 20, 2026 04:32
- Add lastGraphLines to track previous graph height
- Add clearPreviousGraph function to clear only previous graph lines
  instead of clearing entire screen
- This improves realtime plotting by reducing screen flicker

Fixes guptarohit#44
Erase only the previous graph's lines instead of wiping the whole
screen, fixing the realtime cursor drift and preserving output above
the graph.
@guptarohit guptarohit force-pushed the fix/issue-44-realtime-graph-clearing branch from 0584151 to 66346cb Compare June 19, 2026 23:39
@guptarohit guptarohit changed the title fix(cli): clear previous graph before plotting in realtime mode feat(cli): clear only previous graph in realtime mode Jun 19, 2026
@guptarohit guptarohit merged commit 3c935a3 into guptarohit:master Jun 19, 2026
14 checks passed
@guptarohit guptarohit mentioned this pull request Jun 19, 2026
guptarohit added a commit that referenced this pull request Jun 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.10.0](v0.9.0...v0.10.0)
(2026-06-19)


### Added

* add ClearLines to redraw realtime graph without flicker
([66346cb](66346cb))
* **cli:** clear only previous graph in realtime mode
([#79](#79))
([3c935a3](3c935a3))


### Fixed

* **cli:** clear previous graph before plotting in realtime mode
([cbc1f4a](cbc1f4a)),
closes [#44](#44)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
@guptarohit guptarohit mentioned this pull request Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI: for realtime data stream, clear old graph before plotting new data

2 participants