mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 21:53:50 +01:00
Tab autocompletion now works on commands. Updated to v0.19.6
This commit is contained in:
parent
7701249cfe
commit
d1e4ef77fd
@ -1,5 +1,5 @@
|
|||||||
CONSTANTS = {
|
CONSTANTS = {
|
||||||
Version: "0.19.5",
|
Version: "0.19.6",
|
||||||
|
|
||||||
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
|
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
|
||||||
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
|
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
|
||||||
@ -556,8 +556,14 @@ CONSTANTS = {
|
|||||||
"-Made the effects of many Augmentations slightly more powerful<br>" +
|
"-Made the effects of many Augmentations slightly more powerful<br>" +
|
||||||
"-Slightly increased company job wages across the board (~5-10% for each position)<br>" +
|
"-Slightly increased company job wages across the board (~5-10% for each position)<br>" +
|
||||||
"-Gyms and classes are now significantly more expensive<br>" +
|
"-Gyms and classes are now significantly more expensive<br>" +
|
||||||
"-Doubled the amount by which a server's security increases when it is hacked. Now, it will<br>" +
|
"-Doubled the amount by which a server's security increases when it is hacked. Now, it will " +
|
||||||
"increase by 0.002. Calling weaken() on a server will lower the security by 0.1.",
|
"increase by 0.002. Calling weaken() on a server will lower the security by 0.1.<br><br>" +
|
||||||
|
"v0.19.6<br>" +
|
||||||
|
"-Script editor now saves its state even when you change tabs <br>" +
|
||||||
|
"-scp() command in Terminal/script will now overwrite files at the destination <br>" +
|
||||||
|
"-Terminal commands are no longer case-sensitive (only the commands themselves such as 'run' or 'nano'. Filenames are " +
|
||||||
|
"still case sensitive<br>" +
|
||||||
|
"-Tab automcompletion will now work on commands",
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -104,12 +104,10 @@ $(document).keydown(function(event) {
|
|||||||
|
|
||||||
var commandArray = input.split(" ");
|
var commandArray = input.split(" ");
|
||||||
var index = commandArray.length - 2;
|
var index = commandArray.length - 2;
|
||||||
if (index < 0) {index = 0;}
|
if (index < -1) {index = 0;}
|
||||||
var allPos = determineAllPossibilitiesForTabCompletion(input, index);
|
var allPos = determineAllPossibilitiesForTabCompletion(input, index);
|
||||||
if (allPos.length == 0) {return;}
|
if (allPos.length == 0) {return;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var arg = "";
|
var arg = "";
|
||||||
var command = "";
|
var command = "";
|
||||||
if (commandArray.length == 0) {return;}
|
if (commandArray.length == 0) {return;}
|
||||||
@ -170,41 +168,79 @@ function tabCompletion(command, arg, allPossibilities, index=0) {
|
|||||||
if (!(allPossibilities.constructor === Array)) {return;}
|
if (!(allPossibilities.constructor === Array)) {return;}
|
||||||
if (!containsAllStrings(allPossibilities)) {return;}
|
if (!containsAllStrings(allPossibilities)) {return;}
|
||||||
|
|
||||||
for (var i = allPossibilities.length-1; i >= 0; --i) {
|
command = command.toLowerCase();
|
||||||
if (!allPossibilities[i].startsWith(arg)) {
|
arg = arg.toLowerCase();
|
||||||
allPossibilities.splice(i, 1);
|
|
||||||
|
if (arg == "") {
|
||||||
|
for (var i = allPossibilities.length-1; i >= 0; --i) {
|
||||||
|
if (!allPossibilities[i].startsWith(command)) {
|
||||||
|
allPossibilities.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (var i = allPossibilities.length-1; i >= 0; --i) {
|
||||||
|
if (!allPossibilities[i].startsWith(arg)) {
|
||||||
|
allPossibilities.splice(i, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var val = "";
|
||||||
if (allPossibilities.length == 0) {
|
if (allPossibilities.length == 0) {
|
||||||
return;
|
return;
|
||||||
} else if (allPossibilities.length == 1) {
|
} else if (allPossibilities.length == 1) {
|
||||||
document.getElementById("terminal-input-text-box").value = command + " " + allPossibilities[0];
|
if (arg == "") {
|
||||||
|
//Autocomplete command
|
||||||
|
val = allPossibilities[0];
|
||||||
|
} else {
|
||||||
|
val = command + " " + allPossibilities[0];
|
||||||
|
}
|
||||||
|
document.getElementById("terminal-input-text-box").value = 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);
|
||||||
//If the longest common starting substring of remaining possibilities is the same
|
//If the longest common starting substring of remaining possibilities is the same
|
||||||
//as whatevers already in terminal, just list all possible options. Otherwise,
|
//as whatevers already in terminal, just list all possible options. Otherwise,
|
||||||
//change the input in the terminal to the longest common starting substr
|
//change the input in the terminal to the longest common starting substr
|
||||||
if (longestStartSubstr == arg) {
|
var allOptionsStr = "";
|
||||||
//List all possible options
|
for (var i = 0; i < allPossibilities.length; ++i) {
|
||||||
var allOptionsStr = "";
|
allOptionsStr += allPossibilities[i];
|
||||||
for (var i = 0; i < allPossibilities.length; ++i) {
|
allOptionsStr += " ";
|
||||||
allOptionsStr += allPossibilities[i];
|
|
||||||
allOptionsStr += " ";
|
|
||||||
}
|
|
||||||
post("> " + command + " " + arg);
|
|
||||||
post(allOptionsStr);
|
|
||||||
} else {
|
|
||||||
document.getElementById("terminal-input-text-box").value = command + " " + longestStartSubstr;
|
|
||||||
document.getElementById("terminal-input-text-box").focus();
|
|
||||||
}
|
}
|
||||||
|
if (arg == "") {
|
||||||
|
if (longestStartSubstr == command) {
|
||||||
|
post("> " + command);
|
||||||
|
post(allOptionsStr);
|
||||||
|
} else {
|
||||||
|
document.getElementById("terminal-input-text-box").value = longestStartSubstr;
|
||||||
|
document.getElementById("terminal-input-text-box").focus();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (longestStartSubstr == arg) {
|
||||||
|
//List all possible options
|
||||||
|
post("> " + command + " " + arg);
|
||||||
|
post(allOptionsStr);
|
||||||
|
} else {
|
||||||
|
document.getElementById("terminal-input-text-box").value = command + " " + longestStartSubstr;
|
||||||
|
document.getElementById("terminal-input-text-box").focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||||
var allPos = [];
|
var allPos = [];
|
||||||
var currServ = Player.getCurrentServer();
|
var currServ = Player.getCurrentServer();
|
||||||
|
input = input.toLowerCase();
|
||||||
|
|
||||||
|
//Autocomplete the command
|
||||||
|
if (index == -1) {
|
||||||
|
return ["alias", "analyze", "cat", "clear", "cls", "connect", "free",
|
||||||
|
"hack", "help", "home", "hostname", "ifconfig", "kill",
|
||||||
|
"ls", "mem", "nano", "ps", "rm", "run", "scan", "scan-analyze",
|
||||||
|
"scp", "sudov", "tail", "top"];
|
||||||
|
}
|
||||||
|
|
||||||
if (input.startsWith("scp ") && index == 1) {
|
if (input.startsWith("scp ") && index == 1) {
|
||||||
for (var iphostname in AllServers) {
|
for (var iphostname in AllServers) {
|
||||||
|
Loading…
Reference in New Issue
Block a user