Comments (8)
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.
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.
That all looks like a great plan. I would leave color
for now, we can rename later.
from cpp-terminal.
Sounds good. Let me know if you need help.
from cpp-terminal.
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';
}
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.
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.
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.
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)
- Color are wrong with unicode characters on Windows HOT 2
- Flickering HOT 20
- Windows terminal can be turned into `legacy mode` and so crash our ANSII support detection
- example 'kilo' does not support special characters HOT 7
- exception leaking destructor is dangerous HOT 10
- build as shared library, error adding symbols: DSO missing from command line HOT 12
- Compiling the examples with GCC results in errors HOT 7
- Create a list of projects that are using this library HOT 3
- Bug: cpp-terminal crashes if two utf8 are inserted simultaneously HOT 42
- Multiline prompt stopped working on macOS
- Ctrl + I and Tab HOT 6
- Bug: Text Wrap Incompatibility HOT 6
- Bring back the list of other similar libraries HOT 4
- Pressing Ctrl, Alt, Shift creates a copy paste event on windows? HOT 3
- Addition of Metakey and Key results in warning of deprecation HOT 1
- Bug in key + metakey arithmetic HOT 7
- Exception thrown at this line when typeing to fast HOT 7
- mouse sending random characters to the terminal after examples/minimal ends HOT 8
- `std::cin` doesn't read pipe redirection HOT 8
- Issue with file headers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpp-terminal.