<commit_before>import blessed from 'blessed';
import devnull from 'dev-null';
import _ from 'lodash';

import BlessedRootComponent from './blessed/RootComponent';
//import ReactBlessedRootComponent from './react-blessed/RootComponent';
import conf from 'conf';
import EventManager from 'lib/EventManager';
import SingletonMixin from 'lib/mixins/SingletonMixin';


const COMPONENT_MODES = [
  'blessed',
  'react-blessed'
];


export default class Screen {

  constructor({ componentMode }) {

    if (!COMPONENT_MODES.some((v) => componentMode === v)) {
      throw new Error(`${componentMode} is invalid component-mode`);
    }
    this._componentMode = componentMode;

    let screen;
    switch (this._componentMode) {
      case 'blessed':
        screen = this._createBlessedScreen();
        break;
      case 'react-blessed':
        screen = this._createReactBlessedScreen();
        break;
    }
    this._screen = screen;

    Object.defineProperty(this, 'screen', { get() { return this._screen; } });
  }

  _createBlessedOptions() {
    let options = {
      debug: true,
      title: 'Escape From The Maze'
    };

    if (conf.ignoreScreenOutput) {
      options.output = devnull();
    }

    return options;
  }

  _createBlessedScreen() {
    let screen = blessed.screen(this._createBlessedOptions());
    new BlessedRootComponent({ screen, $parent: screen });
    return screen;
  }

  _createReactBlessedScreen() {
  }
}

Object.assign(Screen, SingletonMixin);<commit_msg>Disable screen.debugLog's default key bind<commit_after>import blessed from 'blessed';
import devnull from 'dev-null';
import _ from 'lodash';
import reactBlessed from 'react-blessed';

import BlessedRootComponent from './blessed/RootComponent';
import ReactBlessedRootComponent from './react-blessed/RootComponent';
import conf from 'conf';
import EventManager from 'lib/EventManager';
import SingletonMixin from 'lib/mixins/SingletonMixin';


const COMPONENT_MODES = [
  'blessed',
  'react-blessed'
];


export default class Screen {

  constructor({ componentMode }) {

    if (!COMPONENT_MODES.some((v) => componentMode === v)) {
      throw new Error(`${componentMode} is invalid component-mode`);
    }

    let initializeScreen = {
      'blessed': this._initializeBlessedScreen.bind(this),
      'react-blessed': this._initializeReactBlessedScreen.bind(this)
    }[componentMode];

    this._screen = initializeScreen();
  }

  _createBlessedOptions() {
    let options = {
      debug: true,
      title: 'Escape From The Maze'
    };

    if (conf.ignoreScreenOutput) {
      options.output = devnull();
    }

    return options;
  }

  _initializeBlessedScreen() {
    let screen = blessed.screen(this._createBlessedOptions());
    // Disable default key bind for debug
    // Ref) blessed/lib/widgets/screen.js#L374
    screen.debugLog.unkey(['q', 'escape'], () => {});
    new BlessedRootComponent({ screen, $parent: screen });
    return screen;
  }

  _initializeReactBlessedScreen() {
    return reactBlessed.render(<RootComponent />, this._createBlessedOptions());
  }
}

Object.assign(Screen, SingletonMixin);
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0009615384615384616, 'mean_word_length': 3.714501510574018, 'pattern_counts': {'":': 0, '<': 4, '<?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': '2842516', 'n_tokens_mistral': 964, 'n_tokens_neox': 950, 'n_words': 214}