gui: attempt to auto-reset color pairs even when full #1258
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.
Previously if color pairs fill up because all pairs are rendered at once and auto-reset therefore fails, weechat will never try to auto-reset again and manual reset is necessary.
This attempts to auto-reset even a full table, in case now less pairs are visible and the reset will be successful.
For testing I wrote this script to spam a huge number of color combinations into a single buffer to fill up all the ncurses color pairs: https://gist.github.com/sim642/dde23725f23907bc960fce308ecda4f1.
Running the script messes up bar colors etc and switching to a different buffer, which doesn't need all those color pairs should auto reset and fix the color pairs again, but it doesn't. This PR changes that and attempts auto color reset when the pairs are already completely full.
On at least two occasions in the recent months this issue has been brought up in #weechat, which seems to have been caused by such color pair spam. One would expect color pair auto reset to eventually fix the colors but it didn't because nothing was attempted when the limit was already over.
Happy Hacktoberfest!