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

Syntactic sugar for binary pairs #38

Closed
caseykneale opened this issue Jul 16, 2020 · 2 comments
Closed

Syntactic sugar for binary pairs #38

caseykneale opened this issue Jul 16, 2020 · 2 comments

Comments

@caseykneale
Copy link

I really like crayons but it adds a bit of bloat syntactically. Would it be reasonable to suggest something like the following below?

using Crayons
cols = "black, red, green, yellow, blue, magenta, cyan, light_gray, default, dark_gray, light_red, light_green, light_yellow, light_blue, light_magenta, light_cyan, white"
fxs = "reset, bold, faint, italics, underline, blink, negative, conceal, strikethrough"

for (col, fx) in Iterators.product( split(cols, ", "), split(fxs, ", ") )
    name = Symbol(col * "_" * fx)
    global colsym = Symbol( col )
    global fxsym = Symbol( fx )
    @eval $colsym = colsym
    @eval $fxsym = fxsym
    @eval $name() = Crayon( foreground = $colsym, $fxsym = true)
end

print( magenta_italics(), "woah", cyan_underline(), " wooooo" )

Basically just make it a little less verbose so you don't end up with really long lines of code to print text?

@KristofferC
Copy link
Owner

There are some hardcoded combinations in #38.

You can also use the string macro

bild

@caseykneale
Copy link
Author

Did I reinvent something already existing? if so just close this "issue".

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

No branches or pull requests

2 participants