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

Enable advanced color modes in screen/put-string #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

charlot-shaw
Copy link

@charlot-shaw charlot-shaw commented Apr 19, 2024

Reasoning

I'm poking around roguelike design in clojure, using clojure-lanterna. I wanted to specify the RGB colors drawn, and use more advanced features in the underlying library.

Features

  • No API changes for people consuming the library correctly.
  • Indexed mode accessible.
  • RGB mode accessible.
  • Mostly delegates to the wrapped library, so maintenance should be minimal.

Implementation

I have a few questions relating to implementation I'd like to see before this is merged.

  1. Is the Markdown in the docstring acceptable? I personally feel it helps with readability, but I'm not a maintainer here.
  2. Given put-string is likely to be called a lot, I'm considering adding a core.cache to it, so that we aren't parsing the same string over and over in a hot loop. (This was partially why I setup the TextColor passthrough, to allow users to optimize.) I have no benchmarks, but it is a concern. I also considered a protocol, to allow for faster dispatch, but that felt heavyhanded for a first go.
  3. Most of the library doesn't seem to get in the way of any underlying java errors, but providing a bad string now gives a two layered exception, first an IllegalArgumentException, then an error from trying to type-hint the first exception. Between that and the exception making the default return of TextColor$ANSI/DEFAULT no longer guaranteed, it makes me wonder if I should catch and suppress the error.

Adds terminal/parse-color, which allows for colors
outside of the constants previously used.

It allows for indexed and RGB modes, which were
previously inacessible.

It doesn't change the behavior of existing code,
except in one edge case of someone using put-string
:fg or :bg options with a string, in which case it
now throws an error rather than a default value.

Finally, it includes an escape hatch that allows
for user-provided TextColors to flow through it.
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.

1 participant