@Override
        protected int drawUnselectedText(final Graphics g, int x, int y,
                int p0, int p1)
                throws BadLocationException {
            // Copied, with a few changes
            final Font boldFont = g.getFont().deriveFont(Font.BOLD);
            final Font plainFont = g.getFont().deriveFont(Font.PLAIN);
            final Document doc = getDocument();
            
            Color last = null;
            Color fg;
            
            boolean bold = false;
            boolean lastBold = false;
            
            int mark = p0;
            
            while (p0 < p1) {
                updateScanner(p0);
                int p = Math.min(scanner.getEndOffset(), p1);
                p = (p <= p0) ? p1 : p;
                
                MutableAttributeSet style = styles.getStyle(scanner.lastToken(), scanner.lastStr());
                fg = StyleConstants.getForeground(style);
                bold = StyleConstants.isBold(style);
                
                if ((fg != last && last != null) || (bold != lastBold)) {
                    // color change, flush what we have
                    g.setColor(last);
                    g.setFont(lastBold ? boldFont : plainFont);
                    Segment text = getLineBuffer();
                    doc.getText(mark, p0 - mark, text);
                    x = Utilities.drawTabbedText(text, x, y, g, this, mark);
                    mark = p0;
                }
                last = fg;
                lastBold = bold;
                p0 = p;
            }
            // flush remaining
            g.setColor(last);
            g.setFont(lastBold ? boldFont : plainFont);
            Segment text = getLineBuffer();
            doc.getText(mark, p1 - mark, text);
            return Utilities.drawTabbedText(text, x, y, g, this, mark);
        }