diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/de/mud/terminal/VDUBuffer.java | 33 | ||||
| -rw-r--r-- | src/de/mud/terminal/vt320.java | 22 | 
2 files changed, 49 insertions, 6 deletions
| diff --git a/src/de/mud/terminal/VDUBuffer.java b/src/de/mud/terminal/VDUBuffer.java index a0d6b3b..90d5452 100644 --- a/src/de/mud/terminal/VDUBuffer.java +++ b/src/de/mud/terminal/VDUBuffer.java @@ -481,10 +481,13 @@ public class VDUBuffer {      int bottom = (l > bottomMargin ? height - 1:              (l < topMargin?topMargin:bottomMargin + 1)); -    System.arraycopy(charArray, screenBase + l + 1, -                     charArray, screenBase + l, bottom - l - 1); -    System.arraycopy(charAttributes, screenBase + l + 1, -                     charAttributes, screenBase + l, bottom - l - 1); +    int numRows = bottom - l - 1; +    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];      charAttributes[screenBase + bottom - 1] = new int[width];      markLine(l, bottom - l); @@ -613,6 +616,28 @@ public class VDUBuffer {    }    /** +   * Set the scroll margins simultaneously. If they're backwards, swap them. +   * If they're out of bounds, trim them. +   * @param l1 line that is the top +   * @param l2 line that is the bottom +   */ +  public void setMargins(int l1, int l2) { +	  if (l1 > l2) { +		  int temp = l2; +		  l2 = l1; +		  l1 = temp; +	  } +	   +	  if (l1 < 0) +		  l1 = 0; +	  if (l2 > height - 1) +		  l2 = height - 1; +	   +	  topMargin = l1; +	  bottomMargin = l2; +  } +   +  /**     * Set the top scroll margin for the screen. If the current bottom margin     * is smaller it will become the top margin and the line will become the     * bottom margin. diff --git a/src/de/mud/terminal/vt320.java b/src/de/mud/terminal/vt320.java index d4aa05a..49af8f0 100644 --- a/src/de/mud/terminal/vt320.java +++ b/src/de/mud/terminal/vt320.java @@ -526,6 +526,7 @@ public abstract class vt320 extends VDUBuffer implements VDUInput {    private final static int TSTATE_VT52Y = 15;    private final static int TSTATE_CSI_TICKS = 16;    private final static int TSTATE_CSI_EQUAL = 17; /* ESC [ = */ +  private final static int TSTATE_TITLE = 18; /* xterm title */    /* Keys we support */    public final static int KEY_PAUSE = 1; @@ -1839,6 +1840,13 @@ public abstract class vt320 extends VDUBuffer implements VDUInput {            case 'Y': /* vt52 cursor address mode , next chars are x,y */              term_state = TSTATE_VT52Y;              break; +          case '_': +          	term_state = TSTATE_TITLE; +          	break; +          case '\\': +          	// TODO save title +          	term_state = TSTATE_DATA; +          	break;            default:              System.out.println("ESC unknown letter: " + c + " (" + ((int) c) + ")");              break; @@ -2409,14 +2417,14 @@ public abstract class vt320 extends VDUBuffer implements VDUInput {                }              } else                R = rows - 1; -            setBottomMargin(R); +            int bot = R;              System.out.println("setBottomMargin R="+R);              if (R >= DCEvars[0]) {                R = DCEvars[0] - 1;                if (R < 0)                  R = 0;              } -            setTopMargin(R); +            setMargins(R, bot);              System.out.println("setTopMargin R="+R);              _SetCursor(0, 0);              if (debug > 1) @@ -2699,6 +2707,16 @@ public abstract class vt320 extends VDUBuffer implements VDUInput {              break;          }          break; +      case TSTATE_TITLE: +      	switch (c) { +      	  case ESC: +      		term_state = TSTATE_ESC; +      		break; +      	  default: +      		// TODO save title +      		break; +      	} +      	break;        default:          term_state = TSTATE_DATA;          break; | 
