<commit_before>package control;

import java.util.HashSet;
import java.util.Set;

import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;

/**
 * Handles all events triggered by the user
 * @author ivan
 */
public class MainHandler {

	private static Set<String> unreleasedKeys = new HashSet<String>();
	
	/**
	 * Handle a key press event
	 * @param event
	 */
	public static void handleKeyPressed(KeyEvent event) {
		
		// letter key 
		if (event.getCode().isLetterKey()) {
			// forward to slice handler if just pressed
			if (!unreleasedKeys.contains(event.getCode().toString())) {
				SliceHandler.handleLetterKey(event.getCode().toString());
			}
			// remember that key has been pressed
			unreleasedKeys.add(event.getCode().toString());
		}
		
		// space key
		if (event.getCode().equals(KeyCode.SPACE)) {
			// pause
			SliceHandler.toggleBreak();
		}

		// backspace key
		if (event.getCode().equals(KeyCode.BACK_SPACE)) {
			// reset measurement
			SliceHandler.resetSlices();
		}
		
		// enter key
		if (event.getCode().equals(KeyCode.ENTER)) {
			// save data
			SliceHandler.exportData();
		}

		// escape key
		if (event.getCode().equals(KeyCode.ESCAPE)) {
			// exit application
			System.exit(0);
		}
				<commit_msg>adding user confirmation for resetting values<commit_after>package control;

import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

import javafx.event.EventHandler;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DialogEvent;
import javafx.scene.input.InputEvent;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;

/**
 * Handles all events triggered by the user
 * @author ivan
 */
public class MainHandler {

	private static Set<String> unreleasedKeys = new HashSet<String>();
	
	/**
	 * Handle a key press event
	 * @param event
	 */
	public static void handleKeyPressed(KeyEvent event) {
		
		// letter key 
		if (event.getCode().isLetterKey()) {
			// forward to slice handler if just pressed
			if (!unreleasedKeys.contains(event.getCode().toString())) {
				SliceHandler.handleLetterKey(event.getCode().toString());
			}
			// remember that key has been pressed
			unreleasedKeys.add(event.getCode().toString());
		}
		
		// space key
		if (event.getCode().equals(KeyCode.SPACE)) {
			// pause
			SliceHandler.toggleBreak();
		}

		// backspace key
		if (event.getCode().equals(KeyCode.BACK_SPACE)) {
			// ask user to confirm reset
			Alert alert = new Alert(AlertType.CONFIRMATION);
			alert.setTitle("Confirm Reset");
			alert.setHeaderText("Do you really want to reset all timers?");
			Optional<ButtonType> result = alert.showAndWait();
			if (result.get() == ButtonType.OK){
			    // User says OK, so reset measurement
				SliceHandler.resetSlices();
			} else {
			    // Cancel, do nothing
			}
		}
		
		// enter key
		if (event.getCode().equals(KeyCode.ENTER)) {
			// save data
			SliceHandler.exportData();
		}

		// escape key
		if (event.getCode().equals(KeyCode.ESCAPE)) {
			// ask user to confirm exit
//			Alert alert = new Alert(AlertType.CONFIRMATION);
//			alert.setOnCloseRequest(new EventHandler<DialogEvent>() {
//			    public void handle(DialogEvent event) {
//			    	System.out.println(event.getEventType().toString());
//			        event.consume();
//			    }});
//			alert.setTitle("Confirm Exit");
//			alert.setHeaderText("Do you really want to exit the application?");
//			Optional<ButtonType> result = alert.showAndWait();
//			if (result.get() == ButtonType.OK){
//				// User says OK, so exit application
//				System.exit(0);
//			} else {
//			    // Cancel, do nothing
//			}
		}
				
{'fraction_non_alphanumeric': 0.138635142396561, 'fraction_numerical': 0.0005373455131649651, 'mean_word_length': 3.2403189066059226, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '369397', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1147, 'n_words': 269}