Giter Site home page Giter Site logo

Comments (8)

certik avatar certik commented on May 24, 2024 1

We can have a function for \033[0m in addition to the other functions.

Great job a the 24 bit colors. Something like what you did should work!

from cpp-terminal.

MCWertGaming avatar MCWertGaming commented on May 24, 2024 1

Yeah! I'll do the changes inside of the window class next. I would also take that opportunity to create a "test" example for the terminal tests, it would include all features of cpp-terminal so we can easily determine which terminals are supporting which things / colors. Also I would like to either add colors24 to the readme or move the color part from the readme into a section of the wiki.

What do you think?
also should color() stay that way, or is color4() better? (because color 4bit)

from cpp-terminal.

certik avatar certik commented on May 24, 2024 1

That all looks like a great plan. I would leave color for now, we can rename later.

from cpp-terminal.

certik avatar certik commented on May 24, 2024 1

Sounds good. Let me know if you need help.

from cpp-terminal.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

I have experimented a bit with RGB coloring in cpp-terminal and it's going well so far. I have created the function color24(int, int, int, bool). I know it looks ugly, but how are we going to handle the input of it? The problem with using a struct like color() does isn't possible, as we have 255x255x255 colors. Another problem is that we need to set foreground and background values, as \033[38;2;<r>;<g>;<b>m is only changing the foreground, the background is set with \033[48;2;<r>;<g>;<b>m (just 48 instead of 38).

I would so it like this:

std::string color24(unsigned int red, unsigned int green, unsigned int blue, bool fg)
{
    if (fg)
        return "\033[38;2;" + std::to_string(red) + ';' + std::to_string(green) + ';' + std::to_string(blue) + 'm';
    else
        return "\033[48;2;" + std::to_string(red) + ';' + std::to_string(green) + ';' + std::to_string(blue) + 'm';
}

I have already tested it:
image

What do you think about that?

I have also checked, if color(fg::reset) resets also 24bit colors and it does! But I would suggest to create a function with \033[0m as it's the ANSI reset code and resets all attributes (and is 1 character shorter than \033[39m).

I'll look into the color struct of the window class next.

from cpp-terminal.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

I have started to edit the parts in the Window class. Your Color struct is not compiling at all due to the -Wall compiler flag, because ISO C++ forbids anonymous structures and unions inside of structures. The correct way to do that is to create the color type enum separately, as well as the rgb struct and create a union to group the 4bit and 24bit colors together. Just have to change a bit because I cant initilize a vector holding a struct like you did with the normal vectors Window() : vector(size, content) I'll probably need some more testing around to get a good approach.

from cpp-terminal.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

A small update: I have tried a few ideas to implement the colors inside of the window class. 24bit color is really complicated, as we can't just re-use all of the code already there. Also the render function gets really blown as we have to check for the tag vector all the time and make big if monsters. I would suggest to simply make it two classes (like Window_4bit and Window_24bit). I think that would make the usage a bit easier as well. But If you would prefer it to be one class, I can try to merge the them together afterwards.

from cpp-terminal.

MCWertGaming avatar MCWertGaming commented on May 24, 2024

Also: the window demo crashes my visual studio code integrated terminal and has some color issues inside of it. That might be a problem on other Terminal as well (just the window example though). We should test that in #73 as well to be safe. It is possible, that the visual studio terminal has some problems, because the same binary just works perfectly fine on my normal terminal (Kitty). I open a separate issue on that one!

from cpp-terminal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.