<commit_before>package com.actram.solace.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Collections;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.MatteBorder;
import javax.swing.text.DefaultCaret;

import com.actram.solace.ui.event.CloseListener;
import com.actram.solace.ui.event.InputListener;
import com.actram.solace.ui.event.KeyListener;

/**
 * A text-based user interface that can display and receive text input.
 * 
 * @author <NAME>
 */
public class DefaultWindowUI implements WindowUI {

	public static final int DEFAULT_WIDTH = 600;
	public static final int DEFAULT_HEIGHT = 300;
	public static final Font DEFAULT_FONT = Font.decode("monospace");

	private final JFrame frame;
	private final JTextArea outputArea;
	private final JTextField inputArea;

	private CloseListener closeListener;
	private KeyListener keyListener;
	private InputListener inputListener;

	/**
	 * Creates a new visible window user interface.
	 */
	public DefaultWindowUI() {
		this(true);
	}

	/**
	 * Creates a new window user interface with the given initial visibility.
	 */
	public DefaultWindowUI(boolean visible) {

		// Create output area
		this.outputArea = new JTextArea();
		outputArea.setBorder(new EmptyBorder(5, 5, 5, 5));
		outputArea.setEditable(false);
		outputArea.setLineWrap(true);
		outputArea.setMargin(null);
		outputArea.setWrapStyleWord(true);
		DefaultCaret caret = (DefaultCaret) outputArea.getCaret();
		caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

		// Create output area scroll pane
		final JScrollPane outputAreaScrollPane = new JScrollPane();
		outputAreaScrollPane.setBorder(null);
		outputAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		outputAreaScrollPane.setViewportView(outputArea);

		// Create input area
		this.inputArea = new JTextField();
		MatteBorder outsideBorder = new MatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY);
		EmptyBorder insideBorder = new EmptyBorder(5, 5, 5, 5);
		inputArea.setBorder(new CompoundBorder(outsideBorder, insideBorder));
		inputArea.addActionListener(evt -> {
			String input = inputArea.getText();
			if (inputListener != null && !input.isEmpty()) {
				inputListener.receiveInput(input);
			}
			clearInput();
		});
		inputArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.emptySet());<commit_msg>Use system look and feel<commit_after>package com.actram.solace.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.KeyboardFocusManager;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Collections;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.MatteBorder;
import javax.swing.text.DefaultCaret;

import com.actram.solace.ui.event.CloseListener;
import com.actram.solace.ui.event.InputListener;
import com.actram.solace.ui.event.KeyListener;

/**
 * A text-based user interface that can display and receive text input.
 * 
 * @author <NAME>
 */
public class DefaultWindowUI implements WindowUI {

	public static final int DEFAULT_WIDTH = 600;
	public static final int DEFAULT_HEIGHT = 300;
	public static final Font DEFAULT_FONT = Font.decode("monospace");

	private final JFrame frame;
	private final JTextArea outputArea;
	private final JTextField inputArea;

	private CloseListener closeListener;
	private KeyListener keyListener;
	private InputListener inputListener;

	/**
	 * Creates a new visible window user interface.
	 */
	public DefaultWindowUI() {
		this(true);
	}

	/**
	 * Creates a new window user interface with the given initial visibility.
	 */
	public DefaultWindowUI(boolean visible) {
		
		// Attempt to set the look and feel to the system's
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
			// e.printStackTrace();
		}

		// Create output area
		this.outputArea = new JTextArea();
		outputArea.setBorder(new EmptyBorder(5, 5, 5, 5));
		outputArea.setEditable(false);
		outputArea.setLineWrap(true);
		outputArea.setMargin(null);
		outputArea.setWrapStyleWord(true);
		DefaultCaret caret = (DefaultCaret) outputArea.getCaret();
		caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

		// Create output area scroll pane
		final JScrollPane outputAreaScrollPane = new JScrollPane();
		outputAreaScrollPane.setBorder(null);
		outputAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		outputAreaScrollPane.setViewportView(outputArea);

		// Create input area
		this.inputArea = new JTextField();
		MatteBorder outsideBorder = new MatteBorder(1, 0, 0, 0, Color.LIGHT_GRAY);
		EmptyBorder insideBorder = new EmptyBorder(5, 5, 5, 5);
		inputArea.setBorder(new CompoundBorder(outsideBorder, insideBorder));
		inputArea.addActionListener(evt -> {
			String input = inputArea.getText();
			if (inputListener != null && !input.isEmpty()) {
				inputListener.receiveInput(input);
			}
			clearInput();
		});
		inputArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Collections.emptySet());
{'fraction_non_alphanumeric': 0.09872611464968153, 'fraction_numerical': 0.006034193764666443, 'mean_word_length': 5.368196371398079, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1213774', 'n_tokens_mistral': 1925, 'n_tokens_neox': 1779, 'n_words': 418}