@Override
    public void repaint(TextGraphics graphics)
    {
        if(hasFocus())
            graphics.applyTheme(Category.TEXTBOX_FOCUSED);
        else
            graphics.applyTheme(Category.TEXTBOX);
        
        if(visibleLeftPosition >= backend.length()) {
            visibleLeftPosition = backend.length() - 1;
            if(visibleLeftPosition < 0) {
                visibleLeftPosition = 0;
            }
        }
        
        graphics.fillArea(' ');
        String displayString = prerenderTransformation(backend).substring(visibleLeftPosition);
        if(displayString.length() > graphics.getWidth())
            displayString = displayString.substring(0, graphics.getWidth()-1);
        graphics.drawString(0, 0, displayString);
        setHotspot(graphics.translateToGlobalCoordinates(new TerminalPosition(editPosition - visibleLeftPosition, 0)));
        lastKnownWidth = graphics.getWidth();
    }