Coder Social home page Coder Social logo

color-console's People

Contributors

imfl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

color-console's Issues

Question about strings

I want to try to dye a string that is defined by a cin >> input, and make the string reference the color each time the string is called.
I.E.
string firstName
cin >> firstName
how do I do this?

Avoid unnecessary Allocations and Copys

You are using a lot of std::string types and always copy them. Consider using const char* pointer since you are only using raw literal strings. This will avoid unnecessary copys and allocations (this of course depends on the implementation of std::string and if its using short string optimisation)

And I took a deeper look at your code. Why are you not just using an enum value that already has the value needed for the win32 api? Something like

enum class hue {black = 0, .... }

Then you would just need to overload the stream operator for the enum.

linker error:

color-console-error.txt
See errors in file.

Not all functions are marked with the keywords inline or constexpr or are templated. As a result if one would include this headder more than twice the linker is going to complain.

Not compatible with wcout ?

I'd like to use this lib with wcout to dispaly utf16 characters, but when writing
wcout << dye::green(L"hello");
I get the error:

error: no match for 'operator<<' (operand types are 'std::wostream' {aka 'std::basic_ostream<wchar_t>'} and 'dye::R<const wchar_t*>' {aka 'dye::colorful<const wchar_t*>'})
     wcout << dye::green(L"hello");
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Any quick solution for this issue?

LNK1169, LNK2005 Errors

Error LNK1169 one or more multiply defined symbols found

Error LNK2005 "void __cdecl hue::set_text(class std::basic_string<char,struct std::char_traits,class std::allocator >)" (?set_text@hue@@yaxv?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@z) already defined in person.obj

Error LNK2005 "void __cdecl hue::set_background(class std::basic_string<char,struct std::char_traits,class std::allocator >)" (?set_background@hue@@yaxv?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@@z) already defined in person.obj C++_Weak_ptr

Severity Code Description Project File Line Suppression State
Error LNK2005 "void __cdecl hue::set(int,int)" (?set@hue@@yaxhh@Z) already defined in person.obj C++_Weak_ptr


_there are still as many as 300 more link errors like this happend when i tried to compile the program.
_when you include color-console library inside a user defined class this link errors happen, but if you use it without being included
in any class no errors generate.

please help me what shoul i do now?

FIX the problem sooooooooooooooooooon

:-)

thank you very much helped me a lot!
I'm making a code editor based on the vim type terminal

Conflicting with windows.h

Not sure what library conflicts with windows.h as some library also defines byte, was necessary to add #define WIN32_LEAN_AND_MEAN at the top of the header file to make it work, without the macro, throws a bunch of compilation errors like this:
In file included from c:\mingdef\mingw\x86_64-w64-mingw32\include\wtypes.h:8, from c:\mingdef\mingw\x86_64-w64-mingw32\include\winscard.h:10, from c:\mingdef\mingw\x86_64-w64-mingw32\include\windows.h:97, from {path} headers/color.hpp:11, from {path} testing.cpp:7: c:\mingdef\mingw\x86_64-w64-mingw32\include\rpcndr.h:64:11: error: reference to 'byte' is ambiguous 64 | typedef byte cs_byte; | ^~~~

I create a new macro that help using function in hue namespace

Add a new macro that can support function-like call for hue namespace

#define color(operation,content) operation << content << hue::reset

std::cout<<color(hue::red, "Hello world!"); //(color red)
std::cout<<color(hue::red, "Hello world!") << "just kidding"; //first one color red
std::cout<<color(hue::red, "Hello world!" << "just kidding") ; //2 string color red

all three work, everything outside of the color macro will be reset to original, because this macro call hue::reset after all operation

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.