jalvesaq / colorout

Colorize R output in terminal emulators
288 stars 21 forks source link

[Suggestions] User should be able to define their own colours #12

Closed Nevrage closed 6 years ago

Nevrage commented 6 years ago

I maybe be wrong but it seems we can only use pre defined colours from the colors() list. Would it be possible to use user defined colours based on RGB values instead ?

jalvesaq commented 6 years ago

I could implement support for this, but what terminal emulator really display RGB colors? I have just tested xterm on Ubuntu 17.10 and the terminal outputs the closest ANSI color:

cat("\x1b[38;2;255;0;0mTRUECOLOR\x1b[0m\n")
cat("\x1b[38;2;255;20;0mTRUECOLOR\x1b[0m\n")
cat("\x1b[38;2;255;40;0mTRUECOLOR\x1b[0m\n")

cat("\x1b[38;2;255;60;0mTRUECOLOR\x1b[0m\n")
cat("\x1b[38;2;255;80;0mTRUECOLOR\x1b[0m\n")
cat("\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n")

Anyway, the simplest way of support this would be to accept strings as color definitions. Then, it would be up to the user to define the color correctly.

Nevrage commented 6 years ago

I don't know much about terminals bit I thought URxvt supported RGB colours.

Though I think I'm being confusing, my only issue is that on certain terminals my R output is not colored by the values in my Xresources file or by the theme of the terminal

jalvesaq commented 6 years ago

colorout does not read Xresources. Please, do this in R:

library(colorout)
?setOutputColors256
Nevrage commented 6 years ago

Yes I have read the documentation.

I was just wondering if there was a way to have colorout at least pick the closest color. So that changing the Xresources would change the colors in colorout.

jalvesaq commented 6 years ago

I am sorry, but I am not going to support Xresources. But I am working to let you pass any arbitrary string as color code.

Nevrage commented 6 years ago

Of course, that's perfect, I'll have something in my Rprofile to parse the Xresources.

Thank you very much!

jalvesaq commented 6 years ago

I am going to commit the change. Please, update the package, see the example of ?setOutputColors and reopen the issue if anything goes wrong.

mschilli87 commented 6 years ago

@Nevrage: If you come up with some Xresourses parsing code that works with the new colorout code, maybe you could share it here (as a gist?) for others that try to achieve the same and land here by search?

Nevrage commented 6 years ago

I ended up using the colors from wal, available here Could be made a lot cleaner I'm sure. Though I'm having an issue. Not certain if it is a bug or just me not understanding escape codes and how the colorout plugin works. The background doesn't seem to sit properly, here

jalvesaq commented 6 years ago

@Nevrage I cannot replicate the background leaking issue. What setOutputColors256() would replicate your color scheme? Can you replicate the issue in other terminal emulators?

Nevrage commented 6 years ago

I tried iTerm2 and never was able to reproduce it. Starting fresh with a simpler .Xresources seem to have fixed it on URxvt. I'll write an issue if I ever find the setting that broke it.