<commit_before><?php

namespace Dahl\PhpTerm\Output;

/**
 * Element class. For printing text.
 * 
 * @copyright Copyright (C) 2015 <NAME>
 * @author <NAME> <<EMAIL>> 
 * @license MIT License <http://opensource.org/licenses/MIT>
 */
class Element
{
    /**
     * The text to print.
     * 
     * @var array
     * @access protected
     */
    protected $_text;

    /**
     * If element text or style has changed.
     * 
     * @var boolean
     * @access protected
     */
    protected $_hasChanges = false;

    /**
     * The element Id
     * 
     * @var string
     * @access protected
     */
    protected $_id;

    /**
     * The parent element
     * 
     * @var Window | Element
     * @access protected
     */
    protected $_parent;

    /**
     * The size of parent element.
     * 
     * @var array
     * @access protected
     */
    protected $_size;

    /**
     * The element style.
     * 
     * @var array
     * @access protected
     */
    protected $_style = array();

    /**
     * Constructor.
     * 
     * @param string $id 
     * @access public
     * @return void
     */
    public function __construct($id)
    {
        $this->_id = $id;
    }

    /**
     * Returns element id.
     * 
     * @access public
     * @return string
     */
    public function getId()
    {
        return $this->_id;
    }

    /**
     * Returns element parent.
     * 
     * @access public
     * @return Window | Element
     */
    public function getParent()
    {
        return $this->_parent;
    }

    /**
     * Sets the element parent.
     * 
     * @param Window | Element $parent
     * @access public
     * @return void
     */
    public function setParent($parent)
    {
        $this->_parent = $parent;

        return $this;
    }

    /**
     * Returns the output object.
     * 
     * @access public
     * @return Terminal
     */
    public function getOutput()
    {
        return $this->_parent->getOutput();
    }

    /**
     * Set element text.
     * 
     * @param string $string
     * @access public
     * @return void
     */
    public function setText($string)
    {
        $this->_hasChanges = true;
        $this->_text = explode("\n", $string);
    }

    /**
     * Set the element style.
     * 
     * @param string $string
     * @access public
     * @return Element
     */
    public function setStyle($string)
    {
        $this->_hasChanges = true;
        $styles = explode(';', $string);
        foreach ($styles as $style) {
            $style = explode(':', $style);
            if (count($style) == 2) {<commit_msg>Added Element focus method<commit_after><?php

namespace Dahl\PhpTerm\Output;

/**
 * Element class. For printing text.
 * 
 * @copyright Copyright (C) 2015 <NAME>
 * @author <NAME> <<EMAIL>> 
 * @license MIT License <http://opensource.org/licenses/MIT>
 */
class Element
{
    /**
     * The text to print.
     * 
     * @var array
     * @access protected
     */
    protected $_text;

    /**
     * If element text or style has changed.
     * 
     * @var boolean
     * @access protected
     */
    protected $_hasChanges = false;

    /**
     * The element Id
     * 
     * @var string
     * @access protected
     */
    protected $_id;

    /**
     * The parent element
     * 
     * @var Window | Element
     * @access protected
     */
    protected $_parent;

    /**
     * The size of parent element.
     * 
     * @var array
     * @access protected
     */
    protected $_size;

    /**
     * The element style.
     * 
     * @var array
     * @access protected
     */
    protected $_style = array();

    /**
     * Constructor.
     * 
     * @param string $id 
     * @access public
     * @return void
     */
    public function __construct($id)
    {
        $this->_id = $id;
    }

    /**
     * Returns element id.
     * 
     * @access public
     * @return string
     */
    public function getId()
    {
        return $this->_id;
    }

    /**
     * Returns element parent.
     * 
     * @access public
     * @return Window | Element
     */
    public function getParent()
    {
        return $this->_parent;
    }

    /**
     * Sets the element parent.
     * 
     * @param Window | Element $parent
     * @access public
     * @return void
     */
    public function setParent($parent)
    {
        $this->_parent = $parent;

        return $this;
    }

    /**
     * Returns the output object.
     * 
     * @access public
     * @return Terminal
     */
    public function getOutput()
    {
        return $this->_parent->getOutput();
    }

    /**
     * Select this element as the focus element.
     * 
     * @access public
     * @return Element
     */
    public function setFocus()
    {
        $this->_parent->setFocus($this);

        return $this;
    }

    /**
     * Applies focus, moving the cursor to the end of the
     * element.
     * 
     * @access public
     * @return void
     */
    public function applyFocus()
    {
        $output = $this->getOutput();
        $width  = $this->getWidth();
        $height = $this->getHeight();

        $row = $this->_getStartRow($height);
        $col = $this->_getStartCol($width, $width);
        $output->setPos($row, $col + $width);
    }

    /**
     * Set element text.
     * 
     * @param string $string
     * @access public
     * @return void
     */
    public function setText($string)
    {
        $this->_hasChanges = true;
        $this->_text = explode("\n", $string);
    }

    /**
     * Set the element style.
     * 
     * @param string $string
     * @access public
     * @return Element
     */
    public function setStyle($string)
    {
        $this->_hasChanges = true;
        $styles = explode(';', $string);
        foreach ($styles as $style) {
            $style = explode(':', $style);
            if (count($style) == 2) {
{'fraction_non_alphanumeric': 0.13303994583615436, 'fraction_numerical': 0.0016926201760324984, 'mean_word_length': 1.5646701388888888, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 39, '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': '3052865', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1727, 'n_words': 458}