setCaretColour();
}
}
private void setCaretColour() {
Caret caret = control.getCaret();
Rectangle bounds = caret.getBounds();
int width = bounds.width;
int height = bounds.height;
caret = new Caret(control, SWT.NONE);
Display display = Display.getCurrent();
// System.out.printf("caret colour: %s %d %d\n", globalColour("caret"), width, height);
String caretColourString = bareGlobalColour("caret");
Color caretColour = ColourUtil.getColour(caretColourString);
Color white = display.getSystemColor(SWT.COLOR_WHITE);
Color black = display.getSystemColor(SWT.COLOR_BLACK);
String backgroundColourString = globalBackground();
int red = Integer.parseInt(backgroundColourString.substring(1, 3), 16) ^
Integer.parseInt(caretColourString.substring(1, 3), 16);
int green = Integer.parseInt(backgroundColourString.substring(3, 5), 16) ^
Integer.parseInt(caretColourString.substring(3, 5), 16);
int blue = Integer.parseInt(backgroundColourString.substring(5, 7), 16) ^
Integer.parseInt(caretColourString.substring(5, 7), 16);
PaletteData palette = new PaletteData (
new RGB [] {
new RGB (0, 0, 0),
new RGB (red, green, blue),
new RGB (0xFF, 0xFF, 0xFF),
});
ImageData maskData = new ImageData (1, height, 2, palette);
for (int y=0; y < height; y++)
maskData.setPixel(0, y, 1);
Image image = new Image (display, maskData);
caret.setImage(image);
control.setCaret(caret);
}