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

Why does highline do coloring via ERb replacements and not via colored? #74

Closed
Sleft opened this issue Apr 1, 2013 · 1 comment
Closed

Comments

@Sleft
Copy link

Sleft commented Apr 1, 2013

Does Highline do coloring via ERb replacements and not via colored for any particular reason? Colored seems easier to use and cleaner and there is a fork that supports disabling of colors.

@JEG2
Copy link
Owner

JEG2 commented Apr 1, 2013

The ERb replacement syntax exists in case you don't have a reference to the HighLine instance. It's not required though. You can alway use the instance:

#!/usr/bin/env ruby -w

require "highline"

terminal = HighLine.new
terminal.say "#{terminal.color 'Red',      HighLine::RED}, "   +
             "#{terminal.color 'White',    HighLine::WHITE}, " +
             "and #{terminal.color 'Blue', HighLine::BLUE}."

You can use the class-level helper:

#!/usr/bin/env ruby -w

require "highline/import"

say "#{HighLine.color 'Red',      HighLine::RED}, "   +
    "#{HighLine.color 'White',    HighLine::WHITE}, " +
    "and #{HighLine.color 'Blue', HighLine::BLUE}."

Or you can use the global instance that the import system relies on:

#!/usr/bin/env ruby -w

require "highline/import"

say "#{$terminal.color 'Red',      HighLine::RED}, "   +
    "#{$terminal.color 'White',    HighLine::WHITE}, " +
    "and #{$terminal.color 'Blue', HighLine::BLUE}."

As for why doesn't HighLine use colored, it's probably just that it didn't exist back then or we didn't know about it. It looks like HighLine supports a much wider range of ANSI escape though. We also support color schemes.

It should be possible to use colored with HighLine though, if you desire. I don't think they would conflict.

Did I answer your questions?

@Sleft Sleft closed this as completed Apr 1, 2013
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