Based on Terminal lib from Simon Ford, some adds

Fork of TerminalPlus by Max Scordamaglia

Revision:
3:e72f2addfaf8
Parent:
2:85184c13476c
Child:
4:ee2311717b80
--- a/Terminal.cpp	Tue Nov 23 16:03:35 2010 +0000
+++ b/Terminal.cpp	Thu Sep 10 23:39:04 2015 +0000
@@ -26,32 +26,75 @@
 
 Terminal::Terminal(PinName tx, PinName rx) : Serial(tx, rx) {}
 
-void Terminal::cls() {
+void Terminal::cls()
+{
     this->printf("\033[2J");
 }
 
-void Terminal::locate(int column, int row) {
+void Terminal::locate(int column, int row)
+{
     // Cursor Home    <ESC>[{ROW};{COLUMN}H
-    this->printf("\033[%d;%dH%c", row + 1, column + 1);
+
+    //  this->printf("\033[%d;%dH%c", row + 1, column + 1); //original
+    this->printf("\033[%d;%dH", row + 1, column + 1);
 }
 
-static int rgb888tobgr111(int colour) {
+static int rgb888tobgr111(int colour)
+{
     int r = (colour >> 23) & 1;
     int g = (colour >> 15) & 1;
     int b = (colour >> 7) & 1;
     return (b << 2) | (g << 1) | (r << 0);
 }
 
-void Terminal::foreground(int colour) {
+void Terminal::foreground(int colour)
+{
     // Set Attribute Mode    <ESC>[{n}m
     // Foreground Colours : 30 + bgr
     int c = 30 + rgb888tobgr111(colour);
     this->printf("\033[%dm", c);
 }
 
-void Terminal::background(int colour) {
+void Terminal::background(int colour)
+{
     // Set Attribute Mode    <ESC>[{n}m
     // Background Colours : 40 + bgr
     int c = 40 + rgb888tobgr111(colour);
     this->printf("\033[%dm", c);
 }
+
+void frame(int x, int y, int w, int h), int boxtype=1)
+{
+    switch (boxtype) {
+        case 0: //singolo
+            break;
+
+        case 1: //doppio
+            BLOCK  =219;
+            B_H =205;
+            B_V  =186;
+            B_TL =201;
+            B_TR =187;
+            B_BL= 200;
+            B_BR =188;
+            break;
+    }
+    //riga superiore
+    this->printf("\033[%d;%dH", x, y);
+    this->printf(B_TL);
+    for(int i=x+1; i<x+w; i++) this->printf(B_H);
+    this->printf(B_TR);
+    //corpo
+    for(int i=y+1; i<y+h; i++) {
+        this->printf("\033[%d;%dH", x, i);
+        this->printf(B_V);
+        this->printf("\033[%d;%dH", x+w, i);
+        this->printf(B_V);
+    }
+    //riga inferiore
+    this->printf("\033[%d;%dH", x, y+h);
+    this->printf(B_BL);
+    for(int i=x+1; i<x+w; i++) this->printf(B_H);
+    this->printf(B_BR);
+
+}