src/main/java/dev/lambdaurora/spruceui/widget/text/SpruceTextAreaWidget.java
protected void drawSelection(MatrixStack matrices, String line, int lineY, int row) {
        if (!this.isFocused())
            return;
        if (!this.selection.isRowSelected(row))
            return;

        int startIndex;
        if (selection.getStart().row != row) startIndex = 0;
        else startIndex = selection.getStart().column;

        int endIndex;
        if (selection.getEnd().row != row) endIndex = line.length();
        else endIndex = selection.getEnd().column;

        if (endIndex >= line.length())
            endIndex = line.length();

        if (startIndex >= line.length() || startIndex == endIndex)
            return;

        int x = this.getX() + 4 + this.textRenderer.getWidth(line.substring(0, startIndex));
        var selected = line.substring(startIndex, endIndex);

        int x2 = x + this.textRenderer.getWidth(selected);
        int y2 = lineY + this.textRenderer.fontHeight;

        var tessellator = Tessellator.getInstance();
        var buffer = tessellator.getBuffer();
        RenderSystem.disableTexture();
        RenderSystem.enableColorLogicOp();
        RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
        RenderSystem.setShader(GameRenderer::getPositionShader);
        RenderSystem.setShaderColor(0.f, 0.f, 255.f, 255.f);
        buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
        buffer.vertex(x, y2, 0.d).next();
        buffer.vertex(x2, y2, 0.d).next();
        buffer.vertex(x2, lineY, 0.d).next();
        buffer.vertex(x, lineY, 0.d).next();
        tessellator.draw();
        RenderSystem.disableColorLogicOp();
        RenderSystem.enableTexture();
    }
/**
     * Draws the selection over the text.
     *
     * @param matrices the matrices
     * @param line the current line
     * @param lineY the line Y-coordinates
     * @param row the row number
     */
Draws the selection over the text.
@param matrices the matrices
@param line the current line
@param lineY the line Y-coordinates
@param row the row number
Draws the selection over the text . @param matrices the matrices @param line the current line @param lineY the line Y - coordinates @param row the row number
protected void drawSelection(MatrixStack matrices, String line, int lineY, int row) {
        if (!this.isFocused())
            return;
        if (!this.selection.isRowSelected(row))
            return;
        int startIndex;
        if (selection.getStart().row != row) startIndex = 0;
        else startIndex = selection.getStart().column;
        int endIndex;
        if (selection.getEnd().row != row) endIndex = line.length();
        else endIndex = selection.getEnd().column;
        if (endIndex >= line.length())
            endIndex = line.length();
        if (startIndex >= line.length() || startIndex == endIndex)
            return;
        int x = this.getX() + 4 + this.textRenderer.getWidth(line.substring(0, startIndex));
        var selected = line.substring(startIndex, endIndex);
        int x2 = x + this.textRenderer.getWidth(selected);
        int y2 = lineY + this.textRenderer.fontHeight;
        var tessellator = Tessellator.getInstance();
        var buffer = tessellator.getBuffer();
        RenderSystem.disableTexture();
        RenderSystem.enableColorLogicOp();
        RenderSystem.logicOp(GlStateManager.LogicOp.OR_REVERSE);
        RenderSystem.setShader(GameRenderer::getPositionShader);
        RenderSystem.setShaderColor(0.f, 0.f, 255.f, 255.f);
        buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
        buffer.vertex(x, y2, 0.d).next();
        buffer.vertex(x2, y2, 0.d).next();
        buffer.vertex(x2, lineY, 0.d).next();
        buffer.vertex(x, lineY, 0.d).next();
        tessellator.draw();
        RenderSystem.disableColorLogicOp();
        RenderSystem.enableTexture();
    }
protected void drawSelection ( MatrixStack matrices , String line , int lineY , int row ) { if ( ! this . isFocused ( ) ) return ; if ( ! this . selection . isRowSelected ( row ) ) return ; int startIndex ; if ( selection . getStart ( ) . row != row ) startIndex = 0 ; else startIndex = selection . getStart ( ) . column ; int endIndex ; if ( selection . getEnd ( ) . row != row ) endIndex = line . length ( ) ; else endIndex = selection . getEnd ( ) . column ; if ( endIndex >= line . length ( ) ) endIndex = line . length ( ) ; if ( startIndex >= line . length ( ) || startIndex == endIndex ) return ; int x = this . getX ( ) + 4 + this . textRenderer . getWidth ( line . substring ( 0 , startIndex ) ) ; var selected = line . substring ( startIndex , endIndex ) ; int x2 = x + this . textRenderer . getWidth ( selected ) ; int y2 = lineY + this . textRenderer . fontHeight ; var tessellator = Tessellator . getInstance ( ) ; var buffer = tessellator . getBuffer ( ) ; RenderSystem . disableTexture ( ) ; RenderSystem . enableColorLogicOp ( ) ; RenderSystem . logicOp ( GlStateManager . LogicOp . OR_REVERSE ) ; RenderSystem . setShader ( GameRenderer :: getPositionShader ) ; RenderSystem . setShaderColor ( 0.f , 0.f , 255.f , 255.f ) ; buffer . begin ( VertexFormat . DrawMode . QUADS , VertexFormats . POSITION ) ; buffer . vertex ( x , y2 , 0.d ) . next ( ) ; buffer . vertex ( x2 , y2 , 0.d ) . next ( ) ; buffer . vertex ( x2 , lineY , 0.d ) . next ( ) ; buffer . vertex ( x , lineY , 0.d ) . next ( ) ; tessellator . draw ( ) ; RenderSystem . disableColorLogicOp ( ) ; RenderSystem . enableTexture ( ) ; }
Draws the selection over the text.
Draws the selection over the text .