ti.swing.console
Class ConsoleKeyListener

java.lang.Object
  extended byjava.awt.event.KeyAdapter
      extended byti.swing.console.ConsoleKeyListener
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener, java.io.Serializable

public class ConsoleKeyListener
extends java.awt.event.KeyAdapter
implements java.io.Serializable

Handle keyboard input, and provide a reader interface.... this really should be thought of as an inner-class of ConsoleTextArea, but was moved here to preserve sane file sizes...

Version:
0.1
Author:
Rob Clark
See Also:
Serialized Form

Constructor Summary
ConsoleKeyListener(Console console)
          Class Constructor.
 
Method Summary
 void dispose()
          This should called when getting rid of this text-area...
 java.lang.Object getHistory()
          Get the history.
 java.io.Reader getReader()
          Get the Reader for the console.
 void insertChar(char c)
          Append char to current active buffer.
 void keyPressed(java.awt.event.KeyEvent evt)
          Keep track of modifiers.
 void keyReleased(java.awt.event.KeyEvent evt)
          Certain keys don't generate keyTyped events, so we have to do this.
 void keyTyped(java.awt.event.KeyEvent evt)
          Invoked when a key is typed.
 void paintCursor(java.awt.Graphics g)
          Draw the cursor over the graphics.
 void setHistory(java.lang.Object history)
          Set the history.
 void setTabCompleter(ConsoleTabCompleter tabCompleter)
          Set the ConsoleTabCompleter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleKeyListener

public ConsoleKeyListener(Console console)
Class Constructor.

Parameters:
console - the console we belong to
Method Detail

setHistory

public void setHistory(java.lang.Object history)
Set the history. The history object must be an object that was previously returned by getHistory(), but may be serialized/deserialized.

Parameters:
history - a history object, as returned by getHistory()
See Also:
getHistory()

getHistory

public java.lang.Object getHistory()
Get the history. The history is externally treated as opaque, but the get/set methods allow the creator of the Console to make history persistant. The history object is Serializable

Returns:
a opaque history object, which is serializable
See Also:
setHistory(java.lang.Object)

setTabCompleter

public void setTabCompleter(ConsoleTabCompleter tabCompleter)
Set the ConsoleTabCompleter


getReader

public java.io.Reader getReader()
Get the Reader for the console. By using this reader, an application can use this console for input.

Returns:
a reader that can be used to read from the console

dispose

public void dispose()
This should called when getting rid of this text-area... this will cause any blocking readers to return.


insertChar

public void insertChar(char c)
Append char to current active buffer.


keyTyped

public void keyTyped(java.awt.event.KeyEvent evt)
Invoked when a key is typed.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Keep track of modifiers.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent evt)
Certain keys don't generate keyTyped events, so we have to do this.

Specified by:
keyReleased in interface java.awt.event.KeyListener

paintCursor

public void paintCursor(java.awt.Graphics g)
Draw the cursor over the graphics.