aboutsummaryrefslogtreecommitdiffstats
path: root/src/de
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2009-07-09 21:12:02 +0000
committerKenny Root <kenny@the-b.org>2009-07-09 21:12:02 +0000
commit99c6e404f90578a7c05622f381f8b220bea2b026 (patch)
treec2ef751bf6f6489897b26f6811ad6cbe01dba551 /src/de
parentfac1309bac44d6ba4294ff397197ddb7baffb8ba (diff)
downloadconnectbot-99c6e404f90578a7c05622f381f8b220bea2b026.tar.gz
connectbot-99c6e404f90578a7c05622f381f8b220bea2b026.tar.bz2
connectbot-99c6e404f90578a7c05622f381f8b220bea2b026.zip
Be wary of where our cursor moves to
git-svn-id: https://connectbot.googlecode.com/svn/trunk/connectbot@366 df292f66-193f-0410-a5fc-6d59da041ff2
Diffstat (limited to 'src/de')
-rw-r--r--src/de/mud/terminal/VDUBuffer.java21
-rw-r--r--src/de/mud/terminal/vt320.java75
2 files changed, 57 insertions, 39 deletions
diff --git a/src/de/mud/terminal/VDUBuffer.java b/src/de/mud/terminal/VDUBuffer.java
index 1b90da9..0f5fda6 100644
--- a/src/de/mud/terminal/VDUBuffer.java
+++ b/src/de/mud/terminal/VDUBuffer.java
@@ -559,7 +559,6 @@ public class VDUBuffer {
public void setCursorPosition(int c, int l) {
cursorX = c;
cursorY = l;
- update[cursorY + 1] = true;
}
/**
@@ -610,7 +609,7 @@ public class VDUBuffer {
if (l1 < 0)
l1 = 0;
- if (l2 > height - 1)
+ if (l2 >= height)
l2 = height - 1;
topMargin = l1;
@@ -630,7 +629,7 @@ public class VDUBuffer {
} else
topMargin = l;
if (topMargin < 0) topMargin = 0;
- if (bottomMargin > height - 1) bottomMargin = height - 1;
+ if (bottomMargin >= height) bottomMargin = height - 1;
}
/**
@@ -653,7 +652,7 @@ public class VDUBuffer {
} else
bottomMargin = l;
if (topMargin < 0) topMargin = 0;
- if (bottomMargin > height - 1) bottomMargin = height - 1;
+ if (bottomMargin >= height) bottomMargin = height - 1;
}
/**
@@ -760,6 +759,20 @@ public class VDUBuffer {
}
}
+ int C = getCursorColumn();
+ if (C < 0)
+ C = 0;
+ else if (C >= width)
+ C = width - 1;
+
+ int R = getCursorRow();
+ if (R < 0)
+ R = 0;
+ else if (R >= height)
+ R = height - 1;
+
+ setCursorPosition(C, R);
+
charArray = cbuf;
charAttributes = abuf;
width = w;
diff --git a/src/de/mud/terminal/vt320.java b/src/de/mud/terminal/vt320.java
index 417ff3b..bdafefd 100644
--- a/src/de/mud/terminal/vt320.java
+++ b/src/de/mud/terminal/vt320.java
@@ -153,12 +153,7 @@ public void setScreenSize(int c, int r, boolean broadcast) {
/* Tricky, since the VDUBuffer works strangely. */
if (r > oldrows) {
- int newR = R + (r - oldrows);
- if (newR < 0)
- newR = 0;
- else if (newR > height - 1)
- newR = height - 1;
- setCursorPosition(C, R = newR);
+ setCursorPosition(C, R + (r - oldrows));
redraw();
}
if (broadcast) {
@@ -1493,7 +1488,7 @@ public void setScreenSize(int c, int r, boolean broadcast) {
int tm = getTopMargin();
R = (row < 0)?0: row;
- C = (col < 0)?0: (col > width - 1) ? width - 1 : col;
+ C = (col < 0)?0: (col >= width) ? width - 1 : col;
if (!moveoutsidemargins) {
R += tm;
@@ -1840,7 +1835,7 @@ public void setScreenSize(int c, int r, boolean broadcast) {
break;
case 'B': /* CUD */
R++;
- if (R > rows - 1) R = rows - 1;
+ if (R >= rows) R = rows - 1;
break;
case 'C':
C++;
@@ -1993,10 +1988,18 @@ public void setScreenSize(int c, int r, boolean broadcast) {
break;
case TSTATE_VT52X:
C = c - 37;
+ if (C < 0)
+ C = 0;
+ else if (C >= width)
+ C = width - 1;
term_state = TSTATE_VT52Y;
break;
case TSTATE_VT52Y:
R = c - 37;
+ if (R < 0)
+ R = 0;
+ else if (R >= height)
+ R = height - 1;
term_state = TSTATE_DATA;
break;
case TSTATE_SETG0:
@@ -2526,13 +2529,17 @@ public void setScreenSize(int c, int r, boolean broadcast) {
C++;
else
C += DCEvars[0];
- if (C > columns - 1)
+ if (C >= columns)
C = columns - 1;
if (debug > 1)
debug("ESC [ " + DCEvars[0] + " C");
break;
case 'd': // CVA
R = DCEvars[0];
+ if (R < 0)
+ R = 0;
+ else if (R >= height)
+ R = height - 1;
if (debug > 1)
debug("ESC [ " + DCEvars[0] + " d");
break;
@@ -2569,6 +2576,10 @@ public void setScreenSize(int c, int r, boolean broadcast) {
break;
case 'G': /* CUP / cursor absolute column */
C = DCEvars[0];
+ if (C < 0)
+ C = 0;
+ else if (C >= width)
+ C = width - 1;
if (debug > 1) debug("ESC [ " + DCEvars[0] + " G");
break;
case 'H': /* CUP / cursor position */
@@ -2583,8 +2594,14 @@ public void setScreenSize(int c, int r, boolean broadcast) {
/* gets 2 arguments */
R = DCEvars[0] - 1;
C = DCEvars[1] - 1;
- if (C < 0) C = 0;
- if (R < 0) R = 0;
+ if (C < 0)
+ C = 0;
+ else if (C >= width)
+ C = width - 1;
+ if (R < 0)
+ R = 0;
+ else if (R >= height)
+ R = height - 1;
if (debug > 2)
debug("ESC [ " + DCEvars[0] + ";" + DCEvars[1] + " f");
break;
@@ -2760,8 +2777,8 @@ public void setScreenSize(int c, int r, boolean broadcast) {
}
break;
case 3: /* italics */
- attributes |= INVERT;
- break;
+ attributes |= INVERT;
+ break;
case 4:
attributes |= UNDERLINE;
break;
@@ -2906,33 +2923,21 @@ public void setScreenSize(int c, int r, boolean broadcast) {
}
break;
case TSTATE_TITLE:
- switch (c) {
- case ESC:
- term_state = TSTATE_ESC;
- break;
- default:
- // TODO save title
- break;
- }
- break;
+ switch (c) {
+ case ESC:
+ term_state = TSTATE_ESC;
+ break;
+ default:
+ // TODO save title
+ break;
+ }
+ break;
default:
term_state = TSTATE_DATA;
break;
}
- if (C > columns)
- C = columns;
- else if (C < 0)
- C = 0;
-
- if (R > rows)
- R = rows;
- else if (R < 0)
- R = 0;
-
- if (doshowcursor)
- setCursorPosition(C, R);
- //markLine(R, 1);
+ setCursorPosition(C, R);
}
/* hard reset the terminal */