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

Implement termux colorschemes #311

Merged
merged 3 commits into from
Feb 17, 2024

Conversation

socksthefennec
Copy link
Contributor

This implements basic support for termux's colorschemes (~/.termux/colors.properties) through the new option terminal.colors. It takes an attribute set of strings and naively converts that to the key-value format termux expects, e.g.

terminal.colors = rec {
  background = color0;
  foreground = color15;
  cursor = color15;

  color0 = "#000000";
  # color1-14 here :)
  color15 = "#FFFFFF";
};

would become

background=#000000
color0=#000000
color15=#FFFFFF
cursor=#FFFFFF
foreground=#FFFFFF

I wasn't sure whether to use attrsOf or lazyAttrsOf, so I chose the latter as a guess.
I've mostly just copied over the implementation from what fonts do, I hope that's correct.

There are a couple issues with this as it stands:

  1. Colors aren't strictly checked, you can input any string.
  2. Attributes aren't checked, you can input any attribute (whereas I believe termux only ever uses background, foreground, cursor and color0-15).
  3. There isn't any option to use a preexisting file.
  4. The changes don't immediately apply and require opening a new session, but as I understand it that's blocked by Cannot run 'am' #221.
  5. Since both font and colors share most of the same code, maybe it could be pulled out into a separate function/functions?
  6. My documentation here could probably be better.

It works enough for my usecase, but there's certainly a lot that could be improved.

@t184256
Copy link
Collaborator

t184256 commented Feb 14, 2024

Hello and sorry for not getting to this PR for so long.

I took the liberty of rebasing, bumping copyright year, squashing, limiting allowed attrnames and adding some tests. Please take a look.

@t184256
Copy link
Collaborator

t184256 commented Feb 14, 2024

One more thing we'll need is a changelog entry.

@t184256 t184256 merged commit b237029 into nix-community:master Feb 17, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants