Support library for the ESP8266 Wireless Terminal. Can also be used for communicating with any VT100-compatible terminal.

Revision:
6:7e7550084e5f
Parent:
5:7379bd37f3e2
--- a/espterm.cpp	Sun Mar 19 18:16:17 2017 +0000
+++ b/espterm.cpp	Sun Mar 19 19:51:21 2017 +0000
@@ -119,6 +119,32 @@
 }
 
 
+void ESPTerm::move(int dy, int dx)
+{
+    if (dy != 0) {
+        if (dy > 0) {
+            // Down
+            ser->printf("\033[%dB", dy);
+        }    
+        else {
+            // Up
+            ser->printf("\033[%dA", -dy);
+        }
+    } 
+    
+    if (dx != 0) {
+        if (dx > 0) {
+            // Forward
+            ser->printf("\033[%dC", dx);
+        }    
+        else {
+            // Backward
+            ser->printf("\033[%dD", -dx);
+        }
+    }   
+}
+
+
 void ESPTerm::clear_screen(ClearMode mode)
 {
     ser->printf("\033[%dJ", mode);
@@ -139,10 +165,56 @@
 
 void ESPTerm::show_cursor(bool yes)
 {
-    if (yes)
+    if (yes) {
         ser->puts("\033[?25h");
-    else
+    } 
+    else {
         ser->puts("\033[?25l");
+    }
+}
+
+
+void ESPTerm::scroll(int lines)
+{
+    if (lines > 0) {        
+        ser->printf("\033[%dT", lines);    
+    }  
+    else {
+        ser->printf("\033[%dS", -lines);
+    }  
+}
+
+
+void ESPTerm::cursor_push(bool with_attribs)
+{
+    if (with_attribs) {
+        ser->puts("\0337");
+    } 
+    else {
+        ser->puts("\033[s");
+    }
+}
+
+
+void ESPTerm::cursor_pop(bool with_attribs)
+{
+    if (with_attribs) {
+        ser->puts("\0338");
+    } 
+    else {
+        ser->puts("\033[u");
+    }    
+}
+
+
+void ESPTerm::wrap_enable(bool yes)
+{
+    if (yes) {
+        ser->puts("\033[?7h");
+    } 
+    else {
+        ser->puts("\033[?7l");
+    }    
 }