Add word wrap to console output and fix scrolling in console

Change-Id: Ibcf89952ee1391350c715f1ec82cf0cdb9b0ca7d
diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c
index ddff571..3a35c58 100644
--- a/minuitwrp/graphics.c
+++ b/minuitwrp/graphics.c
@@ -311,6 +311,30 @@
     return total;
 }
 
+int gr_maxExW(const char *s, void* font, int max_width)
+{
+    GRFont* fnt = (GRFont*) font;
+    int total = 0;
+    unsigned pos;
+    unsigned off;
+
+    if (!fnt)   fnt = gr_font;
+
+    while ((off = *s++))
+    {
+        off -= 32;
+        if (off < 96) {
+            max_width -= (fnt->offset[off+1] - fnt->offset[off]);
+			if (max_width > 0) {
+				total++;
+			} else {
+				return total;
+			}
+		}
+    }
+    return total;
+}
+
 unsigned character_width(const char *s, void* pFont)
 {
 	GRFont *font = (GRFont*) pFont;