<commit_before>/* global ipc, ace, remote */
import { PropTypes, Component } from 'react';
// import { default as fs } from 'fs';
// import { stateStore } from '../stores/StateStore';
// import * as lib from '../lib';

import fileStore   from '../stores/file-store'
import configStore from '../stores/config-store'

export default class Editor extends Component
{
    // static propTypes = {
    //     filePath : PropTypes.string
    // };
    //
    // static defaultProps = {
    //     filePath : ''
    // };

    constructor(props)
    {
        super(props);
        this.state = {
            config : configStore.getState()
        };
        this._onChange = this._onChange.bind(this);
    }

    componentWillUnmount()
    {
        fileStore.unlisten(this._onChange);
        configStore.unlisten(this._onChange);
        // ipc.removeListener('setSyntaxTheme');
    }

    _onChange()
    {
        let cfg = configStore.getState()

        this.editor.setTheme(cfg.editor.theme);
        this.editor.setDisplayIndentGuides(false);
        this.editor.setFontSize(this.state.config.editor.fontSize);

        let currentFile = fileStore.getState().current;
        if (currentFile) {
            this.editor.setSession(currentFile.session);
        }
        else {
            this.editor.setSession(
                ace.createEditSession('')
            );
        }
    }

    componentDidMount()
    {
        fileStore.listen(this._onChange);
        configStore.listen(this._onChange);
        this.editor = ace.edit(this.refs.wrapper);
        this.editor.$blockScrolling = Infinity;
        this.editor.setTheme(this.state.config.editor.theme);
        this.editor.setFontSize(this.state.config.editor.fontSize);
        // this.editor.setTheme("ace/theme/twilight");
        // this.editor.setDisplayIndentGuides(false);
        // ipc.on('setSyntaxTheme', theme => {
        //     this.editor.setTheme(theme);
        // });
        // ipc.on('saveFile', lib.saveCurrentFile);<commit_msg>More editor preferences from the config file<commit_after>/* global ipc, ace, remote */
import { PropTypes, Component } from 'react';
// import { default as fs } from 'fs';
// import { stateStore } from '../stores/StateStore';
// import * as lib from '../lib';

import fileStore   from '../stores/file-store'
import configStore from '../stores/config-store'

export default class Editor extends Component
{
    // static propTypes = {
    //     filePath : PropTypes.string
    // };
    //
    // static defaultProps = {
    //     filePath : ''
    // };

    constructor(props)
    {
        super(props);
        this.state = {
            config : configStore.getState()
        };
        this._onChange = this._onChange.bind(this);
    }

    componentWillUnmount()
    {
        fileStore.unlisten(this._onChange);
        configStore.unlisten(this._onChange);
        // ipc.removeListener('setSyntaxTheme');
    }

    _onChange()
    {
        let cfg = configStore.getState()

        this.editor.setTheme('ace/theme/' + cfg.editor.theme)
        this.editor.setDisplayIndentGuides(false)
        this.editor.setFontSize(this.state.config.editor.fontSize)
        this.editor.setAnimatedScroll(this.state.config.editor.animatedScroll)
        this.editor.setBehavioursEnabled(this.state.config.editor.autoPairing)
        this.editor.setDisplayIndentGuides(this.state.config.editor.displayIndentGuides)
        this.editor.setHighlightActiveLine(this.state.config.editor.highlightActiveLine)
        this.editor.setHighlightGutterLine(this.state.config.editor.highlightGutterLine)
        this.editor.setHighlightSelectedWord(this.state.config.editor.highlightSelectedWord)
        this.editor.setShowPrintMargin(this.state.config.editor.showPrintMargin)
        this.editor.setPrintMarginColumn(this.state.config.editor.printMarginColumn)
        this.editor.setScrollSpeed(this.state.config.editor.scrollSpeed)
        this.editor.setShowFoldWidgets(this.state.config.editor.showFoldWidgets)
        this.editor.setShowInvisibles(this.state.config.editor.showInvisibles)


        let currentFile = fileStore.getState().current;
        if (currentFile) {
            this.editor.setSession(currentFile.session);
        }
        else {
            this.editor.setSession(
                ace.createEditSession('')
            );
        }
    }

    componentDidMount()
    {
        fileStore.listen(this._onChange);
        configStore.listen(this._onChange);
        this.editor = ace.edit(this.refs.wrapper);
        this.editor.$blockScrolling = Infinity;
        // this.editor.setTheme(this.state.config.editor.theme);
        // this.editor.setFontSize(this.state.config.editor.fontSize);
        this._onChange()
        // this.editor.setTheme("ace/theme/twilight");
        // this.editor.setDisplayIndentGuides(false);
        // ipc.on('setSyntaxTheme', theme => {
        //     this.editor.setTheme(theme);
        // });
        // ipc.on('saveFile', lib.saveCurrentFile);
{'fraction_non_alphanumeric': 0.13098086124401914, 'fraction_numerical': 0.0, 'mean_word_length': 2.3739071956960323, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7455185', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1451, 'n_words': 196}