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

lib/colors: split out metaprogramming #2019

Merged
merged 6 commits into from
Jan 29, 2022

Conversation

gaelicWizard
Copy link
Contributor

@gaelicWizard gaelicWizard commented Jan 5, 2022

Description

In #99, an advanced method for computing color code escape sequences was committed to allow generation of any combination of text attributes: bold, underline, color, background color, &c. In #699, it was reverted for wasting a lot of time at every shell startup computing the same colors every time. Now, this PR splits the file in to two: lib/colors which contains the color codes used by Bash It, and plugin/colors which contains the metaprogramming color-escape computation engine.

Motivation and Context

The whole file was just hard to understand until I stumbled across the commits that made it that way...and the commit that removed it. This change has zero changes to the code as run, just separates the meta from the utility.

  • I specifically made sure that the file history would correctly follow both files by using two branches for git merge so that the new files both show history back through themes/colors.theme.bash.
  • I've alsö linted the files.
  • I've made zero substantive changes to the code. Everything should run exactly as before.
  • This could be a breaking change if anyone uses the metaprogramming framework for these colors, in which case they would need to bash-it enable plugin colors.
  • The plugin/colors framework could actually be used to run tests against lib/colors, to make sure that the colors precomputed match the colors generated. That sounds fun...said no-one ever...(I'm a nerd, ok?)

How Has This Been Tested?

Tested locally and full test suite passes.

Types of changes

  • Breaking change (may require someone to bash-it enable plugin colors)

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

@gaelicWizard gaelicWizard marked this pull request as ready for review January 5, 2022 21:16
@gaelicWizard gaelicWizard force-pushed the lib/colors branch 3 times, most recently from 8ea9d8c to 1b3c86b Compare January 6, 2022 07:48
bash_it.sh Show resolved Hide resolved
Copy link
Member

@NoahGorny NoahGorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gaelicWizard gaelicWizard force-pushed the lib/colors branch 6 times, most recently from 099b9d5 to 621db6c Compare January 9, 2022 08:32
@gaelicWizard gaelicWizard force-pushed the lib/colors branch 3 times, most recently from 03a8260 to fd212c5 Compare January 26, 2022 20:32
gaelicWizard and others added 6 commits January 28, 2022 13:08
This reverts Bash-it#99, a metaprogramming adventure in terminal color code escape computation. It was functionally reverted in Bash-it#699; I'm just finishing the job.
This reverts commit 2a3fde2 but does *not* restore the previous variables. Those are still provided by `lib/colors`.

This plugin exists for anyone who likes the metaprogramming adventure of computing colors dynamically rather than using hard-coded value. Potentially this could be used by themes, or possibly by a theme color-scheme randomizer?
@NoahGorny NoahGorny merged commit 2a9ee7e into Bash-it:master Jan 29, 2022
@gaelicWizard gaelicWizard deleted the lib/colors branch January 29, 2022 22:24
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.

None yet

2 participants