diff shterm.js @ 9:826a7ced69f8

Make the emulator screen resizable.
author John "Elwin" Edwards <elwin@sdf.org>
date Wed, 09 May 2012 13:38:05 -0700
parents d1b3c3af34d6
children d051aad3e95f
line wrap: on
line diff
--- a/shterm.js	Mon May 07 16:08:59 2012 -0700
+++ b/shterm.js	Wed May 09 13:38:05 2012 -0700
@@ -270,7 +270,7 @@
 
 function setup() {
   keyHexCodes.init();
-  termemu.init("termwrap", 25, 80);
+  termemu.init("termwrap", 24, 80);
   setTitle("Not connected.");
   return;
 }
@@ -295,7 +295,7 @@
   return;
 }
 
-function login() {
+function login(h, w) {
   if (termemu.alive)
     return;
   var req = new XMLHttpRequest();
@@ -304,6 +304,8 @@
       var datalines = req.responseText.split("\n");
       if (datalines[0] == 'l1') {
         /* Success */
+        // FIXME extract the size from the response instead of hardcoding
+        termemu.resize(25, 80);
         termemu.alive = true;
 	setTitle("Logged in");
         debug(1, "Logged in with id " + datalines[1]);
@@ -314,7 +316,7 @@
     }
   };
   req.open('POST', '/login', true);
-  req.send("login=login");
+  req.send("login=login&h=" + String(h) + "&w=" + String(w));
   return;
 }
 
@@ -388,7 +390,7 @@
       nsize = 48;
   }
   document.getElementById("term").style.fontSize = nsize.toString() + "px";
-  termemu.resize();
+  termemu.fixsize();
   debug(1, "Changing font size to " + nsize.toString());
   return;
 }