src/main/java/dev/lambdaurora/spruceui/widget/text/SpruceTextFieldWidget.java
protected void drawSelection(String line, int lineY) {
        if (!this.isFocused() || !this.selection.active)
            return;

        int startIndex = Math.max(0, selection.getStart().column - this.firstCharacterIndex);
        int endIndex = Math.min(line.length(), selection.getEnd().column - this.firstCharacterIndex);

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

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

        int x2 = x + this.client.textRenderer.getWidth(selected);
        int y2 = lineY + this.client.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 line the current line
     * @param lineY the line Y-coordinates
     */
Draws the selection over the text.
@param line the current line
@param lineY the line Y-coordinates
Draws the selection over the text . @param line the current line @param lineY the line Y - coordinates
protected void drawSelection(String line, int lineY) {
        if (!this.isFocused() || !this.selection.active)
            return;
        int startIndex = Math.max(0, selection.getStart().column - this.firstCharacterIndex);
        int endIndex = Math.min(line.length(), selection.getEnd().column - this.firstCharacterIndex);
        if (startIndex >= line.length())
            return;
        int x = this.getX() + 4 + this.client.textRenderer.getWidth(line.substring(0, startIndex));
        var selected = line.substring(startIndex, endIndex);
        int x2 = x + this.client.textRenderer.getWidth(selected);
        int y2 = lineY + this.client.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 ( String line , int lineY ) { if ( ! this . isFocused ( ) || ! this . selection . active ) return ; int startIndex = Math . max ( 0 , selection . getStart ( ) . column - this . firstCharacterIndex ) ; int endIndex = Math . min ( line . length ( ) , selection . getEnd ( ) . column - this . firstCharacterIndex ) ; if ( startIndex >= line . length ( ) ) return ; int x = this . getX ( ) + 4 + this . client . textRenderer . getWidth ( line . substring ( 0 , startIndex ) ) ; var selected = line . substring ( startIndex , endIndex ) ; int x2 = x + this . client . textRenderer . getWidth ( selected ) ; int y2 = lineY + this . client . 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 .