fix eclipse warnings
[fanfix.git] / src / jexer / tterminal / ECMA48.java
index df157cf4af9bbdee13e7dcd245e45a1a12c1f767..22867e1d1c6e7c45e549dfdfc55999940e6aee53 100644 (file)
@@ -179,7 +179,7 @@ public class ECMA48 implements Runnable {
      * @param deviceType DeviceType.VT100, DeviceType, XTERM, etc.
      * @param baseLang a base language without UTF-8 flag such as "C" or
      * "en_US"
-     * @return "LANG=en_US", "LANG=en_US.UTF-8", etc.
+     * @return "en_US", "en_US.UTF-8", etc.
      */
     public static String deviceTypeLang(final DeviceType deviceType,
         final String baseLang) {
@@ -690,6 +690,15 @@ public class ECMA48 implements Runnable {
     private boolean columns132 = false;
 
     /**
+     * Get 132 columns value.
+     *
+     * @return if true, the terminal is in 132 column mode
+     */
+    public final boolean isColumns132() {
+                return columns132;
+        }
+
+        /**
      * true = reverse video.  Set by DECSCNM.
      */
     private boolean reverseVideo = false;
@@ -891,7 +900,7 @@ public class ECMA48 implements Runnable {
      * @param type one of the DeviceType constants to select VT100, VT102,
      * VT220, or XTERM
      * @param inputStream an InputStream connected to the remote side.  For
-     * type == XTERM, inputStrem is converted to a Reader with UTF-8
+     * type == XTERM, inputStream is converted to a Reader with UTF-8
      * encoding.
      * @param outputStream an OutputStream connected to the remote user.  For
      * type == XTERM, outputStream is converted to a Writer with UTF-8
@@ -978,7 +987,6 @@ public class ECMA48 implements Runnable {
      * Handle a linefeed.
      */
     private void linefeed() {
-        int i;
 
         if (currentState.cursorY < scrollRegionBottom) {
             // Increment screen y
@@ -1096,25 +1104,18 @@ public class ECMA48 implements Runnable {
      * @param mouse mouse event received from the local user
      */
     public void mouse(final TMouseEvent mouse) {
+
         /*
-         * TODO:
-         *
-         * - Parse the mouse requests from the remote side regarding protocol
-         *   + encoding
-         *
-         * - Send mouse events to the other side.
-         *
-         *  - Handle the cursor (double invert).
+        System.err.printf("mouse(): protocol %s encoding %s mouse %s\n",
+            mouseProtocol, mouseEncoding, mouse);
          */
 
-        // System.err.printf("Mouse: %s\n", mouse);
-
-        /*
         if (mouseEncoding != MouseEncoding.UTF8) {
-            // We only support UTF8 encoding, bail out now.
-            return;
+            // We will support X10 but only for (160,94) and smaller.
+            if ((mouse.getX() >= 160) || (mouse.getY() >= 94)) {
+                return;
+            }
         }
-         */
 
         switch (mouseProtocol) {
 
@@ -1165,7 +1166,9 @@ public class ECMA48 implements Runnable {
         sb.append((char) 0x1B);
         sb.append('[');
         sb.append('M');
-        if (mouse.getMouse1()) {
+        if (mouse.getType() == TMouseEvent.Type.MOUSE_UP) {
+            sb.append((char) (0x03 + 32));
+        } else if (mouse.getMouse1()) {
             sb.append((char) (0x00 + 32));
         } else if (mouse.getMouse2()) {
             sb.append((char) (0x01 + 32));
@@ -3312,17 +3315,31 @@ public class ECMA48 implements Runnable {
      * DECSTBM - Set top and bottom margins.
      */
     private void decstbm() {
-        int top = getCsiParam(0, 1, 1, height) - 1;
-        int bottom = getCsiParam(1, height, 1, height) - 1;
+        boolean decPrivateModeFlag = false;
 
-        if (top > bottom) {
-            top = bottom;
+        for (int i = 0; i < collectBuffer.length(); i++) {
+            if (collectBuffer.charAt(i) == '?') {
+                decPrivateModeFlag = true;
+                break;
+            }
         }
-        scrollRegionTop = top;
-        scrollRegionBottom = bottom;
+        if (decPrivateModeFlag) {
+            // This could be restore DEC private mode values.
+            // Ignore it.
+        } else {
+            // DECSTBM
+            int top = getCsiParam(0, 1, 1, height) - 1;
+            int bottom = getCsiParam(1, height, 1, height) - 1;
 
-        // Home cursor
-        cursorPosition(0, 0);
+            if (top > bottom) {
+                top = bottom;
+            }
+            scrollRegionTop = top;
+            scrollRegionBottom = bottom;
+
+            // Home cursor
+            cursorPosition(0, 0);
+        }
     }
 
     /**
@@ -3688,7 +3705,7 @@ public class ECMA48 implements Runnable {
      *
      * @param ch character from the remote side
      */
-    public void consume(char ch) {
+    private void consume(char ch) {
 
         // DEBUG
         // System.err.printf("%c", ch);