<commit_before>import { h, Component, render } from 'preact';
import LedMatrix from './led/matrix';
import { createStore } from './led/store';
import * as fonts from './led/fonts';

interface State {
  cols?: number;
  rows?: number;
  text?: string;
  color?: string;
  fonts?: string[];
  font?: string;
}

class Playground extends Component<any, State> {
  canvas: HTMLCanvasElement;
  led: LedMatrix;
  
  constructor() {
    super();
    this.state = {
      cols: 32,
      rows: 16,
      text: 'Hello\nThere',
      color: '#5fd3ff',
      fonts: Object.keys(fonts),
      font: 'fivebyfive'
    };
  }

  componentDidMount() {
    this.led = new LedMatrix(this.canvas, {
      x: this.state.cols,
      y: this.state.rows
    });
    this.draw();
  }

  draw() {
    const store = createStore(this.state.cols, this.state.rows);
    store.write(this.state.text, (fonts as any)[this.state.font], this.state.color);
    this.led.clear();
    this.led.draw(store.matrix);
  }

  slideChange(e: any, prop: string) {
    this.setState({
      [prop]: parseInt(e.target.value)
    });
    this.led.setNewDimensions(this.state.cols, this.state.rows);
    this.draw();
  }

  propChange(e: any, prop: string) {<commit_msg>Remove non ascii characters from input<commit_after>import { h, Component, render } from 'preact';
import LedMatrix from './led/matrix';
import { createStore } from './led/store';
import * as fonts from './led/fonts';

interface State {
  cols?: number;
  rows?: number;
  text?: string;
  color?: string;
  fonts?: string[];
  font?: string;
}

class Playground extends Component<any, State> {
  canvas: HTMLCanvasElement;
  led: LedMatrix;
  
  constructor() {
    super();
    this.state = {
      cols: 32,
      rows: 16,
      text: 'Hello\nThere',
      color: '#5fd3ff',
      fonts: Object.keys(fonts),
      font: 'fivebyfive'
    };
  }

  componentDidMount() {
    this.led = new LedMatrix(this.canvas, {
      x: this.state.cols,
      y: this.state.rows
    });
    this.draw();
  }

  draw() {
    // keep ascii codes 0 - 127 
    const text = this.state.text.replace(/[^\x00-\x7F]/g, '');
    const store = createStore(this.state.cols, this.state.rows);
    store.write(text, (fonts as any)[this.state.font], this.state.color);
    this.led.clear();
    this.led.draw(store.matrix);
  }

  slideChange(e: any, prop: string) {
    this.setState({
      [prop]: parseInt(e.target.value)
    });
    this.led.setNewDimensions(this.state.cols, this.state.rows);
    this.draw();
  }

  propChange(e: any, prop: string) {
{'fraction_non_alphanumeric': 0.16327329678935004, 'fraction_numerical': 0.0074393108848864525, 'mean_word_length': 2.8478915662650603, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2597055', 'n_tokens_mistral': 903, 'n_tokens_neox': 868, 'n_words': 197}