jmathlib.ui.swing
Class KeyHandler

java.lang.Object
  extended by jmathlib.ui.swing.KeyHandler
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener, JMathLibOutput

public class KeyHandler
extends java.lang.Object
implements java.awt.event.KeyListener, JMathLibOutput

Console-keys class handler.

Provides command history handling via the up and down keys.

See MathLib/Source/UI/Swing/releasenotes.txt for more information.

This class is not guaranteed to work on older releases than jdk1.4.0-b92.
See GN0004 for more information.

Version:
3.1.1

Field Summary
(package private)  CommandHistoryManager commandHistory
           
(package private)  Console con
           
(package private)  Interpreter interpreter
           
static KeyHandler runningReference
           
 
Constructor Summary
KeyHandler(Console _con)
          Main constructor.
 
Method Summary
 void displayText(java.lang.String text)
           
private  boolean isOutsideTyping(java.awt.event.KeyEvent e)
          Checks if we type a key out the last line.
 void keyPressed(java.awt.event.KeyEvent e)
          Handles key-typing.
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped(java.awt.event.KeyEvent e)
          Handles key-typing not handled by keyPressed.
 void setStatusText(java.lang.String status)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

runningReference

public static KeyHandler runningReference

commandHistory

final CommandHistoryManager commandHistory

interpreter

Interpreter interpreter

con

Console con
Constructor Detail

KeyHandler

public KeyHandler(Console _con)
Main constructor. Initializes the interpreter.

Parameters:
con - Where the interpreter will place its output.
Method Detail

displayText

public void displayText(java.lang.String text)
Specified by:
displayText in interface JMathLibOutput

setStatusText

public void setStatusText(java.lang.String status)
Specified by:
setStatusText in interface JMathLibOutput

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Handles key-typing not handled by keyPressed.

This method only takes care of the backspace key

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
e - The event

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Handles key-typing.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
e - The event

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

isOutsideTyping

private boolean isOutsideTyping(java.awt.event.KeyEvent e)
Checks if we type a key out the last line. It never consume's the key.

Parameters:
e - The event
Returns:
True - The key was typed out the last line or inside the prompt.

FOOTER

BOTTOM