Skip to content

Color functionality to the code. #4

Open
jlmolinero wants to merge 1 commit into766F6964:masterfrom
jlmolinero:adding-color
Open

Color functionality to the code. #4
jlmolinero wants to merge 1 commit into766F6964:masterfrom
jlmolinero:adding-color

Conversation

@jlmolinero
Copy link

The user only need to add color substring to the text in cell, with a bash format.

Examples and guide:
https://misc.flogisoft.com/bash/tip_colors_and_formatting

@jlmolinero jlmolinero force-pushed the adding-color branch 7 times, most recently from baca6dd to 4a49231 Compare November 15, 2023 01:06
@766F6964
Copy link
Owner

Thanks for the PR. I like the idea of adding color support.
However, I am not a fan that the user will have to manually enter the ansii escape sequences (It is easy to mess that up e.g. forget the reset escape sequence etc).
Instead, I would prefer an abstraction, where the user can just call function that colors a specific cell/row/col.
Something like:

table.set_cell_background_color(x, y, color);
table.set_cell_text_color(x, y, color);

Where color could be an enum of the 256 pre-defined colors, - they have names.
That way we could have a pre-defined mapping between ansii-color-sequences to an identifier a human can understand.

Maybe it would also make sense to have something like an init_colors() function that needs to be called at the start, to verify if 256 colors is supported by the terminal, otherwise, fallback to 16 colors.
Let me know if you are interested in making these changes.

@jlmolinero
Copy link
Author

Hello, sorry for the delay in responding but I have been a father and I have not been able to dedicate myself to this outside of work, now that the girl is older I have a little more time...

I will try to do something about it, I also wanted to tell you that I am going to use your code with some modifications for a Linux command that I am preparing, it is like a "free" linux command but on steroids.

I'm still in a very early version.

Greetings, I hope to give you information and modifications in a short period of time...

I hope my daughter lets me work.

@766F6964
Copy link
Owner

766F6964 commented Nov 1, 2024

@jlmolinero No problem, I will leave the issue open and you can get back to me if you made some progress. 👍

While this is a fairly old project of mine, I would still like to keep the API pretty self-descriptive and simple.
So it would be nice to have explicit functions to change the color as stated in my previous reply.

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.

2 participants