<commit_before>import { arr, obj } from "lively.lang";
import { pt, Rectangle, Color } from "lively.graphics";
import config from "../config.js";

import { connect } from "lively.bindings";
import { Morph, Text, Menu } from "../index.js";
import { StyleRange } from "../text/style.js";

import { Token, Mode, Theme } from "./highlighting.js";
import JavaScriptMode from "./modes/javascript.js";
import PlainMode from "./modes/plain.js";
import ChromeTheme from "./themes/chrome.js";
import TomorrowNightTheme from "./themes/tomorrow-night.js";
import GithubTheme from "./themes/github.js";

const modes = {
  "plain": PlainMode,
  "javascript": JavaScriptMode
}; // {[string] -> Mode}

const themes = {
  "chrome": ChromeTheme,
  "tomorrowNight": TomorrowNightTheme,
  "github" : GithubTheme
}; // {[string] -> Mode}


export default class CodeEditor extends Morph {

  constructor(props) {
    super({
      extent: props.extent || pt(400,300),
      submorphs: [{
        type: "text",
        name: "text",
        extent: props.extent || pt(400,300),
        textString: props.textString || "",
        fixedWidth: true,
        fixedHeight: true,
        clipMode: "auto",
        padding: Rectangle.inset(4, 2, 4, 2),
        fontFamily: "Monaco, monospace",
        onChange(change) { // work-around for lively.bindings bug<commit_msg>CodeEditor: allow to set font + size<commit_after>import { arr, obj } from "lively.lang";
import { pt, Rectangle, Color } from "lively.graphics";
import config from "../config.js";

import { connect } from "lively.bindings";
import { Morph, Text, Menu } from "../index.js";
import { StyleRange } from "../text/style.js";

import { Token, Mode, Theme } from "./highlighting.js";
import JavaScriptMode from "./modes/javascript.js";
import PlainMode from "./modes/plain.js";
import ChromeTheme from "./themes/chrome.js";
import TomorrowNightTheme from "./themes/tomorrow-night.js";
import GithubTheme from "./themes/github.js";

const modes = {
  "plain": PlainMode,
  "javascript": JavaScriptMode
}; // {[string] -> Mode}

const themes = {
  "chrome": ChromeTheme,
  "tomorrowNight": TomorrowNightTheme,
  "github" : GithubTheme
}; // {[string] -> Mode}


export default class CodeEditor extends Morph {

  constructor(props) {
    super({
      extent: props.extent || pt(400,300),
      submorphs: [{
        type: "text",
        name: "text",
        extent: props.extent || pt(400,300),
        textString: props.textString || "",
        fixedWidth: true,
        fixedHeight: true,
        clipMode: "auto",
        padding: Rectangle.inset(4, 2, 4, 2),
        fontSize: props.fontSize || 12,
        fontFamily: props.fontFamily || "Monaco, monospace",
        onChange(change) { // work-around for lively.bindings bug
{'fraction_non_alphanumeric': 0.1539573545355981, 'fraction_numerical': 0.012287676183592338, 'mean_word_length': 3.2650231124807396, 'pattern_counts': {'":': 8, '<': 3, '<?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': '1258797', 'n_tokens_mistral': 886, 'n_tokens_neox': 829, 'n_words': 234}