Allow blank lines
git-svn-id: https://shellinabox.googlecode.com/svn/trunk@98 0da03de8-d603-11dd-86c2-0f8696b7b6f9
This commit is contained in:
parent
e7db6d64e2
commit
f21ffb934f
1 changed files with 24 additions and 21 deletions
|
@ -218,31 +218,34 @@ Demo.prototype.doCommand = function() {
|
||||||
this.gotoState(STATE_PROMPT);
|
this.gotoState(STATE_PROMPT);
|
||||||
var tokens = new Tokens(this.line);
|
var tokens = new Tokens(this.line);
|
||||||
this.line = '';
|
this.line = '';
|
||||||
var cmd = tokens.nextToken().toUpperCase();
|
var cmd = tokens.nextToken();
|
||||||
if (cmd.match(/^[0-9]+$/)) {
|
if (cmd != undefined) {
|
||||||
tokens.removeLineNumber();
|
cmd = cmd.toUpperCase();
|
||||||
var lineNumber = parseInt(cmd);
|
if (cmd.match(/^[0-9]+$/)) {
|
||||||
var index = this.findLine(lineNumber);
|
tokens.removeLineNumber();
|
||||||
if (tokens.nextToken() == undefined) {
|
var lineNumber = parseInt(cmd);
|
||||||
if (index > 0) {
|
var index = this.findLine(lineNumber);
|
||||||
// Delete line from program
|
if (tokens.nextToken() == undefined) {
|
||||||
this.program.splice(index, 1);
|
if (index > 0) {
|
||||||
|
// Delete line from program
|
||||||
|
this.program.splice(index, 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (index >= 0) {
|
||||||
|
// Replace line in program
|
||||||
|
this.program[index].setTokens(tokens);
|
||||||
|
} else {
|
||||||
|
// Add new line to program
|
||||||
|
this.program.splice(-index - 1, 0, new Line(lineNumber, tokens));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (index >= 0) {
|
this.currentLineIndex = -1;
|
||||||
// Replace line in program
|
this.tokens = tokens;
|
||||||
this.program[index].setTokens(tokens);
|
this.gotoState(STATE_EVAL);
|
||||||
} else {
|
|
||||||
// Add new line to program
|
|
||||||
this.program.splice(-index - 1, 0, new Line(lineNumber, tokens));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
tokens.reset();
|
||||||
this.currentLineIndex = -1;
|
|
||||||
this.tokens = tokens;
|
|
||||||
this.gotoState(STATE_EVAL);
|
|
||||||
}
|
}
|
||||||
tokens.reset();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Demo.prototype.doEval = function() {
|
Demo.prototype.doEval = function() {
|
||||||
|
|
Loading…
Reference in a new issue