|
From: <ls...@us...> - 2008-07-25 18:41:39
|
Revision: 4355
http://jnode.svn.sourceforge.net/jnode/?rev=4355&view=rev
Author: lsantha
Date: 2008-07-25 18:41:34 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
Reverted console and text screen refacoring of FabienD.
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/NoDisplayTextScreen.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/swing/SwingPcTextScreen.java
trunk/gui/src/test/org/jnode/test/gui/FBConsole.java
Modified: trunk/core/src/driver/org/jnode/driver/console/TextConsole.java
===================================================================
--- trunk/core/src/driver/org/jnode/driver/console/TextConsole.java 2008-07-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/console/TextConsole.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,13 +9,13 @@
* 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
+ * 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
+ * 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.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
@@ -155,6 +155,13 @@
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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/console/spi/AbstractConsoleManager.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,13 +9,13 @@
* 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
+ * 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
+ * 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.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
@@ -35,9 +35,7 @@
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;
@@ -53,7 +51,6 @@
import org.jnode.naming.InitialNaming;
import org.jnode.system.BootLog;
import org.jnode.system.event.FocusEvent;
-import org.jnode.vm.Unsafe;
/**
* @author epr
@@ -210,14 +207,14 @@
* @param console
*/
public synchronized void focus(Console console) {
- Unsafe.debug("focus(" + console.getConsoleName() + ")");
+ log.debug("focus(" + console.getConsoleName() + ")");
if (this.current != null && this.current != console) {
- Unsafe.debug("Sending focusLost to " + current.getConsoleName());
+ log.debug("Sending focusLost to " + current.getConsoleName());
this.current.focusLost(new FocusEvent(FocusEvent.FOCUS_LOST));
}
this.current = console;
if (this.current != null) {
- Unsafe.debug("Sending focusGained to " + current.getConsoleName());
+ log.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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/console/textscreen/Line.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -25,7 +25,6 @@
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;
@@ -203,7 +202,7 @@
for (String item : list) {
// item may actually be a single item or in fact multiple items
if (item.length() % SCREEN_WIDTH == 0) {
- // we are already at the first column of the next line
+ // we are already at the first column of the next line
out.print(item);
} else {
// we aren't at the first column of the next line
@@ -334,12 +333,7 @@
// if the line has not been shortened (delete, backspace...)
if (!shortened) {
// ensure that the location of the input cursor is included.
- 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.ensureVisible(inputCursorY);
}
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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/console/textscreen/ScrollableTextScreenConsole.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,23 +9,22 @@
* 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
+ * 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
+ * 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.,
+ * 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.console.ScrollableTextConsole;
import org.jnode.driver.input.KeyboardEvent;
import org.jnode.driver.input.PointerEvent;
import org.jnode.driver.textscreen.ScrollableTextScreen;
@@ -33,7 +32,7 @@
/**
* @author Ewout Prangsma (ep...@us...)
*/
-public class ScrollableTextScreenConsole extends TextScreenConsole implements ScrollableTextConsole {
+public class ScrollableTextScreenConsole extends TextScreenConsole {
/**
* @param mgr
@@ -44,47 +43,34 @@
ScrollableTextScreen screen, int options) {
super(mgr, name, screen, options);
}
-
+
/**
- * Append characters to the current line.
- *
- * @param v
- * @param offset
- * @param lenght
- * @param color
+ * Scroll a given number of rows up.
+ *
+ * @param rows
*/
- @Override
- public void putChar(char v[], int offset, int lenght, int color) {
- super.putChar(v, offset, lenght, color);
- ensureVisible(getCursorY());
+ 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);
}
/**
- * Append a character to the current line.
- *
- * @param v
- * @param color
+ * Scroll a given number of rows down.
+ *
+ * @param rows
*/
- @Override
- public void putChar(char v, int color) {
- super.putChar(v, color);
- ensureVisible(getCursorY());
+ public void scrollDown(int rows) {
+ final ScrollableTextScreen screen = (ScrollableTextScreen) getScreen();
+ screen.scrollDown(rows);
+ screen.sync(0, rows * screen.getWidth());
}
-
+
/**
- * Ensure that the given row is visible.
- *
- * @param row
- */
- @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();
@@ -107,7 +93,7 @@
event.consume();
break;
}
- }
+ }
}
if (!event.isConsumed()) {
super.keyPressed(event);
@@ -117,12 +103,11 @@
/**
* @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();
if (z < 0) {
- scrollUp(Math.abs(z));
+ scrollUp(Math.abs(z));
} else {
scrollDown(Math.abs(z));
}
@@ -132,26 +117,4 @@
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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/console/textscreen/TextScreenConsole.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,16 +9,16 @@
* 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
+ * 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
+ * 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.,
+ * 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;
@@ -33,10 +33,8 @@
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;
@@ -45,6 +43,7 @@
* @author Levente S\u00e1ntha (ls...@us...)
*/
public class TextScreenConsole extends AbstractConsole implements TextConsole {
+
/**
* The screen I'm writing on
*/
@@ -108,41 +107,37 @@
// ConsoleManager.CreateOptions.NO_SYSTEM_OUT_ERR) == 0);
this.claimSystemOutErr = false;
this.myIsolate = VmIsolate.currentIsolate();
-
- // force initial displayed state
- updateScreenDisplayedState();
}
/**
* Clear the console
- *
+ *
* @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);
}
/**
* Append characters to the current line.
- *
+ *
* @param v
* @param offset
* @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++) {
@@ -161,17 +156,18 @@
doPutChar(c, color);
}
}
+ screen.ensureVisible(curY, isFocused()); // synchronize if focused
}
/**
* Append a character to the current line.
- *
+ *
* @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) {
@@ -212,7 +208,6 @@
/**
* @return Returns the tabSize.
*/
- @Override
public int getTabSize() {
return tabSize;
}
@@ -220,7 +215,6 @@
/**
* @param tabSize The tabSize to set.
*/
- @Override
public void setTabSize(int tabSize) {
this.tabSize = tabSize;
}
@@ -228,7 +222,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getColor(int, int)
*/
- @Override
public int getColor(int x, int y) {
return screen.getColor(screen.getOffset(x, y));
}
@@ -236,7 +229,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getChar(int, int)
*/
- @Override
public char getChar(int x, int y) {
return screen.getChar(screen.getOffset(x, y));
}
@@ -244,7 +236,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getCursorX()
*/
- @Override
public int getCursorX() {
return curX;
}
@@ -252,7 +243,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getCursorY()
*/
- @Override
public int getCursorY() {
return curY;
}
@@ -260,7 +250,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getHeight()
*/
- @Override
public int getHeight() {
return screen.getHeight();
}
@@ -268,7 +257,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getWidth()
*/
- @Override
public int getWidth() {
return screen.getWidth();
}
@@ -276,43 +264,49 @@
/**
* @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 updateScreenDisplayedState() {
- if (screen instanceof PcBufferTextScreen) {
- ((PcBufferTextScreen) screen).setDisplayed(isFocused());
- } else {
- Unsafe.debug("updateScreenDisplayedState: screen not instanceof PcBufferTextScreen");
+ private void syncScreen(int offset, int size) {
+ if (isFocused()) {
+ screen.sync(offset, size);
}
}
- @Override
+ /**
+ * 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();
@@ -321,7 +315,6 @@
}
}
- @Override
public void setCompleter(InputCompleter completer) {
if (in instanceof KeyboardInputStream) {
((KeyboardInputStream) in).setCompleter(completer);
@@ -331,7 +324,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getIn()
*/
- @Override
public InputStream getIn() {
return in;
}
@@ -343,7 +335,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getErr()
*/
- @Override
public PrintStream getErr() {
return err;
}
@@ -351,7 +342,6 @@
/**
* @see org.jnode.driver.console.TextConsole#getOut()
*/
- @Override
public PrintStream getOut() {
return out;
}
@@ -359,29 +349,27 @@
/**
* Is the cursor visible.
*/
- @Override
public boolean isCursorVisible() {
return cursorVisible;
}
/**
* Make the cursor visible or not visible.
- *
+ *
* @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);
- updateScreenDisplayedState();
+ syncScreen(0, screen.getWidth() * screen.getHeight());
if (in instanceof FocusListener) {
((FocusListener) in).focusGained(event);
}
@@ -403,7 +391,6 @@
/**
* @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);
@@ -417,7 +404,6 @@
});
}
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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/textscreen/ScrollableTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,13 +9,13 @@
* 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
+ * 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
+ * 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.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
@@ -31,14 +31,6 @@
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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/textscreen/TextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,24 +9,24 @@
* 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
+ * 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
+ * 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.,
+ * 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;
/**
* Abstract class that represents different kinds of screens : - physical screen
- * (video memory) - buffered screen (system memory, faster than video memory) -
+ * (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,7 +53,7 @@
/**
* Set an series of characters with a given color at a given offset.
- *
+ *
* @param offset
* @param ch
* @param color
@@ -64,7 +64,7 @@
/**
* Set an series of characters with a given series of colors at a given
* offset.
- *
+ *
* @param offset
* @param ch
* @param colors
@@ -76,13 +76,13 @@
/**
* Copy the content of the screen from a given source to a given
* 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
@@ -96,18 +96,18 @@
/**
* 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.
*
@@ -116,15 +116,22 @@
* @return
*/
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.
*
* @return
*/
public TextScreen createCompatibleBufferScreen();
-
+
/**
* Create an in-memory buffer text screen that is compatible
* with this, but larger and supports scrolling.
@@ -132,8 +139,16 @@
* @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, 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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcBufferTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -21,8 +21,6 @@
package org.jnode.driver.textscreen.x86;
-import java.util.Arrays;
-
import org.jnode.driver.textscreen.TextScreen;
import org.jnode.vm.Unsafe;
@@ -46,8 +44,6 @@
private int cursorIndex = 0;
private boolean cursorVisible = true;
- private final boolean ignoreColors;
-
/**
* Initialize this instance.
*
@@ -55,111 +51,88 @@
* @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)
*/
- @Override
- public final void copyContent(int srcOffset, int destOffset, int length) {
+ public 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)
*/
- @Override
- public final char getChar(int offset) {
- return (char) PcTextScreenUtils.decodeCharacter(buffer[offset]);
+ public char getChar(int offset) {
+ return (char) (buffer[offset] & 0xFF);
}
/**
* @see org.jnode.driver.textscreen.TextScreen#getColor(int)
*/
- @Override
- public final int getColor(int offset) {
- //TODO do we really need to cast that to a char ?
- return (char) PcTextScreenUtils.decodeColor(buffer[offset]);
+ public int getColor(int offset) {
+ return (char) ((buffer[offset] >> 8) & 0xFF);
}
/**
* @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);
-
- Arrays.fill(buffer, offset, offset + count, encodeCharacterAndColor(ch, color));
+ for (int i = 0; i < count; i++) {
+ buffer[offset + i] = v;
+ }
}
/**
* @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int,
* int)
*/
- @Override
- public void set(final int offset, final char[] ch, final int chOfs, int length, int color) {
- color = PcTextScreenUtils.encodeColor(color);
+ public void set(int offset, char[] ch, int chOfs, int length, int color) {
+ color = (color & 0xFF) << 8;
length = Math.min(length, buffer.length - offset);
-
- int bufOffset = offset;
- int chOffset = chOfs;
for (int i = 0; i < length; i++) {
- buffer[bufOffset++] = (char) (PcTextScreenUtils.encodeCharacter(ch[chOffset++]) | color);
+ buffer[offset + i] = (char) ((ch[chOfs + i] & 0xFF) | color);
}
-
- sync(offset, length);
}
/**
* @see org.jnode.driver.textscreen.TextScreen#set(int, char[], int, int,
* int[], int)
*/
- @Override
- public void set(final int offset, char[] ch, final int chOfs, int length, int[] colors, int colorsOfs) {
+ public void set(int offset, char[] ch, 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[bufOffset++] = encodeCharacterAndColor(ch[chOffset++], colors[colorsOffset++]);
+ buffer[offset + i] =
+ (char) ((ch[chOfs + i] & 0xFF) | (colors[colorsOfs + i] & 0xFF) << 8);
}
-
- sync(offset, length);
}
/**
* 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) {
+ 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);
-
- screenBuffer[cursorIndex] = PcTextScreenUtils.exchangeColors(buffer[cursorIndex]);
+ 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;
toScreen = screenBuffer;
}
((AbstractPcTextScreen) dst).copyFrom(toScreen, getTopOffset());
@@ -171,7 +144,7 @@
/**
* Return the offset in the buffer of the first visible row.
- *
+ *
* @return the offset
*/
protected int getTopOffset() {
@@ -180,76 +153,32 @@
/**
* Copy the content of the given rawData into this screen.
- *
+ *
* @param rawData
* @param rawDataOffset
*/
- @Override
- public final void copyFrom(char[] rawData, final int rawDataOffset) {
+ public final void copyFrom(char[] rawData, int rawDataOffset) {
if (rawDataOffset < 0) {
Unsafe.die("Buffer:rawDataOffset = " + rawDataOffset);
}
- 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);
+ System.arraycopy(rawData, rawDataOffset, buffer, getTopOffset(), getWidth() * getHeight());
}
/**
* Synchronize the state with the actual device.
- * @param offset
- * @param length
*/
- protected abstract void sync(int offset, int length);
+ public abstract void sync(int offset, int length);
- @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);
- }
-
+ 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);
- @Override
- public final int setCursorVisible(boolean visible) {
+ public 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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/AbstractPcTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,16 +9,16 @@
* 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
+ * 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
+ * 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.,
+ * 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,27 +42,25 @@
this.width = width;
this.height = height;
}
-
+
/**
* Gets the height of the screen in letters.
- *
+ *
* @return Returns the height.
*/
- @Override
- public final int getHeight() {
- return height;
+ public int getHeight() {
+ return height;
}
/**
* Gets the width of the screen in letters.
- *
+ *
* @return Returns the width.
*/
- @Override
- public final int getWidth() {
+ public int getWidth() {
return width;
}
-
+
/**
* Calculate the offset for a given x,y coordinate.
*
@@ -70,8 +68,7 @@
* @param y
* @return
*/
- @Override
- public final int getOffset(int x, int y) {
+ public int getOffset(int x, int y) {
return (y * width) + x;
}
@@ -86,22 +83,29 @@
/**
* @see org.jnode.driver.textscreen.TextScreen#createCompatibleBufferScreen()
*/
- @Override
- public final TextScreen createCompatibleBufferScreen() {
- return new PcBufferTextScreen(this);
+ 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.
*
* @return
*/
- @Override
- public final ScrollableTextScreen createCompatibleScrollableBufferScreen(int height) {
+ public ScrollableTextScreen createCompatibleScrollableBufferScreen(int height) {
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, boolean sync) {
+ // do nothing by default
+ }
}
Modified: trunk/core/src/driver/org/jnode/driver/textscreen/x86/NoDisplayTextScreen.java
===================================================================
--- trunk/core/src/driver/org/jnode/driver/textscreen/x86/NoDisplayTextScreen.java 2008-07-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/NoDisplayTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -138,4 +138,14 @@
Unsafe.debug("\nNoDisplayTextScreen.setCursorVisible: visible=" + visible + " return 0");
return 0;
}
+
+ /**
+ * Synchronize the state with the actual device.
+ *
+ * @param offset
+ * @param length
+ */
+ public void sync(int offset, int length) {
+ //todo implement it
+ }
}
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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcBufferTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,20 +9,19 @@
* 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
+ * 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
+ * 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.,
+ * 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;
-
/**
* @author Ewout Prangsma (ep...@us...)
*/
@@ -32,10 +31,6 @@
* My parent
*/
private final AbstractPcTextScreen parent;
-
- private final NoDisplayTextScreen noDisplay;
-
- private AbstractPcTextScreen actualParent;
/**
* Initialize this instance.
@@ -43,38 +38,26 @@
* @param width
* @param height
*/
- public PcBufferTextScreen(AbstractPcTextScreen parent) {
- this(parent.getWidth(), parent.getHeight(), parent);
+ public PcBufferTextScreen(int width, int height, AbstractPcTextScreen parent) {
+ super(width, height);
+ this.parent = parent;
}
/**
- * Initialize this instance.
- *
- * @param width
- * @param height
+ * Synchronize the state with the actual device.
*/
- protected PcBufferTextScreen(int width, int height, AbstractPcTextScreen parent) {
- super(width, height);
- this.parent = parent;
- this.noDisplay = new NoDisplayTextScreen(width, height);
- setDisplayed(false);
+ public void sync(int offset, int length) {
+ copyTo(parent, offset, length);
}
-
-
- public final void setDisplayed(boolean displayed) {
- if (displayed) {
- actualParent = parent;
- sync(0, getWidth() * getHeight());
- } else {
- actualParent = noDisplay;
- }
+
+ protected void setParentCursor(int x, int y) {
+ parent.setCursor(x, y);
}
-
+
/**
- * Synchronize the state with the actual device.
+ * @return Returns the parent.
*/
- @Override
- protected final void sync(int offset, int length) {
- copyTo(actualParent, offset, length);
+ protected final AbstractPcTextScreen getParent() {
+ return this.parent;
}
}
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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcScrollableTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,16 +9,16 @@
* 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
+ * 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
+ * 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.,
+ * 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;
@@ -33,7 +33,7 @@
* Offset of top visible row
*/
private int ofsY;
-
+
/**
* Height of the parent screen
*/
@@ -56,7 +56,6 @@
/**
* @see org.jnode.driver.textscreen.ScrollableTextScreen#ensureVisible(int, boolean)
*/
- @Override
public void ensureVisible(int row, boolean sync) {
if (row < ofsY) {
ofsY = row;
@@ -68,7 +67,6 @@
/**
* @see org.jnode.driver.textscreen.ScrollableTextScreen#scrollDown(int)
*/
- @Override
public void scrollDown(int rows) {
if (rows < 0) {
throw new IllegalArgumentException("rows < 0");
@@ -77,14 +75,11 @@
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");
@@ -92,25 +87,20 @@
if (ofsY > 0) {
ofsY = ofsY - Math.min(ofsY, rows);
}
-
- final int length = rows * getWidth();
- sync(getHeight() * getWidth() - length, length);
}
/**
* Return the offset in the buffer of the first visible row.
- *
+ *
* @return
*/
- @Override
protected int getTopOffset() {
return ofsY * getWidth();
- }
-
+ }
+
/**
* @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);
@@ -118,7 +108,6 @@
/**
* @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);
@@ -126,7 +115,6 @@
/**
* @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-25 14:03:14 UTC (rev 4354)
+++ trunk/core/src/driver/org/jnode/driver/textscreen/x86/PcTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -9,16 +9,16 @@
* 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
+ * 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
+ * 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.,
+ * 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;
@@ -69,7 +69,7 @@
/**
* Get the singleton instance and create it if necessary.
- *
+ *
* @return @throws
* PragmaUninterruptible
*/
@@ -90,7 +90,6 @@
/**
* @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);
}
@@ -98,25 +97,22 @@
/**
* @see org.jnode.driver.textscreen.TextScreen#getChar(int)
*/
- @Override
public char getChar(int offset) {
- return (char) PcTextScreenUtils.decodeCharacter(memory.getByte(offset * 2));
+ return (char) (memory.getByte(offset * 2) & 0xFF);
}
/**
* @see org.jnode.driver.textscreen.TextScreen#getColor(int)
*/
- @Override
public int getColor(int offset) {
- return PcTextScreenUtils.decodeColor((char) memory.getByte(offset * 2 + 1));
+ return memory.getByte(offset * 2 + 1) & 0xFF;
}
/**
* @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 = PcTextScreenUtils.encodeCharacterAndColor(ch, color);
+ final char v = (char) ((ch & 0xFF) | ((color & 0xFF) << 8));
memory.setChar(offset * 2, v, count);
}
@@ -124,11 +120,10 @@
* @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 = PcTextScreenUtils.encodeColor(color);
+ color = (color & 0xFF) << 8;
for (int i = 0; i < length; i++) {
- final int v = PcTextScreenUtils.encodeCharacter(ch[chOfs + i]) | color;
+ final int v = (ch[chOfs + i] & 0xFF) | color;
memory.setChar((offset + i) * 2, (char) v);
}
}
@@ -137,22 +132,21 @@
* @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 char v = PcTextScreenUtils.encodeCharacterAndColor(ch[chOfs + i], colors[colorsOfs + i]);
- memory.setChar((offset + i) * 2, v);
+ final int v = (ch[chOfs + i] & 0xFF)
+ | ((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
*/
- @Override
public final void copyFrom(char[] rawData, int rawDataOffset) {
if (rawDataOffset < 0) {
Unsafe.die("Screen:rawDataOffset = " + rawDataOffset);
@@ -163,21 +157,26 @@
/**
* Copies the entire screen to the given destination. For this operation to
* succeed, the screens involved must be compatible.
- *
+ *
* @param dst
*/
- @Override
public void copyTo(TextScreen dst, int offset, int length) {
throw new UnsupportedOperationException();
}
-
- @Override
+
+ /**
+ * Synchronize the state with the actual device.
+ */
+ public void sync(int offset, int length) {
+ // Nothing to do here
+ }
+
public int setCursor(int x, int y) {
- return 0;
+ //instance.setCursor( x,y);
+ return 0; // TODO what should we return if we don't call instance.setCursor ?
}
- @Override
public int setCursorVisible(boolean visible) {
- return 0;
+ return instance.setCursorVisible(visible);
}
}
Modified: trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreen.java
===================================================================
--- trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreen.java 2008-07-25 14:03:14 UTC (rev 4354)
+++ trunk/distr/src/apps/org/jnode/apps/telnetd/RemoteTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -5,36 +5,116 @@
import net.wimpi.telnetd.io.TelnetIO;
import net.wimpi.telnetd.io.TerminalIO;
-import org.jnode.driver.textscreen.x86.AbstractPcBufferTextScreen;
+import org.jnode.driver.textscreen.TextScreen;
+import org.jnode.driver.textscreen.x86.AbstractPcTextScreen;
/**
- *
+ *
* @author Fabien DUMINY (fduminy at jnode.org)
- *
+ *
*/
-public class RemoteTextScreen extends AbstractPcBufferTextScreen {
+public class RemoteTextScreen extends AbstractPcTextScreen {
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
- protected void sync(int offset, int length) {
+ 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) {
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++) {
- //TODO is that proper way to manage colors ?
- terminalIO.setForegroundColor(getColor(offs++));
-
- telnetIO.write(getChar(offs++));
+ telnetIO.write(buffer[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-25 14:03:14 UTC (rev 4354)
+++ trunk/gui/src/driver/org/jnode/driver/console/swing/JTextAreaTextScreen.java 2008-07-25 18:41:34 UTC (rev 4355)
@@ -70,7 +70,6 @@
System.out.println("new JTextAreaTextScreen" + width + "x" + height);
}
- @Override
public char getChar(int offset) {
try {
return document.getText(offset, 1).charAt(0);
@@ -80,13 +79,11 @@
}
}
- @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 {
@@ -100,7 +97,6 @@
}
}
- @Override
public void set(int offset, char[] ch, int chOfs, int length, int color) {
System.out.println("set2 " + offset);
try {
@@ -113,7 +109,6 @@
}
}
- @Override
public void set(int offset, char[] ch, int chOfs, int length, int[] colors, int colorsOfs) {
System.out.println("set3 " + offset);
try {
@@ -132,22 +127,18 @@
}
}
- @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();
}
@@ -155,45 +146,44 @@
/**
* Calculate the offset for a given x,y coordinate. (copied from
* AbstractPcTextScreen)
- *
+ *
* @param x
* @param y
* @return
*/
- @Override
public int getOffset(int x, int y) {
return (y * getWidth()) + x;
}
- @Override
+ public void sync(int offset, int length) {
+ // TODO Auto-generated method stub
+
+ }
+
public TextScreen createCompatibleBufferScreen() {
// TODO Auto-generated method stub
return null;
}
- @Override
public ScrollableTextScreen createCompatibleScrollableBufferScreen(int height) {
// TODO Auto-generated method stub
return null;
}
- @Override
+ public void ensureVisible(int row, boolean sync) {
+ }
+
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
//
@@ -212,4 +202,8 @@
return attributes;
}
+
+ public Component getTextArea() {
+ return textArea;
+ }
}
Modified: trunk/gui/src/driver/org/jnode/driver/textscreen/fb/FbScreenPainter.java
===================================================================
...
[truncated message content] |