From: <fd...@us...> - 2008-06-19 19:11:13
|
Revision: 4263 http://jnode.svn.sourceforge.net/jnode/?rev=4263&view=rev Author: fduminy Date: 2008-06-19 12:10:50 -0700 (Thu, 19 Jun 2008) Log Message: ----------- optimizations of TextScreen(Console) operations (sync/copy/update) Modified Paths: -------------- trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeCommandShell.java trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeShell.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteConsoleInputStream.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteConsoleManager.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteConsoleOutputStream.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreen.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreenManager.java trunk/distr/src/apps/org/jnode/apps/telnetd/TelnetServerCommand.java trunk/distr/src/apps/org/jnode/apps/telnetd/TelnetUtils.java trunk/distr/src/apps/org/jnode/apps/telnetd/telnetd.properties trunk/gui/descriptors/org.jnode.driver.video.vesa.xml trunk/gui/src/driver/org/jnode/driver/console/swing/JTextAreaTextScreen.java trunk/gui/src/driver/org/jnode/driver/console/swing/SwingTextScreenConsoleManager.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScrollableTextScreen.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbTextScreen.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbTextScreenPlugin.java trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingPcTextScreen.java trunk/gui/src/test/org/jnode/test/gui/FBConsole.java trunk/shell/src/shell/org/jnode/shell/CommandShell.java Added Paths: ----------- trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteKeyboardHandler.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FBConsole.java Added: trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java (rev 0) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/DefaultKeyboardHandler.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -0,0 +1,112 @@ +package org.jnode.driver.console.textscreen; + +import java.io.IOException; + +import javax.naming.NameNotFoundException; + +import org.jnode.driver.ApiNotFoundException; +import org.jnode.driver.Device; +import org.jnode.driver.DeviceListener; +import org.jnode.driver.DeviceManager; +import org.jnode.driver.input.KeyboardAPI; +import org.jnode.driver.input.KeyboardEvent; +import org.jnode.driver.input.KeyboardListener; +import org.jnode.naming.InitialNaming; +import org.jnode.system.BootLog; +import org.jnode.system.event.FocusEvent; +import org.jnode.system.event.FocusListener; +import org.jnode.util.Queue; + + +/** + * @author cr...@jn... + * + */ +public class DefaultKeyboardHandler extends KeyboardHandler +implements KeyboardListener, FocusListener, DeviceListener { + + private KeyboardAPI api; + private final DeviceManager devMan; + + private boolean hasFocus; + + public DefaultKeyboardHandler(KeyboardAPI api) { + if (api != null) { + this.devMan = null; + this.api = api; + this.api.addKeyboardListener(this); + } + else { + DeviceManager dm = null; + try { + dm = InitialNaming.lookup(DeviceManager.NAME); + dm.addListener(this); + } + catch (NameNotFoundException ex) { + BootLog.error("DeviceManager not found", ex); + } + this.devMan = dm; + } + } + + private void registerKeyboardApi(Device device) { + if (this.api == null) { + try { + this.api = device.getAPI(KeyboardAPI.class); + this.api.addKeyboardListener(this); + } + catch (ApiNotFoundException ex) { + BootLog.error("KeyboardAPI not found", ex); + } + this.devMan.removeListener(this); + } + } + + /** + * @see org.jnode.driver.input.KeyboardListener#keyPressed(org.jnode.driver.input.KeyboardEvent) + */ + public void keyPressed(KeyboardEvent event) { + if (hasFocus) { + postEvent(event); + } + } + + /** + * @see org.jnode.driver.input.KeyboardListener#keyReleased(org.jnode.driver.input.KeyboardEvent) + */ + public void keyReleased(KeyboardEvent event) { + } + + /** + * @see java.io.InputStream#close() + */ + public void close() throws IOException { + if (api != null) { + api.removeKeyboardListener(this); + } + } + + /** + * @see org.jnode.driver.DeviceListener#deviceStarted(org.jnode.driver.Device) + */ + public void deviceStarted(Device device) { + if (device.implementsAPI(KeyboardAPI.class)) { + registerKeyboardApi(device); + } + } + + /** + * @see org.jnode.driver.DeviceListener#deviceStop(org.jnode.driver.Device) + */ + public void deviceStop(Device device) { + /* Do nothing */ + } + + public void focusGained(FocusEvent event) { + hasFocus = true; + } + + public void focusLost(FocusEvent event) { + hasFocus = false; + } +} Added: trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java (rev 0) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/KeyboardHandler.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -0,0 +1,70 @@ +package org.jnode.driver.console.textscreen; + +import java.io.IOException; + +import javax.naming.NameNotFoundException; + +import org.jnode.driver.ApiNotFoundException; +import org.jnode.driver.Device; +import org.jnode.driver.DeviceListener; +import org.jnode.driver.DeviceManager; +import org.jnode.driver.input.KeyboardAPI; +import org.jnode.driver.input.KeyboardEvent; +import org.jnode.driver.input.KeyboardListener; +import org.jnode.naming.InitialNaming; +import org.jnode.system.BootLog; +import org.jnode.system.event.FocusEvent; +import org.jnode.system.event.FocusListener; +import org.jnode.util.Queue; + + +/** + * KeyInputStream maps keyboard events into a stream of characters. Current functionality includes: + * <ul> + * <li>line buffering and line editing, using a text console, + * <li>integrated input history and completion, + * <li>CTRL-D is interpretted as a 'soft' EOF mark,KeyboardInputStream + * <li>listens to keyboard focus events. + * </ul> + * + * Future enhancements include: + * <ul> + * <li>a "raw" mode in which characters and other keyboard events are delivered without line editing, + * <li>a "no echo" mode in which line editting occurs without echoing of input characters, + * <li>making the active characters and keycodes "soft", + * <li>making completion and history context sensitive; e.g. when switching between a shell and + * an application, and + * <li>code refactoring to support classical terminal devices and remote consoles. + * </ul> + * + * Bugs: + * <ul> + * <li>The current method of echoing the input is suboptimal, and is broken in the case where an + * application outputs a prompt string to stdout or stderr. + * </ul> + * + * @author cr...@jn... + * + */ +abstract public class KeyboardHandler { + + /** The queue of keyboard events */ + private final Queue<KeyboardEvent> queue = new Queue<KeyboardEvent>(); + + protected void postEvent(KeyboardEvent event) + { + queue.add(event); + } + + /** + * Get the next KeyboardEvent from the internal queue (and wait if none is available). + * + * @return + */ + public final KeyboardEvent getEvent() + { + return queue.get(); + } + + abstract public void close() throws IOException; +} Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,11 +18,12 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.console.textscreen; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; + import org.jnode.driver.console.ConsoleManager; import org.jnode.driver.input.KeyboardEvent; import org.jnode.driver.input.PointerEvent; @@ -39,58 +40,60 @@ * @param screen */ public ScrollableTextScreenConsole(ConsoleManager mgr, String name, - ScrollableTextScreen screen, int options) { + ScrollableTextScreen screen, int options) { super(mgr, name, screen, options); } - + /** * Scroll a given number of rows up. * * @param rows */ public void scrollUp(int rows) { - final ScrollableTextScreen screen = (ScrollableTextScreen) getScreen(); + final ScrollableTextScreen screen = (ScrollableTextScreen)getScreen(); screen.scrollUp(rows); - screen.sync(); + + final int length = rows * screen.getWidth(); + screen.sync(screen.getHeight() * screen.getWidth() - length, length); } - + /** * Scroll a given number of rows down. * * @param rows */ public void scrollDown(int rows) { - final ScrollableTextScreen screen = (ScrollableTextScreen) getScreen(); - screen.scrollDown(rows); - screen.sync(); + final ScrollableTextScreen screen = (ScrollableTextScreen)getScreen(); + screen.scrollDown(rows); + screen.sync(0, rows * screen.getWidth()); } - + /** * @see org.jnode.driver.input.KeyboardListener#keyPressed(org.jnode.driver.input.KeyboardEvent) */ public void keyPressed(KeyboardEvent event) { if (isFocused() && !event.isConsumed()) { - final int modifiers = event.getModifiers(); - if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { - switch (event.getKeyCode()) { - case KeyEvent.VK_PAGE_UP: - scrollUp(10); - event.consume(); - break; - case KeyEvent.VK_PAGE_DOWN: - scrollDown(10); - event.consume(); - break; - case KeyEvent.VK_UP: - scrollUp(1); - event.consume(); - break; - case KeyEvent.VK_DOWN: - scrollDown(1); - event.consume(); - break; - } - } + final int modifiers = event.getModifiers(); + if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { + switch (event.getKeyCode()) { + case KeyEvent.VK_PAGE_UP : + scrollUp(10); + event.consume(); + break; + case KeyEvent.VK_PAGE_DOWN : + scrollDown(10); + event.consume(); + break; + case KeyEvent.VK_UP : + scrollUp(1); + event.consume(); + break; + case KeyEvent.VK_DOWN : + scrollDown(1); + event.consume(); + break; + } + } } if (!event.isConsumed()) { super.keyPressed(event); @@ -104,7 +107,7 @@ if (isFocused() && (event.getZ() != 0)) { final int z = event.getZ(); if (z < 0) { - scrollUp(Math.abs(z)); + scrollUp(Math.abs(z)); } else { scrollDown(Math.abs(z)); } Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,13 +18,14 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.console.textscreen; import java.io.InputStream; import java.io.PrintStream; import java.security.AccessController; import java.security.PrivilegedAction; + import org.jnode.driver.console.ConsoleManager; import org.jnode.driver.console.InputCompleter; import org.jnode.driver.console.TextConsole; @@ -46,336 +47,337 @@ /** * The screen I'm writing on */ - private final TextScreen screen; + private final TextScreen screen; /** * Width of the screen */ - private final int scrWidth; + private final int scrWidth; /** * Height of the screen */ - private final int scrHeight; + private final int scrHeight; /** * Current tab size */ - private int tabSize = 4; + private int tabSize = 4; /** * Current X position */ - private int curX; + private int curX; /** * Current Y position */ - private int curY; + private int curY; + + private InputStream in; - private InputStream in; + private final ConsolePrintStream out; - private final ConsolePrintStream out; + private final ConsolePrintStream err; - private final ConsolePrintStream err; + private PrintStream savedOut; - private PrintStream savedOut; + private PrintStream savedErr; - private PrintStream savedErr; + private boolean cursorVisible = true; - private boolean cursorVisible = true; + private final boolean claimSystemOutErr; - private final boolean claimSystemOutErr; - private VmIsolate myIsolate; /** - * @param mgr - * @param name - * @param screen - */ - public TextScreenConsole(ConsoleManager mgr, String name, - TextScreen screen, int options) { - super(mgr, name); - this.screen = screen; - this.scrWidth = screen.getWidth(); - this.scrHeight = screen.getHeight(); - this.savedOut = this.out = new ConsolePrintStream(new ConsoleOutputStream( - this, 0x07)); - this.savedErr = this.err = new ConsolePrintStream(new ConsoleOutputStream( - this, 0x04)); + * @param mgr + * @param name + * @param screen + */ + public TextScreenConsole(ConsoleManager mgr, String name, + TextScreen screen, int options) { + super(mgr, name); + this.screen = screen; + this.scrWidth = screen.getWidth(); + this.scrHeight = screen.getHeight(); + this.savedOut = this.out = new ConsolePrintStream(new ConsoleOutputStream( + this, 0x07)); + this.savedErr = this.err = new ConsolePrintStream(new ConsoleOutputStream( + this, 0x04)); //todo crawley, will the console not set System.out/err any more? -// this.claimSystemOutErr = ((options & ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR) == 0); - this.claimSystemOutErr = false; +// this.claimSystemOutErr = ((options & ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR) == 0); + this.claimSystemOutErr = false; this.myIsolate = VmIsolate.currentIsolate(); } - /** - * Clear the console - * - * @see org.jnode.driver.console.TextConsole#clear() - */ - public void clear() { - final int size = screen.getWidth() * screen.getHeight(); - screen.set(0, ' ', size, 0x07); - syncScreen(); - } + /** + * Clear the console + * + * @see org.jnode.driver.console.TextConsole#clear() + */ + public void clear() { + final int size = screen.getWidth() * screen.getHeight(); + screen.set(0, ' ', size, 0x07); + syncScreen(0, size); + } - /** - * Clear a given row - */ - public void clearRow(int row) { - final int size = screen.getWidth(); - screen.set(screen.getOffset(0, row), ' ', size, 0x07); - syncScreen(); - } + /** + * Clear a given row + */ + public void clearRow(int row) { + final int size = screen.getWidth(); + final int offset = screen.getOffset(0, row); + screen.set(offset, ' ', size, 0x07); + syncScreen(offset, size); + } - /** - * Append characters to the current line. - * - * @param v + /** + * Append characters to the current line. + * + * @param v * @param offset * @param lenght - * @param color - */ + * @param color + */ public void putChar(char v[], int offset, int lenght, int color) { int mark = 0; - for (int i = 0; i < lenght; i++) { + for(int i = 0; i < lenght; i++){ char c = v[i + offset]; - if (c == '\n' || c == '\b' || c == '\t' || - curX + i == scrWidth - 1 || i == lenght - 1) { + if(c == '\n' || c =='\b' || c == '\t' || + curX + i == scrWidth - 1 || i == lenght - 1){ final int ln = i - mark; - if (ln > 0) { + if(ln > 0){ screen.set(screen.getOffset(curX, curY), v, offset + mark, ln, color); curX += ln; if (curX >= scrWidth) { curY++; curX = curX - scrWidth; - } + } } mark = i + 1; doPutChar(c, color); } } - screen.ensureVisible(curY); - syncScreen(); + screen.ensureVisible(curY, isFocused()); // synchronize if focused } - /** - * Append a character to the current line. - * - * @param v - * @param color - */ - public void putChar(char v, int color) { - doPutChar(v, color); - screen.ensureVisible(curY); - syncScreen(); - } - - private void doPutChar(char v, int color) { - if (v == '\n') { - // Goto next line - // Clear till eol + /** + * Append a character to the current line. + * + * @param v + * @param color + */ + public void putChar(char v, int color) { + doPutChar(v, color); + screen.ensureVisible(curY, isFocused()); // synchronize if focused + } + + private void doPutChar(char v, int color) { + if (v == '\n') { + // Goto next line + // Clear till eol screen.set(screen.getOffset(curX, curY), ' ', scrWidth - curX, color); - curX = 0; - curY++; - } else if (v == '\b') { - if (curX > 0) { - curX--; - } else if (curY > 0) { - curX = scrWidth - 1; - curY--; - } - setChar(curX, curY, ' ', color); - } else if (v == '\t') { - putChar(' ', color); - while ((curX % tabSize) != 0) { - putChar(' ', color); - } - } else { - setChar(curX, curY, v, color); - curX++; - if (curX >= scrWidth) { - curY++; - curX = 0; - } - } - while (curY >= scrHeight) { - screen.copyContent(scrWidth, 0, (scrHeight - 1) * scrWidth); - curY--; - clearRow(curY); - } - } + curX = 0; + curY++; + } else if (v == '\b') { + if (curX > 0) { + curX--; + } else if (curY > 0) { + curX = scrWidth - 1; + curY--; + } + setChar(curX, curY, ' ', color); + } else if (v == '\t') { + putChar(' ', color); + while ((curX % tabSize) != 0) { + putChar(' ', color); + } + } else { + setChar(curX, curY, v, color); + curX++; + if (curX >= scrWidth) { + curY++; + curX = 0; + } + } + while (curY >= scrHeight) { + screen.copyContent(scrWidth, 0, (scrHeight - 1) * scrWidth); + curY--; + clearRow(curY); + } + } - /** - * @return Returns the tabSize. - */ - public int getTabSize() { - return tabSize; - } + /** + * @return Returns the tabSize. + */ + public int getTabSize() { + return tabSize; + } - /** + /** * @param tabSize The tabSize to set. - */ - public void setTabSize(int tabSize) { - this.tabSize = tabSize; - } + */ + public void setTabSize(int tabSize) { + this.tabSize = tabSize; + } - /** - * @see org.jnode.driver.console.TextConsole#getColor(int, int) - */ - public int getColor(int x, int y) { - return screen.getColor(screen.getOffset(x, y)); - } + /** + * @see org.jnode.driver.console.TextConsole#getColor(int, int) + */ + public int getColor(int x, int y) { + return screen.getColor(screen.getOffset(x, y)); + } - /** - * @see org.jnode.driver.console.TextConsole#getChar(int, int) - */ - public char getChar(int x, int y) { - return screen.getChar(screen.getOffset(x, y)); - } + /** + * @see org.jnode.driver.console.TextConsole#getChar(int, int) + */ + public char getChar(int x, int y) { + return screen.getChar(screen.getOffset(x, y)); + } - /** - * @see org.jnode.driver.console.TextConsole#getCursorX() - */ - public int getCursorX() { - return curX; - } + /** + * @see org.jnode.driver.console.TextConsole#getCursorX() + */ + public int getCursorX() { + return curX; + } - /** - * @see org.jnode.driver.console.TextConsole#getCursorY() - */ - public int getCursorY() { - return curY; - } + /** + * @see org.jnode.driver.console.TextConsole#getCursorY() + */ + public int getCursorY() { + return curY; + } - /** - * @see org.jnode.driver.console.TextConsole#getHeight() - */ - public int getHeight() { - return screen.getHeight(); - } + /** + * @see org.jnode.driver.console.TextConsole#getHeight() + */ + public int getHeight() { + return screen.getHeight(); + } - /** - * @see org.jnode.driver.console.TextConsole#getWidth() - */ - public int getWidth() { - return screen.getWidth(); - } + /** + * @see org.jnode.driver.console.TextConsole#getWidth() + */ + public int getWidth() { + return screen.getWidth(); + } - /** - * @see org.jnode.driver.console.TextConsole#setChar(int, int, char, int) - */ - public void setChar(int x, int y, char ch, int color) { - screen.set(screen.getOffset(x, y), ch, 1, color); - syncScreen(); - } + /** + * @see org.jnode.driver.console.TextConsole#setChar(int, int, char, int) + */ + public void setChar(int x, int y, char ch, int color) { + int offset = screen.getOffset(x, y); + screen.set(offset, ch, 1, color); + syncScreen(offset, 1); + } - public void setChar(int x, int y, char[] ch, int color) { - screen.set(screen.getOffset(x, y), ch, 0, ch.length, color); - syncScreen(); - } + public void setChar(int x, int y, char[] ch, int color) { + int offset = screen.getOffset(x, y); + screen.set(offset, ch, 0, ch.length, color); + syncScreen(offset, ch.length); + } - public void setChar(int x, int y, char[] ch, int cOfset, int cLength, - int color) { - screen.set(screen.getOffset(x, y), ch, cOfset, cLength, color); - syncScreen(); - } + public void setChar(int x, int y, char[] ch, int cOfset, int cLength, + int color) { + int offset = screen.getOffset(x, y); + screen.set(offset, ch, cOfset, cLength, color); + syncScreen(offset, cLength); + } - /** - * @see org.jnode.driver.console.TextConsole#setCursor(int, int) - */ - public void setCursor(int x, int y) { - this.curX = x; - this.curY = y; - screen.setCursor(x, y); - syncScreen(); - } + /** + * @see org.jnode.driver.console.TextConsole#setCursor(int, int) + */ + public void setCursor(int x, int y) { + this.curX = x; + this.curY = y; + int offset = screen.setCursor(x,y); + syncScreen(offset, 1); + } - protected final void syncScreen() { - if (isFocused()) { - screen.sync(); - } - } + private void syncScreen(int offset, int size) { + if (isFocused()) { + screen.sync(offset, size); + } + } - /** - * Ensure that the given row is visible. - * - * @param row - */ - public void ensureVisible(int row) { - screen.ensureVisible(row); - syncScreen(); - } + /** + * Ensure that the given row is visible. + * + * @param row + */ + public void ensureVisible(int row) { + screen.ensureVisible(row, isFocused()); // synchronize if focused + } - public InputCompleter getCompleter() { - if (in instanceof KeyboardInputStream) { - return ((KeyboardInputStream) in).getCompleter(); + public InputCompleter getCompleter() { + if (in instanceof KeyboardInputStream) { + return ((KeyboardInputStream) in).getCompleter(); } else { - return null; - } - } + return null; + } + } - public void setCompleter(InputCompleter completer) { - if (in instanceof KeyboardInputStream) { - ((KeyboardInputStream) in).setCompleter(completer); - } - } + public void setCompleter(InputCompleter completer) { + if (in instanceof KeyboardInputStream) { + ((KeyboardInputStream) in).setCompleter(completer); + } + } - /** - * @see org.jnode.driver.console.TextConsole#getIn() - */ - public InputStream getIn() { - return in; - } + /** + * @see org.jnode.driver.console.TextConsole#getIn() + */ + public InputStream getIn() { + return in; + } - void setIn(InputStream in) { - this.in = in; - } + void setIn(InputStream in) { + this.in = in; + } - /** - * @see org.jnode.driver.console.TextConsole#getErr() - */ - public PrintStream getErr() { - return err; - } + /** + * @see org.jnode.driver.console.TextConsole#getErr() + */ + public PrintStream getErr() { + return err; + } - /** - * @see org.jnode.driver.console.TextConsole#getOut() - */ - public PrintStream getOut() { - return out; - } + /** + * @see org.jnode.driver.console.TextConsole#getOut() + */ + public PrintStream getOut() { + return out; + } - /** - * Is the cursor visible. - */ - public boolean isCursorVisible() { - return cursorVisible; - } + /** + * Is the cursor visible. + */ + public boolean isCursorVisible() { + return cursorVisible; + } - /** - * Make the cursor visible or not visible. - * - * @param visible - */ - public void setCursorVisible(boolean visible) { - this.cursorVisible = visible; - screen.setCursorVisible(visible); - syncScreen(); - } + /** + * Make the cursor visible or not visible. + * + * @param visible + */ + public void setCursorVisible(boolean visible) { + this.cursorVisible = visible; + int offset = screen.setCursorVisible(visible); + syncScreen(offset, 1); + } - /** - * @see org.jnode.system.event.FocusListener#focusGained(org.jnode.system.event.FocusEvent) - */ - public void focusGained(FocusEvent event) { - super.focusGained(event); - syncScreen(); - if (in instanceof FocusListener) { - ((FocusListener) in).focusGained(event); - } - if (claimSystemOutErr && VmSystem.hasVmIOContext()) { + /** + * @see org.jnode.system.event.FocusListener#focusGained(org.jnode.system.event.FocusEvent) + */ + public void focusGained(FocusEvent event) { + super.focusGained(event); + syncScreen(0, screen.getWidth() * screen.getHeight()); + if (in instanceof FocusListener) { + ((FocusListener) in).focusGained(event); + } + if (claimSystemOutErr && VmSystem.hasVmIOContext()) { myIsolate.invokeAndWait(new Runnable() { public void run() { AccessController.doPrivileged(new PrivilegedAction<Object>() { @@ -387,31 +389,31 @@ }); } }); - } - } + } + } - /** - * @see org.jnode.system.event.FocusListener#focusLost(org.jnode.system.event.FocusEvent) - */ - public void focusLost(FocusEvent event) { - if (in instanceof FocusListener) { - ((FocusListener) in).focusLost(event); - } - if (claimSystemOutErr && VmSystem.hasVmIOContext()) { + /** + * @see org.jnode.system.event.FocusListener#focusLost(org.jnode.system.event.FocusEvent) + */ + public void focusLost(FocusEvent event) { + if (in instanceof FocusListener) { + ((FocusListener) in).focusLost(event); + } + if (claimSystemOutErr && VmSystem.hasVmIOContext()) { myIsolate.invokeAndWait(new Runnable() { public void run() { savedOut = System.out; savedErr = System.err; } }); - } - super.focusLost(event); - } + } + super.focusLost(event); + } - /** - * @return Returns the screen. - */ - protected final TextScreen getScreen() { - return this.screen; - } + /** + * @return Returns the screen. + */ + protected final TextScreen getScreen() { + return this.screen; + } } Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsoleManager.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,11 +18,13 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.console.textscreen; import java.io.InputStream; + import javax.naming.NameNotFoundException; + import org.jnode.driver.console.ConsoleException; import org.jnode.driver.console.spi.AbstractConsoleManager; import org.jnode.driver.textscreen.ScrollableTextScreen; @@ -36,22 +38,22 @@ public class TextScreenConsoleManager extends AbstractConsoleManager { private int SCROLLABLE_HEIGHT = 500; - + /** * Initialize this instance. * * @throws ConsoleException */ public TextScreenConsoleManager() - throws ConsoleException { + throws ConsoleException { } - - + + /** * @see org.jnode.driver.console.ConsoleManager#createConsole(String, int) */ public TextScreenConsole createConsole(String name, int options) { - if ((options & CreateOptions.TEXT) != 0) { + if ((options & CreateOptions.TEXT) != 0) { final TextScreenManager tsm; tsm = getTextScreenManager(); final TextScreenConsole console; @@ -67,12 +69,9 @@ screen = tsm.getSystemScreen().createCompatibleBufferScreen(); console = new TextScreenConsole(this, name, screen, options); } - InputStream in = System.in; - if ((options & CreateOptions.NO_LINE_EDITTING) == 0) { - in = new KeyboardInputStream(getKeyboardApi(), console); - } - console.setIn(in); - if ((options & CreateOptions.STACKED) != 0) { + InputStream in = getInputStream(options, console); + console.setIn(in); + if ((options & CreateOptions.STACKED) != 0){ stackConsole(console); } else { setAccelerator(console); @@ -84,7 +83,18 @@ throw new IllegalArgumentException("Unknown option " + options); } } - + + protected InputStream getInputStream(int options, TextScreenConsole console) + { + InputStream in = System.in; + if ((options & CreateOptions.NO_LINE_EDITTING) == 0) { + KeyboardHandler kbHandler = new DefaultKeyboardHandler(getKeyboardApi()); + in = new KeyboardInputStream(kbHandler, console); + } + + return in; + } + protected TextScreenManager getTextScreenManager() { TextScreenManager tsm; try { Modified: trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen; /** @@ -26,7 +26,7 @@ * (video memory) - buffered screen (system memory, faster that video memory) - * remote screen, shared screen, multiple screens ... - recording screen (movies * for demos or tutorials) - * + * * @author epr */ public interface TextScreen { @@ -44,7 +44,7 @@ /** * Set a series of of the same character with a given color at a given * offset. - * + * * @param offset * @param ch * @param color @@ -53,59 +53,61 @@ /** * Set an series of characters with a given color at a given offset. - * + * * @param offset * @param ch * @param color */ public abstract void set(int offset, char[] ch, int chOfs, int length, - int color); + int color); /** * Set an series of characters with a given series of colors at a given * offset. - * + * * @param offset * @param ch * @param colors * @param colorsOfs */ public abstract void set(int offset, char[] ch, int chOfs, int length, - int[] colors, int colorsOfs); + int[] colors, int colorsOfs); /** * Copy the content of the screen from a given source to a given - * destionation offset. - * + * destination offset. + * * @param srcOffset * @param destOffset * @param length */ public abstract void copyContent(int srcOffset, int destOffset, int length); - + /** * Copies the entire screen to the given destination. * For this operation to succeed, the screens involved must be * compatible. * * @param dst + * @param offset + * @param length */ - public abstract void copyTo(TextScreen dst); + public abstract void copyTo(TextScreen dst, int offset, int length); /** * Gets the height of the screen in letters. - * + * * @return Returns the height. */ public int getHeight(); /** * Gets the width of the screen in letters. - * + * * @return Returns the width. */ public int getWidth(); - + /** * Calculate the offset for a given x,y coordinate. * @@ -114,12 +116,14 @@ * @return */ public int getOffset(int x, int y); - + /** * Synchronize the state with the actual device. + * @param offset + * @param length */ - public void sync(); - + public void sync(int offset, int length); + /** * Create an in-memory buffer text screen that is compatible * with this screen. @@ -127,7 +131,7 @@ * @return */ public TextScreen createCompatibleBufferScreen(); - + /** * Create an in-memory buffer text screen that is compatible * with this, but larger and supports scrolling. @@ -135,15 +139,27 @@ * @return */ public ScrollableTextScreen createCompatibleScrollableBufferScreen(int height); - + /** * Ensure that the given row is visible. * * @param row + * @param sync true if screen should synchronize */ - public void ensureVisible(int row); + public void ensureVisible(int row, boolean sync); - void setCursor(int x, int y); + /** + * + * @param x + * @param y + * @return offset of the cursor + */ + public int setCursor( int x, int y ); - void setCursorVisible(boolean visible); + /** + * + * @param visible + * @return offset of the cursor + */ + int setCursorVisible( boolean visible ); } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import org.jnode.driver.textscreen.TextScreen; @@ -28,7 +28,7 @@ * @author Ewout Prangsma (ep...@us...) * @author Fabien DUMINY (fduminy at jnode.org) */ -public abstract class AbstractPcBufferTextScreen extends AbstractPcTextScreen implements TextScreen { +public abstract class AbstractPcBufferTextScreen extends AbstractPcTextScreen { /** * Actual content buffer @@ -40,9 +40,9 @@ * Slower, but more likely to be correct than a temporary pointer to the last character * the cursor was over, as in previous versions. */ - private final char[] screenBuffer; - private int cursorIndex = 0; - private boolean cursorVisible = true; + private final char[]screenBuffer; + private int cursorIndex=0; + private boolean cursorVisible=true; /** * Initialize this instance. @@ -53,7 +53,7 @@ public AbstractPcBufferTextScreen(int width, int height) { super(width, height); this.buffer = new char[width * height]; - this.screenBuffer = new char[buffer.length]; + this.screenBuffer=new char[buffer.length]; } /** @@ -67,24 +67,24 @@ * @see org.jnode.driver.textscreen.TextScreen#getChar(int) */ public char getChar(int offset) { - return (char) (buffer[offset] & 0xFF); + return (char)(buffer[offset] & 0xFF); } /** * @see org.jnode.driver.textscreen.TextScreen#getColor(int) */ public int getColor(int offset) { - return (char) ((buffer[offset] >> 8) & 0xFF); + return (char)((buffer[offset] >> 8) & 0xFF); } /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char, int, int) */ public void set(int offset, char ch, int count, int color) { - final char v = (char) ((ch & 0xFF) | ((color & 0xFF) << 8)); + final char v = (char)((ch & 0xFF) | ((color & 0xFF) << 8)); count = Math.min(count, buffer.length - offset); for (int i = 0; i < count; i++) { - buffer[offset + i] = v; + buffer[offset+i] = v; } } @@ -95,7 +95,7 @@ color = (color & 0xFF) << 8; length = Math.min(length, buffer.length - offset); for (int i = 0; i < length; i++) { - buffer[offset + i] = (char) ((ch[chOfs + i] & 0xFF) | color); + buffer[offset+i] = (char)((ch[chOfs+i] & 0xFF) | color); } } @@ -103,10 +103,10 @@ * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int[], int) */ public void set(int offset, char[] ch, int chOfs, int length, int[] colors, - int colorsOfs) { + int colorsOfs) { length = Math.min(length, buffer.length - offset); for (int i = 0; i < length; i++) { - buffer[offset + i] = (char) ((ch[chOfs + i] & 0xFF) | (colors[colorsOfs + i] & 0xFF) << 8); + buffer[offset+i] = (char)((ch[chOfs+i] & 0xFF) | (colors[colorsOfs+i] & 0xFF) << 8); } } @@ -117,26 +117,26 @@ * * @param dst */ - public void copyTo(TextScreen dst) { - if (dst instanceof AbstractPcTextScreen) { + public void copyTo( TextScreen dst, int offset, int length ) { + if( dst instanceof AbstractPcTextScreen ) { char[] toScreen = buffer; - if (cursorVisible && cursorIndex < buffer.length && cursorIndex >= 0) { - System.arraycopy(buffer, 0, screenBuffer, 0, buffer.length); + if( cursorVisible&&cursorIndex<buffer.length&&cursorIndex>=0 ) { + System.arraycopy( buffer, 0, screenBuffer, 0, buffer.length ); char origValue = buffer[cursorIndex]; //origValue |= 0x7000;//from december 2003 jnode code. //exchange the background with the foreground - int color = (origValue >> 8) & 0xFF; + int color = (origValue >>8) & 0xFF; color = ((color >> 4) & 0xF) | ((color << 4) & 0xF0); origValue &= 0x00FF; origValue |= (color << 8) & 0xFF00; - + screenBuffer[cursorIndex] = origValue; toScreen = screenBuffer; } - ((AbstractPcTextScreen) dst).copyFrom(toScreen, getTopOffset()); + ( (AbstractPcTextScreen)dst ).copyFrom( toScreen, getTopOffset() ); } else { - throw new IllegalArgumentException("Unknown destination type " + dst.getClass().getName()); + throw new IllegalArgumentException( "Unknown destination type " + dst.getClass().getName() ); } } @@ -165,16 +165,18 @@ /** * Synchronize the state with the actual device. */ - public abstract void sync(); + public abstract void sync(int offset, int length); - public void setCursor(int x, int y) { - this.cursorIndex = getOffset(x, y); + public int setCursor( int x, int y ) { + this.cursorIndex=getOffset( x,y); setParentCursor(x, y); + return cursorIndex; } + + protected abstract void setParentCursor( int x, int y ); - protected abstract void setParentCursor(int x, int y); - - public void setCursorVisible(boolean visible) { - this.cursorVisible = visible; + public int setCursorVisible(boolean visible) { + this.cursorVisible=visible; + return cursorIndex; } } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import org.jnode.driver.textscreen.ScrollableTextScreen; @@ -42,25 +42,25 @@ this.width = width; this.height = height; } - + /** * Gets the height of the screen in letters. - * + * * @return Returns the height. */ public int getHeight() { - return height; + return height; } /** * Gets the width of the screen in letters. - * + * * @return Returns the width. */ public int getWidth() { return width; } - + /** * Calculate the offset for a given x,y coordinate. * @@ -86,7 +86,7 @@ public TextScreen createCompatibleBufferScreen() { return new PcBufferTextScreen(getWidth(), getHeight(), this); } - + /** * Create an in-memory buffer text screen that is compatible * with the system screen, but larges and supports scrolling. @@ -97,15 +97,15 @@ if (height < getHeight()) { throw new IllegalArgumentException("Invalid height " + height); } - return new PcScrollableTextScreen(getWidth(), height, this); + return new PcScrollableTextScreen(getWidth(), height, this); } - + /** * Ensure that the given row is visible. * * @param row */ - public void ensureVisible(int row) { + public void ensureVisible(int row, boolean sync) { // do nothing by default } } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import org.jnode.driver.textscreen.TextScreen; @@ -26,7 +26,7 @@ /** * @author Ewout Prangsma (ep...@us...) */ -public class PcBufferTextScreen extends AbstractPcBufferTextScreen implements TextScreen { +public class PcBufferTextScreen extends AbstractPcBufferTextScreen { /** * My parent @@ -47,11 +47,11 @@ /** * Synchronize the state with the actual device. */ - public void sync() { - copyTo(parent); + public void sync(int offset, int length) { + copyTo(parent, offset, length); } - protected void setParentCursor(int x, int y) { + protected void setParentCursor( int x, int y ) { parent.setCursor(x, y); } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,7 +18,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import org.jnode.driver.textscreen.ScrollableTextScreen; @@ -27,18 +27,18 @@ * @author Ewout Prangsma (ep...@us...) */ class PcScrollableTextScreen extends PcBufferTextScreen implements - ScrollableTextScreen { + ScrollableTextScreen { /** * Offset of top visible row */ private int ofsY; - + /** * Height of the parent screen */ private final int parentHeight; - + /** * Maximum row that has valid data */ @@ -54,9 +54,9 @@ } /** - * @see org.jnode.driver.textscreen.ScrollableTextScreen#ensureVisible(int) + * @see org.jnode.driver.textscreen.ScrollableTextScreen#ensureVisible(int, boolean) */ - public void ensureVisible(int row) { + public void ensureVisible(int row, boolean sync) { if (row < ofsY) { ofsY = row; } else if (row >= ofsY + parentHeight) { @@ -91,13 +91,13 @@ /** * Return the offset in the buffer of the first visible row. - * + * * @return */ protected int getTopOffset() { return ofsY * getWidth(); - } - + } + /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char, int, int) */ @@ -105,21 +105,19 @@ maxValidY = Math.max(maxValidY, offset / getWidth()); super.set(offset, ch, count, color); } - /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int) */ public void set(int offset, char[] ch, int chOfs, int length, int color) { - maxValidY = Math.max(maxValidY, (offset + length - 1) / getWidth()); + maxValidY = Math.max(maxValidY, (offset + length-1) / getWidth()); super.set(offset, ch, chOfs, length, color); } - /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int[], int) */ public void set(int offset, char[] ch, int chOfs, int length, int[] colors, - int colorsOfs) { - maxValidY = Math.max(maxValidY, (offset + length - 1) / getWidth()); + int colorsOfs) { + maxValidY = Math.max(maxValidY, (offset + length-1) / getWidth()); super.set(offset, ch, chOfs, length, colors, colorsOfs); } } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -18,10 +18,11 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.driver.textscreen.x86; import javax.naming.NameNotFoundException; + import org.jnode.driver.textscreen.TextScreen; import org.jnode.naming.InitialNaming; import org.jnode.system.BootLog; @@ -36,7 +37,7 @@ /** * @author Ewout Prangsma (ep...@us...) */ -public class PcTextScreen extends AbstractPcTextScreen implements TextScreen { +public class PcTextScreen extends AbstractPcTextScreen { /** * The MemoryResource we use to store (and display) characters. @@ -57,10 +58,10 @@ Address ptr = Address.fromIntZeroExtend(0xb8000); try { final ResourceManager rm = (ResourceManager) InitialNaming - .lookup(ResourceManager.NAME); + .lookup(ResourceManager.NAME); final ResourceOwner owner = new SimpleResourceOwner("Screen"); memory = rm.claimMemoryResource(owner, ptr, getWidth() - * getHeight() * 2, ResourceManager.MEMMODE_NORMAL); + * getHeight() * 2, ResourceManager.MEMMODE_NORMAL); } catch (NameNotFoundException ex) { throw new ResourceNotFreeException("ResourceManager not found", ex); } @@ -68,7 +69,7 @@ /** * Get the singleton instance and create it if necessary. - * + * * @return @throws * PragmaUninterruptible */ @@ -132,17 +133,17 @@ * int[], int) */ public void set(int offset, char[] ch, int chOfs, int length, int[] colors, - int colorsOfs) { + int colorsOfs) { for (int i = 0; i < length; i++) { final int v = (ch[chOfs + i] & 0xFF) - | ((colors[colorsOfs + i] & 0xFF) << 8); + | ((colors[colorsOfs + i] & 0xFF) << 8); memory.setChar((offset + i) * 2, (char) v); } } /** * Copy the content of the given rawData into this screen. - * + * * @param rawData * @param rawDataOffset */ @@ -156,25 +157,26 @@ /** * Copies the entire screen to the given destination. For this operation to * succeed, the screens involved must be compatible. - * + * * @param dst */ - public void copyTo(TextScreen dst) { + public void copyTo(TextScreen dst, int offset, int length) { throw new UnsupportedOperationException(); } /** * Synchronize the state with the actual device. */ - public void sync() { + public void sync(int offset, int length) { // Nothing to do here } - public void setCursor(int x, int y) { + public int setCursor( int x, int y ) { //instance.setCursor( x,y); + return 0; // TODO what should we return if we don't call instance.setCursor ? } - public void setCursorVisible(boolean visible) { - instance.setCursorVisible(visible); + public int setCursorVisible( boolean visible ) { + return instance.setCursorVisible( visible ); } } Modified: trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeCommandShell.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeCommandShell.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeCommandShell.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -1,29 +1,33 @@ package org.jnode.apps.telnetd; -import java.io.InputStream; -import java.io.PrintStream; - import org.jnode.driver.console.TextConsole; import org.jnode.shell.CommandShell; import org.jnode.shell.ShellException; /** -* -* @author Fabien DUMINY (fduminy at jnode.org) -* -*/ + * + * @author Fabien DUMINY (fduminy at jnode.org) + * + */ public class JNodeCommandShell extends CommandShell { - private final JNodeShell shell; + private final JNodeShell shell; - public JNodeCommandShell(JNodeShell shell, TextConsole console, InputStream in, PrintStream out, PrintStream err) - throws ShellException { - super(console, in, out, err); - this.shell = shell; - } + // public JNodeCommandShell(JNodeShell shell, TextConsole console, + // InputStream in, PrintStream out, PrintStream err) + // throws ShellException { + // super(console, in, out, err); + // this.shell = shell; + // } - @Override - public void exit(){ - shell.close(); - super.exit(); - } + public JNodeCommandShell(TextConsole cons, JNodeShell shell) throws ShellException { + super(cons); + this.shell = shell; + System.err.println("JNodeCommandShell"); + } + + @Override + public void exit() { + shell.close(); + super.exit(); + } } Modified: trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeShell.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeShell.java 2008-06-19 10:19:24 UTC (rev 4262) +++ trunk/distr/src/apps/org/jnode/apps/telnetd/JNodeShell.java 2008-06-19 19:10:50 UTC (rev 4263) @@ -1,8 +1,5 @@ package org.jnode.apps.telnetd; -import java.io.InputStream; -import java.io.PrintStream; - import net.wimpi.telnetd.io.TerminalIO; import net.wimpi.telnetd.net.Connection; import net.wimpi.telnetd.net.ConnectionEvent; @@ -11,340 +8,278 @@ import org.apache.log4j.Logger; import org.jnode.driver.console.ConsoleException; import org.jnode.driver.console.ConsoleManager; -import org.jnode.driver.console.TextConsole; import org.jnode.driver.console.textscreen.ScrollableTextScreenConsole; -import org.jnode.driver.textscreen.ScrollableTextScreen; import org.jnode.shell.CommandShell; /** - * + * * @author Fabien DUMINY (fduminy at jnode.org) - * + * */ public class JNodeShell implements Shell { - private static final RemoteConsoleManager CONSOLE_MANAGER; + private static final RemoteConsoleManager CONSOLE_MANAGER; - static - { - try { - CONSOLE_MANAGER = new RemoteConsoleManager(); - } catch (ConsoleException e) { - throw new RuntimeException("can't create RemoteConsoleManager", e); - } - } + static { + try { + CONSOLE_MANAGER = new RemoteConsoleManager(); + } catch (ConsoleException e) { + throw new RuntimeException("can't create RemoteConsoleManager", e); + } + } - private static final Logger log = Logger.getLogger(JNodeShell.class); + private static final Logger log = Logger.getLogger(JNodeShell.class); - private CommandShell commandShell; - private Connection connection; - private TerminalIO terminalIO; - private ScrollableTextScreenConsole console; + private CommandShell commandShell; + private Connection connection; + private TerminalIO terminalIO; + private ScrollableTextScreenConsole console; -// private Editfield m_EF; + // private Editfield m_EF; - /** - * Method that runs a shell - * - * @param con Connection that runs the shell. - */ - public void run(Connection con) { - try { - connection = con; - //mycon.setNextShell("nothing"); - terminalIO = (TerminalIO) connection.getTerminalIO(); + /** + * Method that runs a shell + * + * @param con Connection that runs the shell. + */ + public void run(Connection con) { + try { + connection = con; + // mycon.setNextShell("nothing"); + terminalIO = (TerminalIO) connection.getTerminalIO(); - //dont forget to register listener - connection.addConnectionListener(this); + // dont forget to register listener + connection.addConnectionListener(this); - //clear the screen and start from zero - terminalIO.eraseScreen(); - terminalIO.homeCursor(); + // clear the screen and start from zero + terminalIO.eraseScreen(); + terminalIO.homeCursor(); - //We just read any key - terminalIO.write("Welcome to JNode telnet server. Thanks for connecting.\r\n" + - "You can type any jnode command and press enter **2 times**(it's a bug!!!) to execute it.\r\n" + - "Use the exit command to logout!\r\n"); // some output - terminalIO.flush(); + // We just read any key + terminalIO + .write("Welcome to JNode telnet server. Thanks for connecting.\r\n" + + "You can type any jnode command and " + + "press enter **2 times**(it's a bug!!!) to execute it.\r\n" + + "Use the exit command to logout!\r\n"); // some + // output + terminalIO.flush(); - final String name = connection.getConnectionData().getHostName(); -// synchronized (CONSOLE_MANAGER) { -// CONSOLE_MANAGER.setTerminalIO(terminalIO); -// console = (ScrollableTextScreenConsole) CONSOLE_MANAGER.createConsole(name, ConsoleManager.CreateOptions.TEXT -// | ConsoleManager.CreateOptions.SCROLLABLE); -// } + final String name = connection.getConnectionData().getHostName(); + synchronized (CONSOLE_MANAGER) { + CONSOLE_MANAGER.setTerminalIO(terminalIO); + console = + (ScrollableTextScreenConsole) CONSOLE_MANAGER.createConsole(name, + ConsoleManager.CreateOptions.TEXT | + ConsoleManager.CreateOptions.SCROLLABLE); + } + CONSOLE_MANAGER.focus(console); - final RemoteTextScreen screen = new RemoteTextScreen(terminalIO); - final ScrollableTextScreen scrollScreen = screen.createCompatibleScrollableBufferScreen(terminalIO.getRows()*10); - console = new ScrollableTextScreenConsole(CONSOLE_MANAGER, name, - scrollScreen, ConsoleManager.CreateOptions.TEXT - | ConsoleManager.CreateOptions.SCROLLABLE); - CONSOLE_MANAGER.registerConsole(console); + // final RemoteTextScreen screen = new RemoteTextScreen(terminalIO); + // final ScrollableTextScreen scrollScreen = + // screen.createCompatibleScrollableBufferScreen(terminalIO.getRows()*10); + // console = new ScrollableTextScreenConsole(CONSOLE_MANAGER, name, + // scrollScreen, ConsoleManager.Create... [truncated message content] |