<commit_before>#ifndef _TEXTFIELD_H_
#define _TEXTFIELD_H_

#include <InputElement.h>
#include <Command.h>
#include <ValueEvent.h>

class TextField : public InputElement {
 public:
 TextField(unsigned int _flags = 0) : InputElement(0, _flags) {  }

  bool isA(const std::string & className) const override {
    if (className == "TextField") return true;
    return InputElement::isA(className);
  }

  void onValueEvent(ValueEvent & ev) override {
    value = ev.getTextValue();
    notify(value);
    ev.setHandled(true);
  }

  void clear() {
    sendCommand(Command(Command::CLEAR, getInternalId()));
  }

  bool call(bool t) override { return call(t ? "true" : "false"); }
  bool call(const std::string & s) override {
    value = s;
    Command c(Command::SET_TEXT_VALUE, getInternalId());
    c.setTextValue(value);
    sendCommand(c);
    return true;
  }

  const std::string & getValue() const { return value; }

 protected:
  void create() override {
    Command c(Command::CREATE_TEXTFIELD, getParentInternalId(), getInternalId());
    c.setTextValue(value);
    sendCommand(c);
  }

 private:
  std::string value;<commit_msg>add text() method<commit_after>#ifndef _TEXTFIELD_H_
#define _TEXTFIELD_H_

#include <InputElement.h>
#include <Command.h>
#include <ValueEvent.h>

class TextField : public InputElement {
 public:
 TextField(unsigned int _flags = 0) : InputElement(0, _flags) {  }

  bool isA(const std::string & className) const override {
    if (className == "TextField") return true;
    return InputElement::isA(className);
  }

  void onValueEvent(ValueEvent & ev) override {
    value = ev.getTextValue();
    notify(value);
    ev.setHandled(true);
  }

  void clear() {
    sendCommand(Command(Command::CLEAR, getInternalId()));
  }

  bool call(bool t) override { return call(t ? "true" : "false"); }
  bool call(const std::string & s) override {
    text(s);
    return true;
  }

  void text(const std::string & _value) override {
    value = _value;

    if (isInitialized()) {
      Command c(Command::SET_TEXT_VALUE, getInternalId());
      c.setTextValue(value);
      sendCommand(c);
    }
  }

  const std::string & getValue() const { return value; }

 protected:
  void create() override {
    Command c(Command::CREATE_TEXTFIELD, getParentInternalId(), getInternalId());
    c.setTextValue(value);
    sendCommand(c);
  }

 private:
  std::string value;
{'fraction_non_alphanumeric': 0.13450292397660818, 'fraction_numerical': 0.001670843776106934, 'mean_word_length': 4.031512605042017, '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': '308698', 'n_tokens_mistral': 772, 'n_tokens_neox': 753, 'n_words': 183}