Skip to content
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
merged 19 commits into from
Feb 23, 2020
Merged

Eliminate flashing by repainting rather than replacing #74

merged 19 commits into from
Feb 23, 2020

Conversation

tgjohnst
Copy link
Sponsor Contributor

@tgjohnst tgjohnst commented Feb 22, 2020

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 a tput 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

@tgjohnst tgjohnst requested a review from jpmck February 22, 2020 08:24
@jpmck jpmck merged commit d6df934 into pi-hole:master Feb 23, 2020
@jpmck
Copy link
Contributor

jpmck commented Feb 23, 2020

Thanks @tgjohnst!

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.

None yet

2 participants