void (final @NotNull Graphics g, @NotNull PairFunction<? super Integer, ? super Integer, ? extends Couple<Integer>> _position) { Font oldFont = null; if (myFont != null) { oldFont = g.getFont(); g.setFont(myFont); } Color oldColor = null; if (myColor != null) { oldColor = g.getColor(); g.setColor(myColor); } try { final int[] maxWidth = {0}; final int[] height = {0}; ContainerUtil.process(myLines, text -> { FontMetrics fm = g.getFontMetrics(); maxWidth[0] = Math.max(fm.stringWidth(text.replace("<shortcut>", "").replace("</shortcut>", "")), maxWidth[0]); height[0] += (fm.getHeight() + fm.getLeading()) * myLineSpacing; return true; }); final Couple<Integer> position = _position.fun(maxWidth[0] + 20, height[0]); assert position != null; final int[] yOffset = {position.getSecond()}; ContainerUtil.process(myLines, text -> { String shortcut = ""; if (text.contains("<shortcut>")) { shortcut = text.substring(text.indexOf("<shortcut>") + "<shortcut>".length(), text.indexOf("</shortcut>")); text = text.substring(0, text.indexOf("<shortcut>")); } int x = position.getFirst() + 10; FontMetrics fm = g.getFontMetrics(); if (myDrawShadow) { int xOff = StartupUiUtil.isUnderDarcula() ? 1 : 0; Color oldColor1 = g.getColor(); g.setColor(myShadowColor); int yOff = 1; g.drawString(text, x + xOff, yOffset[0] + yOff); g.setColor(oldColor1); } g.drawString(text, x, yOffset[0]); if (!Strings.isEmpty(shortcut)) { Color oldColor1 = g.getColor(); g.setColor(JBColor.namedColor("Editor.shortcutForeground", new JBColor(new Color(82, 99, 155), new Color(88, 157, 246)))); g.drawString(shortcut, x + fm.stringWidth(text + (StartupUiUtil.isUnderDarcula() ? " " : "")), yOffset[0]); g.setColor(oldColor1); } yOffset[0] += (fm.getHeight() + fm.getLeading()) * myLineSpacing; return true; }); } finally { if (oldFont != null) g.setFont(oldFont); if (oldColor != null) g.setColor(oldColor); } }