<commit_before>/**
 * this program copied from Blockly and modified
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

<%
  require 'smalruby_editor'
%>

Blockly.Names.prototype.safeName_ = function(name) {
  if (!name) {
    name = 'unnamed';
  } else {
    // Unfortunately names in non-latin characters will look like
    // _E9_9F_B3_E4_B9_90 which is pretty meaningless.
    // HACK: Rubyでは日本語の変数名を許可しているためencodeURIを行わない。
    // また、使えない記号を置換する。
    name = name.replace(/[ !"#$%&'()=\-~^\\|`@{\[+;*:}\]<>,.?\/]/g, '_')
    // Most languages don't allow names with leading numbers.
    if ('0123456789'.indexOf(name[0]) != -1) {
      name = '_' + name;
    }
  }
  return name;
};

// blockly/core/toolbox.js
// HACK: don't close category when clicked twice
Blockly.Toolbox.TreeNode.prototype.onMouseDown = function(e) {
  // Expand icon.
  if (this.hasChildren() && this.isUserCollapsible_) {
    this.toggle();
    this.select();
  } else if (this.isSelected()) {
    //this.getTree().setSelectedItem(null);
  } else {
    this.select();
  }
  this.updateRow();
};

Blockly.Blocks.math.HUE = <%= SmalrubyEditor::COLORS[:operators] %>;
Blockly.Blocks.texts.HUE = <%= SmalrubyEditor::COLORS[:operators] %>;<commit_msg>[#76846676] ignore pressing return key when turn on IME.<commit_after>/**
 * this program copied from Blockly and modified
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

<%
  require 'smalruby_editor'
%>

// blockly/core/toolbox.js
// HACK: don't close category when clicked twice
Blockly.Toolbox.TreeNode.prototype.onMouseDown = function(e) {
  // Expand icon.
  if (this.hasChildren() && this.isUserCollapsible_) {
    this.toggle();
    this.select();
  } else if (this.isSelected()) {
    //this.getTree().setSelectedItem(null);
  } else {
    this.select();
  }
  this.updateRow();
};

Blockly.Blocks.math.HUE = <%= SmalrubyEditor::COLORS[:operators] %>;
Blockly.Blocks.texts.HUE = <%= SmalrubyEditor::COLORS[:operators] %>;

// blockly/core/field_textinput.js
Blockly.FieldTextInput.prototype.showEditorOrig_ =
  Blockly.FieldTextInput.prototype.showEditor_;
Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) {
  Blockly.FieldTextInput.prototype.showEditorOrig_.apply(this, arguments);
  var htmlInput = Blockly.FieldTextInput.htmlInput_;
  htmlInput.onKeyDownWrapper_ =
      Blockly.bindEvent_(htmlInput, 'keydown', this, this.onHtmlInputChange2_);
};

Blockly.FieldTextInput.prototype.onHtmlInputChange_ = function(e) {
  var htmlInput = Blockly.FieldTextInput.htmlInput_;
  if (e.keyCode != 13 && e.keyCode != 27) {
    // Update source block.
    var text = htmlInput.value;
    if (text !== htmlInput.oldValue_) {
      htmlInput.oldValue_ = text;
      this.setText(text);
      this.validate_();
    } else if (goog.userAgent.WEBKIT) {
      // Cursor key.  Render the source block to show the caret moving.
      // Chrome only (version 26, OS X).
      this.sourceBlock_.render();
    }
  }
};

Blockly.FieldTextInput.prototype.onHtmlInputChange2_ = function(e) {
  var htmlInput = Blockly.FieldTextInput.htmlInput_;
  if (e.keyCode == 13) {
    // Enter
    Blockly.WidgetDiv.hide();
  } else if (e.keyCode == 27) {
    // Esc
    this.setText(htmlInput.defaultValue);
    Blockly.WidgetDiv.hide();
  }
};

Blockly.FieldTextInput.prototype.widgetDisposeOrig_ =
  Blockly.FieldTextInput.prototype.widgetDispose_;
Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
  var thisField = this;
  return function() {
    Blockly.FieldTextInput.prototype.widgetDisposeOrig_.call(thisField);
    var htmlInput = Blockly.FieldTextInput.htmlInput_;
    Blockly.unbindEvent_(htmlInput.onKeyDownWrapper_);
  };
};

// blockly/core/names.js
Blockly.Names.prototype.safeName_ = function(name) {
  if (!name) {
    name = 'unnamed';
  } else {
    // Unfortunately names in non-latin characters will look like
    // _E9_9F_B3_E4_B9_90 which is pretty meaningless.
    // HACK: Rubyでは日本語の変数名を許可しているためencodeURIを行わない。
    // また、使えない記号を置換する。
    name = name.replace(/[ !"#$%&'()=\-~^\\|`@{\[+;*:}\]<>,.?\/]/g, '_')
    // Most languages don't allow names with leading numbers.
    if ('0123456789'.indexOf(name[0]) != -1) {
      name = '_' + name;
    }
  }
  return name;
};
{'fraction_non_alphanumeric': 0.13630306491528651, 'fraction_numerical': 0.012564249000571102, 'mean_word_length': 3.6128182616330116, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6707161', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1711, 'n_words': 413}