Color picker for string token
Answered
How create ColorPicker in my custom language string token? ElementColorProvider return only one color, but string can contain any number of colors.
s = “#ff00ff one #ffaaff two…”
Please sign in to leave a comment.
Hi,
Try the annotator approach:
https://github.com/JetBrains/intellij-community/blob/master/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxAnnotator.java#L115-L178
It annotates each color occurrence with a silent annotation that adds a gutter icon with the color picker.
Strings can contain very many colors. In your example, it is not clear what part of the string is given a color in the chooseColor method.
You should compute ranges of colors and add an annotation for each range with
com.intellij.lang.annotation.AnnotationBuilder#range(com.intellij.openapi.util.TextRange)
.When there are many colors in one line, it is not clear which icon is responsible for which color. The ideal solution would be to add an icon to the row. As it is implemented in VSCode.
Please vote/follow: https://youtrack.jetbrains.com/issue/IJPL-975/Inline-component-inlays
I think this might already be possible - doesn't the debugger do this for its inline breakpoints?
Looks like com.intellij.xdebugger.impl.breakpoints.InlineBreakpointInlayRenderer/Manager, but it doesn't look easy to extend right now.