-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eliminate flashing by repainting rather than replacing #74
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uses tput instead of clear. uses ceol, may behave nicely if screen is resized (fingers crossed?)
Thanks @tgjohnst! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous PADD display routine would 1) get info, 2) print the dashboard 3) wait 5 seconds 4) clear
This was causing issues, particularly on slower displays, where there was a perceptble black "flash" between the terminal being cleared and the dashboard being repopulated.
I tried moving the clear command to just prior to the repopulation of the dashboard text, which helped a bit but the flash was still perceptible.
In order to solve the issue, instead of clearing the whole terminal and then rewriting all the lines, I move the cursor to the topleft of the console just prior to printing (
tput cup 0 0
) and overwrite each line. When I rewrite, I add a "clear to end of line" escape character that blanks out anything after the written text - this takes care of any artifacts after you shrink the screen, since a simple repaint would leave anything longer than the newline present. To do this cleanly and not bloat the code, I've added wrapper functions for echo (CleanEcho=echo -e "text" "$(tput el)
) and printf (CleanPrintf), writing the clear-line-from-here escape character"\e[0K"
prior to any newline in the printf calls. I also add atput ed
call after printing the rest of the output to clear any remaining text below the last line, which cleans up artifacts after resizing to a smaller format.I recognize that the CleanPrintf wrapper isn't necessary in the final form, but it maintains consistency with CleanEcho so I kept it.
This update changes printing behavior only and it's friendly to resizing (you can resize to any size/format you want and it should still display just fine within 10 seconds aka 2 refresh cycles).
This pull request was a great exercise in learning the finer points of bash terminal control. Please let me know if there are any comments or changes, or if you encounter issues in your OS!
This fixes issue #69