aboutsummaryrefslogtreecommitdiffstats
path: root/src/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/de')
-rw-r--r--src/de/mud/terminal/VDUBuffer.java51
-rw-r--r--src/de/mud/terminal/vt320.java34
2 files changed, 51 insertions, 34 deletions
diff --git a/src/de/mud/terminal/VDUBuffer.java b/src/de/mud/terminal/VDUBuffer.java
index 269f57e..e8f6617 100644
--- a/src/de/mud/terminal/VDUBuffer.java
+++ b/src/de/mud/terminal/VDUBuffer.java
@@ -32,7 +32,7 @@ import java.util.Arrays;
* all methods to manipulate the buffer that stores characters and their
* attributes as well as the regions displayed.
*
- * @author Matthias L. Jugel, Marcus Mei�ner
+ * @author Matthias L. Jugel, Marcus Meißner
* @version $Id: VDUBuffer.java 503 2005-10-24 07:34:13Z marcus $
*/
public class VDUBuffer {
@@ -344,8 +344,8 @@ public class VDUBuffer {
if (n > (bottom - top)) n = (bottom - top);
int size = bottom - l - (n - 1);
if(size < 0) size = 0;
- cbuf = new char[size][width];
- abuf = new int[size][width];
+ cbuf = new char[size][];
+ abuf = new int[size][];
System.arraycopy(charArray, oldBase + l, cbuf, 0, bottom - l - (n - 1));
System.arraycopy(charAttributes, oldBase + l,
@@ -373,8 +373,8 @@ public class VDUBuffer {
bufSize += n;
}
- cbuf = new char[bufSize][width];
- abuf = new int[bufSize][width];
+ cbuf = new char[bufSize][];
+ abuf = new int[bufSize][];
} else {
offset = n;
cbuf = charArray;
@@ -482,15 +482,23 @@ public class VDUBuffer {
int bottom = (l > bottomMargin ? height - 1:
(l < topMargin?topMargin:bottomMargin + 1));
int numRows = bottom - l - 1;
+
+ char[] discardedChars = charArray[screenBase + l];
+ int[] discardedAttributes = charAttributes[screenBase + l];
+
if (numRows > 0) {
System.arraycopy(charArray, screenBase + l + 1,
charArray, screenBase + l, numRows);
System.arraycopy(charAttributes, screenBase + l + 1,
charAttributes, screenBase + l, numRows);
}
- charArray[screenBase + bottom - 1] = new char[width];
- Arrays.fill(charArray[screenBase + bottom - 1], ' ');
- charAttributes[screenBase + bottom - 1] = new int[width];
+
+ int newBottomRow = screenBase + bottom - 1;
+ charArray[newBottomRow] = discardedChars;
+ charAttributes[newBottomRow] = discardedAttributes;
+ Arrays.fill(charArray[newBottomRow], ' ');
+ Arrays.fill(charAttributes[newBottomRow], 0);
+
markLine(l, bottom - l);
}
@@ -510,15 +518,12 @@ public class VDUBuffer {
c = checkBounds(c, 0, width - 1);
l = checkBounds(l, 0, height - 1);
- char cbuf[] = new char[w];
- int abuf[] = new int[w];
-
- Arrays.fill(cbuf, ' ');
-
- for (int i = 0; i < w; i++) abuf[i] = curAttr;
+ int endColumn = c + w;
+ int targetRow = screenBase + l;
for (int i = 0; i < h && l + i < height; i++) {
- System.arraycopy(cbuf, 0, charArray[screenBase + l + i], c, w);
- System.arraycopy(abuf, 0, charAttributes[screenBase + l + i], c, w);
+ Arrays.fill(charAttributes[targetRow], c, endColumn, curAttr);
+ Arrays.fill(charArray[targetRow], c, endColumn, ' ');
+ targetRow++;
}
markLine(l, h);
}
@@ -535,19 +540,7 @@ public class VDUBuffer {
* @see #redraw
*/
public void deleteArea(int c, int l, int w, int h) {
- c = checkBounds(c, 0, width - 1);
- l = checkBounds(l, 0, height - 1);
-
- char cbuf[] = new char[w];
- int abuf[] = new int[w];
-
- Arrays.fill(cbuf, ' ');
-
- for (int i = 0; i < h && l + i < height; i++) {
- System.arraycopy(cbuf, 0, charArray[screenBase + l + i], c, w);
- System.arraycopy(abuf, 0, charAttributes[screenBase + l + i], c, w);
- }
- markLine(l, h);
+ deleteArea(c, l, w, h, 0);
}
/**
diff --git a/src/de/mud/terminal/vt320.java b/src/de/mud/terminal/vt320.java
index dd43528..0e92523 100644
--- a/src/de/mud/terminal/vt320.java
+++ b/src/de/mud/terminal/vt320.java
@@ -56,6 +56,13 @@ public abstract class vt320 extends VDUBuffer implements VDUInput {
public abstract void write(byte[] b);
/**
+ * Write an answer back to the remote host. This is needed to be able to
+ * send terminal answers requests like status and type information.
+ * @param b the array of bytes to be sent
+ */
+ public abstract void write(int b);
+
+ /**
* Play the beep sound ...
*/
public void beep() { /* do nothing by default */
@@ -511,6 +518,23 @@ public void setScreenSize(int c, int r, boolean broadcast) {
return true;
}
+ private boolean write(int s, boolean doecho) {
+ if (debug > 2) {
+ debugStr.append("write(|")
+ .append(s)
+ .append("|,")
+ .append(doecho);
+ debug(debugStr.toString());
+ debugStr.setLength(0);
+ }
+
+ write(s);
+
+ if (doecho)
+ putChar((char)s, false);
+ return true;
+ }
+
private boolean write(String s) {
return write(s, localecho);
}
@@ -958,20 +982,20 @@ public void setScreenSize(int c, int r, boolean broadcast) {
return;
}
if (alt) {
- write("" + ((char) (keyChar | 0x80)));
+ write(((char) (keyChar | 0x80)));
return;
}
if (((keyCode == KEY_ENTER) || (keyChar == 10))
&& !control) {
- write("\r", false);
+ write('\r');
if (localecho) putString("\r\n"); // bad hack
return;
}
if ((keyCode == 10) && !control) {
debug("Sending \\r");
- write("\r", false);
+ write('\r');
return;
}
@@ -981,7 +1005,7 @@ public void setScreenSize(int c, int r, boolean broadcast) {
// if(((!vms && keyChar == '2') || keyChar == '@' || keyChar == ' ')
// && control)
if (((!vms && keyChar == '2') || keyChar == ' ') && control)
- write("" + (char) 0);
+ write(0);
if (vms) {
if (keyChar == 127 && !control) {
@@ -1117,7 +1141,7 @@ public void setScreenSize(int c, int r, boolean broadcast) {
}
if (!((keyChar == 8) || (keyChar == 127) || (keyChar == '\r') || (keyChar == '\n'))) {
- write("" + keyChar);
+ write(keyChar);
return;
}
}