From: <fd...@us...> - 2008-07-24 21:20:11
|
Revision: 4352 http://jnode.svn.sourceforge.net/jnode/?rev=4352&view=rev Author: fduminy Date: 2008-07-24 21:20:06 +0000 (Thu, 24 Jul 2008) Log Message: ----------- - moved ensureVisible(int) method from TextScreen to new interface ScrollableTextConsole - all TextScreen implementations that were using a char[] as buffer are now inheriting from AbstractPcBufferTextScreen - moved method sync(offset, length) method from TextScreen to AbstractPcBufferTextScreen, only place it is really needed - PcBufferTextScreen class now have a method setDisplayed which allow to render the buffer to a AbstractPcTextScreen or not (new class NoDisplayTextScreen) - externalized common behavior (get/set a character/color from/to a screen) in new class PcTextScreenUtils - workaround in GradientBackground in which getClipBounds always returned (0,0,0,0) Modified Paths: -------------- trunk/core/src/driver/org/jnode/driver/console/TextConsole.java trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java trunk/core/src/driver/org/jnode/driver/console/textscreen/Line.java 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/textscreen/ScrollableTextScreen.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/RemoteTextScreen.java trunk/gui/src/driver/org/jnode/driver/console/swing/JTextAreaTextScreen.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScreenPainter.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbTextScreen.java trunk/gui/src/driver/org/jnode/driver/textscreen/fb/GradientBackground.java trunk/gui/src/driver/org/jnode/driver/textscreen/swing/SwingPcTextScreen.java trunk/gui/src/test/org/jnode/test/gui/FBConsole.java Added Paths: ----------- trunk/core/src/driver/org/jnode/driver/console/ScrollableTextConsole.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/NoDisplayTextScreen.java trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenUtils.java Added: trunk/core/src/driver/org/jnode/driver/console/ScrollableTextConsole.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/ScrollableTextConsole.java (rev 0) +++ trunk/core/src/driver/org/jnode/driver/console/ScrollableTextConsole.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -0,0 +1,37 @@ +/* + * $Id: TextConsole.java 4153 2008-05-30 12:20:45Z lsantha $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * 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; + + +/** + * @author Ewout Prangsma (ep...@us...) + * @author Levente S\u00e1ntha (ls...@us...) + */ +public interface ScrollableTextConsole extends TextConsole { + + /** + * Ensure that the given row is visible. + * + * @param row + */ + public void ensureVisible(int row); +} Modified: trunk/core/src/driver/org/jnode/driver/console/TextConsole.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/TextConsole.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/console/TextConsole.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -155,13 +155,6 @@ public void setTabSize(int tabSize); /** - * Ensure that the given row is visible. - * - * @param row - */ - public void ensureVisible(int row); - - /** * Gets the input stream of this console. * * @return Modified: trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -35,7 +35,9 @@ import java.util.Map; import java.util.Set; import java.util.Stack; + import javax.naming.NameNotFoundException; + import org.apache.log4j.Logger; import org.jnode.driver.ApiNotFoundException; import org.jnode.driver.Device; @@ -51,6 +53,7 @@ import org.jnode.naming.InitialNaming; import org.jnode.system.BootLog; import org.jnode.system.event.FocusEvent; +import org.jnode.vm.Unsafe; /** * @author epr @@ -207,14 +210,14 @@ * @param console */ public synchronized void focus(Console console) { - log.debug("focus(" + console.getConsoleName() + ")"); + Unsafe.debug("focus(" + console.getConsoleName() + ")"); if (this.current != null && this.current != console) { - log.debug("Sending focusLost to " + current.getConsoleName()); + Unsafe.debug("Sending focusLost to " + current.getConsoleName()); this.current.focusLost(new FocusEvent(FocusEvent.FOCUS_LOST)); } this.current = console; if (this.current != null) { - log.debug("Sending focusGained to " + current.getConsoleName()); + Unsafe.debug("Sending focusGained to " + current.getConsoleName()); current.focusGained(new FocusEvent(FocusEvent.FOCUS_GAINED)); } } Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/Line.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/Line.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/Line.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -25,6 +25,7 @@ import java.util.SortedSet; import org.jnode.driver.console.CompletionInfo; import org.jnode.driver.console.InputCompleter; +import org.jnode.driver.console.ScrollableTextConsole; import org.jnode.driver.console.TextConsole; import org.jnode.driver.console.spi.ConsolePrintStream; @@ -333,7 +334,12 @@ // if the line has not been shortened (delete, backspace...) if (!shortened) { // ensure that the location of the input cursor is included. - console.ensureVisible(inputCursorY); + if (console instanceof ScrollableTextConsole) { + ((ScrollableTextConsole) console).ensureVisible(inputCursorY); + } else { + // since the console is not scrollable, we can't do anything + // if the row is not visible (the row is completely lost) + } } console.setCursorVisible(true); } catch (Exception e) { Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -25,6 +25,7 @@ import java.awt.event.KeyEvent; import org.jnode.driver.console.ConsoleManager; +import org.jnode.driver.console.ScrollableTextConsole; import org.jnode.driver.input.KeyboardEvent; import org.jnode.driver.input.PointerEvent; import org.jnode.driver.textscreen.ScrollableTextScreen; @@ -32,7 +33,7 @@ /** * @author Ewout Prangsma (ep...@us...) */ -public class ScrollableTextScreenConsole extends TextScreenConsole { +public class ScrollableTextScreenConsole extends TextScreenConsole implements ScrollableTextConsole { /** * @param mgr @@ -43,34 +44,47 @@ ScrollableTextScreen screen, int options) { super(mgr, name, screen, options); } - + /** - * Scroll a given number of rows up. - * - * @param rows + * Append characters to the current line. + * + * @param v + * @param offset + * @param lenght + * @param color */ - public void scrollUp(int rows) { - final ScrollableTextScreen screen = (ScrollableTextScreen) getScreen(); - screen.scrollUp(rows); - - final int length = rows * screen.getWidth(); - screen.sync(screen.getHeight() * screen.getWidth() - length, length); + @Override + public void putChar(char v[], int offset, int lenght, int color) { + super.putChar(v, offset, lenght, color); + ensureVisible(getCursorY()); } + + /** + * Append a character to the current line. + * + * @param v + * @param color + */ + @Override + public void putChar(char v, int color) { + super.putChar(v, color); + ensureVisible(getCursorY()); + } /** - * Scroll a given number of rows down. - * - * @param rows + * Ensure that the given row is visible. + * + * @param row */ - public void scrollDown(int rows) { - final ScrollableTextScreen screen = (ScrollableTextScreen) getScreen(); - screen.scrollDown(rows); - screen.sync(0, rows * screen.getWidth()); + @Override + public void ensureVisible(int row) { + getScrollableTextScreen().ensureVisible(row, isFocused()); } /** * @see org.jnode.driver.input.KeyboardListener#keyPressed(org.jnode.driver.input.KeyboardEvent) */ + @Override public void keyPressed(KeyboardEvent event) { if (isFocused() && !event.isConsumed()) { final int modifiers = event.getModifiers(); @@ -103,6 +117,7 @@ /** * @see org.jnode.driver.input.PointerListener#pointerStateChanged(org.jnode.driver.input.PointerEvent) */ + @Override public void pointerStateChanged(PointerEvent event) { if (isFocused() && (event.getZ() != 0)) { final int z = event.getZ(); @@ -117,4 +132,26 @@ super.pointerStateChanged(event); } } + + private final ScrollableTextScreen getScrollableTextScreen() { + return (ScrollableTextScreen) getScreen(); + } + + /** + * Scroll a given number of rows up. + * + * @param rows + */ + private void scrollUp(int rows) { + getScrollableTextScreen().scrollUp(rows); + } + + /** + * Scroll a given number of rows down. + * + * @param rows + */ + private void scrollDown(int rows) { + getScrollableTextScreen().scrollDown(rows); + } } Modified: trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -33,8 +33,10 @@ import org.jnode.driver.console.spi.ConsoleOutputStream; import org.jnode.driver.console.spi.ConsolePrintStream; import org.jnode.driver.textscreen.TextScreen; +import org.jnode.driver.textscreen.x86.PcBufferTextScreen; import org.jnode.system.event.FocusEvent; import org.jnode.system.event.FocusListener; +import org.jnode.vm.Unsafe; import org.jnode.vm.VmSystem; import org.jnode.vm.isolate.VmIsolate; @@ -43,7 +45,6 @@ * @author Levente S\u00e1ntha (ls...@us...) */ public class TextScreenConsole extends AbstractConsole implements TextConsole { - /** * The screen I'm writing on */ @@ -107,6 +108,9 @@ // ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR) == 0); this.claimSystemOutErr = false; this.myIsolate = VmIsolate.currentIsolate(); + + // force initial displayed state + updateScreenDisplayedState(); } /** @@ -114,20 +118,20 @@ * * @see org.jnode.driver.console.TextConsole#clear() */ + @Override public void clear() { final int size = screen.getWidth() * screen.getHeight(); screen.set(0, ' ', size, 0x07); - syncScreen(0, size); } /** * Clear a given row */ + @Override 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); } /** @@ -138,6 +142,7 @@ * @param lenght * @param color */ + @Override public void putChar(char v[], int offset, int lenght, int color) { int mark = 0; for (int i = 0; i < lenght; i++) { @@ -156,7 +161,6 @@ doPutChar(c, color); } } - screen.ensureVisible(curY, isFocused()); // synchronize if focused } /** @@ -165,9 +169,9 @@ * @param v * @param color */ + @Override public void putChar(char v, int color) { doPutChar(v, color); - screen.ensureVisible(curY, isFocused()); // synchronize if focused } private void doPutChar(char v, int color) { @@ -208,6 +212,7 @@ /** * @return Returns the tabSize. */ + @Override public int getTabSize() { return tabSize; } @@ -215,6 +220,7 @@ /** * @param tabSize The tabSize to set. */ + @Override public void setTabSize(int tabSize) { this.tabSize = tabSize; } @@ -222,6 +228,7 @@ /** * @see org.jnode.driver.console.TextConsole#getColor(int, int) */ + @Override public int getColor(int x, int y) { return screen.getColor(screen.getOffset(x, y)); } @@ -229,6 +236,7 @@ /** * @see org.jnode.driver.console.TextConsole#getChar(int, int) */ + @Override public char getChar(int x, int y) { return screen.getChar(screen.getOffset(x, y)); } @@ -236,6 +244,7 @@ /** * @see org.jnode.driver.console.TextConsole#getCursorX() */ + @Override public int getCursorX() { return curX; } @@ -243,6 +252,7 @@ /** * @see org.jnode.driver.console.TextConsole#getCursorY() */ + @Override public int getCursorY() { return curY; } @@ -250,6 +260,7 @@ /** * @see org.jnode.driver.console.TextConsole#getHeight() */ + @Override public int getHeight() { return screen.getHeight(); } @@ -257,6 +268,7 @@ /** * @see org.jnode.driver.console.TextConsole#getWidth() */ + @Override public int getWidth() { return screen.getWidth(); } @@ -264,49 +276,43 @@ /** * @see org.jnode.driver.console.TextConsole#setChar(int, int, char, int) */ + @Override 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); } + @Override 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); } + @Override 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) */ + @Override public void setCursor(int x, int y) { this.curX = x; this.curY = y; int offset = screen.setCursor(x, y); - syncScreen(offset, 1); } - private void syncScreen(int offset, int size) { - if (isFocused()) { - screen.sync(offset, size); + private void updateScreenDisplayedState() { + if (screen instanceof PcBufferTextScreen) { + ((PcBufferTextScreen) screen).setDisplayed(isFocused()); + } else { + Unsafe.debug("updateScreenDisplayedState: screen not instanceof PcBufferTextScreen"); } } - /** - * Ensure that the given row is visible. - * - * @param row - */ - public void ensureVisible(int row) { - screen.ensureVisible(row, isFocused()); // synchronize if focused - } - + @Override public InputCompleter getCompleter() { if (in instanceof KeyboardInputStream) { return ((KeyboardInputStream) in).getCompleter(); @@ -315,6 +321,7 @@ } } + @Override public void setCompleter(InputCompleter completer) { if (in instanceof KeyboardInputStream) { ((KeyboardInputStream) in).setCompleter(completer); @@ -324,6 +331,7 @@ /** * @see org.jnode.driver.console.TextConsole#getIn() */ + @Override public InputStream getIn() { return in; } @@ -335,6 +343,7 @@ /** * @see org.jnode.driver.console.TextConsole#getErr() */ + @Override public PrintStream getErr() { return err; } @@ -342,6 +351,7 @@ /** * @see org.jnode.driver.console.TextConsole#getOut() */ + @Override public PrintStream getOut() { return out; } @@ -349,6 +359,7 @@ /** * Is the cursor visible. */ + @Override public boolean isCursorVisible() { return cursorVisible; } @@ -358,18 +369,19 @@ * * @param visible */ + @Override 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) */ + @Override public void focusGained(FocusEvent event) { super.focusGained(event); - syncScreen(0, screen.getWidth() * screen.getHeight()); + updateScreenDisplayedState(); if (in instanceof FocusListener) { ((FocusListener) in).focusGained(event); } @@ -391,6 +403,7 @@ /** * @see org.jnode.system.event.FocusListener#focusLost(org.jnode.system.event.FocusEvent) */ + @Override public void focusLost(FocusEvent event) { if (in instanceof FocusListener) { ((FocusListener) in).focusLost(event); @@ -404,6 +417,7 @@ }); } super.focusLost(event); + updateScreenDisplayedState(); } /** Modified: trunk/core/src/driver/org/jnode/driver/textscreen/ScrollableTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/ScrollableTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/textscreen/ScrollableTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -31,6 +31,14 @@ public interface ScrollableTextScreen extends TextScreen { /** + * Ensure that the given row is visible. + * + * @param row + * @param sync true if screen should synchronize + */ + public void ensureVisible(int row, boolean sync); + + /** * Scroll a given number of rows up. * * @param rows Modified: trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -23,7 +23,7 @@ /** * Abstract class that represents different kinds of screens : - physical screen - * (video memory) - buffered screen (system memory, faster that video memory) - + * (video memory) - buffered screen (system memory, faster than video memory) - * remote screen, shared screen, multiple screens ... - recording screen (movies * for demos or tutorials) * @@ -118,13 +118,6 @@ public int getOffset(int x, int y); /** - * Synchronize the state with the actual device. - * @param offset - * @param length - */ - public void sync(int offset, int length); - - /** * Create an in-memory buffer text screen that is compatible * with this screen. * @@ -141,14 +134,6 @@ 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, boolean sync); - - /** * * @param x * @param y Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -21,6 +21,8 @@ package org.jnode.driver.textscreen.x86; +import java.util.Arrays; + import org.jnode.driver.textscreen.TextScreen; import org.jnode.vm.Unsafe; @@ -44,6 +46,8 @@ private int cursorIndex = 0; private boolean cursorVisible = true; + private final boolean ignoreColors; + /** * Initialize this instance. * @@ -51,65 +55,95 @@ * @param height */ public AbstractPcBufferTextScreen(int width, int height) { + this(width, height, false); + } + + /** + * Initialize this instance. + * + * @param width + * @param height + * @param ignoreColors + */ + public AbstractPcBufferTextScreen(int width, int height, boolean ignoreColors) { super(width, height); + this.ignoreColors = ignoreColors; this.buffer = new char[width * height]; this.screenBuffer = new char[buffer.length]; + + Arrays.fill(buffer, ' '); } /** * @see org.jnode.driver.textscreen.TextScreen#copyContent(int, int, int) */ - public void copyContent(int srcOffset, int destOffset, int length) { + @Override + public final void copyContent(int srcOffset, int destOffset, int length) { System.arraycopy(buffer, srcOffset, buffer, destOffset, length); + sync(destOffset, length); } /** * @see org.jnode.driver.textscreen.TextScreen#getChar(int) */ - public char getChar(int offset) { - return (char) (buffer[offset] & 0xFF); + @Override + public final char getChar(int offset) { + return (char) PcTextScreenUtils.decodeCharacter(buffer[offset]); } /** * @see org.jnode.driver.textscreen.TextScreen#getColor(int) */ - public int getColor(int offset) { - return (char) ((buffer[offset] >> 8) & 0xFF); + @Override + public final int getColor(int offset) { + //TODO do we really need to cast that to a char ? + return (char) PcTextScreenUtils.decodeColor(buffer[offset]); } /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char, int, int) */ + @Override public void set(int offset, char ch, int count, int color) { - 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; - } + + Arrays.fill(buffer, offset, offset + count, encodeCharacterAndColor(ch, 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) { - color = (color & 0xFF) << 8; + @Override + public void set(final int offset, final char[] ch, final int chOfs, int length, int color) { + color = PcTextScreenUtils.encodeColor(color); length = Math.min(length, buffer.length - offset); + + int bufOffset = offset; + int chOffset = chOfs; for (int i = 0; i < length; i++) { - buffer[offset + i] = (char) ((ch[chOfs + i] & 0xFF) | color); + buffer[bufOffset++] = (char) (PcTextScreenUtils.encodeCharacter(ch[chOffset++]) | color); } + + sync(offset, length); } /** * @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) { + @Override + public void set(final int offset, char[] ch, final int chOfs, int length, int[] colors, int colorsOfs) { length = Math.min(length, buffer.length - offset); + + int bufOffset = offset; + int chOffset = chOfs; + int colorsOffset = colorsOfs; for (int i = 0; i < length; i++) { - buffer[offset + i] = - (char) ((ch[chOfs + i] & 0xFF) | (colors[colorsOfs + i] & 0xFF) << 8); + buffer[bufOffset++] = encodeCharacterAndColor(ch[chOffset++], colors[colorsOffset++]); } + + sync(offset, length); } /** @@ -118,21 +152,14 @@ * * @param dst */ - public void copyTo(TextScreen dst, int offset, int length) { + @Override + public final 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); - char origValue = buffer[cursorIndex]; - // origValue |= 0x7000;//from december 2003 jnode code. - - // exchange the background with the foreground - int color = (origValue >> 8) & 0xFF; - color = ((color >> 4) & 0xF) | ((color << 4) & 0xF0); - origValue &= 0x00FF; - origValue |= (color << 8) & 0xFF00; - - screenBuffer[cursorIndex] = origValue; + + screenBuffer[cursorIndex] = PcTextScreenUtils.exchangeColors(buffer[cursorIndex]); toScreen = screenBuffer; } ((AbstractPcTextScreen) dst).copyFrom(toScreen, getTopOffset()); @@ -157,28 +184,72 @@ * @param rawData * @param rawDataOffset */ - public final void copyFrom(char[] rawData, int rawDataOffset) { + @Override + public final void copyFrom(char[] rawData, final int rawDataOffset) { if (rawDataOffset < 0) { Unsafe.die("Buffer:rawDataOffset = " + rawDataOffset); } - System.arraycopy(rawData, rawDataOffset, buffer, getTopOffset(), getWidth() * getHeight()); + final int size = getWidth() * getHeight(); + + char[] cha = rawData; + + if (ignoreColors) { + cha = new char[rawData.length]; + for (int i = 0; i < cha.length; i++) { + cha[i] = (char) PcTextScreenUtils.encodeCharacter(rawData[i]); + } + } + + System.arraycopy(cha, rawDataOffset, buffer, getTopOffset(), size); + sync(0, size); } /** * Synchronize the state with the actual device. + * @param offset + * @param length */ - public abstract void sync(int offset, int length); + protected abstract void sync(int offset, int length); - public int setCursor(int x, int y) { - this.cursorIndex = getOffset(x, y); - setParentCursor(x, y); + @Override + public final int setCursor(int x, int y) { + int oldCursorIndex = cursorIndex; + cursorIndex = getOffset(x, y); + + if (oldCursorIndex != cursorIndex) { + sync(oldCursorIndex, 1); + sync(cursorIndex, 1); + } + return cursorIndex; } - protected abstract void setParentCursor(int x, int y); + //protected abstract void setParentCursor(int x, int y); - public int setCursorVisible(boolean visible) { + @Override + public final int setCursorVisible(boolean visible) { this.cursorVisible = visible; + sync(cursorIndex, 1); return cursorIndex; } + + protected final int getCursorOffset() { + return cursorIndex; + } + + protected final char[] getBuffer() { + return buffer; + } + + private final char encodeCharacterAndColor(char character, int color) { + int c; + + if (ignoreColors) { + c = PcTextScreenUtils.encodeCharacter(character); + } else { + c = PcTextScreenUtils.encodeCharacterAndColor(character, color); + } + + return (char) c; + } } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -48,7 +48,8 @@ * * @return Returns the height. */ - public int getHeight() { + @Override + public final int getHeight() { return height; } @@ -57,7 +58,8 @@ * * @return Returns the width. */ - public int getWidth() { + @Override + public final int getWidth() { return width; } @@ -68,7 +70,8 @@ * @param y * @return */ - public int getOffset(int x, int y) { + @Override + public final int getOffset(int x, int y) { return (y * width) + x; } @@ -83,8 +86,9 @@ /** * @see org.jnode.driver.textscreen.TextScreen#createCompatibleBufferScreen() */ - public TextScreen createCompatibleBufferScreen() { - return new PcBufferTextScreen(getWidth(), getHeight(), this); + @Override + public final TextScreen createCompatibleBufferScreen() { + return new PcBufferTextScreen(this); } /** @@ -93,19 +97,11 @@ * * @return */ - public ScrollableTextScreen createCompatibleScrollableBufferScreen(int height) { + @Override + public final ScrollableTextScreen createCompatibleScrollableBufferScreen(int height) { if (height < getHeight()) { throw new IllegalArgumentException("Invalid height " + height); } return new PcScrollableTextScreen(getWidth(), height, this); } - - /** - * Ensure that the given row is visible. - * - * @param row - */ - public void ensureVisible(int row, boolean sync) { - // do nothing by default - } } Added: trunk/core/src/driver/org/jnode/driver/textscreen/x86/NoDisplayTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/NoDisplayTextScreen.java (rev 0) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/NoDisplayTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -0,0 +1,141 @@ +/* + * $Id: PcTextScreen.java 4266 2008-06-19 20:07:25Z fduminy $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * 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; +import org.jnode.vm.Unsafe; + +/** + * That class is an AbstractPcTextScreen that display nothing to any screen. + * It's useful to avoid rendering of consoles that aren't focused. + * + * @author Fabien DUMINY + */ +public class NoDisplayTextScreen extends AbstractPcTextScreen { + /** + * Initialize this instance. + * + * @param width + * @param height + */ + public NoDisplayTextScreen(int width, int height) { + super(width, height); + } + + /** + * @see org.jnode.driver.textscreen.TextScreen#copyContent(int, int, int) + */ + @Override + public final void copyContent(int srcOffset, int destOffset, int length) { + // do nothing + Unsafe.debug("\nNoDisplayTextScreen.copyContent: srcOffset=" + srcOffset + " destOffset=" + + destOffset + " length=" + length); + } + + /** + * @see org.jnode.driver.textscreen.TextScreen#getChar(int) + */ + @Override + public final char getChar(int offset) { + Unsafe.debug("\nNoDisplayTextScreen.getChar: offset=" + offset + " return 0"); + return 0; + } + + /** + * @see org.jnode.driver.textscreen.TextScreen#getColor(int) + */ + @Override + public final int getColor(int offset) { + Unsafe.debug("\nNoDisplayTextScreen.getColor: offset=" + offset + " return 0"); + return 0; + } + + /** + * @see org.jnode.driver.textscreen.TextScreen#set(int, char, int, int) + */ + @Override + public final void set(int offset, char ch, int count, int color) { + // do nothing + Unsafe.debug("\nNoDisplayTextScreen.set: offset=" + offset + " ch=" + ch + " count=" + + count + " color=" + color); + } + + /** + * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, + * int) + */ + @Override + public final void set(int offset, char[] ch, int chOfs, int length, int color) { + // do nothing + Unsafe.debug("\nNoDisplayTextScreen.set: offset=" + offset + " chOfs=" + + chOfs + " length=" + length + " color=" + color); + } + + /** + * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, + * int[], int) + */ + @Override + public final void set(int offset, char[] ch, int chOfs, int length, int[] colors, + int colorsOfs) { + // do nothing + Unsafe.debug("\nNoDisplayTextScreen.set: offset=" + offset + " chOfs=" + + chOfs + " length=" + length + " colors=" + colors + " colorsOfs=" + colorsOfs); + } + + /** + * Copy the content of the given rawData into this screen. + * + * @param rawData + * @param rawDataOffset + */ + @Override + public final void copyFrom(char[] rawData, int rawDataOffset) { + // do nothing + //Unsafe.debug("\nNoDisplayTextScreen.copyFrom: rawDataOffset=" + rawDataOffset); + } + + /** + * Copies the entire screen to the given destination. For this operation to + * succeed, the screens involved must be compatible. + * + * @param dst + */ + @Override + public final void copyTo(TextScreen dst, int offset, int length) { + // do nothing + //Unsafe.debug("\nNoDisplayTextScreen.copyTo: dst=" + dst + " offset=" + offset + " length=" + + // length); + } + + @Override + public final int setCursor(int x, int y) { + Unsafe.debug("\nNoDisplayTextScreen.setCursor: x=" + x + " y=" + y + " return 0"); + return 0; + } + + @Override + public final int setCursorVisible(boolean visible) { + Unsafe.debug("\nNoDisplayTextScreen.setCursorVisible: visible=" + visible + " return 0"); + return 0; + } +} Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -22,6 +22,7 @@ package org.jnode.driver.textscreen.x86; + /** * @author Ewout Prangsma (ep...@us...) */ @@ -31,6 +32,10 @@ * My parent */ private final AbstractPcTextScreen parent; + + private final NoDisplayTextScreen noDisplay; + + private AbstractPcTextScreen actualParent; /** * Initialize this instance. @@ -38,26 +43,38 @@ * @param width * @param height */ - public PcBufferTextScreen(int width, int height, AbstractPcTextScreen parent) { - super(width, height); - this.parent = parent; + public PcBufferTextScreen(AbstractPcTextScreen parent) { + this(parent.getWidth(), parent.getHeight(), parent); } /** - * Synchronize the state with the actual device. + * Initialize this instance. + * + * @param width + * @param height */ - public void sync(int offset, int length) { - copyTo(parent, offset, length); + protected PcBufferTextScreen(int width, int height, AbstractPcTextScreen parent) { + super(width, height); + this.parent = parent; + this.noDisplay = new NoDisplayTextScreen(width, height); + setDisplayed(false); } - - protected void setParentCursor(int x, int y) { - parent.setCursor(x, y); + + + public final void setDisplayed(boolean displayed) { + if (displayed) { + actualParent = parent; + sync(0, getWidth() * getHeight()); + } else { + actualParent = noDisplay; + } } - + /** - * @return Returns the parent. + * Synchronize the state with the actual device. */ - protected final AbstractPcTextScreen getParent() { - return this.parent; + @Override + protected final void sync(int offset, int length) { + copyTo(actualParent, offset, length); } } Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -38,7 +38,7 @@ * Height of the parent screen */ private final int parentHeight; - + /** * Maximum row that has valid data */ @@ -56,6 +56,7 @@ /** * @see org.jnode.driver.textscreen.ScrollableTextScreen#ensureVisible(int, boolean) */ + @Override public void ensureVisible(int row, boolean sync) { if (row < ofsY) { ofsY = row; @@ -67,6 +68,7 @@ /** * @see org.jnode.driver.textscreen.ScrollableTextScreen#scrollDown(int) */ + @Override public void scrollDown(int rows) { if (rows < 0) { throw new IllegalArgumentException("rows < 0"); @@ -75,11 +77,14 @@ if (ofsY + parentHeight < height) { ofsY = ofsY + Math.min(rows, height - (ofsY + parentHeight)); } + + sync(0, rows * getWidth()); } /** * @see org.jnode.driver.textscreen.ScrollableTextScreen#scrollUp(int) */ + @Override public void scrollUp(int rows) { if (rows < 0) { throw new IllegalArgumentException("rows < 0"); @@ -87,6 +92,9 @@ if (ofsY > 0) { ofsY = ofsY - Math.min(ofsY, rows); } + + final int length = rows * getWidth(); + sync(getHeight() * getWidth() - length, length); } /** @@ -94,6 +102,7 @@ * * @return */ + @Override protected int getTopOffset() { return ofsY * getWidth(); } @@ -101,6 +110,7 @@ /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char, int, int) */ + @Override public void set(int offset, char ch, int count, int color) { maxValidY = Math.max(maxValidY, offset / getWidth()); super.set(offset, ch, count, color); @@ -108,6 +118,7 @@ /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int) */ + @Override public void set(int offset, char[] ch, int chOfs, int length, int color) { maxValidY = Math.max(maxValidY, (offset + length - 1) / getWidth()); super.set(offset, ch, chOfs, length, color); @@ -115,6 +126,7 @@ /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, int[], int) */ + @Override public void set(int offset, char[] ch, int chOfs, int length, int[] colors, int colorsOfs) { maxValidY = Math.max(maxValidY, (offset + length - 1) / getWidth()); Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -90,6 +90,7 @@ /** * @see org.jnode.driver.textscreen.TextScreen#copyContent(int, int, int) */ + @Override public void copyContent(int srcOffset, int destOffset, int length) { memory.copy(srcOffset * 2, destOffset * 2, length * 2); } @@ -97,22 +98,25 @@ /** * @see org.jnode.driver.textscreen.TextScreen#getChar(int) */ + @Override public char getChar(int offset) { - return (char) (memory.getByte(offset * 2) & 0xFF); + return (char) PcTextScreenUtils.decodeCharacter(memory.getByte(offset * 2)); } /** * @see org.jnode.driver.textscreen.TextScreen#getColor(int) */ + @Override public int getColor(int offset) { - return memory.getByte(offset * 2 + 1) & 0xFF; + return PcTextScreenUtils.decodeColor((char) memory.getByte(offset * 2 + 1)); } /** * @see org.jnode.driver.textscreen.TextScreen#set(int, char, int, int) */ + @Override public void set(int offset, char ch, int count, int color) { - final char v = (char) ((ch & 0xFF) | ((color & 0xFF) << 8)); + final char v = PcTextScreenUtils.encodeCharacterAndColor(ch, color); memory.setChar(offset * 2, v, count); } @@ -120,10 +124,11 @@ * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, * int) */ + @Override public void set(int offset, char[] ch, int chOfs, int length, int color) { - color = (color & 0xFF) << 8; + color = PcTextScreenUtils.encodeColor(color); for (int i = 0; i < length; i++) { - final int v = (ch[chOfs + i] & 0xFF) | color; + final int v = PcTextScreenUtils.encodeCharacter(ch[chOfs + i]) | color; memory.setChar((offset + i) * 2, (char) v); } } @@ -132,12 +137,12 @@ * @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int, * int[], int) */ + @Override public void set(int offset, char[] ch, int chOfs, int length, int[] colors, int colorsOfs) { for (int i = 0; i < length; i++) { - final int v = (ch[chOfs + i] & 0xFF) - | ((colors[colorsOfs + i] & 0xFF) << 8); - memory.setChar((offset + i) * 2, (char) v); + final char v = PcTextScreenUtils.encodeCharacterAndColor(ch[chOfs + i], colors[colorsOfs + i]); + memory.setChar((offset + i) * 2, v); } } @@ -147,6 +152,7 @@ * @param rawData * @param rawDataOffset */ + @Override public final void copyFrom(char[] rawData, int rawDataOffset) { if (rawDataOffset < 0) { Unsafe.die("Screen:rawDataOffset = " + rawDataOffset); @@ -160,23 +166,18 @@ * * @param dst */ + @Override public void copyTo(TextScreen dst, int offset, int length) { throw new UnsupportedOperationException(); } - - /** - * Synchronize the state with the actual device. - */ - public void sync(int offset, int length) { - // Nothing to do here - } - + + @Override 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 ? + return 0; } + @Override public int setCursorVisible(boolean visible) { - return instance.setCursorVisible(visible); + return 0; } } Added: trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenUtils.java =================================================================== --- trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenUtils.java (rev 0) +++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreenUtils.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -0,0 +1,47 @@ +package org.jnode.driver.textscreen.x86; + +public class PcTextScreenUtils { + private static final int COLOR_MASK = 0xFF00; + private static final int COLOR_SHIFT = 8; + + private static final int CHARACTER_MASK = 0x00FF; + + public static final int encodeColor(int color) { + return (color << COLOR_SHIFT) & COLOR_MASK; + } + + public static final int decodeColor(char characterAndColor) { + return (characterAndColor & COLOR_MASK) >> COLOR_SHIFT; + } + + public static final int encodeCharacter(int character) { + int ch = (character & CHARACTER_MASK); + ch = ((ch == 0) ? ' ' : ch); + return ch; + } + + public static final int decodeCharacter(int characterAndColor) { + return (characterAndColor & CHARACTER_MASK); + } + + public static final char encodeCharacterAndColor(char character, int color) { + return (char) (PcTextScreenUtils.encodeCharacter(character) | PcTextScreenUtils.encodeColor(color)); + } + + /** + * Exchange the background and the foreground colors + * @param characterAndColor + * @return + */ + public static final char exchangeColors(char characterAndColor) { + int color = PcTextScreenUtils.decodeColor(characterAndColor); + color = ((color & 0xF0) >> 4) | ((color & 0x0F) << 4); + //int color = 0x70; + char character = (char) decodeCharacter(characterAndColor); + + return encodeCharacterAndColor(character, color); + } + + private PcTextScreenUtils() { + } +} Modified: trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreen.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -5,116 +5,36 @@ import net.wimpi.telnetd.io.TelnetIO; import net.wimpi.telnetd.io.TerminalIO; -import org.jnode.driver.textscreen.TextScreen; -import org.jnode.driver.textscreen.x86.AbstractPcTextScreen; +import org.jnode.driver.textscreen.x86.AbstractPcBufferTextScreen; /** * * @author Fabien DUMINY (fduminy at jnode.org) * */ -public class RemoteTextScreen extends AbstractPcTextScreen { +public class RemoteTextScreen extends AbstractPcBufferTextScreen { private final TerminalIO terminalIO; - private final char[] buffer; - private int cursorOffset; public RemoteTextScreen(TerminalIO terminalIO) { super(terminalIO.getColumns(), terminalIO.getRows()); this.terminalIO = terminalIO; - - buffer = new char[terminalIO.getColumns() * terminalIO.getRows()]; - for (int i = 0; i < buffer.length; i++) { - buffer[i] = ' '; - } } - /** - * Copy the content of the given rawData into this screen. - * - * @param rawData - * @param rawDataOffset - */ @Override - public void copyFrom(char[] rawData, int rawDataOffset) { - if (rawDataOffset < 0) { - // Unsafe.die("Screen:rawDataOffset = " + rawDataOffset); - } - char[] cha = new char[rawData.length]; - for (int i = 0; i < cha.length; i++) { - cha[i] = getCharacter(rawData[i]); - } - System.arraycopy(cha, rawDataOffset, buffer, 0, buffer.length); - sync(0, buffer.length); - } - - public void copyContent(int srcOffset, int destOffset, int length) { - System.arraycopy(buffer, srcOffset * 2, buffer, destOffset * 2, length * 2); - sync(destOffset * 2, length * 2); - } - - public void copyTo(TextScreen dst, int offset, int length) { - // TODO Auto-generated method stub - - } - - public char getChar(int offset) { - return buffer[offset]; - } - - public int getColor(int offset) { - return 0; - } - - public void set(int offset, char ch, int count, int color) { - buffer[offset] = getCharacter(ch); - sync(offset, 1); - } - - private char getCharacter(char ch) { - char c = (char) (ch & 0xFF); - return (c == 0) ? ' ' : c; - } - - public void set(int offset, char[] ch, int chOfs, int length, int color) { - char[] cha = new char[ch.length]; - for (int i = 0; i < cha.length; i++) { - cha[i] = getCharacter(ch[i]); - } - System.arraycopy(cha, chOfs, buffer, offset, length); - sync(offset, length); - } - - public void set(int offset, char[] ch, int chOfs, int length, int[] colors, int colorsOfs) { - set(offset, ch, chOfs, length, 0); - } - - public int setCursor(int x, int y) { + protected void sync(int offset, int length) { try { - terminalIO.setCursor(y, x); - cursorOffset = getOffset(x, y); - } catch (IOException e) { - e.printStackTrace(); - } - - return cursorOffset; - } - - public int setCursorVisible(boolean visible) { - // ignore : cursor will allways be visible - return cursorOffset; - } - - public void sync(int offset, int length) { - try { final int y = offset / getWidth(); final int x = offset % getWidth(); terminalIO.setCursor(y, x); final TelnetIO telnetIO = terminalIO.getTelnetIO(); - + int offs = offset; for (int i = 0; i < length; i++) { - telnetIO.write(buffer[offs++]); + //TODO is that proper way to manage colors ? + terminalIO.setForegroundColor(getColor(offs++)); + + telnetIO.write(getChar(offs++)); } if (terminalIO.isAutoflushing()) { terminalIO.flush(); Modified: trunk/gui/src/driver/org/jnode/driver/console/swing/JTextAreaTextScreen.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/console/swing/JTextAreaTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/gui/src/driver/org/jnode/driver/console/swing/JTextAreaTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -70,6 +70,7 @@ System.out.println("new JTextAreaTextScreen" + width + "x" + height); } + @Override public char getChar(int offset) { try { return document.getText(offset, 1).charAt(0); @@ -79,11 +80,13 @@ } } + @Override public int getColor(int offset) { AttributeSet as = document.getCharacterElement(offset).getAttributes(); return ((Color) as.getAttribute(ColorConstants.Foreground)).getRGB(); } + @Override public void set(int offset, char ch, int count, int color) { System.out.println("set1 " + offset); try { @@ -97,6 +100,7 @@ } } + @Override public void set(int offset, char[] ch, int chOfs, int length, int color) { System.out.println("set2 " + offset); try { @@ -109,6 +113,7 @@ } } + @Override public void set(int offset, char[] ch, int chOfs, int length, int[] colors, int colorsOfs) { System.out.println("set3 " + offset); try { @@ -127,18 +132,22 @@ } } + @Override public void copyContent(int srcOffset, int destOffset, int length) { // TODO Auto-generated method stub } + @Override public void copyTo(TextScreen dst, int offset, int length) { // TODO Auto-generated method stub } + @Override public int getHeight() { return textArea.getRows(); } + @Override public int getWidth() { return textArea.getColumns(); } @@ -151,39 +160,40 @@ * @param y * @return */ + @Override public int getOffset(int x, int y) { return (y * getWidth()) + x; } - public void sync(int offset, int length) { - // TODO Auto-generated method stub - - } - + @Override public TextScreen createCompatibleBufferScreen() { // TODO Auto-generated method stub return null; } + @Override public ScrollableTextScreen createCompatibleScrollableBufferScreen(int height) { // TODO Auto-generated method stub return null; } - public void ensureVisible(int row, boolean sync) { - } - + @Override public int setCursor(int x, int y) { int offset = x + y * textArea.getColumns(); textArea.setCaretPosition(offset); return offset; } + @Override public int setCursorVisible(boolean visible) { textArea.getCaret().setVisible(visible); return textArea.getCaretPosition(); } + public Component getTextArea() { + return textArea; + } + // // Private methods // @@ -202,8 +212,4 @@ return attributes; } - - public Component getTextArea() { - return textArea; - } } Modified: trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScreenPainter.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScreenPainter.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScreenPainter.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -7,32 +7,35 @@ import org.jnode.driver.video.Surface; -class FbScreenPainter extends Thread { +class FbScreenPainter { private static final int margin = 5; private static final int w = 7; private static final int h = 18; - private final Surface g; + private final Surface surface; private final int sw; private final int sh; - private final BufferedImage bi; - private final Graphics ig; + private final BufferedImage buffer; + private final Graphics graphics; private final Font font; private final FbTextScreen screen; private final Thread painterThread; - //private final Background background = new DefaultBackground(Color.BLACK); - private final Background background = new GradientBackground(); + private final Background background; private boolean update; public FbScreenPainter(FbTextScreen screen, Surface g) { this.screen = screen; - this.g = g; + this.surface = g; sh = h * screen.getHeight() + 2 * margin; sw = w * screen.getWidth() + 2 * margin; - bi = new BufferedImage(sw, sh, BufferedImage.TYPE_INT_ARGB); - ig = bi.getGraphics(); + + //background = new DefaultBackground(Color.BLACK); + background = new GradientBackground(sw, sh); + + buffer = new BufferedImage(sw, sh, BufferedImage.TYPE_INT_ARGB); + graphics = buffer.getGraphics(); font = new Font( "-FontForge-Bitstream Vera Sans Mono-Book-R-Normal-SansMono--12-120-75-75-P-69-ISO10646", Font.PLAIN, 12); @@ -58,27 +61,28 @@ } protected void paintComponent() { - background.paint(ig); + background.paint(graphics); - ig.setColor(Color.WHITE); - ig.setFont(font); + graphics.setColor(Color.WHITE); + graphics.setFont(font); - final char[] buffer = screen.getBuffer(); + final char[] textBuffer = screen.getScreenBuffer(); final int length = screen.getWidth(); int offset = 0; final int x = margin; int y = h; for (int i = 0; i < screen.getHeight(); i++) { - ig.drawChars(buffer, offset, length, x, y); + graphics.drawChars(textBuffer, offset, length, x, y); offset += length; y += h; } - g.drawCompatibleRaster(bi.getRaster(), 0, 0, 0, 0, sw, sh, Color.BLACK); + surface.drawCompatibleRaster(buffer.getRaster(), 0, 0, 0, 0, sw, sh, Color.BLACK); } public synchronized void repaint() { + //Unsafe.debug("repaint"); if (!update) { update = true; notifyAll(); Modified: trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbTextScreen.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbTextScreen.java 2008-07-24 21:13:57 UTC (rev 4351) +++ trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbTextScreen.java 2008-07-24 21:20:06 UTC (rev 4352) @@ -21,112 +21,27 @@ package org.jnode.driver.textscreen.fb; -import java.util.Arrays; - -import org.jnode.driver.textscreen.TextScreen; -import org.jnode.driver.textscreen.x86.AbstractPcTextScreen; +import org.jnode.driver.textscreen.x86.AbstractPcBufferTextScreen; import org.jnode.driver.video.Surface; -class FbTextScreen extends AbstractPcTextScreen { +class FbTextScreen extends AbstractPcBufferTextScreen { private static final int SCREEN_WIDTH = 80; private static final int SCREEN_HEIGHT = 25; - private final char[] buffer; - - private int cursorOffset; - private boolean cursorVisible = true; - private final FbScreenPainter painter; public FbTextScreen(Surface g) { - super(SCREEN_WIDTH, SCREEN_HEIGHT); - buffer = new char[SCREEN_WIDTH * SCREEN_HEIGHT]; + super(SCREEN_WIDTH, SCREEN_HEIGHT, true); // true = ignore colors painter = new FbScreenPainter(this, g); - Arrays.fill(buffer, ' '); } - - public char getChar(int offset) { - return ... [truncated message content] |