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

Move color settings from taskrc to default.theme #3775

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

linsaraj
Copy link

@linsaraj linsaraj commented Feb 7, 2025

Removed all "color." related settings from "Context.cpp" and relocated them into a newly created file called "default.theme" within the same directory as the "no-color.theme" file.
Included "default.theme" file in "Context.cpp" using "#include default.theme".

linsaraj and others added 2 commits February 6, 2025 23:10
@djmitche djmitche linked an issue Feb 7, 2025 that may be closed by this pull request
Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

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

Nice work! I can confirm that the default.theme gets installed automatically, without having to be mentioned in doc/CMakeLists.txt.

However, this causes a few tests to fail, and I think that's because the removed lines in src/Context.cpp are actually the default config (as in, what Taskwarrior uses if no config file is found or a setting doesn't appear there). So when the tests run, there are no color settings at all.

I tried fixing this by putting include default.theme in configurationDefaults but not surprisingly, this didn't work -- it didn't find that file, since tests run from from the source code and not the installed application.

@d2718nis can correct me if I'm wrong, but I think the idea is to put the theme settings in one place (doc/rc) so we can't forget to update them when adding a new color setting. If that's the case, then we just need to find a way to also include that information in the default settings built into the task binary. https://stackoverflow.com/questions/410980/include-a-text-file-in-a-c-program-as-a-char/47801116 has some ideas of how to do that, but they look pretty complicated and involve messing with CMake.

@linsaraj and @d2718nis what do you think?

linsaraj and others added 2 commits February 7, 2025 17:49
Co-authored-by: Dustin J. Mitchell <[email protected]>
Co-authored-by: Dustin J. Mitchell <[email protected]>
@linsaraj
Copy link
Author

linsaraj commented Feb 8, 2025

Screenshot 2025-02-07 at 6 58 43 PM

Perhaps this would work? It's from the stack overflow you linked and doesn't seem to mess with the CMake! It just creates a pointer to the actual file, making it into a string and part of the source code!

@djmitche
Copy link
Collaborator

djmitche commented Feb 8, 2025

I think the issue with that solution is it requires that the file itself have R"( and )" in the file, which would make it unreadable as an include from .taskrc.

@linsaraj
Copy link
Author

linsaraj commented Feb 8, 2025

Ah, I see. Maybe we can create a function that reads a text file we want (like the "default.theme" file) and outputs it into a string so that we can call that function to include it in the source code? That way, we don't have to edit or add R"()" to the files!

@djmitche
Copy link
Collaborator

djmitche commented Feb 8, 2025

Maybe! Let's try that..

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.

Move color settings from taskrc to default.theme
3 participants