@Nullable private static Color getGutterColor(@NotNull Range.InnerRange range, @Nullable Editor editor) { final EditorColorsScheme scheme = getColorScheme(editor); switch (range.getType()) { case Range.INSERTED: return scheme.getColor(EditorColors.ADDED_LINES_COLOR); case Range.DELETED: return scheme.getColor(EditorColors.DELETED_LINES_COLOR); case Range.MODIFIED: return scheme.getColor(EditorColors.MODIFIED_LINES_COLOR); case Range.EQUAL: return scheme.getColor(EditorColors.WHITESPACES_MODIFIED_LINES_COLOR); default: assert false; return null; } }
@Override public void paint(Editor editor, Graphics g, Rectangle r) { Color gutterColor = getGutterColor(myRange, editor); Color borderColor = getGutterBorderColor(editor); Rectangle area = getMarkerArea(editor, r, myRange.getLine1(), myRange.getLine2()); final int x = area.x; final int endX = area.x + area.width; final int y = area.y; final int endY = area.y + area.height; if (myRange.getInnerRanges() == null) { // Mode.DEFAULT if (y != endY) { paintRect(g, gutterColor, borderColor, x, y, endX, endY); } else { paintTriangle(g, gutterColor, borderColor, x, endX, y); } } else { // Mode.SMART if (y == endY) { paintTriangle(g, gutterColor, borderColor, x, endX, y); } else { List<Range.InnerRange> innerRanges = myRange.getInnerRanges(); for (Range.InnerRange innerRange : innerRanges) { if (innerRange.getType() == Range.DELETED) continue; int start = lineToY(editor, innerRange.getLine1()); int end = lineToY(editor, innerRange.getLine2()); paintRect(g, getGutterColor(innerRange, editor), null, x, start, endX, end); } for (int i = 0; i < innerRanges.size(); i++) { Range.InnerRange innerRange = innerRanges.get(i); if (innerRange.getType() != Range.DELETED) continue; int start; int end; if (i == 0) { start = lineToY(editor, innerRange.getLine1()); end = lineToY(editor, innerRange.getLine2()) + 5; } else if (i == innerRanges.size() - 1) { start = lineToY(editor, innerRange.getLine1()) - 5; end = lineToY(editor, innerRange.getLine2()); } else { start = lineToY(editor, innerRange.getLine1()) - 3; end = lineToY(editor, innerRange.getLine2()) + 3; } paintRect(g, getGutterColor(innerRange, editor), null, x, start, endX, end); } paintRect(g, null, borderColor, x, y, endX, endY); } } }