]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Fix #6
authorparis <paris@sourcelair.com>
Mon, 22 Sep 2014 05:48:05 +0000 (05:48 +0000)
committerparis <paris@sourcelair.com>
Mon, 22 Sep 2014 05:48:05 +0000 (05:48 +0000)
demo/main.js

index 67a2180b91838a3f97ec33182205365973ef95f0..05becab1b65d0a0deab3294f8204e6e02bb9eb72 100644 (file)
@@ -1,12 +1,13 @@
 var terminalContainer = document.getElementById('terminal-container'),
-    term = new Terminal();
+    term = new Terminal(),
+    prompt = '> ';
 
 term.open(terminalContainer);
 term.fit();
 
 term.prompt = function () {
-  term.write('\r\n> ');
-}
+  term.write('\r\n' + prompt);
+};
 
 term.writeln('Welcome to xterm.js');
 term.writeln('Just type some keys in the prompt below.');
@@ -19,7 +20,12 @@ term.on('key', function (key, ev) {
   if (ev.keyIdentifier == 'Enter') {
     term.prompt();
   } else if (ev.keyCode == 8) {
-    term.write('\b \b');
+    /*
+     * Do not delete the prompt
+     */
+    if (term.x > 2) {
+      term.write('\b \b');
+    }
   } else if (printable) {
     term.write(key);
   }