<commit_before>package org.arduglove.mkinterface;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import jssc.SerialPort;
import jssc.SerialPortException;
import jssc.SerialPortList;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Main {
	@Parameter(names = { "-p", "--port"}, description = "Port name")
	String portName;

    @Parameter(names = {"-m", "--mode"}, description = "Mode of input generation. Available modes: mouse, pointer, arrow, wasd")
    String modeName = "mouse";

	@Parameter(names = {"-h", "--help"}, help = true, hidden = true)
	boolean help;

	SerialParser parser;

	public static void main(String[] args) {
		Main main = new Main();
		JCommander jc = new JCommander(main, args);
		if (main.help) {
			jc.setProgramName("arduglove");
			jc.usage();
			System.exit(0);
		}
		main.handler();
}

	private void handler() {
		if (isMac()) createMacGUI();

		if (portName == null) {
			String[] choices = SerialPortList.getPortNames();
			if (choices.length == 0) {
				JOptionPane.showMessageDialog(null, "No ports found");
				System.exit(0);
			}
			if (choices.length == 1) {
				portName = choices[0];
			} else {
				portName = (String) JOptionPane.showInputDialog(null,
						"Choose port", "Choose port", JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
			}
			if (portName == null) {
				System.exit(0);
			}
		}

		SerialPort port = new SerialPort(portName);

		Mode mode = getMode(modeName);
		if (mode == null) {
			JOptionPane.showMessageDialog(null, "Invalid mode switch");
			System.exit(0);
		}

		try {
			parser = new SerialParser(port, mode);
		} catch (SerialPortException e) {
			e.printStackTrace();
		}
	}

	private static Mode getMode(String name) {
		switch (name.toLowerCase()) {
			case "mouse": return new MouseMode();
            case "pointer": return new PointerMode();
			case "arrow": return new ArrowKeyMode();
			case "wasd": return new WasdKeyMode();
		}
		return null;
	}

	private void createMacGUI() {
		System.setProperty("apple.awt.UIElement", "true");
		SystemTray tray = SystemTray.getSystemTray();

		Image image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/trayicon.png"));
		PopupMenu popup = new PopupMenu();
		Menu modes = new Menu("Modes");

		String[] modeStrings = {"Mouse", "Arrow", "WASD"};

		for (final String s : modeStrings) {
			MenuItem m = new MenuItem(s);
			m.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					parser.setMode(getMode(s));
				}
			});
			modes.add(m);
		}

		popup.add(modes);
		MenuItem quit = new MenuItem("Quit");
		quit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		popup.add(quit);
		TrayIcon icon = new TrayIcon(image, "ArduGlove", popup);

		try {
			tray.add(icon);
		} catch (AWTException e) {
			e.printStackTrace();
		}
	}

	private static boolean isMac() {
		return System.getProperty("os.name").startsWith("Mac");
	}
}<commit_msg>Added pointer mode to menu bar icon on Mac<commit_after>package org.arduglove.mkinterface;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import jssc.SerialPort;
import jssc.SerialPortException;
import jssc.SerialPortList;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Main {
	@Parameter(names = { "-p", "--port"}, description = "Port name")
	String portName;

    @Parameter(names = {"-m", "--mode"}, description = "Mode of input generation. Available modes: mouse, pointer, arrow, wasd")
    String modeName = "mouse";

	@Parameter(names = {"-h", "--help"}, help = true, hidden = true)
	boolean help;

	SerialParser parser;

	public static void main(String[] args) {
		Main main = new Main();
		JCommander jc = new JCommander(main, args);
		if (main.help) {
			jc.setProgramName("arduglove");
			jc.usage();
			System.exit(0);
		}
		main.handler();
}

	private void handler() {
		if (isMac()) createMacGUI();

		if (portName == null) {
			String[] choices = SerialPortList.getPortNames();
			if (choices.length == 0) {
				JOptionPane.showMessageDialog(null, "No ports found");
				System.exit(0);
			}
			if (choices.length == 1) {
				portName = choices[0];
			} else {
				portName = (String) JOptionPane.showInputDialog(null,
						"Choose port", "Choose port", JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
			}
			if (portName == null) {
				System.exit(0);
			}
		}

		SerialPort port = new SerialPort(portName);

		Mode mode = getMode(modeName);
		if (mode == null) {
			JOptionPane.showMessageDialog(null, "Invalid mode switch");
			System.exit(0);
		}

		try {
			parser = new SerialParser(port, mode);
		} catch (SerialPortException e) {
			e.printStackTrace();
		}
	}

	private static Mode getMode(String name) {
		switch (name.toLowerCase()) {
			case "mouse": return new MouseMode();
            case "pointer": return new PointerMode();
			case "arrow": return new ArrowKeyMode();
			case "wasd": return new WasdKeyMode();
		}
		return null;
	}

	private void createMacGUI() {
		System.setProperty("apple.awt.UIElement", "true");
		SystemTray tray = SystemTray.getSystemTray();

		Image image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/trayicon.png"));
		PopupMenu popup = new PopupMenu();
		Menu modes = new Menu("Modes");

		String[] modeStrings = {"Mouse", "Pointer", "Arrow", "WASD"};

		for (final String s : modeStrings) {
			MenuItem m = new MenuItem(s);
			m.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					parser.setMode(getMode(s));
				}
			});
			modes.add(m);
		}

		popup.add(modes);
		MenuItem quit = new MenuItem("Quit");
		quit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		popup.add(quit);
		TrayIcon icon = new TrayIcon(image, "ArduGlove", popup);

		try {
			tray.add(icon);
		} catch (AWTException e) {
			e.printStackTrace();
		}
	}

	private static boolean isMac() {
		return System.getProperty("os.name").startsWith("Mac");
	}
}
{'fraction_non_alphanumeric': 0.14982183349530287, 'fraction_numerical': 0.0029154518950437317, 'mean_word_length': 3.809190031152648, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, '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': '1792427', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2014, 'n_words': 497}