bsh.util

Class AWTConsole

Implemented Interfaces:
ConsoleInterface, KeyListener, Runnable

public class AWTConsole
extends TextArea
implements ConsoleInterface, Runnable, KeyListener

An old AWT based console for BeanShell. I looked everwhere for one, and couldn't find anything that worked. I've tried to keep this as small as possible, no frills. (Well, one frill - a simple history with the up/down arrows) My hope is that this can be moved to a lightweight (portable) component with JFC soon... but Swing is still very slow and buggy. Done: see JConsole.java The big Hack: The heinous, disguisting hack in here is to keep the caret (cursor) at the bottom of the text (without the user having to constantly click at the bottom). It wouldn't be so bad if the damned setCaretPostition() worked as expected. But the AWT TextArea for some insane reason treats NLs as characters... oh, and it refuses to let you set a caret position greater than the text length - for which it counts NLs as *one* character. The glorious hack to fix this is to go the TextComponent peer. I really hate this. Out of date: This class is out of date. It does not use the special blocking piped input stream that the jconsole uses. Deprecation: This file uses two deprecate APIs. We want to be a PrintStream so that we can redirect stdout to our console... I don't see a way around this. Also we have to use getPeer() for the big hack above.

Constructor Summary

AWTConsole()
AWTConsole(InputStream in, OutputStream out)
AWTConsole(int rows, int cols, InputStream cin, OutputStream cout)

Method Summary

void
error(String s)
PrintStream
getErr()
Reader
getIn()
PrintStream
getOut()
void
keyPressed(KeyEvent e)
void
keyReleased(KeyEvent e)
void
keyTyped(KeyEvent e)
static void
main(args[] )
void
print(String s)
void
print(String s, Color c)
void
println(String s)
void
run()
void
setCaretPosition(int pos)
String
toString()
void
type(int code, char ch, int modifiers)

Constructor Details

AWTConsole

public AWTConsole()


AWTConsole

public AWTConsole(InputStream in,
                  OutputStream out)


AWTConsole

public AWTConsole(int rows,
                  int cols,
                  InputStream cin,
                  OutputStream cout)

Method Details

error

public void error(String s)
Specified by:
error in interface ConsoleInterface


getErr

public PrintStream getErr()
Specified by:
getErr in interface ConsoleInterface


getIn

public Reader getIn()
Specified by:
getIn in interface ConsoleInterface


getOut

public PrintStream getOut()
Specified by:
getOut in interface ConsoleInterface


keyPressed

public void keyPressed(KeyEvent e)


keyReleased

public void keyReleased(KeyEvent e)


keyTyped

public void keyTyped(KeyEvent e)


main

public static void main(args[] )


print

public void print(String s)
Specified by:
print in interface ConsoleInterface


print

public void print(String s,
                  Color c)


println

public void println(String s)
Specified by:
println in interface ConsoleInterface


run

public void run()


setCaretPosition

public void setCaretPosition(int pos)


toString

public String toString()


type

public void type(int code,
                 char ch,
                 int modifiers)


B) 2000 pat@pat.net :-)