<commit_before>/**
 *	Copyright (C) 2016 3D Repo Ltd
 *
 *	This program is free software: you can redistribute it and/or modify
 *	it under the multiSelect of the GNU Affero General Public License as
 *	published by the Free Software Foundation, either version 3 of the
 *	License, or (at your option) any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU Affero General Public License for more details.
 *
 *	You should have received a copy of the GNU Affero General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

export class MultiSelectService {

	public static $inject: string[] = [
		"ViewerService",
		"$document"
	];

	private isMac = (navigator.platform.indexOf("Mac") !== -1);
	private accumMode = false;
	private decumMode = false;
	private areaSelectMode = false;

	private cursorIcons = {
		accumMode : "url(./icons/cursor_add.png), auto",
		decumMode : "url(./icons/cursor_del.png), auto",
		areaMode  : "url(./icons/cursor_rect.png), auto",
		areaAccumMode: "url(./icons/cursor_rect_add.png), auto",
		areaDecumMode: "url(./icons/cursor_rect_del.png), auto",
		noneCanvas     : "default",
		nonePanel       : "pointer"
	};

	constructor(
		public ViewerService: any,
		public $document: any
	) {

		this.initKeyWatchers();

	}

	public initKeyWatchers() {

		this.$document.bind("keydown", (event) => {
			this.handleKey(event.which, true);
		});

		this.$document.bind("keyup", (event) => {
			this.handleKey(event.which, false);
		});

	}

	public handleKey(key: number, keyDown: boolean) {
		switch (key) {
			case 16:
				// Shift
				this.toggleAreaSelect(keyDown);
				break;
			case 17:
				// Ctrl
				if (!this.isMac) {
					this.setAccumMode(keyDown);
				}
				break;
			case 18:
				// Alt
				this.setDecumMode(keyDown);
				break;
			case 91:
				// Command key(Mac)
				if (this.isMac) {
					this.setAccumMode(keyDown);
				}
				break;
		}
	}

	public isAccumMode() {
		return this.accumMode;
	}

	public isDecumMode() {
		return this.decumMode;<commit_msg>ISSUE #1220 cmd key on firefox has a different key code (#1221)<commit_after>/**
 *	Copyright (C) 2016 3D Repo Ltd
 *
 *	This program is free software: you can redistribute it and/or modify
 *	it under the multiSelect of the GNU Affero General Public License as
 *	published by the Free Software Foundation, either version 3 of the
 *	License, or (at your option) any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU Affero General Public License for more details.
 *
 *	You should have received a copy of the GNU Affero General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

export class MultiSelectService {

	public static $inject: string[] = [
		"ViewerService",
		"$document"
	];

	private isMac = (navigator.platform.indexOf("Mac") !== -1);
	private accumMode = false;
	private decumMode = false;
	private areaSelectMode = false;

	private cursorIcons = {
		accumMode : "url(./icons/cursor_add.png), auto",
		decumMode : "url(./icons/cursor_del.png), auto",
		areaMode  : "url(./icons/cursor_rect.png), auto",
		areaAccumMode: "url(./icons/cursor_rect_add.png), auto",
		areaDecumMode: "url(./icons/cursor_rect_del.png), auto",
		noneCanvas     : "default",
		nonePanel       : "pointer"
	};

	constructor(
		public ViewerService: any,
		public $document: any
	) {

		this.initKeyWatchers();

	}

	public initKeyWatchers() {

		this.$document.bind("keydown", (event) => {
			this.handleKey(event.which, true);
		});

		this.$document.bind("keyup", (event) => {
			this.handleKey(event.which, false);
		});

	}

	public handleKey(key: number, keyDown: boolean) {
		switch (key) {
			case 16:
				// Shift
				this.toggleAreaSelect(keyDown);
				break;
			case 17:
				// Ctrl
				if (!this.isMac) {
					this.setAccumMode(keyDown);
				}
				break;
			case 18:
				// Alt
				this.setDecumMode(keyDown);
				break;
			case 91:
			case 224:
				// Command key(Mac)
				if (this.isMac) {
					this.setAccumMode(keyDown);
				}
				break;
		}
	}

	public isAccumMode() {
		return this.accumMode;
	}

	public isDecumMode() {
		return this.decumMode;
{'fraction_non_alphanumeric': 0.12307348670985034, 'fraction_numerical': 0.00915791824882734, 'mean_word_length': 3.293384467881112, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7244829', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1452, 'n_words': 432}