Open david-romano opened 1 week ago
@david-romano Thank you for the question! Can you provide a code example of doing so?
I'll try, @ronblum, but let me know if I misunderstand what you intended by "code example" — I tried to find the code currently used by RStudio to preview color names and hexadecimal colors, but I had no luck, so I can only give a sketch of what I'm suggesting rather than what I would usually think of as a code example.
I'm assuming that RStudio somehow uses the grDevices colors()
function to create, say, the preview of "red" in the editor. Given that assumption, I'm wondering whether a user could create something a like named vector, like:
user_defined_color_names <- c("amaranth" = "#9f2b68")
that RStudio would recognize as a source of user-defined color names, not unlike an assignment that might go into a .profile file of some kind. One possibility would be to literally use a .profile-like mechanism that RStudio could use to augment the grdDevices colors()
function. Another would be to have RStudio supply a named vector or list object (maybe as part of the ggplot2 package) that has a standard name (like user_defined_color_names
) and is used by RStudio as the source of the name-hexadecimal correspondence, and which users can then append their own name-hexadecimal pairings to.
Does that help, @ronblum ? Or were you suggesting a different kind of code example?
If I name a hexadecimal color, is there currently a way to have the "Enable preview of named and hexadecimal colors" option apply that color wherever the corresponding string appears in the editor?