mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 06:02:26 +01:00
Merge pull request #404 from hydroflame/semicolon
added semicolon support to terminal as well as autocomplete support f…
This commit is contained in:
commit
51c7630dd2
@ -113,7 +113,6 @@ $(document).keydown(function(event) {
|
|||||||
if (event.keyCode === KEY.ENTER) {
|
if (event.keyCode === KEY.ENTER) {
|
||||||
event.preventDefault(); //Prevent newline from being entered in Script Editor
|
event.preventDefault(); //Prevent newline from being entered in Script Editor
|
||||||
var command = $('input[class=terminal-input]').val();
|
var command = $('input[class=terminal-input]').val();
|
||||||
if (command.length > 0) {
|
|
||||||
post(
|
post(
|
||||||
"[" +
|
"[" +
|
||||||
(FconfSettings.ENABLE_TIMESTAMPS ? getTimestamp() + " " : "") +
|
(FconfSettings.ENABLE_TIMESTAMPS ? getTimestamp() + " " : "") +
|
||||||
@ -121,8 +120,13 @@ $(document).keydown(function(event) {
|
|||||||
" ~]> " + command
|
" ~]> " + command
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (command.length > 0) {
|
||||||
Terminal.resetTerminalInput(); //Clear input first
|
Terminal.resetTerminalInput(); //Clear input first
|
||||||
Terminal.executeCommand(command);
|
const commands = command.split(";");
|
||||||
|
for(let i = 0; i < commands.length; i++) {
|
||||||
|
if(commands[i].match(/^\s*$/)) { continue; }
|
||||||
|
Terminal.executeCommand(commands[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +202,12 @@ $(document).keydown(function(event) {
|
|||||||
if (terminalInput == null) {return;}
|
if (terminalInput == null) {return;}
|
||||||
var input = terminalInput.value;
|
var input = terminalInput.value;
|
||||||
if (input == "") {return;}
|
if (input == "") {return;}
|
||||||
|
|
||||||
|
const semiColonIndex = input.lastIndexOf(";");
|
||||||
|
if(semiColonIndex !== -1) {
|
||||||
|
input = input.slice(semiColonIndex+1);
|
||||||
|
}
|
||||||
|
|
||||||
input = input.trim();
|
input = input.trim();
|
||||||
input = input.replace(/\s\s+/g, ' ');
|
input = input.replace(/\s\s+/g, ' ');
|
||||||
|
|
||||||
@ -350,7 +360,18 @@ function tabCompletion(command, arg, allPossibilities, index=0) {
|
|||||||
} else {
|
} else {
|
||||||
val = command + " " + allPossibilities[0];
|
val = command + " " + allPossibilities[0];
|
||||||
}
|
}
|
||||||
document.getElementById("terminal-input-text-box").value = val;
|
|
||||||
|
const textBox = document.getElementById("terminal-input-text-box");
|
||||||
|
const oldValue = textBox.value;
|
||||||
|
const semiColonIndex = oldValue.lastIndexOf(";");
|
||||||
|
if(semiColonIndex === -1) {
|
||||||
|
// no ; replace the whole thing.
|
||||||
|
textBox.value = val;
|
||||||
|
} else {
|
||||||
|
// replace just after the last semicolon
|
||||||
|
textBox.value = textBox.value.slice(0, semiColonIndex+1)+" "+val;
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById("terminal-input-text-box").focus();
|
document.getElementById("terminal-input-text-box").focus();
|
||||||
} else {
|
} else {
|
||||||
var longestStartSubstr = longestCommonStart(allPossibilities);
|
var longestStartSubstr = longestCommonStart(allPossibilities);
|
||||||
|
Loading…
Reference in New Issue
Block a user