<commit_before>package org.liquidengine.legui.component.optional;

import java.util.Objects;
import java.util.function.BiConsumer;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.io.Serializable;

/**
 * Used to hold text state of components.
 */
public class TextState implements Serializable {

    /**
     * Text data.
     */
    private String text = "";

    /**
     * Used to store caret position in text.
     */
    private int caretPosition;

    /**
     * Used to store caret position calculated on mouse position base. Updated by renderers.
     */
    private int mouseCaretPosition;

    /**
     * Used to store start selection index.
     */
    private int startSelectionIndex;

    /**
     * Used to store end selection index.
     */
    private int endSelectionIndex;

    /**
     * Used to store text input editable state. If true then text could be updated by user input.
     */
    private boolean editable = true;

    private float textWidth;
    private float textHeight;

    private Float caretX;
    private Float caretY;

    /**
     * Should be defined to call some extra functionality after {@link #setText(String)}.  Accepts old value as first arg, and new value as the second arg.
     */
    private BiConsumer<String, String> textSetCallback;


    /**
     * Default constructor.
     */
    public TextState() {
    }

    /**
     * Used to create TextState with predefined text.
     *
     * @param text text to set.
     */
    public TextState(String text) {
        setText(text);
    }

    /**
     * Used to create TextState with predefined text.
     *
     * @param textSetCallback callback to call some extra functionality after {@link #setText(String)}. Accepts old value as first arg, and new value as the
     * second arg.
     */
    public TextState(BiConsumer<String, String> textSetCallback) {
        this.textSetCallback = textSetCallback;
    }

    /**
     * Used to create TextState with predefined text.
     *
     * @param text text to set.
     * @param textSetCallback callback to call some extra functionality after {@link #setText(String)}. Accepts old value as first arg, and new value as the
     * second arg.
     */
    public TextState(String text, BiConsumer<String, String> textSetCallback) {
        this.text = text;
        this.textSetCallback = textSetCallback;
    }

    /**
     * Returns text.
     *
     * @return text.
     */
    public String getText() {
        return text;
    }

    /**
     * Used to set new text.
     *
     * @param text new text.<commit_msg>small fix for TextState<commit_after>package org.liquidengine.legui.component.optional;

import java.util.Objects;
import java.util.function.BiConsumer;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.io.Serializable;

/**
 * Used to hold text state of components.
 */
public class TextState implements Serializable {

    /**
     * Text data.
     */
    private String text = "";

    /**
     * Used to store caret position in text.
     */
    private int caretPosition;

    /**
     * Used to store caret position calculated on mouse position base. Updated by renderers.
     */
    private int mouseCaretPosition;

    /**
     * Used to store start selection index.
     */
    private int startSelectionIndex;

    /**
     * Used to store end selection index.
     */
    private int endSelectionIndex;

    /**
     * Used to store text input editable state. If true then text could be updated by user input.
     */
    private boolean editable = true;

    private float textWidth;
    private float textHeight;

    private Float caretX;
    private Float caretY;

    /**
     * Should be defined to call some extra functionality after {@link #setText(String)}.  Accepts old value as first arg, and new value as the second arg.
     */
    private BiConsumer<String, String> textSetCallback;


    /**
     * Default constructor.
     */
    public TextState() {
        this("", null);
    }

    /**
     * Used to create TextState with predefined text.
     *
     * @param text text to set.
     */
    public TextState(String text) {
        this(text, null);
    }

    /**
     * Used to create TextState with predefined text.
     *
     * @param textSetCallback callback to call some extra functionality after {@link #setText(String)}. Accepts old value as first arg, and new value as the
     * second arg.
     */
    public TextState(BiConsumer<String, String> textSetCallback) {
        this("", textSetCallback);
    }

    /**
     * Used to create TextState with predefined text.
     *
     * @param text text to set.
     * @param textSetCallback callback to call some extra functionality after {@link #setText(String)}. Accepts old value as first arg, and new value as the
     * second arg.
     */
    public TextState(String text, BiConsumer<String, String> textSetCallback) {
        this.textSetCallback = textSetCallback;
        setText(text);
    }

    /**
     * Returns text.
     *
     * @return text.
     */
    public String getText() {
        return text;
    }

    /**
     * Used to set new text.
     *
     * @param text new text.
{'fraction_non_alphanumeric': 0.09040200038468936, 'fraction_numerical': 0.00038468936333910367, 'mean_word_length': 2.3036848792884372, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3524163', 'n_tokens_mistral': 1434, 'n_tokens_neox': 1381, 'n_words': 510}