<commit_before>package ru.stablex.ui.widgets;

import nme.text.TextField;
import nme.text.TextFormat;
import ru.stablex.Err;
import ru.stablex.ui.UIBuilder;


/**
* Text field
*/
class Text extends Box{
    //<type>nme.display.TextField</type> used to render text
    public var label  : TextField;
    //Text format wich will be aplied to label on refresh
    public var format : TextFormat;
    //Getter-setter for text.
    public var text (_getText,_setText) : String;


    /**
    * Constructor
    *
    */
    public function new() : Void {
        super();

        this.label = cast(this.addChild(new TextField()), TextField);
        this.label.autoSize = nme.text.TextFieldAutoSize.LEFT;

        this.format = this.label.defaultTextFormat;

        this.align    = 'top,left';
    }//function new()


    /**
    * Refresh widget. Apply format to text, update text alignment and re-apply skin
    *
    */
    override public function refresh() : Void {
        this.label.defaultTextFormat = this.format;
        this.label.setTextFormat(this.format);

        super.refresh();
    }//function refresh()


    /**
    * Text getter
    *
    */
    private function _getText() : String {
        return this.label.text;
    }//function _getText()


    /**
    * Text setter
    *
    */
    private function _setText(txt:String) : String {
        this.label.text = txt;
        if( this.autoWidth ){
            this.refresh();
        }else{
            this.alignElements();
        }
        return txt;
    }//function _setText()

}//class Text<commit_msg>Text is multiline by default. Minor fix for wordWrap<commit_after>package ru.stablex.ui.widgets;

import nme.text.TextField;
import nme.text.TextFormat;
import ru.stablex.Err;
import ru.stablex.ui.UIBuilder;


/**
* Text field
*/
class Text extends Box{
    //<type>nme.display.TextField</type> used to render text
    public var label  : TextField;
    //Text format wich will be aplied to label on refresh
    public var format : TextFormat;
    //Getter-setter for text.
    public var text (_getText,_setText) : String;


    /**
    * Constructor
    *
    */
    public function new() : Void {
        super();

        this.label = cast(this.addChild(new TextField()), TextField);
        this.label.autoSize  = nme.text.TextFieldAutoSize.LEFT;
        this.label.multiline = true;

        this.format = this.label.defaultTextFormat;

        this.align    = 'top,left';
    }//function new()


    /**
    * Refresh widget. Apply format to text, update text alignment and re-apply skin
    *
    */
    override public function refresh() : Void {
        this.label.defaultTextFormat = this.format;
        this.label.setTextFormat(this.format);

        if( !this.autoWidth && this.label.wordWrap ){
            this.label.width = this._width;
        }

        super.refresh();
    }//function refresh()


    /**
    * Text getter
    *
    */
    private function _getText() : String {
        return this.label.text;
    }//function _getText()


    /**
    * Text setter
    *
    */
    private function _setText(txt:String) : String {
        this.label.text = txt;

        if( this.autoWidth || this.autoHeight ){
            this.refresh();
        }else{
            this.alignElements();
        }

        return txt;
    }//function _setText()

}//class Text
{'fraction_non_alphanumeric': 0.1211670139922596, 'fraction_numerical': 0.0, 'mean_word_length': 2.131407269338304, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2627498', 'n_tokens_mistral': 1016, 'n_tokens_neox': 986, 'n_words': 249}