rubychan / coderay

Fast and easy syntax highlighting for selected languages, written in Ruby.
http://coderay.rubychan.de/
Other
846 stars 115 forks source link

Custom Colours - R,G,B values for KDE Konsole (or gnome-terminal) style when piping #166

Open ghost opened 10 years ago

ghost commented 10 years ago

Hey Kornelius,

With coderay one can parse or colourize ruby code even on the commandline.

For instance:

cat foo.rb | coderay -ruby

would colourize as can be seen on this partial screenshot:

http://oi61.tinypic.com/2iijx50.jpg

Now, in KDE konsole, I recently found out that you can use R,G,B values.

Here is an example, from kde konsole itself:

http://oi61.tinypic.com/dqna6r.jpg

So far so fine.

Now I was thinking that it would be nice if I could tell coderay to use these colour codes instead.

The gem that outputs the KDE colour codes is gem install konsole_colours

The ansi escape code that should work in kde konsole is this:

puts "\e[38;2;#{222};#{131};#{141}m Hello world!"

To test; you can see the 3 values here; R,G,B ... 222, 131, 141

Would it be possible to use coderay to also use this scheme, optionally? If so, how and where?

I think what I would need is a simple way to overrule the default colour codes used. Some way to make it permanent, perhaps in a new file, or if I can somehow load this palette into Coderay. The gem konsole_colours already provides the proper values, i.e. I can do:

KonsoleColours['slateblue']

=> "\e[38;2;106;90;205m\e[0;0m\e[0;37m"

And the proper R,G,B values are returned.

I can easily change this to return an array with three values, representing R,G,B.

Do you think there is any way to load up custom colours into Coderay?

ghost commented 10 years ago

test (sorry, my connection broke down ...)

korny commented 10 years ago

CodeRay is optimized for HTML, actually. I only added terminal support later.

My plan is still to integrate 256color support through the Paint gem (#118). This would allow for nicer colors.

There's no plan currently to allow terminal color "schemes". The Style definitions are basically CSS files. If anything, I'd like to have color schemes that can be used for both HTML and the terminal.

It's interesting that KDE has support for full RGB colors. That would certainly make things a bit easier.