diff --git a/clite/commands.js b/clite/commands.js index b5af7de..7b2db11 100644 --- a/clite/commands.js +++ b/clite/commands.js @@ -345,11 +345,6 @@ Options: } } - if (file == null) { - stdio.write(io.stderr,'no file specified'); - return 1; - } - var lines = []; var topLine = 0; var bottomLine = 0; @@ -395,11 +390,20 @@ Options: showAt(0); } - var fd = stdio.open(file,prepFile); - if (!fd) { - stdio.write(io.stderr,'could not open file: '+file); - io.exit(1); - return; + var fd = null; + + if (file == null) { + if (isatty(io.stdin)) { + stdio.write(io.stderr,'no file specified'); + return 1; + } + fd = io.stdin; + }else{ + fd = stdio.open(file,prepFile); + if (!fd) { + stdio.write(io.stderr,'could not open file: '+file); + return 1; + } } var tty = term.opentty(); diff --git a/clite/core.js b/clite/core.js index 450a472..fb1b075 100644 --- a/clite/core.js +++ b/clite/core.js @@ -71,6 +71,11 @@ var clite = { clite = null; l('clite/core.js',function() {setTimeout('clite.init();',500)}); },10); + }, + hostname:function() { + if (window.location.protocol != 'file:') + return window.location.hostname; + return 'localhost'; } }, init:function() { @@ -1322,6 +1327,8 @@ clite.term = { return true; }, keyup:function(e) { + if (clite.term.tty.data != null) + return clite.term.tty.data.data.onkeypress(e); if (e.key.length > 1 && e.key != 'Spacebar' && clite.term.data.handler != null) { if (e.key == 'Enter') { clite.term.data.handler(e.target.value); @@ -1344,16 +1351,7 @@ clite.term = { } }, tty:{ - data:null, - keydown:function(e) { - if (e.key == 'Tab') { - clite.term.events.refocus(); - return false; - } - }, - keyup:function(e) { - return clite.term.tty.data.data.onkeypress(e); - } + data:null }, clear:function() { document.getElementById('terminal').innerHTML = '';