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

gui: support up to 65535 ncurses color pairs (issue #1343) #1365

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sim642
Copy link
Member

@sim642 sim642 commented Jun 29, 2019

This PR improves PR #1345 which fixed issue #1343. Because this introduces additional ncurses-specific behavior, it may be better to not immediately merge this but instead wait and see if #1345 itself has some regressions for someone. I'm still opening the PR because I have implemented the additional limit increase and it could be tested, but it's not as crucial because 32767 color pairs "ought to be enough for everyone".

Changes

The standard curses API uses shorts for color pair numbers, so values above 32767, which ncurses claims to support in 256-color modes, wouldn't actually work because they overflow. Two ncurses-specific extensions allow working around this limitation:

  1. init_extended_pair instead of init_pair allows defining color pairs with int numbers.
  2. opts arguments of many curses color and attribute functions allow passing the color pair with int number as an int* to be used instead of the usual color pair as short.

Because both are ncurses-specific extensions to the curses API, their uses have been implemented conditionally on NCURSES_EXT_FUNCS and NCURSES_EXT_COLORS (through helper macros to reduce duplicating the preprocessor conditions a lot) to attempt to be as compatible as possible.

Potential problems

  • Does this PR actually increase the usable limit from 32767 to 65535?

    I only tested it with colorspam.py, which outputs 1024 color pairs. It should actually be checked that when trying to display more than 32767 color pairs at once, before this PR it wouldn't display correctly but after this PR it would. It's kind of difficult to fit enough output into a buffer to use 32767 color pairs without scrolling and to visually check the its (in)correctness.

  • Some conditions use NCURSES_EXT_FUNCS, others NCURSES_EXT_COLORS — is that exact/correct/sufficient or should both be required to be true?

    For example, is it possible to have an ncurses build that supports only one or the other?

    Change: init_extended_pair and color pair in opts are only supported since ncurses patch 20170401. Made the preprocessor conditions stronger in commit 63fa5a0.

@flashcode flashcode added the feature New feature request label Jun 29, 2019
@codecov-io
Copy link

codecov-io commented Jun 29, 2019

Codecov Report

Merging #1365 into master will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1365      +/-   ##
==========================================
- Coverage   25.93%   25.89%   -0.05%     
==========================================
  Files         198      198              
  Lines       80957    81164     +207     
==========================================
+ Hits        20998    21017      +19     
- Misses      59959    60147     +188
Impacted Files Coverage Δ
src/plugins/relay/relay-config.c 36.71% <0%> (-5.97%) ⬇️
src/plugins/relay/relay-completion.c 9.52% <0%> (-2.25%) ⬇️
src/plugins/exec/exec.c 5.01% <0%> (-0.56%) ⬇️
src/core/wee-string.c 86.98% <0%> (-0.37%) ⬇️
src/plugins/xfer/xfer.c 3.96% <0%> (-0.24%) ⬇️
src/plugins/relay/relay-server.c 0.53% <0%> (-0.15%) ⬇️
src/core/weechat.c 43.97% <0%> (-0.15%) ⬇️
src/plugins/plugin.c 75.23% <0%> (-0.11%) ⬇️
src/plugins/relay/relay.c 48.38% <0%> (-0.1%) ⬇️
src/plugins/relay/relay-command.c 1.58% <0%> (-0.07%) ⬇️
... and 45 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5988d17...40e201d. Read the comment docs.

@sim642 sim642 mentioned this pull request Jul 6, 2019
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants