// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// 	public String readLine() throws IOException;
// 	public String readLine(String prompt) throws IOException;
// 	
// 	public void addConsoleListener(ConsoleListener l);
// 	public void removeConsoleListener(ConsoleListener l);
// 	
// 	public Reader in();
// 	public PrintStream out();
// 	public PrintStream err();
// 	
// 	public void clear();
// 	public void reset();
// }
// 
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// 	// callback for terminating the current running command
// 	public void terminate();
// }
// 
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// 	private String[] m_history;
// 	private int m_count = 0;
// 	private int m_last = -1;
// 	
// 	public History(int size) {
// 		m_history = new String[size];
// 	}
// 	
// 	public int length() { return m_count; }
// 	
// 	//Previous is from 0-histoy.length -1
// 	//0 is the last thing entered
// 	// and history.length - 1 is the first thing entered
// 	public String get(int previous) {
// 		if (m_last < 0) return null;
// 		if (previous >= m_count) return null;
// 				
// 		int idx = Math.min(m_last, Math.max(0, m_last - previous));
// 		
// 		while (idx < 0) {
// 			idx += m_history.length;
// 		}
// 		
// 		return m_history[idx];
// 	}
// 	
// 	public void add(String s) {
// 		String l = get(0);
// 		if (l != null && l.equals(s)) return; //Don't store duplicate entries
// 		
// 		int idx = m_last + 1;
// 		if (idx >= m_history.length) {
// 			idx -= m_history.length;
// 		}
// 		m_history[idx] = s;
// 		
// 		m_last = idx;
// 		
// 		m_count = Math.max(m_history.length, m_count++);
// 	}
// }
// 
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
// public interface InputListener {
// 	public void onInput(String input, String text);
// }


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
import us.pfrommer.insteon.terminal.console.History;
import us.pfrommer.insteon.terminal.console.gui.InputArea.InputListener;
		Font f = new Font(Font.MONOSPACED, Font.PLAIN, 14);
		
		m_output = new OutputArea(f);
		m_output.setEditable(false);
		
		m_output.addMouseListener(new MouseListener() {

			@Override
			public void mouseClicked(MouseEvent e) {
				m_input.requestFocus();
			}

			@Override
			public void mousePressed(MouseEvent e) {
			}

			@Override
			public void mouseReleased(MouseEvent e) {}

			@Override
			public void mouseEntered(MouseEvent e) {}

			@Override
			public void mouseExited(MouseEvent e) {}
		});
		
		m_out = m_output.createOutput(Color.BLACK);
		m_err = m_output.createOutput(Color.RED);
		
		m_input = new InputArea(f, m_history);
// Path: src/us/pfrommer/insteon/terminal/console/Console.java
// public interface Console {
// 	public String readLine() throws IOException;
// 	public String readLine(String prompt) throws IOException;
// 	
// 	public void addConsoleListener(ConsoleListener l);
// 	public void removeConsoleListener(ConsoleListener l);
// 	
// 	public Reader in();
// 	public PrintStream out();
// 	public PrintStream err();
// 	
// 	public void clear();
// 	public void reset();
// }
// 
// Path: src/us/pfrommer/insteon/terminal/console/ConsoleListener.java
// public interface ConsoleListener {
// 	// callback for terminating the current running command
// 	public void terminate();
// }
// 
// Path: src/us/pfrommer/insteon/terminal/console/History.java
// public class History {
// 	private String[] m_history;
// 	private int m_count = 0;
// 	private int m_last = -1;
// 	
// 	public History(int size) {
// 		m_history = new String[size];
// 	}
// 	
// 	public int length() { return m_count; }
// 	
// 	//Previous is from 0-histoy.length -1
// 	//0 is the last thing entered
// 	// and history.length - 1 is the first thing entered
// 	public String get(int previous) {
// 		if (m_last < 0) return null;
// 		if (previous >= m_count) return null;
// 				
// 		int idx = Math.min(m_last, Math.max(0, m_last - previous));
// 		
// 		while (idx < 0) {
// 			idx += m_history.length;
// 		}
// 		
// 		return m_history[idx];
// 	}
// 	
// 	public void add(String s) {
// 		String l = get(0);
// 		if (l != null && l.equals(s)) return; //Don't store duplicate entries
// 		
// 		int idx = m_last + 1;
// 		if (idx >= m_history.length) {
// 			idx -= m_history.length;
// 		}
// 		m_history[idx] = s;
// 		
// 		m_last = idx;
// 		
// 		m_count = Math.max(m_history.length, m_count++);
// 	}
// }
// 
// Path: src/us/pfrommer/insteon/terminal/console/gui/InputArea.java
// public interface InputListener {
// 	public void onInput(String input, String text);
// }


// Path: src/us/pfrommer/insteon/terminal/console/gui/GUI.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.io.PrintStream;
import java.io.Reader;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import us.pfrommer.insteon.terminal.console.Console;
import us.pfrommer.insteon.terminal.console.ConsoleListener;
import us.pfrommer.insteon.terminal.console.History;
import us.pfrommer.insteon.terminal.console.gui.InputArea.InputListener;

		Font f = new Font(Font.MONOSPACED, Font.PLAIN, 14);
		
		m_output = new OutputArea(f);
		m_output.setEditable(false);
		
		m_output.addMouseListener(new MouseListener() {

			@Override
			public void mouseClicked(MouseEvent e) {
				m_input.requestFocus();
			}

			@Override
			public void mousePressed(MouseEvent e) {
			}

			@Override
			public void mouseReleased(MouseEvent e) {}

			@Override
			public void mouseEntered(MouseEvent e) {}

			@Override
			public void mouseExited(MouseEvent e) {}
		});
		
		m_out = m_output.createOutput(Color.BLACK);
		m_err = m_output.createOutput(Color.RED);
		
		m_input = new InputArea(f, m_history);
		m_input.addInputListener(new InputListener() {