get less working again

This commit is contained in:
Lisa Milne 2023-11-26 18:28:54 +10:00
parent 0e4fcf70b2
commit 82e39184f1
2 changed files with 22 additions and 20 deletions

View file

@ -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();

View file

@ -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 = '';