dom96 / nimbox

Fork of https://notabug.org/vktec/nimbox
30 stars 4 forks source link

Add 256 Color Support #5

Closed jonathanabennett closed 6 years ago

jonathanabennett commented 6 years ago

This commit addresses issue #2. It adds 256 color support very naively. It does not check for terminal support of 256 colors. It does not check that the int provided is in the range 0..255. It does not have any error checking or handling of any sort.

Fixes: #2

jonathanabennett commented 6 years ago

New PR with README commit removed.

dom96 commented 6 years ago

Thank you.

Now I must ask: have you tested this?

If I'm honest I would prefer if this code took a Color type from the stdlib colors module but that would clash with the Color type defined by this module :(

Perhaps adding a little documentation comment on how to pass colours would be enough, 0xFF1234 right?

jonathanabennett commented 6 years ago

Yes, I have tested this. It's currently handling the terrain colors in a roguelike I'm working on. I will keep hacking at this because I'm unhappy having to guess at color codes myself. It also gives me a chance to familiarize myself with a bit of Nim that I don't expect to use in my current code.

Termbox takes 256 color numbers, as seen here. The numbers that Termbox (and therefore nimbox) use are the color immediately beside the swatch. We should be able to make stdlib colors work by using explicit namespace, correct? I will write examples/256colors.nim as documentation tomorrow and submit it as an additional pull request.

jonathanabennett commented 6 years ago

I've written a test. If you can test it on your machine and see if it works, that would be great. It's in the same format as the others (only displaying for 1 second before closing). I don't like that, but I kept it consistent with the style of the others.

dom96 commented 6 years ago

Okay, this should be good. Thanks!