<commit_before>/**
 * <NAME> - http://taewon.de - @hataewon
 * See LICENSE
 */

import Cocoa

class KeyUtils {

  static let specialKeys = [
    NSUpArrowFunctionKey: "Up",
    NSDownArrowFunctionKey: "Down",
    NSLeftArrowFunctionKey: "Left",
    NSRightArrowFunctionKey: "Right",
    NSInsertFunctionKey: "Insert",
    0x7F: "BS", // "delete"-key
    NSDeleteFunctionKey: "Del", // "Fn+delete"-key
    NSHomeFunctionKey: "Home",
    NSBeginFunctionKey: "Begin",
    NSEndFunctionKey: "End",
    NSPageUpFunctionKey: "PageUp",
    NSPageDownFunctionKey: "PageDown",
    NSHelpFunctionKey: "Help",
    NSF1FunctionKey: "F1",
    NSF2FunctionKey: "F2",
    NSF3FunctionKey: "F3",
    NSF4FunctionKey: "F4",
    NSF5FunctionKey: "F5",
    NSF6FunctionKey: "F6",
    NSF7FunctionKey: "F7",
    NSF8FunctionKey: "F8",
    NSF9FunctionKey: "F9",
    NSF10FunctionKey: "F10",
    NSF11FunctionKey: "F11",
    NSF12FunctionKey: "F12",
    NSF13FunctionKey: "F13",
    NSF14FunctionKey: "F14",
    NSF15FunctionKey: "F15",
    NSF16FunctionKey: "F16",
    NSF17FunctionKey: "F17",
    NSF18FunctionKey: "F18",
    NSF19FunctionKey: "F19",
    NSF20FunctionKey: "F20",
    NSF21FunctionKey: "F21",
    NSF22FunctionKey: "F22",
    NSF23FunctionKey: "F23",
    NSF24FunctionKey: "F24",
    NSF25FunctionKey: "F25",
    NSF26FunctionKey: "F26",
    NSF27FunctionKey: "F27",
    NSF28FunctionKey: "F28",
    NSF29FunctionKey: "F29",
    NSF30FunctionKey: "F30",
    NSF31FunctionKey: "F31",
    NSF32FunctionKey: "F32",
    NSF33FunctionKey: "F33",
    NSF34FunctionKey: "F34",
    NSF35FunctionKey: "F35",
  ]

  static func isSpecial(key: String) -> Bool {
    guard key.characters.count == 1 else {
      return false
    }

    if let firstChar = key.utf16.first {
      return KeyUtils.specialKeys.keys.contains(Int(firstChar))
    }

    return false
  }

  static func namedKeyFrom(key: String) -> String {
    if let firstChar = key.utf16.first {
      if KeyUtils.specialKeys.keys.contains(Int(firstChar)) {
        return KeyUtils.specialKeys[Int(firstChar)]!
      }
    }

    return key
  }
}<commit_msg>Add (Shift-)Tab as a special key<commit_after>/**
 * <NAME> - http://taewon.de - @hataewon
 * See LICENSE
 */

import Cocoa

class KeyUtils {

  static let specialKeys = [
    NSUpArrowFunctionKey: "Up",
    NSDownArrowFunctionKey: "Down",
    NSLeftArrowFunctionKey: "Left",
    NSRightArrowFunctionKey: "Right",
    NSInsertFunctionKey: "Insert",
    0x7F: "BS", // "delete"-key
    NSDeleteFunctionKey: "Del", // "Fn+delete"-key
    NSHomeFunctionKey: "Home",
    NSBeginFunctionKey: "Begin",
    NSEndFunctionKey: "End",
    NSPageUpFunctionKey: "PageUp",
    NSPageDownFunctionKey: "PageDown",
    NSHelpFunctionKey: "Help",
    NSF1FunctionKey: "F1",
    NSF2FunctionKey: "F2",
    NSF3FunctionKey: "F3",
    NSF4FunctionKey: "F4",
    NSF5FunctionKey: "F5",
    NSF6FunctionKey: "F6",
    NSF7FunctionKey: "F7",
    NSF8FunctionKey: "F8",
    NSF9FunctionKey: "F9",
    NSF10FunctionKey: "F10",
    NSF11FunctionKey: "F11",
    NSF12FunctionKey: "F12",
    NSF13FunctionKey: "F13",
    NSF14FunctionKey: "F14",
    NSF15FunctionKey: "F15",
    NSF16FunctionKey: "F16",
    NSF17FunctionKey: "F17",
    NSF18FunctionKey: "F18",
    NSF19FunctionKey: "F19",
    NSF20FunctionKey: "F20",
    NSF21FunctionKey: "F21",
    NSF22FunctionKey: "F22",
    NSF23FunctionKey: "F23",
    NSF24FunctionKey: "F24",
    NSF25FunctionKey: "F25",
    NSF26FunctionKey: "F26",
    NSF27FunctionKey: "F27",
    NSF28FunctionKey: "F28",
    NSF29FunctionKey: "F29",
    NSF30FunctionKey: "F30",
    NSF31FunctionKey: "F31",
    NSF32FunctionKey: "F32",
    NSF33FunctionKey: "F33",
    NSF34FunctionKey: "F34",
    NSF35FunctionKey: "F35",
    0x19: "Tab",
  ]

  static func isSpecial(key: String) -> Bool {
    guard key.characters.count == 1 else {
      return false
    }

    if let firstChar = key.utf16.first {
      return KeyUtils.specialKeys.keys.contains(Int(firstChar))
    }

    return false
  }

  static func namedKeyFrom(key: String) -> String {
    if let firstChar = key.utf16.first {
      if KeyUtils.specialKeys.keys.contains(Int(firstChar)) {
        return KeyUtils.specialKeys[Int(firstChar)]!
      }
    }

    return key
  }
}
{'fraction_non_alphanumeric': 0.13300376647834275, 'fraction_numerical': 0.0614406779661017, 'mean_word_length': 3.366906474820144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2819746', 'n_tokens_mistral': 1723, 'n_tokens_neox': 1592, 'n_words': 297}