<commit_before>//
//  CarbonKeyCombo.swift
//  HotKey
//
//  Created by <NAME> on 7/21/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import AppKit

public struct KeyCombo {

	// MARK: - Properties

	public var carbonKeyCode: UInt32
	public var carbonModifiers: UInt32

	public var key: Key? {
		get {
			return Key(carbonKeyCode: carbonKeyCode)
		}

		set {
			guard let key = newValue else { return }
			carbonKeyCode = key.carbonKeyCode
		}
	}

	public var modifiers: NSEventModifierFlags {
		get {
			return NSEventModifierFlags(carbonFlags: carbonModifiers)
		}

		set {
			carbonModifiers = modifiers.carbonFlags
		}
	}

	public var isValid: Bool {
		return carbonKeyCode >= 0 && carbonModifiers > 0
	}


	// MARK: - Initializers

	public init(carbonKeyCode: UInt32, carbonModifiers: UInt32) {
		self.carbonKeyCode = carbonKeyCode
		self.carbonModifiers = carbonModifiers
	}

	public init(key: Key, modifiers: NSEventModifierFlags) {
		self.carbonKeyCode = key.carbonKeyCode
		self.carbonModifiers = modifiers.carbonFlags
	}


	// MARK: - Converting Keys

	public static func carbonKeyCodeToString(_ carbonKeyCode: UInt32) -> String? {
		return nil
	}

}


extension KeyCombo: Equatable {
	public static func == (lhs: KeyCombo, rhs: KeyCombo) -> Bool {
		return lhs.carbonKeyCode == rhs.carbonKeyCode && lhs.carbonModifiers == rhs.carbonModifiers
	}<commit_msg>Add KeyCombo serialization<commit_after>//
//  CarbonKeyCombo.swift
//  HotKey
//
//  Created by <NAME> on 7/21/17.
//  Copyright © 2017 <NAME>. All rights reserved.
//

import AppKit

public struct KeyCombo {

	// MARK: - Properties

	public var carbonKeyCode: UInt32
	public var carbonModifiers: UInt32

	public var key: Key? {
		get {
			return Key(carbonKeyCode: carbonKeyCode)
		}

		set {
			guard let key = newValue else { return }
			carbonKeyCode = key.carbonKeyCode
		}
	}

	public var modifiers: NSEventModifierFlags {
		get {
			return NSEventModifierFlags(carbonFlags: carbonModifiers)
		}

		set {
			carbonModifiers = modifiers.carbonFlags
		}
	}

	public var isValid: Bool {
		return carbonKeyCode >= 0 && carbonModifiers > 0
	}


	// MARK: - Initializers

	public init(carbonKeyCode: UInt32, carbonModifiers: UInt32) {
		self.carbonKeyCode = carbonKeyCode
		self.carbonModifiers = carbonModifiers
	}

	public init(key: Key, modifiers: NSEventModifierFlags) {
		self.carbonKeyCode = key.carbonKeyCode
		self.carbonModifiers = modifiers.carbonFlags
	}


	// MARK: - Converting Keys

	public static func carbonKeyCodeToString(_ carbonKeyCode: UInt32) -> String? {
		return nil
	}
}


extension KeyCombo {
	public var dictionary: [String: Any] {
		return [
			"keyCode": Int(carbonKeyCode),
			"modifiers": Int(carbonModifiers)
		]
	}

	public init?(dictionary: [String: Any]) {
		guard let keyCode = dictionary["keyCod"] as? Int,
			let modifiers = dictionary["modifiers"] as? Int
		else {
			return nil
		}

		self.init(carbonKeyCode: UInt32(keyCode), carbonModifiers: UInt32(modifiers))
	}
}


extension KeyCombo: Equatable {
	public static func == (lhs: KeyCombo, rhs: KeyCombo) -> Bool {
		return lhs.carbonKeyCode == rhs.carbonKeyCode && lhs.carbonModifiers == rhs.carbonModifiers
	}
{'fraction_non_alphanumeric': 0.10220125786163523, 'fraction_numerical': 0.014465408805031447, 'mean_word_length': 3.6848306332842413, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 15, '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': '5691093', 'n_tokens_mistral': 1217, 'n_tokens_neox': 1053, 'n_words': 266}